diff options
Diffstat (limited to 'src/libFLAC++')
-rw-r--r-- | src/libFLAC++/CMakeLists.txt | 41 | ||||
-rw-r--r-- | src/libFLAC++/Makefile.am | 68 | ||||
-rw-r--r-- | src/libFLAC++/Makefile.in | 831 | ||||
-rw-r--r-- | src/libFLAC++/flac++.pc.in | 11 | ||||
-rw-r--r-- | src/libFLAC++/libFLAC++.m4 | 114 | ||||
-rw-r--r-- | src/libFLAC++/metadata.cpp | 1745 | ||||
-rw-r--r-- | src/libFLAC++/stream_decoder.cpp | 394 | ||||
-rw-r--r-- | src/libFLAC++/stream_encoder.cpp | 519 | ||||
-rw-r--r-- | src/libFLAC++/version.rc | 40 |
9 files changed, 3763 insertions, 0 deletions
diff --git a/src/libFLAC++/CMakeLists.txt b/src/libFLAC++/CMakeLists.txt new file mode 100644 index 0000000..3be43ba --- /dev/null +++ b/src/libFLAC++/CMakeLists.txt @@ -0,0 +1,41 @@ +add_library(FLAC++ + metadata.cpp + stream_decoder.cpp + stream_encoder.cpp + version.rc) +set_property(TARGET FLAC++ PROPERTY PROJECT_LABEL "libFLAC++") +target_compile_definitions(FLAC++ + PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:FLACPP_API_EXPORTS> + PUBLIC $<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:FLAC__NO_DLL>) +if(NOT WIN32) + target_compile_definitions(FLAC++ PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:FLAC__USE_VISIBILITY_ATTR>) +endif() +target_include_directories(FLAC++ INTERFACE + "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>" + "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>") +target_link_libraries(FLAC++ PUBLIC FLAC) +if(BUILD_SHARED_LIBS) + set_target_properties(FLAC++ PROPERTIES + VERSION 10.0.1 + SOVERSION 10) + if(NOT WIN32) + set_target_properties(FLAC++ PROPERTIES CXX_VISIBILITY_PRESET hidden) + endif() +endif() + +add_library(FLAC::FLAC++ ALIAS FLAC++) + +install(TARGETS FLAC++ EXPORT targets + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/") + +if(INSTALL_PKGCONFIG_MODULES) + set(prefix "${CMAKE_INSTALL_PREFIX}") + set(exec_prefix "${CMAKE_INSTALL_PREFIX}") + set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}") + set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") + configure_file(flac++.pc.in flac++.pc @ONLY) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/flac++.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") +endif() diff --git a/src/libFLAC++/Makefile.am b/src/libFLAC++/Makefile.am new file mode 100644 index 0000000..0b2853b --- /dev/null +++ b/src/libFLAC++/Makefile.am @@ -0,0 +1,68 @@ +# libFLAC++ - Free Lossless Audio Codec library +# Copyright (C) 2002-2009 Josh Coalson +# Copyright (C) 2011-2023 Xiph.Org Foundation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# - Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# - Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# - Neither the name of the Xiph.org Foundation nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +lib_LTLIBRARIES = libFLAC++.la +noinst_LTLIBRARIES = libFLAC++-static.la + +m4datadir = $(datadir)/aclocal +m4data_DATA = libFLAC++.m4 + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = flac++.pc +AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include +EXTRA_DIST = \ + CMakeLists.txt \ + flac++.pc.in \ + libFLAC++.m4 \ + version.rc + +libFLAC___sources = \ + metadata.cpp \ + stream_decoder.cpp \ + stream_encoder.cpp + +if OS_IS_WINDOWS +if HAVE_WINDRES +libFLAC___la_DEPENDENCIES = version.o +windows_resource_link = -Wl,version.o +endif +endif + +# see 'http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning' for numbering convention +libFLAC___la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -version-info 10:1:0 $(windows_resource_link) +libFLAC___la_LIBADD = ../libFLAC/libFLAC.la +libFLAC___la_SOURCES = $(libFLAC___sources) + +libFLAC___static_la_SOURCES = $(libFLAC___sources) +libFLAC___static_la_LIBADD = ../libFLAC/libFLAC-static.la + +.rc.o: + $(RC) $(AM_CPPFLAGS) $< $@ diff --git a/src/libFLAC++/Makefile.in b/src/libFLAC++/Makefile.in new file mode 100644 index 0000000..eff1fca --- /dev/null +++ b/src/libFLAC++/Makefile.in @@ -0,0 +1,831 @@ +# Makefile.in generated by automake 1.16.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2021 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@ + +# libFLAC++ - Free Lossless Audio Codec library +# Copyright (C) 2002-2009 Josh Coalson +# Copyright (C) 2011-2023 Xiph.Org Foundation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# - Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# - Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# - Neither the name of the Xiph.org Foundation nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +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@ +@HAVE_WINDRES_FALSE@libFLAC___la_DEPENDENCIES = ../libFLAC/libFLAC.la +@OS_IS_WINDOWS_FALSE@libFLAC___la_DEPENDENCIES = \ +@OS_IS_WINDOWS_FALSE@ ../libFLAC/libFLAC.la +subdir = src/libFLAC++ +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/ax_add_fortify_source.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_check_enable_debug.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)/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 = flac++.pc +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(m4datadir)" \ + "$(DESTDIR)$(pkgconfigdir)" +LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) +libFLAC___static_la_DEPENDENCIES = ../libFLAC/libFLAC-static.la +am__objects_1 = metadata.lo stream_decoder.lo stream_encoder.lo +am_libFLAC___static_la_OBJECTS = $(am__objects_1) +libFLAC___static_la_OBJECTS = $(am_libFLAC___static_la_OBJECTS) +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_libFLAC___la_OBJECTS = $(am__objects_1) +libFLAC___la_OBJECTS = $(am_libFLAC___la_OBJECTS) +libFLAC___la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(libFLAC___la_LDFLAGS) $(LDFLAGS) -o $@ +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__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/metadata.Plo \ + ./$(DEPDIR)/stream_decoder.Plo ./$(DEPDIR)/stream_encoder.Plo +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) +am__v_CXXLD_0 = @echo " CXXLD " $@; +am__v_CXXLD_1 = +SOURCES = $(libFLAC___static_la_SOURCES) $(libFLAC___la_SOURCES) +DIST_SOURCES = $(libFLAC___static_la_SOURCES) $(libFLAC___la_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +DATA = $(m4data_DATA) $(pkgconfig_DATA) +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)` +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/flac++.pc.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@ +CSCOPE = @CSCOPE@ +CTAGS = @CTAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +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@ +ETAGS = @ETAGS@ +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@ +GIT_COMMIT_VERSION_HASH = @GIT_COMMIT_VERSION_HASH@ +GIT_FOUND = @GIT_FOUND@ +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@ +LIB_FUZZING_ENGINE = @LIB_FUZZING_ENGINE@ +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@ +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@ +PANDOC = @PANDOC@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +RC = @RC@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +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@ +lib_LTLIBRARIES = libFLAC++.la +noinst_LTLIBRARIES = libFLAC++-static.la +m4datadir = $(datadir)/aclocal +m4data_DATA = libFLAC++.m4 +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = flac++.pc +AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include +EXTRA_DIST = \ + CMakeLists.txt \ + flac++.pc.in \ + libFLAC++.m4 \ + version.rc + +libFLAC___sources = \ + metadata.cpp \ + stream_decoder.cpp \ + stream_encoder.cpp + +@HAVE_WINDRES_TRUE@@OS_IS_WINDOWS_TRUE@libFLAC___la_DEPENDENCIES = version.o +@HAVE_WINDRES_TRUE@@OS_IS_WINDOWS_TRUE@windows_resource_link = -Wl,version.o + +# see 'http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning' for numbering convention +libFLAC___la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -version-info 10:1:0 $(windows_resource_link) +libFLAC___la_LIBADD = ../libFLAC/libFLAC.la +libFLAC___la_SOURCES = $(libFLAC___sources) +libFLAC___static_la_SOURCES = $(libFLAC___sources) +libFLAC___static_la_LIBADD = ../libFLAC/libFLAC-static.la +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj .rc +$(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/libFLAC++/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/libFLAC++/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__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + 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): +flac++.pc: $(top_builddir)/config.status $(srcdir)/flac++.pc.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libFLAC++-static.la: $(libFLAC___static_la_OBJECTS) $(libFLAC___static_la_DEPENDENCIES) $(EXTRA_libFLAC___static_la_DEPENDENCIES) + $(AM_V_CXXLD)$(CXXLINK) $(libFLAC___static_la_OBJECTS) $(libFLAC___static_la_LIBADD) $(LIBS) + +libFLAC++.la: $(libFLAC___la_OBJECTS) $(libFLAC___la_DEPENDENCIES) $(EXTRA_libFLAC___la_DEPENDENCIES) + $(AM_V_CXXLD)$(libFLAC___la_LINK) -rpath $(libdir) $(libFLAC___la_OBJECTS) $(libFLAC___la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/metadata.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stream_decoder.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stream_encoder.Plo@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.cpp.o: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-m4dataDATA: $(m4data_DATA) + @$(NORMAL_INSTALL) + @list='$(m4data_DATA)'; test -n "$(m4datadir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(m4datadir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(m4datadir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(m4datadir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(m4datadir)" || exit $$?; \ + done + +uninstall-m4dataDATA: + @$(NORMAL_UNINSTALL) + @list='$(m4data_DATA)'; test -n "$(m4datadir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(m4datadir)'; $(am__uninstall_files_from_dir) +install-pkgconfigDATA: $(pkgconfig_DATA) + @$(NORMAL_INSTALL) + @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ + done + +uninstall-pkgconfigDATA: + @$(NORMAL_UNINSTALL) + @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) + +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: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(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 $(LTLIBRARIES) $(DATA) +installdirs: + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(m4datadir)" "$(DESTDIR)$(pkgconfigdir)"; 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: + +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-generic clean-libLTLIBRARIES clean-libtool \ + clean-noinstLTLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -f ./$(DEPDIR)/metadata.Plo + -rm -f ./$(DEPDIR)/stream_decoder.Plo + -rm -f ./$(DEPDIR)/stream_encoder.Plo + -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-m4dataDATA install-pkgconfigDATA + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-libLTLIBRARIES + +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 -f ./$(DEPDIR)/metadata.Plo + -rm -f ./$(DEPDIR)/stream_decoder.Plo + -rm -f ./$(DEPDIR)/stream_encoder.Plo + -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-libLTLIBRARIES uninstall-m4dataDATA \ + uninstall-pkgconfigDATA + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-generic clean-libLTLIBRARIES clean-libtool \ + clean-noinstLTLIBRARIES 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-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-libLTLIBRARIES install-m4dataDATA install-man \ + install-pdf install-pdf-am install-pkgconfigDATA 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-libLTLIBRARIES uninstall-m4dataDATA \ + uninstall-pkgconfigDATA + +.PRECIOUS: Makefile + + +.rc.o: + $(RC) $(AM_CPPFLAGS) $< $@ + +# 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: diff --git a/src/libFLAC++/flac++.pc.in b/src/libFLAC++/flac++.pc.in new file mode 100644 index 0000000..f09c251 --- /dev/null +++ b/src/libFLAC++/flac++.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: FLAC++ +Description: Free Lossless Audio Codec Library (C++ API) +Version: @VERSION@ +Requires: flac +Libs: -L${libdir} -lFLAC++ +Cflags: -I${includedir} diff --git a/src/libFLAC++/libFLAC++.m4 b/src/libFLAC++/libFLAC++.m4 new file mode 100644 index 0000000..e5e1345 --- /dev/null +++ b/src/libFLAC++/libFLAC++.m4 @@ -0,0 +1,114 @@ +# Configure paths for libFLAC++ +# "Inspired" by ogg.m4 +# Caller must first run AM_PATH_LIBFLAC + +dnl AM_PATH_LIBFLACPP([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl Test for libFLAC++, and define LIBFLACPP_CFLAGS, LIBFLACPP_LIBS, LIBFLACPP_LIBDIR +dnl +AC_DEFUN([AM_PATH_LIBFLACPP], +[dnl +dnl Get the cflags and libraries +dnl +AC_ARG_WITH(libFLACPP,[ --with-libFLACPP=PFX Prefix where libFLAC++ is installed (optional)], libFLACPP_prefix="$withval", libFLACPP_prefix="") +AC_ARG_WITH(libFLACPP-libraries,[ --with-libFLACPP-libraries=DIR Directory where libFLAC++ library is installed (optional)], libFLACPP_libraries="$withval", libFLACPP_libraries="") +AC_ARG_WITH(libFLACPP-includes,[ --with-libFLACPP-includes=DIR Directory where libFLAC++ header files are installed (optional)], libFLACPP_includes="$withval", libFLACPP_includes="") +AC_ARG_ENABLE(libFLACPPtest, [ --disable-libFLACPPtest Do not try to compile and run a test libFLAC++ program],, enable_libFLACPPtest=yes) + + if test "x$libFLACPP_libraries" != "x" ; then + LIBFLACPP_LIBDIR="$libFLACPP_libraries" + elif test "x$libFLACPP_prefix" != "x" ; then + LIBFLACPP_LIBDIR="$libFLACPP_prefix/lib" + elif test "x$prefix" != "xNONE" ; then + LIBFLACPP_LIBDIR="$libdir" + fi + + LIBFLACPP_LIBS="-L$LIBFLACPP_LIBDIR -lFLAC++ $LIBFLAC_LIBS" + + if test "x$libFLACPP_includes" != "x" ; then + LIBFLACPP_CFLAGS="-I$libFLACPP_includes" + elif test "x$libFLACPP_prefix" != "x" ; then + LIBFLACPP_CFLAGS="-I$libFLACPP_prefix/include" + elif test "$prefix" != "xNONE"; then + LIBFLACPP_CFLAGS="" + fi + + LIBFLACPP_CFLAGS="$LIBFLACPP_CFLAGS $LIBFLAC_CFLAGS" + + AC_MSG_CHECKING(for libFLAC++) + no_libFLACPP="" + + + if test "x$enable_libFLACPPtest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_CXXFLAGS="$CXXFLAGS" + ac_save_LIBS="$LIBS" + ac_save_LD_LIBRARY_PATH="$LD_LIBRARY_PATH" + CFLAGS="$CFLAGS $LIBFLACPP_CFLAGS" + CXXFLAGS="$CXXFLAGS $LIBFLACPP_CFLAGS" + LIBS="$LIBS $LIBFLACPP_LIBS" + LD_LIBRARY_PATH="$LIBFLACPP_LIBDIR:$LIBFLAC_LIBDIR:$LD_LIBRARY_PATH" +dnl +dnl Now check if the installed libFLAC++ is sufficiently new. +dnl + rm -f conf.libFLAC++test + AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <FLAC++/decoder.h> +]],[[ + system("touch conf.libFLAC++test"); + return 0; +]])],[],[no_libFLACPP=yes],[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + + CFLAGS="$ac_save_CFLAGS" + CXXFLAGS="$ac_save_CXXFLAGS" + LIBS="$ac_save_LIBS" + LD_LIBRARY_PATH="$ac_save_LD_LIBRARY_PATH" + fi + + if test "x$no_libFLACPP" = "x" ; then + AC_MSG_RESULT(yes) + ifelse([$1], , :, [$1]) + else + AC_MSG_RESULT(no) + if test -f conf.libFLAC++test ; then + : + else + echo "*** Could not run libFLAC++ test program, checking why..." + CFLAGS="$CFLAGS $LIBFLACPP_CFLAGS" + CXXFLAGS="$CXXFLAGS $LIBFLACPP_CFLAGS" + LIBS="$LIBS $LIBFLACPP_LIBS" + LD_LIBRARY_PATH="$LIBFLACPP_LIBDIR:$LIBFLAC_LIBDIR:$LD_LIBRARY_PATH" + AC_TRY_LINK([ +#include <stdio.h> +#include <FLAC++/decoder.h> +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding libFLAC++ or finding the wrong" + echo "*** version of libFLAC++. If it is not finding libFLAC++, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occurred. This usually means libFLAC++ was incorrectly installed" + echo "*** or that you have moved libFLAC++ since it was installed. In the latter case, you" + echo "*** may want to edit the libFLAC++-config script: $LIBFLACPP_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + CXXFLAGS="$ac_save_CXXFLAGS" + LIBS="$ac_save_LIBS" + LD_LIBRARY_PATH="$ac_save_LD_LIBRARY_PATH" + fi + LIBFLACPP_CFLAGS="" + LIBFLACPP_LIBDIR="" + LIBFLACPP_LIBS="" + ifelse([$2], , :, [$2]) + fi + AC_SUBST(LIBFLACPP_CFLAGS) + AC_SUBST(LIBFLACPP_LIBDIR) + AC_SUBST(LIBFLACPP_LIBS) + rm -f conf.libFLAC++test +]) diff --git a/src/libFLAC++/metadata.cpp b/src/libFLAC++/metadata.cpp new file mode 100644 index 0000000..beab110 --- /dev/null +++ b/src/libFLAC++/metadata.cpp @@ -0,0 +1,1745 @@ +/* libFLAC++ - Free Lossless Audio Codec library + * Copyright (C) 2002-2009 Josh Coalson + * Copyright (C) 2011-2023 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define __STDC_LIMIT_MACROS 1 /* otherwise SIZE_MAX is not defined for c++ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "share/alloc.h" +#include "FLAC++/metadata.h" +#include "FLAC/assert.h" +#include <cstdlib> // for malloc(), free() +#include <cstring> // for memcpy() etc. + +#ifdef _MSC_VER +// warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning) +#pragma warning ( disable : 4800 ) +#endif + +namespace FLAC { + namespace Metadata { + + // local utility routines + + namespace local { + + Prototype *construct_block(::FLAC__StreamMetadata *object) + { + if (0 == object) + return 0; + + Prototype *ret = 0; + switch(object->type) { + case FLAC__METADATA_TYPE_STREAMINFO: + ret = new StreamInfo(object, /*copy=*/false); + break; + case FLAC__METADATA_TYPE_PADDING: + ret = new Padding(object, /*copy=*/false); + break; + case FLAC__METADATA_TYPE_APPLICATION: + ret = new Application(object, /*copy=*/false); + break; + case FLAC__METADATA_TYPE_SEEKTABLE: + ret = new SeekTable(object, /*copy=*/false); + break; + case FLAC__METADATA_TYPE_VORBIS_COMMENT: + ret = new VorbisComment(object, /*copy=*/false); + break; + case FLAC__METADATA_TYPE_CUESHEET: + ret = new CueSheet(object, /*copy=*/false); + break; + case FLAC__METADATA_TYPE_PICTURE: + ret = new Picture(object, /*copy=*/false); + break; + default: + ret = new Unknown(object, /*copy=*/false); + break; + } + return ret; + } + + } // namespace local + + FLACPP_API Prototype *clone(const Prototype *object) + { + FLAC__ASSERT(0 != object); + + const StreamInfo *streaminfo = dynamic_cast<const StreamInfo *>(object); + const Padding *padding = dynamic_cast<const Padding *>(object); + const Application *application = dynamic_cast<const Application *>(object); + const SeekTable *seektable = dynamic_cast<const SeekTable *>(object); + const VorbisComment *vorbiscomment = dynamic_cast<const VorbisComment *>(object); + const CueSheet *cuesheet = dynamic_cast<const CueSheet *>(object); + const Picture *picture = dynamic_cast<const Picture *>(object); + const Unknown *unknown = dynamic_cast<const Unknown *>(object); + + if(0 != streaminfo) + return new StreamInfo(*streaminfo); + if(0 != padding) + return new Padding(*padding); + if(0 != application) + return new Application(*application); + if(0 != seektable) + return new SeekTable(*seektable); + if(0 != vorbiscomment) + return new VorbisComment(*vorbiscomment); + if(0 != cuesheet) + return new CueSheet(*cuesheet); + if(0 != picture) + return new Picture(*picture); + if(0 != unknown) + return new Unknown(*unknown); + + FLAC__ASSERT(0); + return 0; + } + + // + // Prototype + // + + Prototype::Prototype(const Prototype &object): + object_(::FLAC__metadata_object_clone(object.object_)), + is_reference_(false) + { + FLAC__ASSERT(object.is_valid()); + } + + Prototype::Prototype(const ::FLAC__StreamMetadata &object): + object_(::FLAC__metadata_object_clone(&object)), + is_reference_(false) + { + } + + Prototype::Prototype(const ::FLAC__StreamMetadata *object): + object_(::FLAC__metadata_object_clone(object)), + is_reference_(false) + { + FLAC__ASSERT(0 != object); + } + + Prototype::Prototype(::FLAC__StreamMetadata *object, bool copy): + object_(copy? ::FLAC__metadata_object_clone(object) : object), + is_reference_(false) + { + FLAC__ASSERT(0 != object); + } + + Prototype::~Prototype() + { + clear(); + } + + void Prototype::clear() + { + if(0 != object_ && !is_reference_) + FLAC__metadata_object_delete(object_); + object_ = 0; + } + + Prototype &Prototype::operator=(const Prototype &object) + { + FLAC__ASSERT(object.is_valid()); + clear(); + is_reference_ = false; + object_ = ::FLAC__metadata_object_clone(object.object_); + return *this; + } + + Prototype &Prototype::operator=(const ::FLAC__StreamMetadata &object) + { + clear(); + is_reference_ = false; + object_ = ::FLAC__metadata_object_clone(&object); + return *this; + } + + Prototype &Prototype::operator=(const ::FLAC__StreamMetadata *object) + { + FLAC__ASSERT(0 != object); + clear(); + is_reference_ = false; + object_ = ::FLAC__metadata_object_clone(object); + return *this; + } + + Prototype &Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy) + { + FLAC__ASSERT(0 != object); + clear(); + object_ = (copy? ::FLAC__metadata_object_clone(object) : object); + is_reference_ = false; + return *this; + } + + bool Prototype::get_is_last() const + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(object_->is_last); + } + + FLAC__MetadataType Prototype::get_type() const + { + FLAC__ASSERT(is_valid()); + return object_->type; + } + + uint32_t Prototype::get_length() const + { + FLAC__ASSERT(is_valid()); + return object_->length; + } + + void Prototype::set_is_last(bool value) + { + FLAC__ASSERT(is_valid()); + object_->is_last = value; + } + + + // + // StreamInfo + // + + StreamInfo::StreamInfo(): + Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_STREAMINFO), /*copy=*/false) + { } + + StreamInfo::~StreamInfo() + { } + + uint32_t StreamInfo::get_min_blocksize() const + { + FLAC__ASSERT(is_valid()); + return object_->data.stream_info.min_blocksize; + } + + uint32_t StreamInfo::get_max_blocksize() const + { + FLAC__ASSERT(is_valid()); + return object_->data.stream_info.max_blocksize; + } + + uint32_t StreamInfo::get_min_framesize() const + { + FLAC__ASSERT(is_valid()); + return object_->data.stream_info.min_framesize; + } + + uint32_t StreamInfo::get_max_framesize() const + { + FLAC__ASSERT(is_valid()); + return object_->data.stream_info.max_framesize; + } + + uint32_t StreamInfo::get_sample_rate() const + { + FLAC__ASSERT(is_valid()); + return object_->data.stream_info.sample_rate; + } + + uint32_t StreamInfo::get_channels() const + { + FLAC__ASSERT(is_valid()); + return object_->data.stream_info.channels; + } + + uint32_t StreamInfo::get_bits_per_sample() const + { + FLAC__ASSERT(is_valid()); + return object_->data.stream_info.bits_per_sample; + } + + FLAC__uint64 StreamInfo::get_total_samples() const + { + FLAC__ASSERT(is_valid()); + return object_->data.stream_info.total_samples; + } + + const FLAC__byte *StreamInfo::get_md5sum() const + { + FLAC__ASSERT(is_valid()); + return object_->data.stream_info.md5sum; + } + + void StreamInfo::set_min_blocksize(uint32_t value) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(value >= FLAC__MIN_BLOCK_SIZE); + FLAC__ASSERT(value <= FLAC__MAX_BLOCK_SIZE); + object_->data.stream_info.min_blocksize = value; + } + + void StreamInfo::set_max_blocksize(uint32_t value) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(value >= FLAC__MIN_BLOCK_SIZE); + FLAC__ASSERT(value <= FLAC__MAX_BLOCK_SIZE); + object_->data.stream_info.max_blocksize = value; + } + + void StreamInfo::set_min_framesize(uint32_t value) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(value < (1u << FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN)); + object_->data.stream_info.min_framesize = value; + } + + void StreamInfo::set_max_framesize(uint32_t value) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(value < (1u << FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN)); + object_->data.stream_info.max_framesize = value; + } + + void StreamInfo::set_sample_rate(uint32_t value) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(FLAC__format_sample_rate_is_valid(value)); + object_->data.stream_info.sample_rate = value; + } + + void StreamInfo::set_channels(uint32_t value) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(value > 0); + FLAC__ASSERT(value <= FLAC__MAX_CHANNELS); + object_->data.stream_info.channels = value; + } + + void StreamInfo::set_bits_per_sample(uint32_t value) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(value >= FLAC__MIN_BITS_PER_SAMPLE); + FLAC__ASSERT(value <= FLAC__MAX_BITS_PER_SAMPLE); + object_->data.stream_info.bits_per_sample = value; + } + + void StreamInfo::set_total_samples(FLAC__uint64 value) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(value < (((FLAC__uint64)1) << FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN)); + object_->data.stream_info.total_samples = value; + } + + void StreamInfo::set_md5sum(const FLAC__byte value[16]) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(0 != value); + std::memcpy(object_->data.stream_info.md5sum, value, 16); + } + + + // + // Padding + // + + Padding::Padding(): + Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING), /*copy=*/false) + { } + + Padding::Padding(uint32_t length): + Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING), /*copy=*/false) + { + set_length(length); + } + + Padding::~Padding() + { } + + void Padding::set_length(uint32_t length) + { + FLAC__ASSERT(is_valid()); + object_->length = length; + } + + + // + // Application + // + + Application::Application(): + Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION), /*copy=*/false) + { } + + Application::~Application() + { } + + const FLAC__byte *Application::get_id() const + { + FLAC__ASSERT(is_valid()); + return object_->data.application.id; + } + + const FLAC__byte *Application::get_data() const + { + FLAC__ASSERT(is_valid()); + return object_->data.application.data; + } + + void Application::set_id(const FLAC__byte value[4]) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(0 != value); + std::memcpy(object_->data.application.id, value, 4); + } + + bool Application::set_data(const FLAC__byte *data, uint32_t length) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_object_application_set_data(object_, const_cast<FLAC__byte*>(data), length, true)); + } + + bool Application::set_data(FLAC__byte *data, uint32_t length, bool copy) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_object_application_set_data(object_, data, length, copy)); + } + + + // + // SeekTable + // + + SeekTable::SeekTable(): + Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_SEEKTABLE), /*copy=*/false) + { } + + SeekTable::~SeekTable() + { } + + uint32_t SeekTable::get_num_points() const + { + FLAC__ASSERT(is_valid()); + return object_->data.seek_table.num_points; + } + + ::FLAC__StreamMetadata_SeekPoint SeekTable::get_point(uint32_t indx) const + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(indx < object_->data.seek_table.num_points); + return object_->data.seek_table.points[indx]; + } + + bool SeekTable::resize_points(uint32_t new_num_points) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_object_seektable_resize_points(object_, new_num_points)); + } + + void SeekTable::set_point(uint32_t indx, const ::FLAC__StreamMetadata_SeekPoint &point) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(indx < object_->data.seek_table.num_points); + ::FLAC__metadata_object_seektable_set_point(object_, indx, point); + } + + bool SeekTable::insert_point(uint32_t indx, const ::FLAC__StreamMetadata_SeekPoint &point) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(indx <= object_->data.seek_table.num_points); + return static_cast<bool>(::FLAC__metadata_object_seektable_insert_point(object_, indx, point)); + } + + bool SeekTable::delete_point(uint32_t indx) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(indx < object_->data.seek_table.num_points); + return static_cast<bool>(::FLAC__metadata_object_seektable_delete_point(object_, indx)); + } + + bool SeekTable::is_legal() const + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_object_seektable_is_legal(object_)); + } + + bool SeekTable::template_append_placeholders(uint32_t num) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_object_seektable_template_append_placeholders(object_, num)); + } + + bool SeekTable::template_append_point(FLAC__uint64 sample_number) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_object_seektable_template_append_point(object_, sample_number)); + } + + bool SeekTable::template_append_points(FLAC__uint64 sample_numbers[], uint32_t num) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_object_seektable_template_append_points(object_, sample_numbers, num)); + } + + bool SeekTable::template_append_spaced_points(uint32_t num, FLAC__uint64 total_samples) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_object_seektable_template_append_spaced_points(object_, num, total_samples)); + } + + bool SeekTable::template_append_spaced_points_by_samples(uint32_t samples, FLAC__uint64 total_samples) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(object_, samples, total_samples)); + } + + bool SeekTable::template_sort(bool compact) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_object_seektable_template_sort(object_, compact)); + } + + + // + // VorbisComment::Entry + // + + VorbisComment::Entry::Entry() : + is_valid_(true), + entry_(), + field_name_(0), + field_name_length_(0), + field_value_(0), + field_value_length_(0) + { + zero(); + } + + VorbisComment::Entry::Entry(const char *field, uint32_t field_length) : + is_valid_(true), + entry_(), + field_name_(0), + field_name_length_(0), + field_value_(0), + field_value_length_(0) + { + zero(); + construct(field, field_length); + } + + VorbisComment::Entry::Entry(const char *field) : + is_valid_(true), + entry_(), + field_name_(0), + field_name_length_(0), + field_value_(0), + field_value_length_(0) + { + zero(); + construct(field); + } + + VorbisComment::Entry::Entry(const char *field_name, const char *field_value, uint32_t field_value_length) : + is_valid_(true), + entry_(), + field_name_(0), + field_name_length_(0), + field_value_(0), + field_value_length_(0) + { + zero(); + construct(field_name, field_value, field_value_length); + } + + VorbisComment::Entry::Entry(const char *field_name, const char *field_value) : + is_valid_(true), + entry_(), + field_name_(0), + field_name_length_(0), + field_value_(0), + field_value_length_(0) + { + zero(); + construct(field_name, field_value); + } + + VorbisComment::Entry::Entry(const Entry &entry) : + is_valid_(true), + entry_(), + field_name_(0), + field_name_length_(0), + field_value_(0), + field_value_length_(0) + { + FLAC__ASSERT(entry.is_valid()); + zero(); + construct(reinterpret_cast<const char *>(entry.entry_.entry), entry.entry_.length); + } + + VorbisComment::Entry &VorbisComment::Entry::operator=(const Entry &entry) + { + FLAC__ASSERT(entry.is_valid()); + clear(); + construct(reinterpret_cast<const char *>(entry.entry_.entry), entry.entry_.length); + return *this; + } + + VorbisComment::Entry::~Entry() + { + clear(); + } + + bool VorbisComment::Entry::is_valid() const + { + return is_valid_; + } + + uint32_t VorbisComment::Entry::get_field_length() const + { + FLAC__ASSERT(is_valid()); + return entry_.length; + } + + uint32_t VorbisComment::Entry::get_field_name_length() const + { + FLAC__ASSERT(is_valid()); + return field_name_length_; + } + + uint32_t VorbisComment::Entry::get_field_value_length() const + { + FLAC__ASSERT(is_valid()); + return field_value_length_; + } + + ::FLAC__StreamMetadata_VorbisComment_Entry VorbisComment::Entry::get_entry() const + { + FLAC__ASSERT(is_valid()); + return entry_; + } + + const char *VorbisComment::Entry::get_field() const + { + FLAC__ASSERT(is_valid()); + return reinterpret_cast<const char *>(entry_.entry); + } + + const char *VorbisComment::Entry::get_field_name() const + { + FLAC__ASSERT(is_valid()); + return field_name_; + } + + const char *VorbisComment::Entry::get_field_value() const + { + FLAC__ASSERT(is_valid()); + return field_value_; + } + + bool VorbisComment::Entry::set_field(const char *field, uint32_t field_length) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(0 != field); + + if(!::FLAC__format_vorbiscomment_entry_is_legal(reinterpret_cast<const ::FLAC__byte*>(field), field_length)) + return is_valid_ = false; + + clear_entry(); + + if(0 == (entry_.entry = static_cast<FLAC__byte*>(safe_malloc_add_2op_(field_length, /*+*/1)))) { + is_valid_ = false; + } + else { + entry_.length = field_length; + std::memcpy(entry_.entry, field, field_length); + entry_.entry[field_length] = '\0'; + (void) parse_field(); + } + + return is_valid_; + } + + bool VorbisComment::Entry::set_field(const char *field) + { + return set_field(field, std::strlen(field)); + } + + bool VorbisComment::Entry::set_field_name(const char *field_name) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(0 != field_name); + + if(!::FLAC__format_vorbiscomment_entry_name_is_legal(field_name)) + return is_valid_ = false; + + clear_field_name(); + + if(0 == (field_name_ = strdup(field_name))) { + is_valid_ = false; + } + else { + field_name_length_ = std::strlen(field_name_); + compose_field(); + } + + return is_valid_; + } + + bool VorbisComment::Entry::set_field_value(const char *field_value, uint32_t field_value_length) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(0 != field_value); + + if(!::FLAC__format_vorbiscomment_entry_value_is_legal(reinterpret_cast<const FLAC__byte*>(field_value), field_value_length)) + return is_valid_ = false; + + clear_field_value(); + + if(0 == (field_value_ = static_cast<char *>(safe_malloc_add_2op_(field_value_length, /*+*/1)))) { + is_valid_ = false; + } + else { + field_value_length_ = field_value_length; + std::memcpy(field_value_, field_value, field_value_length); + field_value_[field_value_length] = '\0'; + compose_field(); + } + + return is_valid_; + } + + bool VorbisComment::Entry::set_field_value(const char *field_value) + { + return set_field_value(field_value, std::strlen(field_value)); + } + + void VorbisComment::Entry::zero() + { + is_valid_ = true; + entry_.length = 0; + entry_.entry = 0; + field_name_ = 0; + field_name_length_ = 0; + field_value_ = 0; + field_value_length_ = 0; + } + + void VorbisComment::Entry::clear() + { + clear_entry(); + clear_field_name(); + clear_field_value(); + is_valid_ = true; + } + + void VorbisComment::Entry::clear_entry() + { + if(0 != entry_.entry) { + std::free(entry_.entry); + entry_.entry = 0; + entry_.length = 0; + } + } + + void VorbisComment::Entry::clear_field_name() + { + if(0 != field_name_) { + std::free(field_name_); + field_name_ = 0; + field_name_length_ = 0; + } + } + + void VorbisComment::Entry::clear_field_value() + { + if(0 != field_value_) { + std::free(field_value_); + field_value_ = 0; + field_value_length_ = 0; + } + } + + void VorbisComment::Entry::construct(const char *field, uint32_t field_length) + { + if(set_field(field, field_length)) + parse_field(); + } + + void VorbisComment::Entry::construct(const char *field) + { + construct(field, std::strlen(field)); + } + + void VorbisComment::Entry::construct(const char *field_name, const char *field_value, uint32_t field_value_length) + { + if(set_field_name(field_name) && set_field_value(field_value, field_value_length)) + compose_field(); + } + + void VorbisComment::Entry::construct(const char *field_name, const char *field_value) + { + construct(field_name, field_value, std::strlen(field_value)); + } + + void VorbisComment::Entry::compose_field() + { + clear_entry(); + + if(0 == (entry_.entry = static_cast<FLAC__byte*>(safe_malloc_add_4op_(field_name_length_, /*+*/1, /*+*/field_value_length_, /*+*/1)))) { + is_valid_ = false; + } + else { + std::memcpy(entry_.entry, field_name_, field_name_length_); + entry_.length += field_name_length_; + std::memcpy(entry_.entry + entry_.length, "=", 1); + entry_.length += 1; + if (field_value_length_ > 0) + std::memcpy(entry_.entry + entry_.length, field_value_, field_value_length_); + entry_.length += field_value_length_; + entry_.entry[entry_.length] = '\0'; + is_valid_ = true; + } + } + + void VorbisComment::Entry::parse_field() + { + clear_field_name(); + clear_field_value(); + + const char *p = static_cast<const char *>(std::memchr(entry_.entry, '=', entry_.length)); + + if(0 == p) + p = reinterpret_cast<const char *>(entry_.entry) + entry_.length; + + field_name_length_ = static_cast<uint32_t>(p - reinterpret_cast<const char *>(entry_.entry)); + if(0 == (field_name_ = static_cast<char *>(safe_malloc_add_2op_(field_name_length_, /*+*/1)))) { // +1 for the trailing \0 + is_valid_ = false; + return; + } + std::memcpy(field_name_, entry_.entry, field_name_length_); + field_name_[field_name_length_] = '\0'; + + if(entry_.length - field_name_length_ == 0) { + field_value_length_ = 0; + if(0 == (field_value_ = static_cast<char *>(safe_malloc_(0)))) { + is_valid_ = false; + return; + } + } + else { + field_value_length_ = entry_.length - field_name_length_ - 1; + if(0 == (field_value_ = static_cast<char *>(safe_malloc_add_2op_(field_value_length_, /*+*/1)))) { // +1 for the trailing \0 + is_valid_ = false; + return; + } + std::memcpy(field_value_, ++p, field_value_length_); + field_value_[field_value_length_] = '\0'; + } + + is_valid_ = true; + } + + + // + // VorbisComment + // + + VorbisComment::VorbisComment(): + Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT), /*copy=*/false) + { } + + VorbisComment::~VorbisComment() + { } + + uint32_t VorbisComment::get_num_comments() const + { + FLAC__ASSERT(is_valid()); + return object_->data.vorbis_comment.num_comments; + } + + const FLAC__byte *VorbisComment::get_vendor_string() const + { + FLAC__ASSERT(is_valid()); + return object_->data.vorbis_comment.vendor_string.entry; + } + + VorbisComment::Entry VorbisComment::get_comment(uint32_t indx) const + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(indx < object_->data.vorbis_comment.num_comments); + return Entry(reinterpret_cast<const char *>(object_->data.vorbis_comment.comments[indx].entry), object_->data.vorbis_comment.comments[indx].length); + } + + bool VorbisComment::set_vendor_string(const FLAC__byte *string) + { + FLAC__ASSERT(is_valid()); + // vendor_string is a special kind of entry + const ::FLAC__StreamMetadata_VorbisComment_Entry vendor_string = { static_cast<FLAC__uint32>(std::strlen(reinterpret_cast<const char *>(string))), const_cast<FLAC__byte*>(string) }; // we can cheat on const-ness because we make a copy below: + return static_cast<bool>(::FLAC__metadata_object_vorbiscomment_set_vendor_string(object_, vendor_string, /*copy=*/true)); + } + + bool VorbisComment::resize_comments(uint32_t new_num_comments) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_object_vorbiscomment_resize_comments(object_, new_num_comments)); + } + + bool VorbisComment::set_comment(uint32_t indx, const VorbisComment::Entry &entry) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(indx < object_->data.vorbis_comment.num_comments); + return static_cast<bool>(::FLAC__metadata_object_vorbiscomment_set_comment(object_, indx, entry.get_entry(), /*copy=*/true)); + } + + bool VorbisComment::insert_comment(uint32_t indx, const VorbisComment::Entry &entry) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(indx <= object_->data.vorbis_comment.num_comments); + return static_cast<bool>(::FLAC__metadata_object_vorbiscomment_insert_comment(object_, indx, entry.get_entry(), /*copy=*/true)); + } + + bool VorbisComment::append_comment(const VorbisComment::Entry &entry) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_object_vorbiscomment_append_comment(object_, entry.get_entry(), /*copy=*/true)); + } + + bool VorbisComment::replace_comment(const VorbisComment::Entry &entry, bool all) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_object_vorbiscomment_replace_comment(object_, entry.get_entry(), static_cast<FLAC__bool>(all), /*copy=*/true)); + } + + bool VorbisComment::delete_comment(uint32_t indx) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(indx < object_->data.vorbis_comment.num_comments); + return static_cast<bool>(::FLAC__metadata_object_vorbiscomment_delete_comment(object_, indx)); + } + + int VorbisComment::find_entry_from(uint32_t offset, const char *field_name) + { + FLAC__ASSERT(is_valid()); + return ::FLAC__metadata_object_vorbiscomment_find_entry_from(object_, offset, field_name); + } + + int VorbisComment::remove_entry_matching(const char *field_name) + { + FLAC__ASSERT(is_valid()); + return ::FLAC__metadata_object_vorbiscomment_remove_entry_matching(object_, field_name); + } + + int VorbisComment::remove_entries_matching(const char *field_name) + { + FLAC__ASSERT(is_valid()); + return ::FLAC__metadata_object_vorbiscomment_remove_entries_matching(object_, field_name); + } + + + // + // CueSheet::Track + // + + CueSheet::Track::Track(): + object_(::FLAC__metadata_object_cuesheet_track_new()) + { } + + CueSheet::Track::Track(const ::FLAC__StreamMetadata_CueSheet_Track *track): + object_(::FLAC__metadata_object_cuesheet_track_clone(track)) + { } + + CueSheet::Track::Track(const Track &track): + object_(::FLAC__metadata_object_cuesheet_track_clone(track.object_)) + { } + + CueSheet::Track &CueSheet::Track::operator=(const Track &track) + { + if(0 != object_) + ::FLAC__metadata_object_cuesheet_track_delete(object_); + object_ = ::FLAC__metadata_object_cuesheet_track_clone(track.object_); + return *this; + } + + CueSheet::Track::~Track() + { + if(0 != object_) + ::FLAC__metadata_object_cuesheet_track_delete(object_); + } + + bool CueSheet::Track::is_valid() const + { + return(0 != object_); + } + + ::FLAC__StreamMetadata_CueSheet_Index CueSheet::Track::get_index(uint32_t i) const + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(i < object_->num_indices); + return object_->indices[i]; + } + + void CueSheet::Track::set_isrc(const char value[12]) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(0 != value); + std::memcpy(object_->isrc, value, 12); + object_->isrc[12] = '\0'; + } + + void CueSheet::Track::set_type(uint32_t value) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(value <= 1); + object_->type = value; + } + + void CueSheet::Track::set_index(uint32_t i, const ::FLAC__StreamMetadata_CueSheet_Index &indx) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(i < object_->num_indices); + object_->indices[i] = indx; + } + + + // + // CueSheet + // + + CueSheet::CueSheet(): + Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_CUESHEET), /*copy=*/false) + { } + + CueSheet::~CueSheet() + { } + + const char *CueSheet::get_media_catalog_number() const + { + FLAC__ASSERT(is_valid()); + return object_->data.cue_sheet.media_catalog_number; + } + + FLAC__uint64 CueSheet::get_lead_in() const + { + FLAC__ASSERT(is_valid()); + return object_->data.cue_sheet.lead_in; + } + + bool CueSheet::get_is_cd() const + { + FLAC__ASSERT(is_valid()); + return object_->data.cue_sheet.is_cd? true : false; + } + + uint32_t CueSheet::get_num_tracks() const + { + FLAC__ASSERT(is_valid()); + return object_->data.cue_sheet.num_tracks; + } + + CueSheet::Track CueSheet::get_track(uint32_t i) const + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(i < object_->data.cue_sheet.num_tracks); + return Track(object_->data.cue_sheet.tracks + i); + } + + void CueSheet::set_media_catalog_number(const char value[128]) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(0 != value); + std::memcpy(object_->data.cue_sheet.media_catalog_number, value, 128); + object_->data.cue_sheet.media_catalog_number[128] = '\0'; + } + + void CueSheet::set_lead_in(FLAC__uint64 value) + { + FLAC__ASSERT(is_valid()); + object_->data.cue_sheet.lead_in = value; + } + + void CueSheet::set_is_cd(bool value) + { + FLAC__ASSERT(is_valid()); + object_->data.cue_sheet.is_cd = value; + } + + void CueSheet::set_index(uint32_t track_num, uint32_t index_num, const ::FLAC__StreamMetadata_CueSheet_Index &indx) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(track_num < object_->data.cue_sheet.num_tracks); + FLAC__ASSERT(index_num < object_->data.cue_sheet.tracks[track_num].num_indices); + object_->data.cue_sheet.tracks[track_num].indices[index_num] = indx; + } + + bool CueSheet::resize_indices(uint32_t track_num, uint32_t new_num_indices) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(track_num < object_->data.cue_sheet.num_tracks); + return static_cast<bool>(::FLAC__metadata_object_cuesheet_track_resize_indices(object_, track_num, new_num_indices)); + } + + bool CueSheet::insert_index(uint32_t track_num, uint32_t index_num, const ::FLAC__StreamMetadata_CueSheet_Index &indx) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(track_num < object_->data.cue_sheet.num_tracks); + FLAC__ASSERT(index_num <= object_->data.cue_sheet.tracks[track_num].num_indices); + return static_cast<bool>(::FLAC__metadata_object_cuesheet_track_insert_index(object_, track_num, index_num, indx)); + } + + bool CueSheet::insert_blank_index(uint32_t track_num, uint32_t index_num) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(track_num < object_->data.cue_sheet.num_tracks); + FLAC__ASSERT(index_num <= object_->data.cue_sheet.tracks[track_num].num_indices); + return static_cast<bool>(::FLAC__metadata_object_cuesheet_track_insert_blank_index(object_, track_num, index_num)); + } + + bool CueSheet::delete_index(uint32_t track_num, uint32_t index_num) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(track_num < object_->data.cue_sheet.num_tracks); + FLAC__ASSERT(index_num < object_->data.cue_sheet.tracks[track_num].num_indices); + return static_cast<bool>(::FLAC__metadata_object_cuesheet_track_delete_index(object_, track_num, index_num)); + } + + bool CueSheet::resize_tracks(uint32_t new_num_tracks) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_object_cuesheet_resize_tracks(object_, new_num_tracks)); + } + + bool CueSheet::set_track(uint32_t i, const CueSheet::Track &track) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(i < object_->data.cue_sheet.num_tracks); + // We can safely const_cast since copy=true + return static_cast<bool>(::FLAC__metadata_object_cuesheet_set_track(object_, i, const_cast< ::FLAC__StreamMetadata_CueSheet_Track*>(track.get_track()), /*copy=*/true)); + } + + bool CueSheet::insert_track(uint32_t i, const CueSheet::Track &track) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(i <= object_->data.cue_sheet.num_tracks); + // We can safely const_cast since copy=true + return static_cast<bool>(::FLAC__metadata_object_cuesheet_insert_track(object_, i, const_cast< ::FLAC__StreamMetadata_CueSheet_Track*>(track.get_track()), /*copy=*/true)); + } + + bool CueSheet::insert_blank_track(uint32_t i) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(i <= object_->data.cue_sheet.num_tracks); + return static_cast<bool>(::FLAC__metadata_object_cuesheet_insert_blank_track(object_, i)); + } + + bool CueSheet::delete_track(uint32_t i) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(i < object_->data.cue_sheet.num_tracks); + return static_cast<bool>(::FLAC__metadata_object_cuesheet_delete_track(object_, i)); + } + + bool CueSheet::is_legal(bool check_cd_da_subset, const char **violation) const + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_object_cuesheet_is_legal(object_, check_cd_da_subset, violation)); + } + + FLAC__uint32 CueSheet::calculate_cddb_id() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__metadata_object_cuesheet_calculate_cddb_id(object_); + } + + + // + // Picture + // + + Picture::Picture(): + Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_PICTURE), /*copy=*/false) + { } + + Picture::~Picture() + { } + + ::FLAC__StreamMetadata_Picture_Type Picture::get_type() const + { + FLAC__ASSERT(is_valid()); + return object_->data.picture.type; + } + + const char *Picture::get_mime_type() const + { + FLAC__ASSERT(is_valid()); + return object_->data.picture.mime_type; + } + + const FLAC__byte *Picture::get_description() const + { + FLAC__ASSERT(is_valid()); + return object_->data.picture.description; + } + + FLAC__uint32 Picture::get_width() const + { + FLAC__ASSERT(is_valid()); + return object_->data.picture.width; + } + + FLAC__uint32 Picture::get_height() const + { + FLAC__ASSERT(is_valid()); + return object_->data.picture.height; + } + + FLAC__uint32 Picture::get_depth() const + { + FLAC__ASSERT(is_valid()); + return object_->data.picture.depth; + } + + FLAC__uint32 Picture::get_colors() const + { + FLAC__ASSERT(is_valid()); + return object_->data.picture.colors; + } + + FLAC__uint32 Picture::get_data_length() const + { + FLAC__ASSERT(is_valid()); + return object_->data.picture.data_length; + } + + const FLAC__byte *Picture::get_data() const + { + FLAC__ASSERT(is_valid()); + return object_->data.picture.data; + } + + void Picture::set_type(::FLAC__StreamMetadata_Picture_Type type) + { + FLAC__ASSERT(is_valid()); + object_->data.picture.type = type; + } + + bool Picture::set_mime_type(const char *string) + { + FLAC__ASSERT(is_valid()); + // We can safely const_cast since copy=true + return static_cast<bool>(::FLAC__metadata_object_picture_set_mime_type(object_, const_cast<char*>(string), /*copy=*/true)); + } + + bool Picture::set_description(const FLAC__byte *string) + { + FLAC__ASSERT(is_valid()); + // We can safely const_cast since copy=true + return static_cast<bool>(::FLAC__metadata_object_picture_set_description(object_, const_cast<FLAC__byte*>(string), /*copy=*/true)); + } + + void Picture::set_width(FLAC__uint32 value) const + { + FLAC__ASSERT(is_valid()); + object_->data.picture.width = value; + } + + void Picture::set_height(FLAC__uint32 value) const + { + FLAC__ASSERT(is_valid()); + object_->data.picture.height = value; + } + + void Picture::set_depth(FLAC__uint32 value) const + { + FLAC__ASSERT(is_valid()); + object_->data.picture.depth = value; + } + + void Picture::set_colors(FLAC__uint32 value) const + { + FLAC__ASSERT(is_valid()); + object_->data.picture.colors = value; + } + + bool Picture::set_data(const FLAC__byte *data, FLAC__uint32 data_length) + { + FLAC__ASSERT(is_valid()); + // We can safely const_cast since copy=true + return static_cast<bool>(::FLAC__metadata_object_picture_set_data(object_, const_cast<FLAC__byte*>(data), data_length, /*copy=*/true)); + } + + bool Picture::is_legal(const char **violation) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_object_picture_is_legal(object_, violation)); + } + + + // + // Unknown + // + + Unknown::Unknown(): + Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION), /*copy=*/false) + { } + + Unknown::~Unknown() + { } + + const FLAC__byte *Unknown::get_data() const + { + FLAC__ASSERT(is_valid()); + return object_->data.application.data; + } + + bool Unknown::set_data(const FLAC__byte *data, uint32_t length) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_object_application_set_data(object_, const_cast<FLAC__byte*>(data), length, true)); + } + + bool Unknown::set_data(FLAC__byte *data, uint32_t length, bool copy) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_object_application_set_data(object_, data, length, copy)); + } + + + // ============================================================ + // + // Level 0 + // + // ============================================================ + + FLACPP_API bool get_streaminfo(const char *filename, StreamInfo &streaminfo) + { + FLAC__ASSERT(0 != filename); + + ::FLAC__StreamMetadata object; + + if(::FLAC__metadata_get_streaminfo(filename, &object)) { + streaminfo = object; + return true; + } + else + return false; + } + + FLACPP_API bool get_tags(const char *filename, VorbisComment *&tags) + { + FLAC__ASSERT(0 != filename); + + ::FLAC__StreamMetadata *object; + + tags = 0; + + if(::FLAC__metadata_get_tags(filename, &object)) { + tags = new VorbisComment(object, /*copy=*/false); + return true; + } + else + return false; + } + + FLACPP_API bool get_tags(const char *filename, VorbisComment &tags) + { + FLAC__ASSERT(0 != filename); + + ::FLAC__StreamMetadata *object; + + if(::FLAC__metadata_get_tags(filename, &object)) { + tags.assign(object, /*copy=*/false); + return true; + } + else + return false; + } + + FLACPP_API bool get_cuesheet(const char *filename, CueSheet *&cuesheet) + { + FLAC__ASSERT(0 != filename); + + ::FLAC__StreamMetadata *object; + + cuesheet = 0; + + if(::FLAC__metadata_get_cuesheet(filename, &object)) { + cuesheet = new CueSheet(object, /*copy=*/false); + return true; + } + else + return false; + } + + FLACPP_API bool get_cuesheet(const char *filename, CueSheet &cuesheet) + { + FLAC__ASSERT(0 != filename); + + ::FLAC__StreamMetadata *object; + + if(::FLAC__metadata_get_cuesheet(filename, &object)) { + cuesheet.assign(object, /*copy=*/false); + return true; + } + else + return false; + } + + FLACPP_API bool get_picture(const char *filename, Picture *&picture, ::FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, uint32_t max_width, uint32_t max_height, uint32_t max_depth, uint32_t max_colors) + { + FLAC__ASSERT(0 != filename); + + ::FLAC__StreamMetadata *object; + + picture = 0; + + if(::FLAC__metadata_get_picture(filename, &object, type, mime_type, description, max_width, max_height, max_depth, max_colors)) { + picture = new Picture(object, /*copy=*/false); + return true; + } + else + return false; + } + + FLACPP_API bool get_picture(const char *filename, Picture &picture, ::FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, uint32_t max_width, uint32_t max_height, uint32_t max_depth, uint32_t max_colors) + { + FLAC__ASSERT(0 != filename); + + ::FLAC__StreamMetadata *object; + + if(::FLAC__metadata_get_picture(filename, &object, type, mime_type, description, max_width, max_height, max_depth, max_colors)) { + picture.assign(object, /*copy=*/false); + return true; + } + else + return false; + } + + + // ============================================================ + // + // Level 1 + // + // ============================================================ + + SimpleIterator::SimpleIterator(): + iterator_(::FLAC__metadata_simple_iterator_new()) + { } + + SimpleIterator::~SimpleIterator() + { + clear(); + } + + void SimpleIterator::clear() + { + if(0 != iterator_) + FLAC__metadata_simple_iterator_delete(iterator_); + iterator_ = 0; + } + + bool SimpleIterator::init(const char *filename, bool read_only, bool preserve_file_stats) + { + FLAC__ASSERT(0 != filename); + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_simple_iterator_init(iterator_, filename, read_only, preserve_file_stats)); + } + + bool SimpleIterator::is_valid() const + { + return 0 != iterator_; + } + + SimpleIterator::Status SimpleIterator::status() + { + FLAC__ASSERT(is_valid()); + return Status(::FLAC__metadata_simple_iterator_status(iterator_)); + } + + bool SimpleIterator::is_writable() const + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_simple_iterator_is_writable(iterator_)); + } + + bool SimpleIterator::next() + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_simple_iterator_next(iterator_)); + } + + bool SimpleIterator::prev() + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_simple_iterator_prev(iterator_)); + } + + //@@@@ add to tests + bool SimpleIterator::is_last() const + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_simple_iterator_is_last(iterator_)); + } + + //@@@@ add to tests + off_t SimpleIterator::get_block_offset() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__metadata_simple_iterator_get_block_offset(iterator_); + } + + ::FLAC__MetadataType SimpleIterator::get_block_type() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__metadata_simple_iterator_get_block_type(iterator_); + } + + //@@@@ add to tests + uint32_t SimpleIterator::get_block_length() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__metadata_simple_iterator_get_block_length(iterator_); + } + + //@@@@ add to tests + bool SimpleIterator::get_application_id(FLAC__byte *id) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_simple_iterator_get_application_id(iterator_, id)); + } + + Prototype *SimpleIterator::get_block() + { + FLAC__ASSERT(is_valid()); + return local::construct_block(::FLAC__metadata_simple_iterator_get_block(iterator_)); + } + + bool SimpleIterator::set_block(Prototype *block, bool use_padding) + { + FLAC__ASSERT(0 != block); + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_simple_iterator_set_block(iterator_, block->object_, use_padding)); + } + + bool SimpleIterator::insert_block_after(Prototype *block, bool use_padding) + { + FLAC__ASSERT(0 != block); + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_simple_iterator_insert_block_after(iterator_, block->object_, use_padding)); + } + + bool SimpleIterator::delete_block(bool use_padding) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_simple_iterator_delete_block(iterator_, use_padding)); + } + + + // ============================================================ + // + // Level 2 + // + // ============================================================ + + Chain::Chain(): + chain_(::FLAC__metadata_chain_new()) + { } + + Chain::~Chain() + { + clear(); + } + + void Chain::clear() + { + if(0 != chain_) + FLAC__metadata_chain_delete(chain_); + chain_ = 0; + } + + bool Chain::is_valid() const + { + return 0 != chain_; + } + + Chain::Status Chain::status() + { + FLAC__ASSERT(is_valid()); + return Status(::FLAC__metadata_chain_status(chain_)); + } + + bool Chain::read(const char *filename, bool is_ogg) + { + FLAC__ASSERT(0 != filename); + FLAC__ASSERT(is_valid()); + return is_ogg? + static_cast<bool>(::FLAC__metadata_chain_read_ogg(chain_, filename)) : + static_cast<bool>(::FLAC__metadata_chain_read(chain_, filename)) + ; + } + + bool Chain::read(FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks, bool is_ogg) + { + FLAC__ASSERT(is_valid()); + return is_ogg? + static_cast<bool>(::FLAC__metadata_chain_read_ogg_with_callbacks(chain_, handle, callbacks)) : + static_cast<bool>(::FLAC__metadata_chain_read_with_callbacks(chain_, handle, callbacks)) + ; + } + + bool Chain::check_if_tempfile_needed(bool use_padding) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_chain_check_if_tempfile_needed(chain_, use_padding)); + } + + bool Chain::write(bool use_padding, bool preserve_file_stats) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_chain_write(chain_, use_padding, preserve_file_stats)); + } + + bool Chain::write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_chain_write_with_callbacks(chain_, use_padding, handle, callbacks)); + } + + bool Chain::write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks, ::FLAC__IOHandle temp_handle, ::FLAC__IOCallbacks temp_callbacks) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_chain_write_with_callbacks_and_tempfile(chain_, use_padding, handle, callbacks, temp_handle, temp_callbacks)); + } + + void Chain::merge_padding() + { + FLAC__ASSERT(is_valid()); + ::FLAC__metadata_chain_merge_padding(chain_); + } + + void Chain::sort_padding() + { + FLAC__ASSERT(is_valid()); + ::FLAC__metadata_chain_sort_padding(chain_); + } + + + Iterator::Iterator(): + iterator_(::FLAC__metadata_iterator_new()) + { } + + Iterator::~Iterator() + { + clear(); + } + + void Iterator::clear() + { + if(0 != iterator_) + FLAC__metadata_iterator_delete(iterator_); + iterator_ = 0; + } + + bool Iterator::is_valid() const + { + return 0 != iterator_; + } + + void Iterator::init(Chain &chain) + { + FLAC__ASSERT(is_valid()); + FLAC__ASSERT(chain.is_valid()); + ::FLAC__metadata_iterator_init(iterator_, chain.chain_); + } + + bool Iterator::next() + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_iterator_next(iterator_)); + } + + bool Iterator::prev() + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_iterator_prev(iterator_)); + } + + ::FLAC__MetadataType Iterator::get_block_type() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__metadata_iterator_get_block_type(iterator_); + } + + Prototype *Iterator::get_block() + { + FLAC__ASSERT(is_valid()); + Prototype *block = local::construct_block(::FLAC__metadata_iterator_get_block(iterator_)); + if(0 != block) + block->set_reference(true); + return block; + } + + bool Iterator::set_block(Prototype *block) + { + FLAC__ASSERT(0 != block); + FLAC__ASSERT(is_valid()); + bool ret = static_cast<bool>(::FLAC__metadata_iterator_set_block(iterator_, block->object_)); + if(ret) { + block->set_reference(true); + delete block; + } + return ret; + } + + bool Iterator::delete_block(bool replace_with_padding) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__metadata_iterator_delete_block(iterator_, replace_with_padding)); + } + + bool Iterator::insert_block_before(Prototype *block) + { + FLAC__ASSERT(0 != block); + FLAC__ASSERT(is_valid()); + bool ret = static_cast<bool>(::FLAC__metadata_iterator_insert_block_before(iterator_, block->object_)); + if(ret) { + block->set_reference(true); + delete block; + } + return ret; + } + + bool Iterator::insert_block_after(Prototype *block) + { + FLAC__ASSERT(0 != block); + FLAC__ASSERT(is_valid()); + bool ret = static_cast<bool>(::FLAC__metadata_iterator_insert_block_after(iterator_, block->object_)); + if(ret) { + block->set_reference(true); + delete block; + } + return ret; + } + + } // namespace Metadata +} // namespace FLAC diff --git a/src/libFLAC++/stream_decoder.cpp b/src/libFLAC++/stream_decoder.cpp new file mode 100644 index 0000000..6e351d9 --- /dev/null +++ b/src/libFLAC++/stream_decoder.cpp @@ -0,0 +1,394 @@ +/* libFLAC++ - Free Lossless Audio Codec library + * Copyright (C) 2002-2009 Josh Coalson + * Copyright (C) 2011-2023 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "FLAC++/decoder.h" +#include "FLAC/assert.h" + +#ifdef _MSC_VER +// warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning) +#pragma warning ( disable : 4800 ) +#endif + +namespace FLAC { + namespace Decoder { + + // ------------------------------------------------------------ + // + // Stream + // + // ------------------------------------------------------------ + + Stream::Stream(): + decoder_(::FLAC__stream_decoder_new()) + { } + + Stream::~Stream() + { + if(0 != decoder_) { + (void)::FLAC__stream_decoder_finish(decoder_); + ::FLAC__stream_decoder_delete(decoder_); + } + } + + bool Stream::is_valid() const + { + return 0 != decoder_; + } + + bool Stream::set_ogg_serial_number(long value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_decoder_set_ogg_serial_number(decoder_, value)); + } + + bool Stream::set_md5_checking(bool value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_decoder_set_md5_checking(decoder_, value)); + } + + bool Stream::set_metadata_respond(::FLAC__MetadataType type) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_decoder_set_metadata_respond(decoder_, type)); + } + + bool Stream::set_metadata_respond_application(const FLAC__byte id[4]) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_decoder_set_metadata_respond_application(decoder_, id)); + } + + bool Stream::set_metadata_respond_all() + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_decoder_set_metadata_respond_all(decoder_)); + } + + bool Stream::set_metadata_ignore(::FLAC__MetadataType type) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_decoder_set_metadata_ignore(decoder_, type)); + } + + bool Stream::set_metadata_ignore_application(const FLAC__byte id[4]) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_decoder_set_metadata_ignore_application(decoder_, id)); + } + + bool Stream::set_metadata_ignore_all() + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_decoder_set_metadata_ignore_all(decoder_)); + } + + Stream::State Stream::get_state() const + { + FLAC__ASSERT(is_valid()); + return State(::FLAC__stream_decoder_get_state(decoder_)); + } + + bool Stream::get_md5_checking() const + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_decoder_get_md5_checking(decoder_)); + } + + FLAC__uint64 Stream::get_total_samples() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_decoder_get_total_samples(decoder_); + } + + uint32_t Stream::get_channels() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_decoder_get_channels(decoder_); + } + + ::FLAC__ChannelAssignment Stream::get_channel_assignment() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_decoder_get_channel_assignment(decoder_); + } + + uint32_t Stream::get_bits_per_sample() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_decoder_get_bits_per_sample(decoder_); + } + + uint32_t Stream::get_sample_rate() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_decoder_get_sample_rate(decoder_); + } + + uint32_t Stream::get_blocksize() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_decoder_get_blocksize(decoder_); + } + + bool Stream::get_decode_position(FLAC__uint64 *position) const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_decoder_get_decode_position(decoder_, position); + } + + ::FLAC__StreamDecoderInitStatus Stream::init() + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_decoder_init_stream(decoder_, read_callback_, seek_callback_, tell_callback_, length_callback_, eof_callback_, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this); + } + + ::FLAC__StreamDecoderInitStatus Stream::init_ogg() + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_decoder_init_ogg_stream(decoder_, read_callback_, seek_callback_, tell_callback_, length_callback_, eof_callback_, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this); + } + + bool Stream::finish() + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_decoder_finish(decoder_)); + } + + bool Stream::flush() + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_decoder_flush(decoder_)); + } + + bool Stream::reset() + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_decoder_reset(decoder_)); + } + + bool Stream::process_single() + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_decoder_process_single(decoder_)); + } + + bool Stream::process_until_end_of_metadata() + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_decoder_process_until_end_of_metadata(decoder_)); + } + + bool Stream::process_until_end_of_stream() + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_decoder_process_until_end_of_stream(decoder_)); + } + + bool Stream::skip_single_frame() + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_decoder_skip_single_frame(decoder_)); + } + + bool Stream::seek_absolute(FLAC__uint64 sample) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_decoder_seek_absolute(decoder_, sample)); + } + + ::FLAC__StreamDecoderSeekStatus Stream::seek_callback(FLAC__uint64 absolute_byte_offset) + { + (void)absolute_byte_offset; + return ::FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED; + } + + ::FLAC__StreamDecoderTellStatus Stream::tell_callback(FLAC__uint64 *absolute_byte_offset) + { + (void)absolute_byte_offset; + return ::FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED; + } + + ::FLAC__StreamDecoderLengthStatus Stream::length_callback(FLAC__uint64 *stream_length) + { + (void)stream_length; + return ::FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED; + } + + bool Stream::eof_callback() + { + return false; + } + + void Stream::metadata_callback(const ::FLAC__StreamMetadata *metadata) + { + (void)metadata; + } + + ::FLAC__StreamDecoderReadStatus Stream::read_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) + { + (void)decoder; + FLAC__ASSERT(0 != client_data); + Stream *instance = reinterpret_cast<Stream *>(client_data); + FLAC__ASSERT(0 != instance); + return instance->read_callback(buffer, bytes); + } + + ::FLAC__StreamDecoderSeekStatus Stream::seek_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) + { + (void) decoder; + FLAC__ASSERT(0 != client_data); + Stream *instance = reinterpret_cast<Stream *>(client_data); + FLAC__ASSERT(0 != instance); + return instance->seek_callback(absolute_byte_offset); + } + + ::FLAC__StreamDecoderTellStatus Stream::tell_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) + { + (void) decoder; + FLAC__ASSERT(0 != client_data); + Stream *instance = reinterpret_cast<Stream *>(client_data); + FLAC__ASSERT(0 != instance); + return instance->tell_callback(absolute_byte_offset); + } + + ::FLAC__StreamDecoderLengthStatus Stream::length_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) + { + (void) decoder; + FLAC__ASSERT(0 != client_data); + Stream *instance = reinterpret_cast<Stream *>(client_data); + FLAC__ASSERT(0 != instance); + return instance->length_callback(stream_length); + } + + FLAC__bool Stream::eof_callback_(const ::FLAC__StreamDecoder *decoder, void *client_data) + { + (void) decoder; + FLAC__ASSERT(0 != client_data); + Stream *instance = reinterpret_cast<Stream *>(client_data); + FLAC__ASSERT(0 != instance); + return instance->eof_callback(); + } + + ::FLAC__StreamDecoderWriteStatus Stream::write_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) + { + (void)decoder; + FLAC__ASSERT(0 != client_data); + Stream *instance = reinterpret_cast<Stream *>(client_data); + FLAC__ASSERT(0 != instance); + return instance->write_callback(frame, buffer); + } + + void Stream::metadata_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data) + { + (void)decoder; + FLAC__ASSERT(0 != client_data); + Stream *instance = reinterpret_cast<Stream *>(client_data); + FLAC__ASSERT(0 != instance); + instance->metadata_callback(metadata); + } + + void Stream::error_callback_(const ::FLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data) + { + (void)decoder; + FLAC__ASSERT(0 != client_data); + Stream *instance = reinterpret_cast<Stream *>(client_data); + FLAC__ASSERT(0 != instance); + instance->error_callback(status); + } + + // ------------------------------------------------------------ + // + // File + // + // ------------------------------------------------------------ + + File::File(): + Stream() + { } + + File::~File() + { + } + + ::FLAC__StreamDecoderInitStatus File::init(FILE *file) + { + FLAC__ASSERT(0 != decoder_); + return ::FLAC__stream_decoder_init_FILE(decoder_, file, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this); + } + + ::FLAC__StreamDecoderInitStatus File::init(const char *filename) + { + FLAC__ASSERT(0 != decoder_); + return ::FLAC__stream_decoder_init_file(decoder_, filename, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this); + } + + ::FLAC__StreamDecoderInitStatus File::init(const std::string &filename) + { + return init(filename.c_str()); + } + + ::FLAC__StreamDecoderInitStatus File::init_ogg(FILE *file) + { + FLAC__ASSERT(0 != decoder_); + return ::FLAC__stream_decoder_init_ogg_FILE(decoder_, file, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this); + } + + ::FLAC__StreamDecoderInitStatus File::init_ogg(const char *filename) + { + FLAC__ASSERT(0 != decoder_); + return ::FLAC__stream_decoder_init_ogg_file(decoder_, filename, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this); + } + + ::FLAC__StreamDecoderInitStatus File::init_ogg(const std::string &filename) + { + return init_ogg(filename.c_str()); + } + + // This is a dummy to satisfy the pure virtual from Stream; the + // read callback will never be called since we are initializing + // with FLAC__stream_decoder_init_FILE() or + // FLAC__stream_decoder_init_file() and those supply the read + // callback internally. + ::FLAC__StreamDecoderReadStatus File::read_callback(FLAC__byte buffer[], size_t *bytes) + { + (void)buffer, (void)bytes; + FLAC__ASSERT(false); + return ::FLAC__STREAM_DECODER_READ_STATUS_ABORT; // double protection + } + + } // namespace Decoder +} // namespace FLAC diff --git a/src/libFLAC++/stream_encoder.cpp b/src/libFLAC++/stream_encoder.cpp new file mode 100644 index 0000000..8377129 --- /dev/null +++ b/src/libFLAC++/stream_encoder.cpp @@ -0,0 +1,519 @@ +/* libFLAC++ - Free Lossless Audio Codec library + * Copyright (C) 2002-2009 Josh Coalson + * Copyright (C) 2011-2023 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "FLAC++/encoder.h" +#include "FLAC++/metadata.h" +#include "FLAC/assert.h" + +#ifdef _MSC_VER +// warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning) +#pragma warning ( disable : 4800 ) +#endif + +namespace FLAC { + namespace Encoder { + + // ------------------------------------------------------------ + // + // Stream + // + // ------------------------------------------------------------ + + Stream::Stream(): + encoder_(::FLAC__stream_encoder_new()) + { } + + Stream::~Stream() + { + if(0 != encoder_) { + (void)::FLAC__stream_encoder_finish(encoder_); + ::FLAC__stream_encoder_delete(encoder_); + } + } + + bool Stream::is_valid() const + { + return 0 != encoder_; + } + + bool Stream::set_ogg_serial_number(long value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_ogg_serial_number(encoder_, value)); + } + + bool Stream::set_verify(bool value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_verify(encoder_, value)); + } + + bool Stream::set_streamable_subset(bool value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_streamable_subset(encoder_, value)); + } + + bool Stream::set_channels(uint32_t value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_channels(encoder_, value)); + } + + bool Stream::set_bits_per_sample(uint32_t value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_bits_per_sample(encoder_, value)); + } + + bool Stream::set_sample_rate(uint32_t value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_sample_rate(encoder_, value)); + } + + bool Stream::set_compression_level(uint32_t value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_compression_level(encoder_, value)); + } + + bool Stream::set_blocksize(uint32_t value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_blocksize(encoder_, value)); + } + + bool Stream::set_do_mid_side_stereo(bool value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_do_mid_side_stereo(encoder_, value)); + } + + bool Stream::set_loose_mid_side_stereo(bool value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_loose_mid_side_stereo(encoder_, value)); + } + + bool Stream::set_apodization(const char *specification) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_apodization(encoder_, specification)); + } + + bool Stream::set_max_lpc_order(uint32_t value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_max_lpc_order(encoder_, value)); + } + + bool Stream::set_qlp_coeff_precision(uint32_t value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_qlp_coeff_precision(encoder_, value)); + } + + bool Stream::set_do_qlp_coeff_prec_search(bool value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_do_qlp_coeff_prec_search(encoder_, value)); + } + + bool Stream::set_do_escape_coding(bool value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_do_escape_coding(encoder_, value)); + } + + bool Stream::set_do_exhaustive_model_search(bool value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_do_exhaustive_model_search(encoder_, value)); + } + + bool Stream::set_min_residual_partition_order(uint32_t value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_min_residual_partition_order(encoder_, value)); + } + + bool Stream::set_max_residual_partition_order(uint32_t value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_max_residual_partition_order(encoder_, value)); + } + + bool Stream::set_rice_parameter_search_dist(uint32_t value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_rice_parameter_search_dist(encoder_, value)); + } + + bool Stream::set_total_samples_estimate(FLAC__uint64 value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_total_samples_estimate(encoder_, value)); + } + + bool Stream::set_metadata(::FLAC__StreamMetadata **metadata, uint32_t num_blocks) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_metadata(encoder_, metadata, num_blocks)); + } + + bool Stream::set_metadata(FLAC::Metadata::Prototype **metadata, uint32_t num_blocks) + { + FLAC__ASSERT(is_valid()); + // because C++ doesn't have VLA's (variable length arrays) + // this ugly workaround is needed + ::FLAC__StreamMetadata **m = new ::FLAC__StreamMetadata*[num_blocks]; + for(uint32_t i = 0; i < num_blocks; i++) { + // we can get away with the const_cast since we know the encoder will only correct the is_last flags + m[i] = const_cast< ::FLAC__StreamMetadata*>(static_cast<const ::FLAC__StreamMetadata*>(*metadata[i])); + } + // complete the hack + const bool ok = static_cast<bool>(::FLAC__stream_encoder_set_metadata(encoder_, m, num_blocks)); + delete [] m; + return ok; + } + + bool Stream::set_limit_min_bitrate(bool value) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_set_limit_min_bitrate(encoder_, value)); + } + + Stream::State Stream::get_state() const + { + FLAC__ASSERT(is_valid()); + return State(::FLAC__stream_encoder_get_state(encoder_)); + } + + Decoder::Stream::State Stream::get_verify_decoder_state() const + { + FLAC__ASSERT(is_valid()); + return Decoder::Stream::State(::FLAC__stream_encoder_get_verify_decoder_state(encoder_)); + } + + void Stream::get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, uint32_t *frame_number, uint32_t *channel, uint32_t *sample, FLAC__int32 *expected, FLAC__int32 *got) + { + FLAC__ASSERT(is_valid()); + ::FLAC__stream_encoder_get_verify_decoder_error_stats(encoder_, absolute_sample, frame_number, channel, sample, expected, got); + } + + bool Stream::get_verify() const + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_get_verify(encoder_)); + } + + bool Stream::get_streamable_subset() const + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_get_streamable_subset(encoder_)); + } + + bool Stream::get_do_mid_side_stereo() const + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_get_do_mid_side_stereo(encoder_)); + } + + bool Stream::get_loose_mid_side_stereo() const + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_get_loose_mid_side_stereo(encoder_)); + } + + uint32_t Stream::get_channels() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_encoder_get_channels(encoder_); + } + + uint32_t Stream::get_bits_per_sample() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_encoder_get_bits_per_sample(encoder_); + } + + uint32_t Stream::get_sample_rate() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_encoder_get_sample_rate(encoder_); + } + + uint32_t Stream::get_blocksize() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_encoder_get_blocksize(encoder_); + } + + uint32_t Stream::get_max_lpc_order() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_encoder_get_max_lpc_order(encoder_); + } + + uint32_t Stream::get_qlp_coeff_precision() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_encoder_get_qlp_coeff_precision(encoder_); + } + + bool Stream::get_do_qlp_coeff_prec_search() const + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_get_do_qlp_coeff_prec_search(encoder_)); + } + + bool Stream::get_do_escape_coding() const + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_get_do_escape_coding(encoder_)); + } + + bool Stream::get_do_exhaustive_model_search() const + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_get_do_exhaustive_model_search(encoder_)); + } + + uint32_t Stream::get_min_residual_partition_order() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_encoder_get_min_residual_partition_order(encoder_); + } + + uint32_t Stream::get_max_residual_partition_order() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_encoder_get_max_residual_partition_order(encoder_); + } + + uint32_t Stream::get_rice_parameter_search_dist() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_encoder_get_rice_parameter_search_dist(encoder_); + } + + FLAC__uint64 Stream::get_total_samples_estimate() const + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_encoder_get_total_samples_estimate(encoder_); + } + + bool Stream::get_limit_min_bitrate() const + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_get_limit_min_bitrate(encoder_)); + } + + ::FLAC__StreamEncoderInitStatus Stream::init() + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_encoder_init_stream(encoder_, write_callback_, seek_callback_, tell_callback_, metadata_callback_, /*client_data=*/(void*)this); + } + + ::FLAC__StreamEncoderInitStatus Stream::init_ogg() + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_encoder_init_ogg_stream(encoder_, read_callback_, write_callback_, seek_callback_, tell_callback_, metadata_callback_, /*client_data=*/(void*)this); + } + + bool Stream::finish() + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_finish(encoder_)); + } + + bool Stream::process(const FLAC__int32 * const buffer[], uint32_t samples) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_process(encoder_, buffer, samples)); + } + + bool Stream::process_interleaved(const FLAC__int32 buffer[], uint32_t samples) + { + FLAC__ASSERT(is_valid()); + return static_cast<bool>(::FLAC__stream_encoder_process_interleaved(encoder_, buffer, samples)); + } + + ::FLAC__StreamEncoderReadStatus Stream::read_callback(FLAC__byte buffer[], size_t *bytes) + { + (void)buffer, (void)bytes; + return ::FLAC__STREAM_ENCODER_READ_STATUS_UNSUPPORTED; + } + + ::FLAC__StreamEncoderSeekStatus Stream::seek_callback(FLAC__uint64 absolute_byte_offset) + { + (void)absolute_byte_offset; + return ::FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED; + } + + ::FLAC__StreamEncoderTellStatus Stream::tell_callback(FLAC__uint64 *absolute_byte_offset) + { + (void)absolute_byte_offset; + return ::FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED; + } + + void Stream::metadata_callback(const ::FLAC__StreamMetadata *metadata) + { + (void)metadata; + } + + ::FLAC__StreamEncoderReadStatus Stream::read_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data) + { + (void)encoder; + FLAC__ASSERT(0 != client_data); + Stream *instance = reinterpret_cast<Stream *>(client_data); + FLAC__ASSERT(0 != instance); + return instance->read_callback(buffer, bytes); + } + + ::FLAC__StreamEncoderWriteStatus Stream::write_callback_(const ::FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data) + { + (void)encoder; + FLAC__ASSERT(0 != client_data); + Stream *instance = reinterpret_cast<Stream *>(client_data); + FLAC__ASSERT(0 != instance); + return instance->write_callback(buffer, bytes, samples, current_frame); + } + + ::FLAC__StreamEncoderSeekStatus Stream::seek_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data) + { + (void)encoder; + FLAC__ASSERT(0 != client_data); + Stream *instance = reinterpret_cast<Stream *>(client_data); + FLAC__ASSERT(0 != instance); + return instance->seek_callback(absolute_byte_offset); + } + + ::FLAC__StreamEncoderTellStatus Stream::tell_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data) + { + (void)encoder; + FLAC__ASSERT(0 != client_data); + Stream *instance = reinterpret_cast<Stream *>(client_data); + FLAC__ASSERT(0 != instance); + return instance->tell_callback(absolute_byte_offset); + } + + void Stream::metadata_callback_(const ::FLAC__StreamEncoder *encoder, const ::FLAC__StreamMetadata *metadata, void *client_data) + { + (void)encoder; + FLAC__ASSERT(0 != client_data); + Stream *instance = reinterpret_cast<Stream *>(client_data); + FLAC__ASSERT(0 != instance); + instance->metadata_callback(metadata); + } + + // ------------------------------------------------------------ + // + // File + // + // ------------------------------------------------------------ + + File::File(): + Stream() + { } + + File::~File() + { + } + + ::FLAC__StreamEncoderInitStatus File::init(FILE *file) + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_encoder_init_FILE(encoder_, file, progress_callback_, /*client_data=*/(void*)this); + } + + ::FLAC__StreamEncoderInitStatus File::init(const char *filename) + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_encoder_init_file(encoder_, filename, progress_callback_, /*client_data=*/(void*)this); + } + + ::FLAC__StreamEncoderInitStatus File::init(const std::string &filename) + { + return init(filename.c_str()); + } + + ::FLAC__StreamEncoderInitStatus File::init_ogg(FILE *file) + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_encoder_init_ogg_FILE(encoder_, file, progress_callback_, /*client_data=*/(void*)this); + } + + ::FLAC__StreamEncoderInitStatus File::init_ogg(const char *filename) + { + FLAC__ASSERT(is_valid()); + return ::FLAC__stream_encoder_init_ogg_file(encoder_, filename, progress_callback_, /*client_data=*/(void*)this); + } + + ::FLAC__StreamEncoderInitStatus File::init_ogg(const std::string &filename) + { + return init_ogg(filename.c_str()); + } + + // This is a dummy to satisfy the pure virtual from Stream; the + // read callback will never be called since we are initializing + // with FLAC__stream_decoder_init_FILE() or + // FLAC__stream_decoder_init_file() and those supply the read + // callback internally. + ::FLAC__StreamEncoderWriteStatus File::write_callback(const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame) + { + (void)buffer, (void)bytes, (void)samples, (void)current_frame; + FLAC__ASSERT(false); + return ::FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR; // double protection + } + + void File::progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate) + { + (void)bytes_written, (void)samples_written, (void)frames_written, (void)total_frames_estimate; + } + + void File::progress_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate, void *client_data) + { + (void)encoder; + FLAC__ASSERT(0 != client_data); + File *instance = reinterpret_cast<File *>(client_data); + FLAC__ASSERT(0 != instance); + instance->progress_callback(bytes_written, samples_written, frames_written, total_frames_estimate); + } + + } // namespace Encoder +} // namespace FLAC diff --git a/src/libFLAC++/version.rc b/src/libFLAC++/version.rc new file mode 100644 index 0000000..14efba0 --- /dev/null +++ b/src/libFLAC++/version.rc @@ -0,0 +1,40 @@ +#include <winver.h> +#include "config.h" +#include "FLAC++/export.h" + +#if (defined GIT_COMMIT_HASH && defined GIT_COMMIT_DATE) +# ifdef GIT_COMMIT_TAG +# define VERSIONSTRING GIT_COMMIT_TAG +# else +# define VERSIONSTRING "git-" GIT_COMMIT_HASH +# endif +#else +# define VERSIONSTRING PACKAGE_VERSION +#endif + +#define xstr(s) str(s) +#define str(s) #s + +VS_VERSION_INFO VERSIONINFO +FILEVERSION FLACPP_API_VERSION_CURRENT,FLACPP_API_VERSION_REVISION,0,0 +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS 0 +FILEOS VOS__WINDOWS32 +FILETYPE VFT_DLL +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "libFLAC++ for Windows" + VALUE "ProductName", "Free Lossless Audio Codec" + VALUE "ProductVersion", VERSIONSTRING + VALUE "CompanyName", "Xiph.Org" + VALUE "LegalCopyright", "2000-2009 Josh Coalson, 2011-2023 Xiph.Org Foundation" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END |