Built SDL2_image and _mixer static

This commit is contained in:
2022-09-30 15:49:16 -04:00
parent e2605bf6c1
commit 1dec4347e0
4473 changed files with 1964551 additions and 9 deletions

View File

@@ -0,0 +1,66 @@
# flac - Command-line FLAC encoder/decoder
# Copyright (C) 2000-2009 Josh Coalson
# Copyright (C) 2011-2016 Xiph.Org Foundation
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bin_PROGRAMS = flac
AM_CFLAGS = @OGG_CFLAGS@
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
EXTRA_DIST = \
Makefile.lite \
Makefile.lite.iffscan \
flac.vcproj \
flac.vcxproj \
flac.vcxproj.filters \
iffscan.c \
iffscan.vcproj \
iffscan.vcxproj \
iffscan.vcxproj.filters
flac_SOURCES = \
analyze.c \
decode.c \
encode.c \
foreign_metadata.c \
main.c \
local_string_utils.c \
utils.c \
vorbiscomment.c \
analyze.h \
decode.h \
encode.h \
foreign_metadata.h \
local_string_utils.h \
utils.h \
vorbiscomment.h
if OS_IS_WINDOWS
win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la
endif
flac_LDADD = \
$(top_builddir)/src/share/utf8/libutf8.la \
$(top_builddir)/src/share/grabbag/libgrabbag.la \
$(top_builddir)/src/share/getopt/libgetopt.la \
$(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \
$(top_builddir)/src/share/replaygain_synthesis/libreplaygain_synthesis.la \
$(top_builddir)/src/libFLAC/libFLAC.la \
$(win_utf8_lib) \
@LIBICONV@ \
-lm
CLEANFILES = flac.exe

View File

@@ -0,0 +1,748 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
# flac - Command-line FLAC encoder/decoder
# Copyright (C) 2000-2009 Josh Coalson
# Copyright (C) 2011-2016 Xiph.Org Foundation
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = flac$(EXEEXT)
subdir = src/flac
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/add_cflags.m4 \
$(top_srcdir)/m4/add_cxxflags.m4 $(top_srcdir)/m4/bswap.m4 \
$(top_srcdir)/m4/clang.m4 $(top_srcdir)/m4/codeset.m4 \
$(top_srcdir)/m4/gcc_version.m4 $(top_srcdir)/m4/iconv.m4 \
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/ogg.m4 $(top_srcdir)/m4/really_gcc.m4 \
$(top_srcdir)/m4/stack_protect.m4 $(top_srcdir)/m4/xmms.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am_flac_OBJECTS = analyze.$(OBJEXT) decode.$(OBJEXT) encode.$(OBJEXT) \
foreign_metadata.$(OBJEXT) main.$(OBJEXT) \
local_string_utils.$(OBJEXT) utils.$(OBJEXT) \
vorbiscomment.$(OBJEXT)
flac_OBJECTS = $(am_flac_OBJECTS)
flac_DEPENDENCIES = $(top_builddir)/src/share/utf8/libutf8.la \
$(top_builddir)/src/share/grabbag/libgrabbag.la \
$(top_builddir)/src/share/getopt/libgetopt.la \
$(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \
$(top_builddir)/src/share/replaygain_synthesis/libreplaygain_synthesis.la \
$(top_builddir)/src/libFLAC/libFLAC.la $(win_utf8_lib)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(flac_SOURCES)
DIST_SOURCES = $(flac_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCAS = @CCAS@
CCASDEPMODE = @CCASDEPMODE@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DOCBOOK_TO_MAN = @DOCBOOK_TO_MAN@
DOXYGEN = @DOXYGEN@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
ENABLE_64_BIT_WORDS = @ENABLE_64_BIT_WORDS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
FLAC__HAS_OGG = @FLAC__HAS_OGG@
FLAC__TEST_LEVEL = @FLAC__TEST_LEVEL@
FLAC__TEST_WITH_VALGRIND = @FLAC__TEST_WITH_VALGRIND@
GCC_MAJOR_VERSION = @GCC_MAJOR_VERSION@
GCC_MINOR_VERSION = @GCC_MINOR_VERSION@
GCC_VERSION = @GCC_VERSION@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBICONV = @LIBICONV@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBICONV = @LTLIBICONV@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NASM = @NASM@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OBJ_FORMAT = @OBJ_FORMAT@
OGG_CFLAGS = @OGG_CFLAGS@
OGG_LIBS = @OGG_LIBS@
OGG_PACKAGE = @OGG_PACKAGE@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
XMMS_CFLAGS = @XMMS_CFLAGS@
XMMS_CONFIG = @XMMS_CONFIG@
XMMS_DATA_DIR = @XMMS_DATA_DIR@
XMMS_EFFECT_PLUGIN_DIR = @XMMS_EFFECT_PLUGIN_DIR@
XMMS_GENERAL_PLUGIN_DIR = @XMMS_GENERAL_PLUGIN_DIR@
XMMS_INPUT_PLUGIN_DIR = @XMMS_INPUT_PLUGIN_DIR@
XMMS_LIBS = @XMMS_LIBS@
XMMS_OUTPUT_PLUGIN_DIR = @XMMS_OUTPUT_PLUGIN_DIR@
XMMS_PLUGIN_DIR = @XMMS_PLUGIN_DIR@
XMMS_VERSION = @XMMS_VERSION@
XMMS_VISUALIZATION_PLUGIN_DIR = @XMMS_VISUALIZATION_PLUGIN_DIR@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CFLAGS = @OGG_CFLAGS@
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
EXTRA_DIST = \
Makefile.lite \
Makefile.lite.iffscan \
flac.vcproj \
flac.vcxproj \
flac.vcxproj.filters \
iffscan.c \
iffscan.vcproj \
iffscan.vcxproj \
iffscan.vcxproj.filters
flac_SOURCES = \
analyze.c \
decode.c \
encode.c \
foreign_metadata.c \
main.c \
local_string_utils.c \
utils.c \
vorbiscomment.c \
analyze.h \
decode.h \
encode.h \
foreign_metadata.h \
local_string_utils.h \
utils.h \
vorbiscomment.h
@OS_IS_WINDOWS_TRUE@win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la
flac_LDADD = \
$(top_builddir)/src/share/utf8/libutf8.la \
$(top_builddir)/src/share/grabbag/libgrabbag.la \
$(top_builddir)/src/share/getopt/libgetopt.la \
$(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \
$(top_builddir)/src/share/replaygain_synthesis/libreplaygain_synthesis.la \
$(top_builddir)/src/libFLAC/libFLAC.la \
$(win_utf8_lib) \
@LIBICONV@ \
-lm
CLEANFILES = flac.exe
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/flac/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign src/flac/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
$(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
fi; \
for p in $$list; do echo "$$p $$p"; done | \
sed 's/$(EXEEXT)$$//' | \
while read p p1; do if test -f $$p \
|| test -f $$p1 \
; then echo "$$p"; echo "$$p"; else :; fi; \
done | \
sed -e 'p;s,.*/,,;n;h' \
-e 's|.*|.|' \
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
sed 'N;N;N;s,\n, ,g' | \
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
if ($$2 == $$4) files[d] = files[d] " " $$1; \
else { print "f", $$3 "/" $$4, $$1; } } \
END { for (d in files) print "f", d, files[d] }' | \
while read type dir files; do \
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
test -z "$$files" || { \
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
} \
; done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
-e 's/$$/$(EXEEXT)/' \
`; \
test -n "$$list" || exit 0; \
echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(bindir)" && rm -f $$files
clean-binPROGRAMS:
@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
echo " rm -f" $$list; \
rm -f $$list || exit $$?; \
test -n "$(EXEEXT)" || exit 0; \
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
flac$(EXEEXT): $(flac_OBJECTS) $(flac_DEPENDENCIES) $(EXTRA_flac_DEPENDENCIES)
@rm -f flac$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(flac_OBJECTS) $(flac_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/analyze.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/decode.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encode.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/foreign_metadata.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/local_string_utils.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vorbiscomment.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS)
installdirs:
for dir in "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am: install-binPROGRAMS
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
clean-binPROGRAMS clean-generic clean-libtool cscopelist-am \
ctags ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-binPROGRAMS \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-binPROGRAMS
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@@ -0,0 +1,54 @@
# flac - Command-line FLAC encoder/decoder
# Copyright (C) 2000-2009 Josh Coalson
# Copyright (C) 2011-2016 Xiph.Org Foundation
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# GNU makefile
#
topdir = ../..
include $(topdir)/build/config.mk
libdir = $(topdir)/objs/$(BUILD)/lib
PROGRAM_NAME = flac
INCLUDES = -I./include -I$(topdir)/include $(OGG_INCLUDES)
ifeq ($(OS),Darwin)
EXPLICIT_LIBS = $(libdir)/libgrabbag.a $(libdir)/libFLAC.a $(libdir)/libreplaygain_analysis.a $(libdir)/libreplaygain_synthesis.a $(libdir)/libgetopt.a $(libdir)/libutf8.a $(OGG_EXPLICIT_LIBS) $(ICONV_LIBS) -lm
else
ifeq ($(findstring Windows,$(OS)),Windows)
LIBS = -lgrabbag -lFLAC -lreplaygain_analysis -lreplaygain_synthesis -lgetopt -lutf8 -lgrabbag -lwin_utf8_io $(OGG_LIBS) -lm
else
LIBS = -lgrabbag -lFLAC -lreplaygain_analysis -lreplaygain_synthesis -lgetopt -lutf8 -lgrabbag $(OGG_LIBS) -lm
endif
endif
SRCS_C = \
analyze.c \
decode.c \
encode.c \
foreign_metadata.c \
local_string_utils.c \
main.c \
utils.c \
vorbiscomment.c
include $(topdir)/build/exe.mk
# DO NOT DELETE THIS LINE -- make depend depends on it.

View File

@@ -0,0 +1,46 @@
# flac - Command-line FLAC encoder/decoder
# Copyright (C) 2000-2009 Josh Coalson
# Copyright (C) 2011-2016 Xiph.Org Foundation
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# GNU makefile
#
topdir = ../..
libdir = $(topdir)/objs/$(BUILD)/lib
PROGRAM_NAME = iffscan
INCLUDES = -I./include -I$(topdir)/include $(OGG_INCLUDES)
ifeq ($(OS),Darwin)
EXPLICIT_LIBS = $(libdir)/libFLAC.a $(OGG_EXPLICIT_LIBS) $(ICONV_LIBS) -lm
else
ifeq ($(findstring Windows,$(OS)),Windows)
LIBS = -lFLAC -lwin_utf8_io $(OGG_LIBS) -lm
else
LIBS = -lFLAC $(OGG_LIBS) -lm
endif
endif
SRCS_C = \
foreign_metadata.c \
iffscan.c
include $(topdir)/build/exe.mk
# DO NOT DELETE THIS LINE -- make depend depends on it.

View File

@@ -0,0 +1,247 @@
/* flac - Command-line FLAC encoder/decoder
* Copyright (C) 2000-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <errno.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "FLAC/all.h"
#include "analyze.h"
#include "share/compat.h"
typedef struct {
FLAC__int32 residual;
unsigned count;
} pair_t;
typedef struct {
pair_t buckets[FLAC__MAX_BLOCK_SIZE];
int peak_index;
unsigned nbuckets;
unsigned nsamples;
double sum, sos;
double variance;
double mean;
double stddev;
} subframe_stats_t;
static subframe_stats_t all_;
static void init_stats(subframe_stats_t *stats);
static void update_stats(subframe_stats_t *stats, FLAC__int32 residual, unsigned incr);
static void compute_stats(subframe_stats_t *stats);
static FLAC__bool dump_stats(const subframe_stats_t *stats, const char *filename);
void flac__analyze_init(analysis_options aopts)
{
if(aopts.do_residual_gnuplot) {
init_stats(&all_);
}
}
void flac__analyze_frame(const FLAC__Frame *frame, unsigned frame_number, FLAC__uint64 frame_offset, unsigned frame_bytes, analysis_options aopts, FILE *fout)
{
const unsigned channels = frame->header.channels;
char outfilename[1024];
subframe_stats_t stats;
unsigned i, channel, partitions;
/* do the human-readable part first */
fprintf(fout, "frame=%u\toffset=%" PRIu64 "\tbits=%u\tblocksize=%u\tsample_rate=%u\tchannels=%u\tchannel_assignment=%s\n", frame_number, frame_offset, frame_bytes*8, frame->header.blocksize, frame->header.sample_rate, channels, FLAC__ChannelAssignmentString[frame->header.channel_assignment]);
for(channel = 0; channel < channels; channel++) {
const FLAC__Subframe *subframe = frame->subframes+channel;
const FLAC__bool is_rice2 = subframe->data.fixed.entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2;
const unsigned pesc = is_rice2? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;
fprintf(fout, "\tsubframe=%u\twasted_bits=%u\ttype=%s", channel, subframe->wasted_bits, FLAC__SubframeTypeString[subframe->type]);
switch(subframe->type) {
case FLAC__SUBFRAME_TYPE_CONSTANT:
fprintf(fout, "\tvalue=%d\n", subframe->data.constant.value);
break;
case FLAC__SUBFRAME_TYPE_FIXED:
FLAC__ASSERT(subframe->data.fixed.entropy_coding_method.type <= FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2);
fprintf(fout, "\torder=%u\tresidual_type=%s\tpartition_order=%u\n", subframe->data.fixed.order, is_rice2? "RICE2":"RICE", subframe->data.fixed.entropy_coding_method.data.partitioned_rice.order);
for(i = 0; i < subframe->data.fixed.order; i++)
fprintf(fout, "\t\twarmup[%u]=%d\n", i, subframe->data.fixed.warmup[i]);
partitions = (1u << subframe->data.fixed.entropy_coding_method.data.partitioned_rice.order);
for(i = 0; i < partitions; i++) {
unsigned parameter = subframe->data.fixed.entropy_coding_method.data.partitioned_rice.contents->parameters[i];
if(parameter == pesc)
fprintf(fout, "\t\tparameter[%u]=ESCAPE, raw_bits=%u\n", i, subframe->data.fixed.entropy_coding_method.data.partitioned_rice.contents->raw_bits[i]);
else
fprintf(fout, "\t\tparameter[%u]=%u\n", i, parameter);
}
if(aopts.do_residual_text) {
for(i = 0; i < frame->header.blocksize-subframe->data.fixed.order; i++)
fprintf(fout, "\t\tresidual[%u]=%d\n", i, subframe->data.fixed.residual[i]);
}
break;
case FLAC__SUBFRAME_TYPE_LPC:
FLAC__ASSERT(subframe->data.lpc.entropy_coding_method.type <= FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2);
fprintf(fout, "\torder=%u\tqlp_coeff_precision=%u\tquantization_level=%d\tresidual_type=%s\tpartition_order=%u\n", subframe->data.lpc.order, subframe->data.lpc.qlp_coeff_precision, subframe->data.lpc.quantization_level, is_rice2? "RICE2":"RICE", subframe->data.lpc.entropy_coding_method.data.partitioned_rice.order);
for(i = 0; i < subframe->data.lpc.order; i++)
fprintf(fout, "\t\tqlp_coeff[%u]=%d\n", i, subframe->data.lpc.qlp_coeff[i]);
for(i = 0; i < subframe->data.lpc.order; i++)
fprintf(fout, "\t\twarmup[%u]=%d\n", i, subframe->data.lpc.warmup[i]);
partitions = (1u << subframe->data.lpc.entropy_coding_method.data.partitioned_rice.order);
for(i = 0; i < partitions; i++) {
unsigned parameter = subframe->data.lpc.entropy_coding_method.data.partitioned_rice.contents->parameters[i];
if(parameter == pesc)
fprintf(fout, "\t\tparameter[%u]=ESCAPE, raw_bits=%u\n", i, subframe->data.lpc.entropy_coding_method.data.partitioned_rice.contents->raw_bits[i]);
else
fprintf(fout, "\t\tparameter[%u]=%u\n", i, parameter);
}
if(aopts.do_residual_text) {
for(i = 0; i < frame->header.blocksize-subframe->data.lpc.order; i++)
fprintf(fout, "\t\tresidual[%u]=%d\n", i, subframe->data.lpc.residual[i]);
}
break;
case FLAC__SUBFRAME_TYPE_VERBATIM:
fprintf(fout, "\n");
break;
}
}
/* now do the residual distributions if requested */
if(aopts.do_residual_gnuplot) {
for(channel = 0; channel < channels; channel++) {
const FLAC__Subframe *subframe = frame->subframes+channel;
unsigned residual_samples;
init_stats(&stats);
switch(subframe->type) {
case FLAC__SUBFRAME_TYPE_FIXED:
residual_samples = frame->header.blocksize - subframe->data.fixed.order;
for(i = 0; i < residual_samples; i++)
update_stats(&stats, subframe->data.fixed.residual[i], 1);
break;
case FLAC__SUBFRAME_TYPE_LPC:
residual_samples = frame->header.blocksize - subframe->data.lpc.order;
for(i = 0; i < residual_samples; i++)
update_stats(&stats, subframe->data.lpc.residual[i], 1);
break;
default:
break;
}
/* update all_ */
for(i = 0; i < stats.nbuckets; i++) {
update_stats(&all_, stats.buckets[i].residual, stats.buckets[i].count);
}
/* write the subframe */
flac_snprintf(outfilename, sizeof (outfilename), "f%06u.s%u.gp", frame_number, channel);
compute_stats(&stats);
(void)dump_stats(&stats, outfilename);
}
}
}
void flac__analyze_finish(analysis_options aopts)
{
if(aopts.do_residual_gnuplot) {
compute_stats(&all_);
(void)dump_stats(&all_, "all");
}
}
void init_stats(subframe_stats_t *stats)
{
stats->peak_index = -1;
stats->nbuckets = 0;
stats->nsamples = 0;
stats->sum = 0.0;
stats->sos = 0.0;
}
void update_stats(subframe_stats_t *stats, FLAC__int32 residual, unsigned incr)
{
unsigned i;
const double r = (double)residual, a = r*incr;
stats->nsamples += incr;
stats->sum += a;
stats->sos += (a*r);
for(i = 0; i < stats->nbuckets; i++) {
if(stats->buckets[i].residual == residual) {
stats->buckets[i].count += incr;
goto find_peak;
}
}
/* not found, make a new bucket */
i = stats->nbuckets;
stats->buckets[i].residual = residual;
stats->buckets[i].count = incr;
stats->nbuckets++;
find_peak:
if(stats->peak_index < 0 || stats->buckets[i].count > stats->buckets[stats->peak_index].count)
stats->peak_index = i;
}
void compute_stats(subframe_stats_t *stats)
{
stats->mean = stats->sum / (double)stats->nsamples;
stats->variance = (stats->sos - (stats->sum * stats->sum / stats->nsamples)) / stats->nsamples;
stats->stddev = sqrt(stats->variance);
}
FLAC__bool dump_stats(const subframe_stats_t *stats, const char *filename)
{
FILE *outfile;
unsigned i;
const double m = stats->mean;
const double s1 = stats->stddev, s2 = s1*2, s3 = s1*3, s4 = s1*4, s5 = s1*5, s6 = s1*6;
const double p = stats->buckets[stats->peak_index].count;
outfile = flac_fopen(filename, "w");
if(0 == outfile) {
fprintf(stderr, "ERROR opening %s: %s\n", filename, strerror(errno));
return false;
}
fprintf(outfile, "plot '-' title 'PDF', '-' title 'mean' with impulses, '-' title '1-stddev' with histeps, '-' title '2-stddev' with histeps, '-' title '3-stddev' with histeps, '-' title '4-stddev' with histeps, '-' title '5-stddev' with histeps, '-' title '6-stddev' with histeps\n");
for(i = 0; i < stats->nbuckets; i++) {
fprintf(outfile, "%d %u\n", stats->buckets[i].residual, stats->buckets[i].count);
}
fprintf(outfile, "e\n");
fprintf(outfile, "%f %f\ne\n", stats->mean, p);
fprintf(outfile, "%f %f\n%f %f\ne\n", m-s1, p*0.8, m+s1, p*0.8);
fprintf(outfile, "%f %f\n%f %f\ne\n", m-s2, p*0.7, m+s2, p*0.7);
fprintf(outfile, "%f %f\n%f %f\ne\n", m-s3, p*0.6, m+s3, p*0.6);
fprintf(outfile, "%f %f\n%f %f\ne\n", m-s4, p*0.5, m+s4, p*0.5);
fprintf(outfile, "%f %f\n%f %f\ne\n", m-s5, p*0.4, m+s5, p*0.4);
fprintf(outfile, "%f %f\n%f %f\ne\n", m-s6, p*0.3, m+s6, p*0.3);
fprintf(outfile, "pause -1 'waiting...'\n");
fclose(outfile);
return true;
}

View File

@@ -0,0 +1,32 @@
/* flac - Command-line FLAC encoder/decoder
* Copyright (C) 2000-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef flac__analyze_h
#define flac__analyze_h
typedef struct {
FLAC__bool do_residual_text;
FLAC__bool do_residual_gnuplot;
} analysis_options;
void flac__analyze_init(analysis_options aopts);
void flac__analyze_frame(const FLAC__Frame *frame, unsigned frame_number, FLAC__uint64 frame_offset, unsigned frame_bytes, analysis_options aopts, FILE *fout);
void flac__analyze_finish(analysis_options aopts);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,71 @@
/* flac - Command-line FLAC encoder/decoder
* Copyright (C) 2000-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef flac__decode_h
#define flac__decode_h
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "analyze.h"
#include "foreign_metadata.h"
#include "utils.h"
#include "share/replaygain_synthesis.h"
typedef struct {
FLAC__bool apply;
FLAC__bool use_album_gain; /* false => use track gain */
enum { RGSS_LIMIT__NONE, RGSS_LIMIT__PEAK, RGSS_LIMIT__HARD} limiter;
NoiseShaping noise_shaping;
double preamp;
} replaygain_synthesis_spec_t;
typedef struct {
FLAC__bool treat_warnings_as_errors;
FLAC__bool continue_through_decode_errors;
replaygain_synthesis_spec_t replaygain_synthesis_spec;
#if FLAC__HAS_OGG
FLAC__bool is_ogg;
FLAC__bool use_first_serial_number;
long serial_number;
#endif
utils__SkipUntilSpecification skip_specification;
utils__SkipUntilSpecification until_specification;
FLAC__bool has_cue_specification;
utils__CueSpecification cue_specification;
FLAC__bool channel_map_none; /* --channel-map=none specified, eventually will expand to take actual channel map */
FileFormat format;
union {
struct {
FLAC__bool is_big_endian;
FLAC__bool is_unsigned_samples;
} raw;
struct {
foreign_metadata_t *foreign_metadata; /* NULL unless --keep-foreign-metadata requested */
} iff;
} format_options;
} decode_options_t;
/* outfile == 0 => test only */
int flac__decode_file(const char *infilename, const char *outfilename, FLAC__bool analysis_mode, analysis_options aopts, decode_options_t options);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,117 @@
/* flac - Command-line FLAC encoder/decoder
* Copyright (C) 2000-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef flac__encode_h
#define flac__encode_h
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "FLAC/metadata.h"
#include "foreign_metadata.h"
#include "utils.h"
#include "share/compat.h"
extern const int FLAC_ENCODE__DEFAULT_PADDING;
typedef enum {
CST_BLOCKSIZE,
CST_COMPRESSION_LEVEL,
CST_DO_MID_SIDE,
CST_LOOSE_MID_SIDE,
CST_APODIZATION,
CST_MAX_LPC_ORDER,
CST_QLP_COEFF_PRECISION,
CST_DO_QLP_COEFF_PREC_SEARCH,
CST_DO_ESCAPE_CODING,
CST_DO_EXHAUSTIVE_MODEL_SEARCH,
CST_MIN_RESIDUAL_PARTITION_ORDER,
CST_MAX_RESIDUAL_PARTITION_ORDER,
CST_RICE_PARAMETER_SEARCH_DIST
} compression_setting_type_t;
typedef struct {
compression_setting_type_t type;
union {
FLAC__bool t_bool;
unsigned t_unsigned;
const char *t_string;
} value;
} compression_setting_t;
typedef struct {
utils__SkipUntilSpecification skip_specification;
utils__SkipUntilSpecification until_specification;
FLAC__bool verify;
#if FLAC__HAS_OGG
FLAC__bool use_ogg;
long serial_number;
#endif
FLAC__bool lax;
int padding;
size_t num_compression_settings;
compression_setting_t compression_settings[64];
char *requested_seek_points;
int num_requested_seek_points;
const char *cuesheet_filename;
FLAC__bool treat_warnings_as_errors;
FLAC__bool continue_through_decode_errors; /* currently only obeyed when encoding from FLAC or Ogg FLAC */
FLAC__bool cued_seekpoints;
FLAC__bool channel_map_none; /* --channel-map=none specified, eventually will expand to take actual channel map */
/* options related to --replay-gain and --sector-align */
FLAC__bool is_first_file;
FLAC__bool is_last_file;
FLAC__int32 **align_reservoir;
unsigned *align_reservoir_samples;
FLAC__bool replay_gain;
FLAC__bool ignore_chunk_sizes;
FLAC__bool sector_align;
FLAC__bool error_on_compression_fail;
FLAC__StreamMetadata *vorbis_comment;
FLAC__StreamMetadata *pictures[64];
unsigned num_pictures;
FileFormat format;
union {
struct {
FLAC__bool is_big_endian;
FLAC__bool is_unsigned_samples;
unsigned channels;
unsigned bps;
unsigned sample_rate;
} raw;
struct {
foreign_metadata_t *foreign_metadata; /* NULL unless --keep-foreign-metadata requested */
} iff;
} format_options;
struct {
FLAC__bool disable_constant_subframes;
FLAC__bool disable_fixed_subframes;
FLAC__bool disable_verbatim_subframes;
FLAC__bool do_md5;
} debug;
} encode_options_t;
int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, encode_options_t options);
#endif

View File

@@ -0,0 +1,255 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="flac"
ProjectGUID="{4cefbc7d-c215-11db-8314-0800200c9a66}"
RootNamespace="flac"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)objs\$(ConfigurationName)\bin"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".;..\..\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;FLAC__HAS_OGG;FLAC__NO_DLL;DEBUG"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
CompileAs="0"
DisableSpecificWarnings="4267;4996"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(SolutionDir)objs\$(ConfigurationName)\lib\libogg_static.lib"
LinkIncremental="2"
IgnoreDefaultLibraryNames="uuid.lib"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)objs\$(ConfigurationName)\bin"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories=".;..\..\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;FLAC__HAS_OGG;FLAC__NO_DLL"
RuntimeLibrary="0"
BufferSecurityCheck="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CompileAs="0"
DisableSpecificWarnings="4267;4996"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(SolutionDir)objs\$(ConfigurationName)\lib\libogg_static.lib"
LinkIncremental="1"
IgnoreDefaultLibraryNames="uuid.lib"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
LinkTimeCodeGeneration="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\analyze.h"
>
</File>
<File
RelativePath=".\decode.h"
>
</File>
<File
RelativePath=".\encode.h"
>
</File>
<File
RelativePath=".\foreign_metadata.h"
>
</File>
<File
RelativePath=".\local_string_utils.h"
>
</File>
<File
RelativePath=".\utils.h"
>
</File>
<File
RelativePath=".\vorbiscomment.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\analyze.c"
>
</File>
<File
RelativePath=".\decode.c"
>
</File>
<File
RelativePath=".\encode.c"
>
</File>
<File
RelativePath=".\foreign_metadata.c"
>
</File>
<File
RelativePath=".\local_string_utils.c"
>
</File>
<File
RelativePath=".\main.c"
>
</File>
<File
RelativePath=".\utils.c"
>
</File>
<File
RelativePath=".\vorbiscomment.c"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,219 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4cefbc7d-c215-11db-8314-0800200c9a66}</ProjectGuid>
<RootNamespace>flac</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)objs\$(Configuration)\bin\</OutDir>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)objs\$(Platform)\$(Configuration)\bin\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)objs\$(Configuration)\bin\</OutDir>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)objs\$(Platform)\$(Configuration)\bin\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;FLAC__HAS_OGG;FLAC__NO_DLL;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4267;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>$(SolutionDir)objs\$(Configuration)\lib\libogg_static.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>uuid.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;FLAC__HAS_OGG;FLAC__NO_DLL;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4267;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>$(SolutionDir)objs\$(Platform)\$(Configuration)\lib\libogg_static.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>uuid.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<WholeProgramOptimization>true</WholeProgramOptimization>
<AdditionalIncludeDirectories>.;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;FLAC__HAS_OGG;FLAC__NO_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4267;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>$(SolutionDir)objs\$(Configuration)\lib\libogg_static.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>uuid.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<WholeProgramOptimization>true</WholeProgramOptimization>
<AdditionalIncludeDirectories>.;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;FLAC__HAS_OGG;FLAC__NO_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4267;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>$(SolutionDir)objs\$(Platform)\$(Configuration)\lib\libogg_static.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>uuid.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="analyze.h" />
<ClInclude Include="decode.h" />
<ClInclude Include="encode.h" />
<ClInclude Include="foreign_metadata.h" />
<ClInclude Include="local_string_utils.h" />
<ClInclude Include="utils.h" />
<ClInclude Include="vorbiscomment.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="analyze.c" />
<ClCompile Include="decode.c" />
<ClCompile Include="encode.c" />
<ClCompile Include="foreign_metadata.c" />
<ClCompile Include="local_string_utils.c" />
<ClCompile Include="main.c" />
<ClCompile Include="utils.c" />
<ClCompile Include="vorbiscomment.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\libFLAC\libFLAC_static.vcxproj">
<Project>{4cefbc84-c215-11db-8314-0800200c9a66}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\share\getopt\getopt_static.vcxproj">
<Project>{4cefbc80-c215-11db-8314-0800200c9a66}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\share\grabbag\grabbag_static.vcxproj">
<Project>{4cefbc81-c215-11db-8314-0800200c9a66}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\share\replaygain_analysis\replaygain_analysis_static.vcxproj">
<Project>{4cefbc89-c215-11db-8314-0800200c9a66}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\share\replaygain_synthesis\replaygain_synthesis_static.vcxproj">
<Project>{4cefbc8a-c215-11db-8314-0800200c9a66}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\share\utf8\utf8_static.vcxproj">
<Project>{4cefbc92-c215-11db-8314-0800200c9a66}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\share\win_utf8_io\win_utf8_io_static.vcxproj">
<Project>{4cefbe02-c215-11db-8314-0800200c9a66}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="analyze.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="decode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="encode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="foreign_metadata.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="local_string_utils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="utils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="vorbiscomment.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="analyze.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="decode.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="encode.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="foreign_metadata.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="local_string_utils.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="utils.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="vorbiscomment.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,819 @@
/* flac - Command-line FLAC encoder/decoder
* Copyright (C) 2000-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h> /* for FILE etc. */
#include <stdlib.h> /* for calloc() etc. */
#include <string.h> /* for memcmp() etc. */
#include "FLAC/assert.h"
#include "FLAC/metadata.h"
#include "share/alloc.h"
#include "share/compat.h"
#include "foreign_metadata.h"
#ifdef min
#undef min
#endif
#define min(x,y) ((x)<(y)?(x):(y))
static const char *FLAC__FOREIGN_METADATA_APPLICATION_ID[3] = { "aiff" , "riff", "w64 " };
static FLAC__uint32 unpack32be_(const FLAC__byte *b)
{
return ((FLAC__uint32)b[0]<<24) + ((FLAC__uint32)b[1]<<16) + ((FLAC__uint32)b[2]<<8) + (FLAC__uint32)b[3];
}
static FLAC__uint32 unpack32le_(const FLAC__byte *b)
{
return (FLAC__uint32)b[0] + ((FLAC__uint32)b[1]<<8) + ((FLAC__uint32)b[2]<<16) + ((FLAC__uint32)b[3]<<24);
}
static FLAC__uint64 unpack64le_(const FLAC__byte *b)
{
return (FLAC__uint64)b[0] + ((FLAC__uint64)b[1]<<8) + ((FLAC__uint64)b[2]<<16) + ((FLAC__uint64)b[3]<<24) + ((FLAC__uint64)b[4]<<32) + ((FLAC__uint64)b[5]<<40) + ((FLAC__uint64)b[6]<<48) + ((FLAC__uint64)b[7]<<56);
}
/* copies 'size' bytes from file 'fin' to 'fout', filling in *error with 'read_error' or 'write_error' as necessary */
static FLAC__bool copy_data_(FILE *fin, FILE *fout, size_t size, const char **error, const char * const read_error, const char * const write_error)
{
FLAC__byte buffer[4096];
size_t left;
for(left = size; left > 0; ) {
size_t need = min(sizeof(buffer), left);
if(fread(buffer, 1, need, fin) < need) {
if(error) *error = read_error;
return false;
}
if(fwrite(buffer, 1, need, fout) < need) {
if(error) *error = write_error;
return false;
}
left -= need;
}
return true;
}
static FLAC__bool append_block_(foreign_metadata_t *fm, FLAC__off_t offset, FLAC__uint32 size, const char **error)
{
foreign_block_t *fb = safe_realloc_muladd2_(fm->blocks, sizeof(foreign_block_t), /*times (*/fm->num_blocks, /*+*/1/*)*/);
if(fb) {
fb[fm->num_blocks].offset = offset;
fb[fm->num_blocks].size = size;
fm->num_blocks++;
fm->blocks = fb;
return true;
}
if(error) *error = "out of memory";
return false;
}
static FLAC__bool read_from_aiff_(foreign_metadata_t *fm, FILE *f, const char **error)
{
FLAC__byte buffer[12];
FLAC__off_t offset, eof_offset;
if((offset = ftello(f)) < 0) {
if(error) *error = "ftello() error (001)";
return false;
}
if(fread(buffer, 1, 12, f) < 12 || memcmp(buffer, "FORM", 4) || (memcmp(buffer+8, "AIFF", 4) && memcmp(buffer+8, "AIFC", 4))) {
if(error) *error = "unsupported FORM layout (002)";
return false;
}
if(!append_block_(fm, offset, 12, error))
return false;
eof_offset = (FLAC__off_t)8 + (FLAC__off_t)unpack32be_(buffer+4);
while(!feof(f)) {
FLAC__uint32 size;
if((offset = ftello(f)) < 0) {
if(error) *error = "ftello() error (003)";
return false;
}
if((size = fread(buffer, 1, 8, f)) < 8) {
if(size == 0 && feof(f))
break;
if(error) *error = "invalid AIFF file (004)";
return false;
}
size = unpack32be_(buffer+4);
/* check if pad byte needed */
if(size & 1)
size++;
if(!memcmp(buffer, "COMM", 4)) {
if(fm->format_block) {
if(error) *error = "invalid AIFF file: multiple \"COMM\" chunks (005)";
return false;
}
if(fm->audio_block) {
if(error) *error = "invalid AIFF file: \"SSND\" chunk before \"COMM\" chunk (006)";
return false;
}
fm->format_block = fm->num_blocks;
}
else if(!memcmp(buffer, "SSND", 4)) {
if(fm->audio_block) {
if(error) *error = "invalid AIFF file: multiple \"SSND\" chunks (007)";
return false;
}
if(!fm->format_block) {
if(error) *error = "invalid AIFF file: \"SSND\" chunk before \"COMM\" chunk (008)";
return false;
}
fm->audio_block = fm->num_blocks;
/* read #offset bytes */
if(fread(buffer+8, 1, 4, f) < 4) {
if(error) *error = "invalid AIFF file (009)";
return false;
}
fm->ssnd_offset_size = unpack32be_(buffer+8);
if(fseeko(f, -4, SEEK_CUR) < 0) {
if(error) *error = "invalid AIFF file: seek error (010)";
return false;
}
/* WATCHOUT: For SSND we ignore the blockSize and are not saving any
* unaligned part at the end of the chunk. In retrospect it is pretty
* pointless to save the unaligned data before the PCM but now it is
* done and cast in stone.
*/
}
if(!append_block_(fm, offset, 8 + (memcmp(buffer, "SSND", 4)? size : 8 + fm->ssnd_offset_size), error))
return false;
/* skip to next chunk */
if(fseeko(f, size, SEEK_CUR) < 0) {
if(error) *error = "invalid AIFF file: seek error (011)";
return false;
}
}
if(eof_offset != ftello(f)) {
if(error) *error = "invalid AIFF file: unexpected EOF (012)";
return false;
}
if(!fm->format_block) {
if(error) *error = "invalid AIFF file: missing \"COMM\" chunk (013)";
return false;
}
if(!fm->audio_block) {
if(error) *error = "invalid AIFF file: missing \"SSND\" chunk (014)";
return false;
}
return true;
}
static FLAC__bool read_from_wave_(foreign_metadata_t *fm, FILE *f, const char **error)
{
FLAC__byte buffer[12];
FLAC__off_t offset, eof_offset = -1, ds64_data_size = -1;
if((offset = ftello(f)) < 0) {
if(error) *error = "ftello() error (001)";
return false;
}
if(fread(buffer, 1, 12, f) < 12 || (memcmp(buffer, "RIFF", 4) && memcmp(buffer, "RF64", 4)) || memcmp(buffer+8, "WAVE", 4)) {
if(error) *error = "unsupported RIFF layout (002)";
return false;
}
if(!memcmp(buffer, "RF64", 4))
fm->is_rf64 = true;
if(fm->is_rf64 && sizeof(FLAC__off_t) < 8) {
if(error) *error = "RF64 is not supported on this compile (r00)";
return false;
}
if(!append_block_(fm, offset, 12, error))
return false;
if(!fm->is_rf64 || unpack32le_(buffer+4) != 0xffffffff) {
eof_offset = (FLAC__off_t)8 + (FLAC__off_t)unpack32le_(buffer+4);
if(eof_offset & 1) /* fix odd RIFF size */
eof_offset++;
}
while(!feof(f)) {
FLAC__uint32 size;
if((offset = ftello(f)) < 0) {
if(error) *error = "ftello() error (003)";
return false;
}
if((size = fread(buffer, 1, 8, f)) < 8) {
if(size == 0 && feof(f))
break;
if(error) *error = "invalid WAVE file (004)";
return false;
}
size = unpack32le_(buffer+4);
/* check if pad byte needed */
if(size & 1)
size++;
if(!memcmp(buffer, "fmt ", 4)) {
if(fm->format_block) {
if(error) *error = "invalid WAVE file: multiple \"fmt \" chunks (005)";
return false;
}
if(fm->audio_block) {
if(error) *error = "invalid WAVE file: \"data\" chunk before \"fmt \" chunk (006)";
return false;
}
fm->format_block = fm->num_blocks;
}
else if(!memcmp(buffer, "data", 4)) {
if(fm->audio_block) {
if(error) *error = "invalid WAVE file: multiple \"data\" chunks (007)";
return false;
}
if(!fm->format_block) {
if(error) *error = "invalid WAVE file: \"data\" chunk before \"fmt \" chunk (008)";
return false;
}
fm->audio_block = fm->num_blocks;
if(fm->is_rf64 && fm->num_blocks < 2) {
if(error) *error = "invalid RF64 file: \"data\" chunk before \"ds64\" chunk (r01)";
return false;
}
}
if(!append_block_(fm, offset, 8 + (memcmp(buffer, "data", 4)? size : 0), error))
return false;
/* parse ds64 chunk if necessary */
if(fm->is_rf64 && fm->num_blocks == 2) {
FLAC__byte buffer2[7*4];
if(memcmp(buffer, "ds64", 4)) {
if(error) *error = "invalid RF64 file: \"ds64\" chunk does not immediately follow \"WAVE\" marker (r02)";
return false;
}
/* unpack the size again since we don't want the padding byte effect */
size = unpack32le_(buffer+4);
if(size < sizeof(buffer2)) {
if(error) *error = "invalid RF64 file: \"ds64\" chunk size is < 28 (r03)";
return false;
}
if(size > sizeof(buffer2)) {
if(error) *error = "RF64 file has \"ds64\" chunk with extra size table, which is not currently supported (r04)";
return false;
}
if(fread(buffer2, 1, sizeof(buffer2), f) < sizeof(buffer2)) {
if(error) *error = "unexpected EOF reading \"ds64\" chunk data in RF64 file (r05)";
return false;
}
ds64_data_size = (FLAC__off_t)unpack64le_(buffer2+8);
if(ds64_data_size == (FLAC__off_t)(-1)) {
if(error) *error = "RF64 file has \"ds64\" chunk with data size == -1 (r08)";
return false;
}
/* check if pad byte needed */
if(ds64_data_size & 1)
ds64_data_size++;
/* @@@ [2^63 limit] */
if(ds64_data_size < 0) {
if(error) *error = "RF64 file too large (r09)";
return false;
}
if(unpack32le_(buffer2+24)) {
if(error) *error = "RF64 file has \"ds64\" chunk with extra size table, which is not currently supported (r06)";
return false;
}
eof_offset = (FLAC__off_t)8 + (FLAC__off_t)unpack64le_(buffer2);
/* @@@ [2^63 limit] */
if((FLAC__off_t)unpack64le_(buffer2) < 0 || eof_offset < 0) {
if(error) *error = "RF64 file too large (r07)";
return false;
}
}
else { /* skip to next chunk */
if(fm->is_rf64 && !memcmp(buffer, "data", 4) && unpack32le_(buffer+4) == 0xffffffff) {
if(fseeko(f, ds64_data_size, SEEK_CUR) < 0) {
if(error) *error = "invalid RF64 file: seek error (r10)";
return false;
}
}
else {
if(fseeko(f, size, SEEK_CUR) < 0) {
if(error) *error = "invalid WAVE file: seek error (009)";
return false;
}
}
}
}
if(fm->is_rf64 && eof_offset == (FLAC__off_t)(-1)) {
if(error) *error = "invalid RF64 file: all RIFF sizes are -1 (r11)";
return false;
}
if(eof_offset != ftello(f)) {
if(error) *error = "invalid WAVE file: unexpected EOF (010)";
return false;
}
if(!fm->format_block) {
if(error) *error = "invalid WAVE file: missing \"fmt \" chunk (011)";
return false;
}
if(!fm->audio_block) {
if(error) *error = "invalid WAVE file: missing \"data\" chunk (012)";
return false;
}
return true;
}
static FLAC__bool read_from_wave64_(foreign_metadata_t *fm, FILE *f, const char **error)
{
FLAC__byte buffer[40];
FLAC__off_t offset, eof_offset = -1;
if((offset = ftello(f)) < 0) {
if(error) *error = "ftello() error (001)";
return false;
}
if(
fread(buffer, 1, 40, f) < 40 ||
/* RIFF GUID 66666972-912E-11CF-A5D6-28DB04C10000 */
memcmp(buffer, "\x72\x69\x66\x66\x2E\x91\xCF\x11\xA5\xD6\x28\xDB\x04\xC1\x00\x00", 16) ||
/* WAVE GUID 65766177-ACF3-11D3-8CD1-00C04F8EDB8A */
memcmp(buffer+24, "\x77\x61\x76\x65\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 16)
) {
if(error) *error = "unsupported Wave64 layout (002)";
return false;
}
if(sizeof(FLAC__off_t) < 8) {
if(error) *error = "Wave64 is not supported on this compile (r00)";
return false;
}
if(!append_block_(fm, offset, 40, error))
return false;
eof_offset = (FLAC__off_t)unpack64le_(buffer+16); /*@@@ [2^63 limit] */
while(!feof(f)) {
FLAC__uint64 size;
if((offset = ftello(f)) < 0) {
if(error) *error = "ftello() error (003)";
return false;
}
if((size = fread(buffer, 1, 24, f)) < 24) {
if(size == 0 && feof(f))
break;
if(error) *error = "invalid Wave64 file (004)";
return false;
}
size = unpack64le_(buffer+16);
/* check if pad bytes needed */
if(size & 7)
size = (size+7) & (~((FLAC__uint64)7));
/* fmt GUID 20746D66-ACF3-11D3-8CD1-00C04F8EDB8A */
if(!memcmp(buffer, "\x66\x6D\x74\x20\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 16)) {
if(fm->format_block) {
if(error) *error = "invalid Wave64 file: multiple \"fmt \" chunks (005)";
return false;
}
if(fm->audio_block) {
if(error) *error = "invalid Wave64 file: \"data\" chunk before \"fmt \" chunk (006)";
return false;
}
fm->format_block = fm->num_blocks;
}
/* data GUID 61746164-ACF3-11D3-8CD1-00C04F8EDB8A */
else if(!memcmp(buffer, "\x64\x61\x74\x61\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 16)) {
if(fm->audio_block) {
if(error) *error = "invalid Wave64 file: multiple \"data\" chunks (007)";
return false;
}
if(!fm->format_block) {
if(error) *error = "invalid Wave64 file: \"data\" chunk before \"fmt \" chunk (008)";
return false;
}
fm->audio_block = fm->num_blocks;
}
if(!append_block_(fm, offset, memcmp(buffer, "\x64\x61\x74\x61\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 16)? (FLAC__uint32)size : 16+8, error))
return false;
/* skip to next chunk */
if(fseeko(f, size-24, SEEK_CUR) < 0) {
if(error) *error = "invalid Wave64 file: seek error (009)";
return false;
}
}
if(eof_offset != ftello(f)) {
if(error) *error = "invalid Wave64 file: unexpected EOF (010)";
return false;
}
if(!fm->format_block) {
if(error) *error = "invalid Wave64 file: missing \"fmt \" chunk (011)";
return false;
}
if(!fm->audio_block) {
if(error) *error = "invalid Wave64 file: missing \"data\" chunk (012)";
return false;
}
return true;
}
static FLAC__bool write_to_flac_(foreign_metadata_t *fm, FILE *fin, FILE *fout, FLAC__Metadata_SimpleIterator *it, const char **error)
{
FLAC__byte buffer[4];
const unsigned ID_LEN = FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8;
size_t block_num = 0;
FLAC__ASSERT(sizeof(buffer) >= ID_LEN);
while(block_num < fm->num_blocks) {
/* find next matching padding block */
do {
/* even on the first chunk's loop there will be a skippable STREAMINFO block, on subsequent loops we are first moving past the PADDING we just used */
if(!FLAC__metadata_simple_iterator_next(it)) {
if(error) *error = "no matching PADDING block found (004)";
return false;
}
} while(FLAC__metadata_simple_iterator_get_block_type(it) != FLAC__METADATA_TYPE_PADDING);
if(FLAC__metadata_simple_iterator_get_block_length(it) != ID_LEN+fm->blocks[block_num].size) {
if(error) *error = "PADDING block with wrong size found (005)";
return false;
}
/* transfer chunk into APPLICATION block */
/* first set up the file pointers */
if(fseeko(fin, fm->blocks[block_num].offset, SEEK_SET) < 0) {
if(error) *error = "seek failed in WAVE/AIFF file (006)";
return false;
}
if(fseeko(fout, FLAC__metadata_simple_iterator_get_block_offset(it), SEEK_SET) < 0) {
if(error) *error = "seek failed in FLAC file (007)";
return false;
}
/* update the type */
buffer[0] = FLAC__METADATA_TYPE_APPLICATION;
if(FLAC__metadata_simple_iterator_is_last(it))
buffer[0] |= 0x80; /*MAGIC number*/
if(fwrite(buffer, 1, 1, fout) < 1) {
if(error) *error = "write failed in FLAC file (008)";
return false;
}
/* length stays the same so skip over it */
if(fseeko(fout, FLAC__STREAM_METADATA_LENGTH_LEN/8, SEEK_CUR) < 0) {
if(error) *error = "seek failed in FLAC file (009)";
return false;
}
/* write the APPLICATION ID */
memcpy(buffer, FLAC__FOREIGN_METADATA_APPLICATION_ID[fm->type], ID_LEN);
if(fwrite(buffer, 1, ID_LEN, fout) < ID_LEN) {
if(error) *error = "write failed in FLAC file (010)";
return false;
}
/* transfer the foreign metadata */
if(!copy_data_(fin, fout, fm->blocks[block_num].size, error, "read failed in WAVE/AIFF file (011)", "write failed in FLAC file (012)"))
return false;
block_num++;
}
return true;
}
static FLAC__bool read_from_flac_(foreign_metadata_t *fm, FILE *f, FLAC__Metadata_SimpleIterator *it, const char **error)
{
FLAC__byte id[4], buffer[12];
FLAC__off_t offset;
FLAC__bool type_found = false, ds64_found = false;
FLAC__ASSERT(FLAC__STREAM_METADATA_APPLICATION_ID_LEN == sizeof(id)*8);
while(FLAC__metadata_simple_iterator_next(it)) {
if(FLAC__metadata_simple_iterator_get_block_type(it) != FLAC__METADATA_TYPE_APPLICATION)
continue;
if(!FLAC__metadata_simple_iterator_get_application_id(it, id)) {
if(error) *error = "FLAC__metadata_simple_iterator_get_application_id() error (002)";
return false;
}
if(memcmp(id, FLAC__FOREIGN_METADATA_APPLICATION_ID[fm->type], sizeof(id)))
continue;
offset = FLAC__metadata_simple_iterator_get_block_offset(it);
/* skip over header and app ID */
offset += (FLAC__STREAM_METADATA_IS_LAST_LEN + FLAC__STREAM_METADATA_TYPE_LEN + FLAC__STREAM_METADATA_LENGTH_LEN) / 8;
offset += sizeof(id);
/* look for format or audio blocks */
if(fseeko(f, offset, SEEK_SET) < 0) {
if(error) *error = "seek error (003)";
return false;
}
if(fread(buffer, 1, 4, f) != 4) {
if(error) *error = "read error (004)";
return false;
}
if(fm->num_blocks == 0) { /* first block? */
fm->is_rf64 = 0 == memcmp(buffer, "RF64", 4);
if(fm->type == FOREIGN_BLOCK_TYPE__RIFF && (0 == memcmp(buffer, "RIFF", 4) || fm->is_rf64))
type_found = true;
else if(fm->type == FOREIGN_BLOCK_TYPE__WAVE64 && 0 == memcmp(buffer, "riff", 4)) /* use first 4 bytes instead of whole GUID */
type_found = true;
else if(fm->type == FOREIGN_BLOCK_TYPE__AIFF && 0 == memcmp(buffer, "FORM", 4))
type_found = true;
else {
if(error) *error = "unsupported foreign metadata found, may need newer FLAC decoder (005)";
return false;
}
}
else if(!type_found) {
FLAC__ASSERT(0);
/* double protection: */
if(error) *error = "unsupported foreign metadata found, may need newer FLAC decoder (006)";
return false;
}
else if(fm->type == FOREIGN_BLOCK_TYPE__RIFF) {
if(!memcmp(buffer, "fmt ", 4)) {
if(fm->format_block) {
if(error) *error = "invalid WAVE metadata: multiple \"fmt \" chunks (007)";
return false;
}
if(fm->audio_block) {
if(error) *error = "invalid WAVE metadata: \"data\" chunk before \"fmt \" chunk (008)";
return false;
}
fm->format_block = fm->num_blocks;
}
else if(!memcmp(buffer, "data", 4)) {
if(fm->audio_block) {
if(error) *error = "invalid WAVE metadata: multiple \"data\" chunks (009)";
return false;
}
if(!fm->format_block) {
if(error) *error = "invalid WAVE metadata: \"data\" chunk before \"fmt \" chunk (010)";
return false;
}
fm->audio_block = fm->num_blocks;
}
else if(fm->is_rf64 && fm->num_blocks == 1) {
if(memcmp(buffer, "ds64", 4)) {
if(error) *error = "invalid RF64 metadata: second chunk is not \"ds64\" (011)";
return false;
}
ds64_found = true;
}
}
else if(fm->type == FOREIGN_BLOCK_TYPE__WAVE64) {
if(!memcmp(buffer, "fmt ", 4)) { /* use first 4 bytes instead of whole GUID */
if(fm->format_block) {
if(error) *error = "invalid Wave64 metadata: multiple \"fmt \" chunks (012)";
return false;
}
if(fm->audio_block) {
if(error) *error = "invalid Wave64 metadata: \"data\" chunk before \"fmt \" chunk (013)";
return false;
}
fm->format_block = fm->num_blocks;
}
else if(!memcmp(buffer, "data", 4)) { /* use first 4 bytes instead of whole GUID */
if(fm->audio_block) {
if(error) *error = "invalid Wave64 metadata: multiple \"data\" chunks (014)";
return false;
}
if(!fm->format_block) {
if(error) *error = "invalid Wave64 metadata: \"data\" chunk before \"fmt \" chunk (015)";
return false;
}
fm->audio_block = fm->num_blocks;
}
}
else if(fm->type == FOREIGN_BLOCK_TYPE__AIFF) {
if(!memcmp(buffer, "COMM", 4)) {
if(fm->format_block) {
if(error) *error = "invalid AIFF metadata: multiple \"COMM\" chunks (016)";
return false;
}
if(fm->audio_block) {
if(error) *error = "invalid AIFF metadata: \"SSND\" chunk before \"COMM\" chunk (017)";
return false;
}
fm->format_block = fm->num_blocks;
}
else if(!memcmp(buffer, "SSND", 4)) {
if(fm->audio_block) {
if(error) *error = "invalid AIFF metadata: multiple \"SSND\" chunks (018)";
return false;
}
if(!fm->format_block) {
if(error) *error = "invalid AIFF metadata: \"SSND\" chunk before \"COMM\" chunk (019)";
return false;
}
fm->audio_block = fm->num_blocks;
/* read SSND offset size */
if(fread(buffer+4, 1, 8, f) != 8) {
if(error) *error = "read error (020)";
return false;
}
fm->ssnd_offset_size = unpack32be_(buffer+8);
}
}
else {
FLAC__ASSERT(0);
/* double protection: */
if(error) *error = "unsupported foreign metadata found, may need newer FLAC decoder (021)";
return false;
}
if(!append_block_(fm, offset, FLAC__metadata_simple_iterator_get_block_length(it)-sizeof(id), error))
return false;
}
if(!type_found) {
if(error) *error = "no foreign metadata found (022)";
return false;
}
if(fm->is_rf64 && !ds64_found) {
if(error) *error = "invalid RF64 file: second chunk is not \"ds64\" (023)";
return false;
}
if(!fm->format_block) {
if(error)
*error =
fm->type==FOREIGN_BLOCK_TYPE__RIFF? "invalid WAVE file: missing \"fmt \" chunk (024)" :
fm->type==FOREIGN_BLOCK_TYPE__WAVE64? "invalid Wave64 file: missing \"fmt \" chunk (025)" :
"invalid AIFF file: missing \"COMM\" chunk (026)";
return false;
}
if(!fm->audio_block) {
if(error)
*error =
fm->type==FOREIGN_BLOCK_TYPE__RIFF? "invalid WAVE file: missing \"data\" chunk (027)" :
fm->type==FOREIGN_BLOCK_TYPE__WAVE64? "invalid Wave64 file: missing \"data\" chunk (028)" :
"invalid AIFF file: missing \"SSND\" chunk (029)";
return false;
}
return true;
}
static FLAC__bool write_to_iff_(foreign_metadata_t *fm, FILE *fin, FILE *fout, FLAC__off_t offset1, FLAC__off_t offset2, FLAC__off_t offset3, const char **error)
{
size_t i;
if(fseeko(fout, offset1, SEEK_SET) < 0) {
if(error) *error = "seek failed in WAVE/AIFF file (002)";
return false;
}
/* don't write first (RIFF/RF64/FORM) chunk, or ds64 chunk in the case of RF64 */
for(i = fm->is_rf64?2:1; i < fm->format_block; i++) {
if(fseeko(fin, fm->blocks[i].offset, SEEK_SET) < 0) {
if(error) *error = "seek failed in FLAC file (003)";
return false;
}
if(!copy_data_(fin, fout, fm->blocks[i].size, error, "read failed in WAVE/AIFF file (004)", "write failed in FLAC file (005)"))
return false;
}
if(fseeko(fout, offset2, SEEK_SET) < 0) {
if(error) *error = "seek failed in WAVE/AIFF file (006)";
return false;
}
for(i = fm->format_block+1; i < fm->audio_block; i++) {
if(fseeko(fin, fm->blocks[i].offset, SEEK_SET) < 0) {
if(error) *error = "seek failed in FLAC file (007)";
return false;
}
if(!copy_data_(fin, fout, fm->blocks[i].size, error, "read failed in WAVE/AIFF file (008)", "write failed in FLAC file (009)"))
return false;
}
if(fseeko(fout, offset3, SEEK_SET) < 0) {
if(error) *error = "seek failed in WAVE/AIFF file (010)";
return false;
}
for(i = fm->audio_block+1; i < fm->num_blocks; i++) {
if(fseeko(fin, fm->blocks[i].offset, SEEK_SET) < 0) {
if(error) *error = "seek failed in FLAC file (011)";
return false;
}
if(!copy_data_(fin, fout, fm->blocks[i].size, error, "read failed in WAVE/AIFF file (012)", "write failed in FLAC file (013)"))
return false;
}
return true;
}
foreign_metadata_t *flac__foreign_metadata_new(foreign_block_type_t type)
{
/* calloc() to zero all the member variables */
foreign_metadata_t *x = calloc(sizeof(foreign_metadata_t), 1);
if(x) {
x->type = type;
x->is_rf64 = false;
}
return x;
}
void flac__foreign_metadata_delete(foreign_metadata_t *fm)
{
if(fm) {
if(fm->blocks)
free(fm->blocks);
free(fm);
}
}
FLAC__bool flac__foreign_metadata_read_from_aiff(foreign_metadata_t *fm, const char *filename, const char **error)
{
FLAC__bool ok;
FILE *f = flac_fopen(filename, "rb");
if(!f) {
if(error) *error = "can't open AIFF file for reading (000)";
return false;
}
ok = read_from_aiff_(fm, f, error);
fclose(f);
return ok;
}
FLAC__bool flac__foreign_metadata_read_from_wave(foreign_metadata_t *fm, const char *filename, const char **error)
{
FLAC__bool ok;
FILE *f = flac_fopen(filename, "rb");
if(!f) {
if(error) *error = "can't open WAVE file for reading (000)";
return false;
}
ok = read_from_wave_(fm, f, error);
fclose(f);
return ok;
}
FLAC__bool flac__foreign_metadata_read_from_wave64(foreign_metadata_t *fm, const char *filename, const char **error)
{
FLAC__bool ok;
FILE *f = flac_fopen(filename, "rb");
if(!f) {
if(error) *error = "can't open Wave64 file for reading (000)";
return false;
}
ok = read_from_wave64_(fm, f, error);
fclose(f);
return ok;
}
FLAC__bool flac__foreign_metadata_write_to_flac(foreign_metadata_t *fm, const char *infilename, const char *outfilename, const char **error)
{
FLAC__bool ok;
FILE *fin, *fout;
FLAC__Metadata_SimpleIterator *it = FLAC__metadata_simple_iterator_new();
if(!it) {
if(error) *error = "out of memory (000)";
return false;
}
if(!FLAC__metadata_simple_iterator_init(it, outfilename, /*read_only=*/true, /*preserve_file_stats=*/false)) {
if(error) *error = "can't initialize iterator (001)";
FLAC__metadata_simple_iterator_delete(it);
return false;
}
if(0 == (fin = flac_fopen(infilename, "rb"))) {
if(error) *error = "can't open WAVE/AIFF file for reading (002)";
FLAC__metadata_simple_iterator_delete(it);
return false;
}
if(0 == (fout = flac_fopen(outfilename, "r+b"))) {
if(error) *error = "can't open FLAC file for updating (003)";
FLAC__metadata_simple_iterator_delete(it);
fclose(fin);
return false;
}
ok = write_to_flac_(fm, fin, fout, it, error);
FLAC__metadata_simple_iterator_delete(it);
fclose(fin);
fclose(fout);
return ok;
}
FLAC__bool flac__foreign_metadata_read_from_flac(foreign_metadata_t *fm, const char *filename, const char **error)
{
FLAC__bool ok;
FILE *f;
FLAC__Metadata_SimpleIterator *it = FLAC__metadata_simple_iterator_new();
if(!it) {
if(error) *error = "out of memory (000)";
return false;
}
if(!FLAC__metadata_simple_iterator_init(it, filename, /*read_only=*/true, /*preserve_file_stats=*/false)) {
if(error) *error = "can't initialize iterator (001)";
FLAC__metadata_simple_iterator_delete(it);
return false;
}
if(0 == (f = flac_fopen(filename, "rb"))) {
if(error) *error = "can't open FLAC file for reading (002)";
FLAC__metadata_simple_iterator_delete(it);
return false;
}
ok = read_from_flac_(fm, f, it, error);
FLAC__metadata_simple_iterator_delete(it);
fclose(f);
return ok;
}
FLAC__bool flac__foreign_metadata_write_to_iff(foreign_metadata_t *fm, const char *infilename, const char *outfilename, FLAC__off_t offset1, FLAC__off_t offset2, FLAC__off_t offset3, const char **error)
{
FLAC__bool ok;
FILE *fin, *fout;
if(0 == (fin = flac_fopen(infilename, "rb"))) {
if(error) *error = "can't open FLAC file for reading (000)";
return false;
}
if(0 == (fout = flac_fopen(outfilename, "r+b"))) {
if(error) *error = "can't open WAVE/AIFF file for updating (001)";
fclose(fin);
return false;
}
ok = write_to_iff_(fm, fin, fout, offset1, offset2, offset3, error);
fclose(fin);
fclose(fout);
return ok;
}

View File

@@ -0,0 +1,74 @@
/* flac - Command-line FLAC encoder/decoder
* Copyright (C) 2000-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef flac__foreign_metadata_h
#define flac__foreign_metadata_h
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "FLAC/metadata.h"
#include "utils.h"
#include "share/compat.h"
/* WATCHOUT: these enums are used to index internal arrays */
typedef enum {
FOREIGN_BLOCK_TYPE__AIFF = 0, /* for AIFF and AIFF-C */
FOREIGN_BLOCK_TYPE__RIFF = 1, /* for WAVE and RF64 */
FOREIGN_BLOCK_TYPE__WAVE64 = 2 /* only for Sony's flavor */
} foreign_block_type_t;
typedef struct {
/* for encoding, this will be the offset in the WAVE/AIFF file of the chunk */
/* for decoding, this will be the offset in the FLAC file of the chunk data inside the APPLICATION block */
FLAC__off_t offset;
/* size is the actual size in bytes of the chunk to be stored/recreated. */
/* It includes the 8 bytes of chunk type and size, and any padding byte for alignment. */
/* For 'data'/'SSND' chunks, the size does not include the actual sound or padding bytes */
/* because these are not stored, they are recreated from the compressed FLAC stream. */
/* So for RIFF 'data', size is 8, and for AIFF 'SSND', size is 8 + 8 + ssnd_offset_size */
/* 32 bit size is OK because we only care about the non-sound data and FLAC metadata */
/* only supports a few megs anyway. */
FLAC__uint32 size;
} foreign_block_t;
typedef struct {
foreign_block_type_t type; /* currently we don't support multiple foreign types in a stream (and maybe never will) */
foreign_block_t *blocks;
size_t num_blocks;
size_t format_block; /* block number of 'fmt ' or 'COMM' chunk */
size_t audio_block; /* block number of 'data' or 'SSND' chunk */
FLAC__bool is_rf64; /* always false if type!=RIFF */
FLAC__uint32 ssnd_offset_size; /* 0 if type!=AIFF */
} foreign_metadata_t;
foreign_metadata_t *flac__foreign_metadata_new(foreign_block_type_t type);
void flac__foreign_metadata_delete(foreign_metadata_t *fm);
FLAC__bool flac__foreign_metadata_read_from_aiff(foreign_metadata_t *fm, const char *filename, const char **error);
FLAC__bool flac__foreign_metadata_read_from_wave(foreign_metadata_t *fm, const char *filename, const char **error);
FLAC__bool flac__foreign_metadata_read_from_wave64(foreign_metadata_t *fm, const char *filename, const char **error);
FLAC__bool flac__foreign_metadata_write_to_flac(foreign_metadata_t *fm, const char *infilename, const char *outfilename, const char **error);
FLAC__bool flac__foreign_metadata_read_from_flac(foreign_metadata_t *fm, const char *filename, const char **error);
FLAC__bool flac__foreign_metadata_write_to_iff(foreign_metadata_t *fm, const char *infilename, const char *outfilename, FLAC__off_t offset1, FLAC__off_t offset2, FLAC__off_t offset3, const char **error);
#endif

View File

@@ -0,0 +1,129 @@
/* iffscan - Simple AIFF/RIFF chunk scanner
* Copyright (C) 2007-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "share/compat.h"
#include "foreign_metadata.h"
static FLAC__uint32 unpack32be_(const FLAC__byte *b)
{
return ((FLAC__uint32)b[0]<<24) + ((FLAC__uint32)b[1]<<16) + ((FLAC__uint32)b[2]<<8) + (FLAC__uint32)b[3];
}
static FLAC__uint32 unpack32le_(const FLAC__byte *b)
{
return (FLAC__uint32)b[0] + ((FLAC__uint32)b[1]<<8) + ((FLAC__uint32)b[2]<<16) + ((FLAC__uint32)b[3]<<24);
}
static FLAC__uint64 unpack64le_(const FLAC__byte *b)
{
return (FLAC__uint64)b[0] + ((FLAC__uint64)b[1]<<8) + ((FLAC__uint64)b[2]<<16) + ((FLAC__uint64)b[3]<<24) + ((FLAC__uint64)b[4]<<32) + ((FLAC__uint64)b[5]<<40) + ((FLAC__uint64)b[6]<<48) + ((FLAC__uint64)b[7]<<56);
}
static FLAC__uint32 unpack32_(const FLAC__byte *b, foreign_block_type_t type)
{
if(type == FOREIGN_BLOCK_TYPE__AIFF)
return unpack32be_(b);
else
return unpack32le_(b);
}
int main(int argc, char *argv[])
{
FILE *f;
char buf[36];
foreign_metadata_t *fm;
const char *fn, *error;
size_t i;
FLAC__uint32 size;
#ifdef _WIN32
if (get_utf8_argv(&argc, &argv) != 0) {
fprintf(stderr, "ERROR: failed to convert command line parameters to UTF-8\n");
return 1;
}
#endif
if(argc != 2) {
flac_fprintf(stderr, "usage: %s { file.wav | file.aif }\n", argv[0]);
return 1;
}
fn = argv[1];
if(0 == (f = flac_fopen(fn, "rb")) || fread(buf, 1, 4, f) != 4) {
flac_fprintf(stderr, "ERROR opening %s for reading\n", fn);
return 1;
}
fclose(f);
if(0 == (fm = flac__foreign_metadata_new(memcmp(buf, "RIFF", 4) && memcmp(buf, "RF64", 4)? FOREIGN_BLOCK_TYPE__AIFF : FOREIGN_BLOCK_TYPE__RIFF))) {
flac_fprintf(stderr, "ERROR: out of memory\n");
return 1;
}
if(fm->type == FOREIGN_BLOCK_TYPE__AIFF) {
if(!flac__foreign_metadata_read_from_aiff(fm, fn, &error)) {
flac_fprintf(stderr, "ERROR reading chunks from %s: %s\n", fn, error);
return 1;
}
}
else {
if(!flac__foreign_metadata_read_from_wave(fm, fn, &error)) {
flac_fprintf(stderr, "ERROR reading chunks from %s: %s\n", fn, error);
return 1;
}
}
if(0 == (f = flac_fopen(fn, "rb"))) {
flac_fprintf(stderr, "ERROR opening %s for reading\n", fn);
return 1;
}
for(i = 0; i < fm->num_blocks; i++) {
if(fseeko(f, fm->blocks[i].offset, SEEK_SET) < 0) {
flac_fprintf(stderr, "ERROR seeking in %s\n", fn);
return 1;
}
if(fread(buf, 1, i==0?12:8, f) != (i==0?12:8)) {
flac_fprintf(stderr, "ERROR reading %s\n", fn);
return 1;
}
size = unpack32_((FLAC__byte*)buf+4, fm->type);
printf("block:[%c%c%c%c] size=%08x=(%10u)", buf[0], buf[1], buf[2], buf[3], size, size);
if(i == 0)
printf(" type:[%c%c%c%c]", buf[8], buf[9], buf[10], buf[11]);
else if(fm->type == FOREIGN_BLOCK_TYPE__AIFF && i == fm->audio_block)
printf(" offset size=%08x=(%10u)", fm->ssnd_offset_size, fm->ssnd_offset_size);
else if(fm->type == FOREIGN_BLOCK_TYPE__RIFF && i == 1 && !memcmp(buf, "ds64", 4)) {
if(fread(buf+8, 1, 36-8, f) != 36-8) {
flac_fprintf(stderr, "ERROR reading %s\n", fn);
return 1;
}
printf("\n RIFF size=%016" PRIx64 "=(%20" PRIu64 ")", unpack64le_((FLAC__byte*)buf+8), unpack64le_((FLAC__byte*)buf+8));
printf("\n data size=%016" PRIx64 "=(%20" PRIu64 ")", unpack64le_((FLAC__byte*)buf+16), unpack64le_((FLAC__byte*)buf+16));
printf("\n sample count=%016" PRIx64 "=(%20" PRIu64 ")", unpack64le_((FLAC__byte*)buf+24), unpack64le_((FLAC__byte*)buf+24));
printf("\n table size=%08x=(%10u)", unpack32le_((FLAC__byte*)buf+32), unpack32le_((FLAC__byte*)buf+32));
}
printf("\n");
}
fclose(f);
flac__foreign_metadata_delete(fm);
return 0;
}

View File

@@ -0,0 +1,207 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="iffscan"
ProjectGUID="{4cefbc94-c215-11db-8314-0800200c9a66}"
RootNamespace="iffscan"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)objs\$(ConfigurationName)\bin"
IntermediateDirectory="$(ConfigurationName)_iffscan"
ConfigurationType="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".;..\..\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;FLAC__HAS_OGG;FLAC__NO_DLL;DEBUG"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
CompileAs="0"
DisableSpecificWarnings="4267;4996"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(SolutionDir)objs\$(ConfigurationName)\lib\libogg_static.lib"
LinkIncremental="2"
IgnoreDefaultLibraryNames="uuid.lib"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)objs\$(ConfigurationName)\bin"
IntermediateDirectory="$(ConfigurationName)_iffscan"
ConfigurationType="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories=".;..\..\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;FLAC__HAS_OGG;FLAC__NO_DLL"
RuntimeLibrary="0"
BufferSecurityCheck="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CompileAs="0"
DisableSpecificWarnings="4267;4996"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(SolutionDir)objs\$(ConfigurationName)\lib\libogg_static.lib"
LinkIncremental="1"
IgnoreDefaultLibraryNames="uuid.lib"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
LinkTimeCodeGeneration="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-6E5FBE522BFB}"
>
<File
RelativePath=".\foreign_metadata.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2D32A752A2FF}"
>
<File
RelativePath=".\foreign_metadata.c"
>
</File>
<File
RelativePath=".\iffscan.c"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,191 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4cefbc94-c215-11db-8314-0800200c9a66}</ProjectGuid>
<RootNamespace>iffscan</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)objs\$(Configuration)\bin\</OutDir>
<IntDir>$(Configuration)_iffscan\</IntDir>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)objs\$(Platform)\$(Configuration)\bin\</OutDir>
<IntDir>$(Platform)\$(Configuration)_iffscan\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)objs\$(Configuration)\bin\</OutDir>
<IntDir>$(Configuration)_iffscan\</IntDir>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)objs\$(Platform)\$(Configuration)\bin\</OutDir>
<IntDir>$(Platform)\$(Configuration)_iffscan\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;FLAC__HAS_OGG;FLAC__NO_DLL;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4267;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>$(SolutionDir)objs\$(Configuration)\lib\libogg_static.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>uuid.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;FLAC__HAS_OGG;FLAC__NO_DLL;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4267;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>$(SolutionDir)objs\$(Platform)\$(Configuration)\lib\libogg_static.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>uuid.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<WholeProgramOptimization>true</WholeProgramOptimization>
<AdditionalIncludeDirectories>.;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;FLAC__HAS_OGG;FLAC__NO_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4267;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>$(SolutionDir)objs\$(Configuration)\lib\libogg_static.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>uuid.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<WholeProgramOptimization>true</WholeProgramOptimization>
<AdditionalIncludeDirectories>.;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;FLAC__HAS_OGG;FLAC__NO_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<DisableSpecificWarnings>4267;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>$(SolutionDir)objs\$(Platform)\$(Configuration)\lib\libogg_static.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>uuid.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="foreign_metadata.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="foreign_metadata.c" />
<ClCompile Include="iffscan.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\libFLAC\libFLAC_static.vcxproj">
<Project>{4cefbc84-c215-11db-8314-0800200c9a66}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\share\win_utf8_io\win_utf8_io_static.vcxproj">
<Project>{4cefbe02-c215-11db-8314-0800200c9a66}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-6E5FBE522BFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2D32A752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="foreign_metadata.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="foreign_metadata.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="iffscan.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,109 @@
/* flac - Command-line FLAC encoder/decoder
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <string.h>
#include "utils.h"
#include "local_string_utils.h"
/* $OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $
*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*
* Copy src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).
* Returns strlen(src); if retval >= siz, truncation occurred.
*/
size_t
flac__strlcpy(char *dst, const char *src, size_t siz)
{
register char *d = dst;
register const char *s = src;
register size_t n = siz;
/* Copy as many bytes as will fit */
if (n != 0 && --n != 0) {
do {
if ((*d++ = *s++) == 0)
break;
} while (--n != 0);
}
/* Not enough room in dst, add NUL and traverse rest of src */
if (n == 0) {
if (siz != 0)
*d = '\0'; /* NUL-terminate dst */
while (*s++)
;
}
return(s - src - 1); /* count does not include NUL */
}
/* $OpenBSD: strlcat.c,v 1.11 2003/06/17 21:56:24 millert Exp $
*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*
* Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters
* will be copied. Always NUL terminates (unless siz <= strlen(dst)).
* Returns strlen(src) + MIN(siz, strlen(initial dst)).
* If retval >= siz, truncation occurred.
*/
size_t
flac__strlcat(char *dst, const char *src, size_t siz)
{
register char *d = dst;
register const char *s = src;
register size_t n = siz;
size_t dlen;
/* Find the end of dst and adjust bytes left but don't go past end */
while (n-- != 0 && *d != '\0')
d++;
dlen = d - dst;
n = siz - dlen;
if (n == 0)
return(dlen + strlen(s));
while (*s != '\0') {
if (n != 1) {
*d++ = *s;
n--;
}
s++;
}
*d = '\0';
return(dlen + (s - src)); /* count does not include NUL */
}

View File

@@ -0,0 +1,28 @@
/* flac - Command-line FLAC encoder/decoder
* Copyright (C) 2002-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef flac__local_string_utils_h
#define flac__local_string_utils_h
#include <stdlib.h> /* for size_t */
size_t flac__strlcpy(char *dst, const char *src, size_t siz);
size_t flac__strlcat(char *dst, const char *src, size_t siz);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,418 @@
/* flac - Command-line FLAC encoder/decoder
* Copyright (C) 2002-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "utils.h"
#include "FLAC/assert.h"
#include "FLAC/metadata.h"
#include "share/compat.h"
#ifndef _WIN32
#include <wchar.h>
#ifdef HAVE_TERMIOS_H
# include <termios.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#endif
const char *CHANNEL_MASK_TAG = "WAVEFORMATEXTENSIBLE_CHANNEL_MASK";
int flac__utils_verbosity_ = 2;
static FLAC__bool local__parse_uint64_(const char *s, FLAC__uint64 *value)
{
FLAC__uint64 ret = 0;
char c;
if(*s == '\0')
return false;
while('\0' != (c = *s++))
if(c >= '0' && c <= '9')
ret = ret * 10 + (c - '0');
else
return false;
*value = ret;
return true;
}
static FLAC__bool local__parse_timecode_(const char *s, double *value)
{
double ret;
unsigned i;
char c, *endptr;
/* parse [0-9][0-9]*: */
c = *s++;
if(c >= '0' && c <= '9')
i = (c - '0');
else
return false;
while(':' != (c = *s++)) {
if(c >= '0' && c <= '9')
i = i * 10 + (c - '0');
else
return false;
}
ret = (double)i * 60.;
/* parse [0-9]*[.,]?[0-9]* i.e. a sign-less rational number (. or , OK for fractional seconds, to support different locales) */
if(strspn(s, "1234567890.,") != strlen(s))
return false;
ret += strtod(s, &endptr);
if (endptr == s || *endptr)
return false;
*value = ret;
return true;
}
static FLAC__bool local__parse_cue_(const char *s, const char *end, unsigned *track, unsigned *indx)
{
FLAC__bool got_track = false, got_index = false;
unsigned t = 0, i = 0;
char c;
while(end? s < end : *s != '\0') {
c = *s++;
if(c >= '0' && c <= '9') {
t = t * 10 + (c - '0');
got_track = true;
}
else if(c == '.')
break;
else
return false;
}
while(end? s < end : *s != '\0') {
c = *s++;
if(c >= '0' && c <= '9') {
i = i * 10 + (c - '0');
got_index = true;
}
else
return false;
}
*track = t;
*indx = i;
return got_track && got_index;
}
/*
* this only works with sorted cuesheets (the spec strongly recommends but
* does not require sorted cuesheets). but if it's not sorted, picking a
* nearest cue point has no significance.
*/
static FLAC__uint64 local__find_closest_cue_(const FLAC__StreamMetadata_CueSheet *cuesheet, unsigned track, unsigned indx, FLAC__uint64 total_samples, FLAC__bool look_forward)
{
int t, i;
if(look_forward) {
for(t = 0; t < (int)cuesheet->num_tracks; t++)
for(i = 0; i < (int)cuesheet->tracks[t].num_indices; i++)
if(cuesheet->tracks[t].number > track || (cuesheet->tracks[t].number == track && cuesheet->tracks[t].indices[i].number >= indx))
return cuesheet->tracks[t].offset + cuesheet->tracks[t].indices[i].offset;
return total_samples;
}
else {
for(t = (int)cuesheet->num_tracks - 1; t >= 0; t--)
for(i = (int)cuesheet->tracks[t].num_indices - 1; i >= 0; i--)
if(cuesheet->tracks[t].number < track || (cuesheet->tracks[t].number == track && cuesheet->tracks[t].indices[i].number <= indx))
return cuesheet->tracks[t].offset + cuesheet->tracks[t].indices[i].offset;
return 0;
}
}
void flac__utils_printf(FILE *stream, int level, const char *format, ...)
{
if(flac__utils_verbosity_ >= level) {
va_list args;
FLAC__ASSERT(0 != format);
va_start(args, format);
(void) flac_vfprintf(stream, format, args);
va_end(args);
#ifdef _MSC_VER
if(stream == stderr)
fflush(stream); /* for some reason stderr is buffered in at least some if not all MSC libs */
#endif
}
}
/* variables and functions for console status output */
static FLAC__bool is_name_printed;
static int stats_char_count = 0;
static int console_width;
static int console_chars_left;
int get_console_width(void)
{
int width = 0;
#if defined _WIN32
width = win_get_console_width();
#elif defined __EMX__
int s[2];
_scrsize (s);
width = s[0];
#elif defined TIOCGWINSZ
struct winsize w;
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != -1)
width = w.ws_col;
#endif
if (width <= 0)
width = 80;
return width;
}
size_t strlen_console(const char *text)
{
#ifdef _WIN32
return strlen_utf8(text);
#else
size_t len;
wchar_t *wtmp;
len = strlen(text)+1;
wtmp = (wchar_t *)malloc(len*sizeof(wchar_t));
if (wtmp == NULL) return len-1;
mbstowcs(wtmp, text, len);
len = wcswidth(wtmp, len);
free(wtmp);
return len;
#endif
}
void stats_new_file(void)
{
is_name_printed = false;
}
void stats_clear(void)
{
while (stats_char_count > 0 && stats_char_count--)
fprintf(stderr, "\b");
}
void stats_print_name(int level, const char *name)
{
int len;
if (flac__utils_verbosity_ >= level) {
stats_clear();
if(is_name_printed) return;
console_width = get_console_width();
len = strlen_console(name)+2;
console_chars_left = console_width - (len % console_width);
flac_fprintf(stderr, "%s: ", name);
is_name_printed = true;
}
}
void stats_print_info(int level, const char *format, ...)
{
char tmp[80];
int len, clear_len;
if (flac__utils_verbosity_ >= level) {
va_list args;
va_start(args, format);
len = flac_vsnprintf(tmp, sizeof(tmp), format, args);
va_end(args);
stats_clear();
if (len >= console_chars_left) {
clear_len = console_chars_left;
while (clear_len > 0 && clear_len--) fprintf(stderr, " ");
fprintf(stderr, "\n");
console_chars_left = console_width;
}
stats_char_count = fprintf(stderr, "%s", tmp);
fflush(stderr);
}
}
#ifdef FLAC__VALGRIND_TESTING
size_t flac__utils_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
{
size_t ret = fwrite(ptr, size, nmemb, stream);
if(!ferror(stream))
fflush(stream);
return ret;
}
#endif
FLAC__bool flac__utils_parse_skip_until_specification(const char *s, utils__SkipUntilSpecification *spec)
{
FLAC__uint64 val;
FLAC__bool is_negative = false;
FLAC__ASSERT(0 != spec);
spec->is_relative = false;
spec->value_is_samples = true;
spec->value.samples = 0;
if(0 != s) {
if(s[0] == '-') {
is_negative = true;
spec->is_relative = true;
s++;
}
else if(s[0] == '+') {
spec->is_relative = true;
s++;
}
if(local__parse_uint64_(s, &val)) {
spec->value_is_samples = true;
spec->value.samples = (FLAC__int64)val;
if(is_negative)
spec->value.samples = -(spec->value.samples);
}
else {
double d;
if(!local__parse_timecode_(s, &d))
return false;
spec->value_is_samples = false;
spec->value.seconds = d;
if(is_negative)
spec->value.seconds = -(spec->value.seconds);
}
}
return true;
}
void flac__utils_canonicalize_skip_until_specification(utils__SkipUntilSpecification *spec, unsigned sample_rate)
{
FLAC__ASSERT(0 != spec);
if(!spec->value_is_samples) {
spec->value.samples = (FLAC__int64)(spec->value.seconds * (double)sample_rate);
spec->value_is_samples = true;
}
}
FLAC__bool flac__utils_parse_cue_specification(const char *s, utils__CueSpecification *spec)
{
const char *start = s, *end = 0;
FLAC__ASSERT(0 != spec);
spec->has_start_point = spec->has_end_point = false;
s = strchr(s, '-');
if(0 != s) {
if(s == start)
start = 0;
end = s+1;
if(*end == '\0')
end = 0;
}
if(start) {
if(!local__parse_cue_(start, s, &spec->start_track, &spec->start_index))
return false;
spec->has_start_point = true;
}
if(end) {
if(!local__parse_cue_(end, 0, &spec->end_track, &spec->end_index))
return false;
spec->has_end_point = true;
}
return true;
}
void flac__utils_canonicalize_cue_specification(const utils__CueSpecification *cue_spec, const FLAC__StreamMetadata_CueSheet *cuesheet, FLAC__uint64 total_samples, utils__SkipUntilSpecification *skip_spec, utils__SkipUntilSpecification *until_spec)
{
FLAC__ASSERT(0 != cue_spec);
FLAC__ASSERT(0 != cuesheet);
FLAC__ASSERT(0 != total_samples);
FLAC__ASSERT(0 != skip_spec);
FLAC__ASSERT(0 != until_spec);
skip_spec->is_relative = false;
skip_spec->value_is_samples = true;
until_spec->is_relative = false;
until_spec->value_is_samples = true;
if(cue_spec->has_start_point)
skip_spec->value.samples = local__find_closest_cue_(cuesheet, cue_spec->start_track, cue_spec->start_index, total_samples, /*look_forward=*/false);
else
skip_spec->value.samples = 0;
if(cue_spec->has_end_point)
until_spec->value.samples = local__find_closest_cue_(cuesheet, cue_spec->end_track, cue_spec->end_index, total_samples, /*look_forward=*/true);
else
until_spec->value.samples = total_samples;
}
FLAC__bool flac__utils_set_channel_mask_tag(FLAC__StreamMetadata *object, FLAC__uint32 channel_mask)
{
FLAC__StreamMetadata_VorbisComment_Entry entry = { 0, 0 };
char tag[128];
FLAC__ASSERT(object);
FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
FLAC__ASSERT(strlen(CHANNEL_MASK_TAG)+1+2+16+1 <= sizeof(tag)); /* +1 for =, +2 for 0x, +16 for digits, +1 for NUL */
entry.entry = (FLAC__byte*)tag;
if((entry.length = flac_snprintf(tag, sizeof(tag), "%s=0x%04X", CHANNEL_MASK_TAG, (unsigned)channel_mask)) >= sizeof(tag))
return false;
if(!FLAC__metadata_object_vorbiscomment_replace_comment(object, entry, /*all=*/true, /*copy=*/true))
return false;
return true;
}
FLAC__bool flac__utils_get_channel_mask_tag(const FLAC__StreamMetadata *object, FLAC__uint32 *channel_mask)
{
int offset;
unsigned val;
char *p;
FLAC__ASSERT(object);
FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
if(0 > (offset = FLAC__metadata_object_vorbiscomment_find_entry_from(object, /*offset=*/0, CHANNEL_MASK_TAG)))
return false;
if(object->data.vorbis_comment.comments[offset].length < strlen(CHANNEL_MASK_TAG)+4)
return false;
if(0 == (p = strchr((const char *)object->data.vorbis_comment.comments[offset].entry, '='))) /* should never happen, but just in case */
return false;
if(FLAC__STRNCASECMP(p, "=0x", 3))
return false;
if(sscanf(p+3, "%x", &val) != 1)
return false;
*channel_mask = val;
return true;
}

View File

@@ -0,0 +1,73 @@
/* flac - Command-line FLAC encoder/decoder
* Copyright (C) 2002-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef flac__utils_h
#define flac__utils_h
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "FLAC/ordinals.h"
#include "FLAC/format.h" /* for FLAC__StreamMetadata_CueSheet */
#include <stdio.h> /* for FILE */
typedef enum { FORMAT_RAW, FORMAT_WAVE, FORMAT_WAVE64, FORMAT_RF64, FORMAT_AIFF, FORMAT_AIFF_C, FORMAT_FLAC, FORMAT_OGGFLAC } FileFormat;
typedef struct {
FLAC__bool is_relative; /* i.e. specification string started with + or - */
FLAC__bool value_is_samples;
union {
double seconds;
FLAC__int64 samples;
} value;
} utils__SkipUntilSpecification;
typedef struct {
FLAC__bool has_start_point, has_end_point;
unsigned start_track, start_index;
unsigned end_track, end_index;
} utils__CueSpecification;
#ifdef FLAC__VALGRIND_TESTING
size_t flac__utils_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
#else
#define flac__utils_fwrite fwrite
#endif
extern int flac__utils_verbosity_;
void flac__utils_printf(FILE *stream, int level, const char *format, ...);
int get_console_width(void);
size_t strlen_console(const char *text);
void stats_new_file(void);
void stats_clear(void);
void stats_print_name(int level, const char *name);
void stats_print_info(int level, const char *format, ...);
FLAC__bool flac__utils_parse_skip_until_specification(const char *s, utils__SkipUntilSpecification *spec);
void flac__utils_canonicalize_skip_until_specification(utils__SkipUntilSpecification *spec, unsigned sample_rate);
FLAC__bool flac__utils_parse_cue_specification(const char *s, utils__CueSpecification *spec);
void flac__utils_canonicalize_cue_specification(const utils__CueSpecification *cue_spec, const FLAC__StreamMetadata_CueSheet *cuesheet, FLAC__uint64 total_samples, utils__SkipUntilSpecification *skip_spec, utils__SkipUntilSpecification *until_spec);
FLAC__bool flac__utils_set_channel_mask_tag(FLAC__StreamMetadata *object, FLAC__uint32 channel_mask);
FLAC__bool flac__utils_get_channel_mask_tag(const FLAC__StreamMetadata *object, FLAC__uint32 *channel_mask);
#endif

View File

@@ -0,0 +1,254 @@
/* flac - Command-line FLAC encoder/decoder
* Copyright (C) 2002-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "vorbiscomment.h"
#include "FLAC/assert.h"
#include "FLAC/metadata.h"
#include "share/grabbag.h" /* for grabbag__file_get_filesize() */
#include "share/utf8.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "share/compat.h"
/*
* This struct and the following 4 static functions are copied from
* ../metaflac/. Maybe someday there will be a convenience
* library for Vorbis comment parsing.
*/
typedef struct {
char *field; /* the whole field as passed on the command line, i.e. "NAME=VALUE" */
char *field_name;
/* according to the vorbis spec, field values can contain \0 so simple C strings are not enough here */
unsigned field_value_length;
char *field_value;
FLAC__bool field_value_from_file; /* true if field_value holds a filename for the value, false for plain value */
} Argument_VcField;
static void die(const char *message)
{
FLAC__ASSERT(0 != message);
fprintf(stderr, "ERROR: %s\n", message);
exit(1);
}
static char *local_strdup(const char *source)
{
char *ret;
FLAC__ASSERT(0 != source);
if(0 == (ret = strdup(source)))
die("out of memory during strdup()");
return ret;
}
static FLAC__bool parse_vorbis_comment_field(const char *field_ref, char **field, char **name, char **value, unsigned *length, const char **violation)
{
static const char * const violations[] = {
"field name contains invalid character",
"field contains no '=' character"
};
char *p, *q, *s;
if(0 != field)
*field = local_strdup(field_ref);
s = local_strdup(field_ref);
if(0 == (p = strchr(s, '='))) {
free(s);
*violation = violations[1];
return false;
}
*p++ = '\0';
for(q = s; *q; q++) {
if(*q < 0x20 || *q > 0x7d || *q == 0x3d) {
free(s);
*violation = violations[0];
return false;
}
}
*name = local_strdup(s);
*value = local_strdup(p);
*length = strlen(p);
free(s);
return true;
}
/* slight modification: no 'filename' arg, and errors are passed back in 'violation' instead of printed to stderr */
static FLAC__bool set_vc_field(FLAC__StreamMetadata *block, const Argument_VcField *field, FLAC__bool *needs_write, FLAC__bool raw, const char **violation)
{
FLAC__StreamMetadata_VorbisComment_Entry entry;
char *converted = NULL;
FLAC__ASSERT(0 != block);
FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
FLAC__ASSERT(0 != field);
FLAC__ASSERT(0 != needs_write);
if(field->field_value_from_file) {
/* read the file into 'data' */
FILE *f = 0;
char *data = 0;
const FLAC__off_t size = grabbag__file_get_filesize(field->field_value);
if(size < 0) {
*violation = "can't open file for tag value";
return false;
}
if(size >= 0x100000) { /* magic arbitrary limit, actual format limit is near 16MB */
*violation = "file for tag value is too large";
return false;
}
if(0 == (data = malloc(size+1)))
die("out of memory allocating tag value");
data[size] = '\0';
if(0 == (f = flac_fopen(field->field_value, "rb")) || fread(data, 1, size, f) != (size_t)size) {
free(data);
if(f)
fclose(f);
*violation = "error while reading file for tag value";
return false;
}
fclose(f);
if(strlen(data) != (size_t)size) {
free(data);
*violation = "file for tag value has embedded NULs";
return false;
}
/* move 'data' into 'converted', converting to UTF-8 if necessary */
if(raw) {
converted = data;
}
else if(utf8_encode(data, &converted) >= 0) {
free(data);
}
else {
free(data);
*violation = "error converting file contents to UTF-8 for tag value";
return false;
}
/* create and entry and append it */
if(!FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, field->field_name, converted)) {
free(converted);
*violation = "file for tag value is not valid UTF-8";
return false;
}
free(converted);
if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/false)) {
*violation = "memory allocation failure";
return false;
}
*needs_write = true;
return true;
}
else {
FLAC__bool needs_free = false;
#ifdef _WIN32 /* everything in UTF-8 already. Must not alter */
entry.entry = (FLAC__byte *)field->field;
#else
if(raw) {
entry.entry = (FLAC__byte *)field->field;
}
else if(utf8_encode(field->field, &converted) >= 0) {
entry.entry = (FLAC__byte *)converted;
needs_free = true;
}
else {
*violation = "error converting comment to UTF-8";
return false;
}
#endif
entry.length = strlen((const char *)entry.entry);
if(!FLAC__format_vorbiscomment_entry_is_legal(entry.entry, entry.length)) {
if(needs_free)
free(converted);
/*
* our previous parsing has already established that the field
* name is OK, so it must be the field value
*/
*violation = "tag value is not valid UTF-8";
return false;
}
if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/true)) {
if(needs_free)
free(converted);
*violation = "memory allocation failure";
return false;
}
*needs_write = true;
if(needs_free)
free(converted);
return true;
}
}
/*
* The rest of the code is novel
*/
static void free_field(Argument_VcField *obj)
{
if(0 != obj->field)
free(obj->field);
if(0 != obj->field_name)
free(obj->field_name);
if(0 != obj->field_value)
free(obj->field_value);
}
FLAC__bool flac__vorbiscomment_add(FLAC__StreamMetadata *block, const char *comment, FLAC__bool value_from_file, FLAC__bool raw, const char **violation)
{
Argument_VcField parsed;
FLAC__bool dummy;
FLAC__ASSERT(0 != block);
FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
FLAC__ASSERT(0 != comment);
memset(&parsed, 0, sizeof(parsed));
parsed.field_value_from_file = value_from_file;
if(!parse_vorbis_comment_field(comment, &(parsed.field), &(parsed.field_name), &(parsed.field_value), &(parsed.field_value_length), violation)) {
free_field(&parsed);
return false;
}
if(parsed.field_value_length > 0 && !set_vc_field(block, &parsed, &dummy, raw, violation)) {
free_field(&parsed);
return false;
}
else {
free_field(&parsed);
return true;
}
}

View File

@@ -0,0 +1,27 @@
/* flac - Command-line FLAC encoder/decoder
* Copyright (C) 2002-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef flac__vorbiscomment_h
#define flac__vorbiscomment_h
#include "FLAC/metadata.h"
FLAC__bool flac__vorbiscomment_add(FLAC__StreamMetadata *block, const char *comment, FLAC__bool value_from_file, FLAC__bool raw, const char **violation);
#endif