bs1770gain-0.9.5/0000775000175000017500000000000014710661572007063 5bs1770gain-0.9.5/aclocal.m40000664000175000017500000012642014710620511010634 # generated automatically by aclocal 1.16.5 -*- Autoconf -*- # Copyright (C) 1996-2021 Free Software Foundation, Inc. # This file 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. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.71],, [m4_warning([this file was generated for autoconf 2.71. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # Copyright (C) 2002-2021 Free Software Foundation, Inc. # # This file 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. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.16' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.16.5], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.16.5])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # Copyright (C) 2011-2021 Free Software Foundation, Inc. # # This file 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. # AM_PROG_AR([ACT-IF-FAIL]) # ------------------------- # Try to determine the archiver interface, and trigger the ar-lib wrapper # if it is needed. If the detection of archiver interface fails, run # ACT-IF-FAIL (default is to abort configure with a proper error message). AC_DEFUN([AM_PROG_AR], [AC_BEFORE([$0], [LT_INIT])dnl AC_BEFORE([$0], [AC_PROG_LIBTOOL])dnl AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([ar-lib])dnl AC_CHECK_TOOLS([AR], [ar lib "link -lib"], [false]) : ${AR=ar} AC_CACHE_CHECK([the archiver ($AR) interface], [am_cv_ar_interface], [AC_LANG_PUSH([C]) am_cv_ar_interface=ar AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int some_variable = 0;]])], [am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([am_ar_try]) if test "$ac_status" -eq 0; then am_cv_ar_interface=ar else am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([am_ar_try]) if test "$ac_status" -eq 0; then am_cv_ar_interface=lib else am_cv_ar_interface=unknown fi fi rm -f conftest.lib libconftest.a ]) AC_LANG_POP([C])]) case $am_cv_ar_interface in ar) ;; lib) # Microsoft lib, so override with the ar-lib wrapper script. # FIXME: It is wrong to rewrite AR. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__AR in this case, # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something # similar. AR="$am_aux_dir/ar-lib $AR" ;; unknown) m4_default([$1], [AC_MSG_ERROR([could not determine $AR interface])]) ;; esac AC_SUBST([AR])dnl ]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file 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. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to # '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2021 Free Software Foundation, Inc. # # This file 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. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999-2021 Free Software Foundation, Inc. # # This file 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. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], [$1], [CXX], [depcc="$CXX" am_compiler_list=], [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], [$1], [UPC], [depcc="$UPC" am_compiler_list=], [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES. AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE([dependency-tracking], [dnl AS_HELP_STRING( [--enable-dependency-tracking], [do not reject slow dependency extractors]) AS_HELP_STRING( [--disable-dependency-tracking], [speeds up one-time build])]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-2021 Free Software Foundation, Inc. # # This file 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. # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. # TODO: see whether this extra hack can be removed once we start # requiring Autoconf 2.70 or later. AS_CASE([$CONFIG_FILES], [*\'*], [eval set x "$CONFIG_FILES"], [*], [set x $CONFIG_FILES]) shift # Used to flag and report bootstrapping failures. am_rc=0 for am_mf do # Strip MF so we end up with the name of the file. am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile which includes # dependency-tracking related rules and includes. # Grep'ing the whole file directly is not great: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ || continue am_dirpart=`AS_DIRNAME(["$am_mf"])` am_filepart=`AS_BASENAME(["$am_mf"])` AM_RUN_LOG([cd "$am_dirpart" \ && sed -e '/# am--include-marker/d' "$am_filepart" \ | $MAKE -f - am--depfiles]) || am_rc=$? done if test $am_rc -ne 0; then AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments for automatic dependency tracking. If GNU make was not used, consider re-running the configure script with MAKE="gmake" (or whatever is necessary). You can also try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking).]) fi AS_UNSET([am_dirpart]) AS_UNSET([am_filepart]) AS_UNSET([am_mf]) AS_UNSET([am_rc]) rm -f conftest-deps.mk } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking is enabled. # This creates each '.Po' and '.Plo' makefile fragment that we'll need in # order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2021 Free Software Foundation, Inc. # # This file 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 macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl m4_ifdef([_$0_ALREADY_INIT], [m4_fatal([$0 expanded multiple times ]m4_defn([_$0_ALREADY_INIT]))], [m4_define([_$0_ALREADY_INIT], m4_expansion_stack)])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( m4_ifset([AC_PACKAGE_NAME], [ok]):m4_ifset([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) AM_MISSING_PROG([AUTOCONF], [autoconf]) AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) AM_MISSING_PROG([AUTOHEADER], [autoheader]) AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES([CC])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) # Variables for tags utilities; see am/tags.am if test -z "$CTAGS"; then CTAGS=ctags fi AC_SUBST([CTAGS]) if test -z "$ETAGS"; then ETAGS=etags fi AC_SUBST([ETAGS]) if test -z "$CSCOPE"; then CSCOPE=cscope fi AC_SUBST([CSCOPE]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi dnl The trailing newline in this macro's definition is deliberate, for dnl backward compatibility and to allow trailing 'dnl'-style comments dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. ]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file 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. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-2021 Free Software Foundation, Inc. # # This file 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. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file 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. # AM_MAKE_INCLUDE() # ----------------- # Check whether make has an 'include' directive that can support all # the idioms we need for our automatic dependency tracking code. AC_DEFUN([AM_MAKE_INCLUDE], [AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive]) cat > confinc.mk << 'END' am__doit: @echo this is the am__doit target >confinc.out .PHONY: am__doit END am__include="#" am__quote= # BSD make does it like this. echo '.include "confinc.mk" # ignored' > confmf.BSD # Other make implementations (GNU, Solaris 10, AIX) do it like this. echo 'include confinc.mk # ignored' > confmf.GNU _am_result=no for s in GNU BSD; do AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out]) AS_CASE([$?:`cat confinc.out 2>/dev/null`], ['0:this is the am__doit target'], [AS_CASE([$s], [BSD], [am__include='.include' am__quote='"'], [am__include='include' am__quote=''])]) if test "$am__include" != "#"; then _am_result="yes ($s style)" break fi done rm -f confinc.* confmf.* AC_MSG_RESULT([${_am_result}]) AC_SUBST([am__include])]) AC_SUBST([am__quote])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2021 Free Software Foundation, Inc. # # This file 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. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it is modern enough. # If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then MISSING="\${SHELL} '$am_aux_dir/missing'" fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file 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. # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 1999-2021 Free Software Foundation, Inc. # # This file 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. # _AM_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file 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. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2021 Free Software Foundation, Inc. # # This file 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. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT([yes]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2021 Free Software Foundation, Inc. # # This file 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. # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # ("yes" being less verbose, "no" or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) case $enable_silent_rules in @%:@ ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using '$V' instead of '$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file 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. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-2021 Free Software Foundation, Inc. # # This file 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. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-2021 Free Software Foundation, Inc. # # This file 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. # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar # AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR bs1770gain-0.9.5/README0000755000175000017500000000030514636462747007674 BS1770GAIN is a loudness scanner compliant with ITU-R BS.1770 and its flavors EBU R128, ATSC A/85, and ReplayGain 2.0. It helps normalizing the loudness of audio and video files to the same level. bs1770gain-0.9.5/ar-lib0000755000175000017500000001336314710620512010070 #! /bin/sh # Wrapper for Microsoft lib.exe me=ar-lib scriptversion=2019-07-04.01; # UTC # Copyright (C) 2010-2021 Free Software Foundation, Inc. # Written by Peter Rosin . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . # func_error message func_error () { echo "$me: $1" 1>&2 exit 1 } file_conv= # func_file_conv build_file # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN* | MSYS*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv in mingw) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin | msys) file=`cygpath -m "$file" || echo "$file"` ;; wine) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_at_file at_file operation archive # Iterate over all members in AT_FILE performing OPERATION on ARCHIVE # for each of them. # When interpreting the content of the @FILE, do NOT use func_file_conv, # since the user would need to supply preconverted file names to # binutils ar, at least for MinGW. func_at_file () { operation=$2 archive=$3 at_file_contents=`cat "$1"` eval set x "$at_file_contents" shift for member do $AR -NOLOGO $operation:"$member" "$archive" || exit $? done } case $1 in '') func_error "no command. Try '$0 --help' for more information." ;; -h | --h*) cat <. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN* | MSYS*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/* | msys/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_dashL linkdir # Make cl look for libraries in LINKDIR func_cl_dashL () { func_file_conv "$1" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" } # func_cl_dashl library # Do a library search-path lookup for cl func_cl_dashl () { lib=$1 found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes lib=$dir/$lib.dll.lib break fi if test -f "$dir/$lib.lib"; then found=yes lib=$dir/$lib.lib break fi if test -f "$dir/lib$lib.a"; then found=yes lib=$dir/lib$lib.a break fi done IFS=$save_IFS if test "$found" != yes; then lib=$lib.lib fi } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I) eat=1 func_file_conv "$2" mingw set x "$@" -I"$file" shift ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l) eat=1 func_cl_dashl "$2" set x "$@" "$lib" shift ;; -l*) func_cl_dashl "${1#-l}" set x "$@" "$lib" shift ;; -L) eat=1 func_cl_dashL "$2" ;; -L*) func_cl_dashL "${1#-L}" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: bs1770gain-0.9.5/config.h0000664000175000017500000000502014710661553010415 /* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* Define to libavcodec major version. */ #define FF_AVCODEC_V "61" /* Define to libavfilter major version. */ #define FF_AVFILTER_V "10" /* Define to libavformat major version. */ #define FF_AVFORMAT_V "61" /* Define to libavutil major version. */ #define FF_AVUTIL_V "59" /* Define to libswscale major version. */ #define FF_POSTPROC_V "58" /* Define to libswresample major version. */ #define FF_SWRESAMPLE_V "5" /* Define to libswscale major version. */ #define FF_SWSCALE_V "8" /* Define to 1 when xml output should be possible. */ #define HAVE_BG_XML 1 /* Define to 1 if FFmpeg should be loaded dynamically. */ #define HAVE_FF_DYNLOAD 1 /* Define to 1 if you have the header file. */ #define HAVE_INTTYPES_H 1 /* Define to 1 if you have libproc. */ /* #undef HAVE_LIBPROC */ /* Define to 1 if you have pthreads. */ #define HAVE_PTHREAD 1 /* Define to 1 if you have the header file. */ #define HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDIO_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDLIB_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STRINGS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STRING_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ #define HAVE_UNISTD_H 1 /* Name of package */ #define PACKAGE "bs1770gain" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "info@pbelkner.de" /* Define to the full name of this package. */ #define PACKAGE_NAME "bs1770gain" /* Define to the full name and version of this package. */ #define PACKAGE_STRING "bs1770gain 0.9.5" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "bs1770gain" /* Define to the home page for this package. */ #define PACKAGE_URL "http://pbelkner.de/" /* Define to the version of this package. */ #define PACKAGE_VERSION "0.9.5" /* Define to 1 if all of the C90 standard headers exist (not just the ones required in a freestanding environment). This macro is provided for backward compatibility; new code need not use it. */ #define STDC_HEADERS 1 /* Version number of package */ #define VERSION "0.9.5" bs1770gain-0.9.5/libbg/0000775000175000017500000000000014710661572010142 5bs1770gain-0.9.5/libbg/bg_print_csv.c0000755000175000017500000002047413747505704012720 /* * bg_print_csv.c * * Copyright (C) 2014 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include #define BG_PRINT_ARGV_HEADER static int _bg_print_csv_tail(bg_tree_t *tree, int depth FFUNUSED, FILE *f, int header); static void bg_print_conf_tail(bg_print_conf_t *c, bg_tree_t *tree FFUNUSED, FILE *f FFUNUSED, int header FFUNUSED) { bg_param_t *param=tree->param; switch (c->argc) { case 1: if (c->argv[0].fn) { if (header) { #if defined (_WIN32) // [ if (stdout!=f&&stderr!=f) { fwprintf(f,L"%c",param->csv.separator); fputws(c->w.label.csv,f); fputws(L" (",f); bg_print_conf_unitw(f,1,c,tree->param,0); fputwc(L')',f); } else { #endif // ] fprintf(f,"%c",param->csv.separator); fputs(c->n.label.csv,f); fputs(" (",f); bg_print_conf_unit(f,1,c,tree->param,0); fputc(')',f); #if defined (_WIN32) // [ } #endif // ] } else { #if defined (_WIN32) // [ if (stdout!=f&&stderr!=f) { fwprintf(f,L"%c",param->csv.separator); fwprintf(f,c->argv[0].w.format,c->argv[0].fn(tree)); } else { #endif // ] fprintf(f,"%c",param->csv.separator); fprintf(f,c->argv[0].n.format,c->argv[0].fn(tree)); #if defined (_WIN32) // [ } #endif // ] } } else _DWARNING("argv[0]"); break; case 2: if (c->argv[0].fn&&c->argv[1].fn) { if (header) { #if defined (_WIN32) // [ if (stdout!=f&&stderr!=f) { fwprintf(f,L"%c",param->csv.separator); fputws(c->w.label.csv,f); fputws(L" (",f); bg_print_conf_unitw(f,1,c,tree->param,0); fputwc(L')',f); fwprintf(f,L"%c",param->csv.separator); fputws(c->w.label.csv,f); fputws(L" (",f); bg_print_conf_unitw(f,1,c,tree->param,1); fputwc(L')',f); } else { #endif // ] fprintf(f,"%c",param->csv.separator); fputs(c->n.label.csv,f); fputs(" (",f); bg_print_conf_unit(f,1,c,tree->param,0); fputc(')',f); fprintf(f,"%c",param->csv.separator); fputs(c->n.label.csv,f); fputs(" (",f); bg_print_conf_unit(f,1,c,tree->param,1); fputc(')',f); #if defined (_WIN32) // [ } #endif // ] } else { #if defined (_WIN32) // [ if (stdout!=f&&stderr!=f) { fwprintf(f,L"%c",param->csv.separator); fwprintf(f,c->argv[0].w.format,c->argv[0].fn(tree)); fwprintf(f,L"%c",param->csv.separator); fwprintf(f,c->argv[1].w.format,c->argv[1].fn(tree)); } else { #endif // ] fprintf(f,"%c",param->csv.separator); fprintf(f,c->argv[0].n.format,c->argv[0].fn(tree)); fprintf(f,"%c",param->csv.separator); fprintf(f,c->argv[1].n.format,c->argv[1].fn(tree)); #if defined (_WIN32) // [ } #endif // ] } } else _DWARNING("argv[0]/argv[1]"); break; default: _DWARNING("argc"); break; } } /////////////////////////////////////////////////////////////////////////////// static void bg_print_csv_encoding(bg_param_t *param, int bits) { param->result.bits=bits; } static int _bg_print_csv_head(bg_tree_t *tree, int depth FFUNUSED, FILE *f) { bg_param_t *param=tree->param; bg_track_t *track; #if defined (BG_PARAM_QUIET) // [ if (param->quiet) goto success; #endif // ] switch (tree->vmt->type) { case BG_TREE_TYPE_FILE: // nothing to do. break; case BG_TREE_TYPE_TRACK: track=&tree->track; #if defined (_WIN32) // [ if (stdout!=f&&stderr!=f) { fwprintf(f,L"%.02f%c%lu%c%lu%c%S",param->norm,param->csv.separator, param->count.max,param->csv.separator,track->root.id, param->csv.separator,tree->source.basename); } else { #endif // ] fprintf(f,"%.02f%c%lu%c%lu%c%s",param->norm,param->csv.separator, param->count.max,param->csv.separator,track->root.id, param->csv.separator,bg_tree_in_basename(tree)); #if defined (_WIN32) // [ } #endif // ] break; case BG_TREE_TYPE_ALBUM: if (!param->suppress.hierarchy) { #if defined (_WIN32) // [ if (stdout!=f&&stderr!=f) { fwprintf(f,L"%.02f%c%c%cALBUM %S",param->norm,param->csv.separator, param->csv.separator,param->csv.separator,tree->source.basename); } else { #endif // ] fprintf(f,"%.02f%c%c%cALBUM %s",param->norm,param->csv.separator, param->csv.separator,param->csv.separator, bg_tree_in_basename(tree)); #if defined (_WIN32) // [ } #endif // ] } break; case BG_TREE_TYPE_ROOT: if (!param->suppress.hierarchy) { #if defined (_WIN32) // [ if (stdout!=f&&stderr!=f) { fwprintf(f,L"%.02f%c%c%cCOLLECTION",param->norm,param->csv.separator, param->csv.separator,param->csv.separator); } else { #endif // ] fprintf(f,"%.02f%c%c%cCOLLECTION",param->norm,param->csv.separator, param->csv.separator,param->csv.separator); #if defined (_WIN32) // [ } #endif // } } break; default: _DMESSAGEV("tree type %d unexpected",tree->vmt->type); goto e_type; } ///////////////////////////////////////////////////////////////////////////// fflush(f); #if defined (BG_PARAM_QUIET) // [ success: #endif // ] return 0; e_type: return -1; } static int bg_print_csv_head(bg_tree_t *tree, int depth, FILE *f) { bg_param_t *param=tree->param; if (stdout!=f&&stderr!=f) { if (param->csv.header.file) goto e_header; param->csv.header.file=1; } else { if (param->csv.header.console) goto e_header; param->csv.header.console=1; } #if defined (_WIN32) // [ if (stdout!=f&&stderr!=f) { fwprintf(f,L"norm%ctotal%cnumber%cfile",param->csv.separator, param->csv.separator,param->csv.separator); _bg_print_csv_tail(tree,0,f,1); fflush(f); } else { #endif // ] fprintf(f,"norm%ctotal%cnumber%cfile",param->csv.separator, param->csv.separator,param->csv.separator); _bg_print_csv_tail(tree,0,f,1); fflush(f); #if defined (_WIN32) // [ } #endif // ] e_header: return _bg_print_csv_head(tree,depth,f); } static int _bg_print_csv_tail(bg_tree_t *tree, int depth FFUNUSED, FILE *f, int header) { int suppress_hierarchy=tree->param->suppress.hierarchy; // path 2: print out the results aligned according to the maximum length // of the involved labels. bg_flags_agg_t agg; bg_print_conf_t *c; #if defined (BG_PARAM_QUIET) // [ if (tree->param->quiet) goto success; #endif // ] if (!suppress_hierarchy||BG_TREE_TYPE_TRACK==tree->vmt->type) { for (agg=1,c=bg_print_conf;aggparam->flags.aggregate)) { // the aggregation isn't involved. continue; } else if (agg!=c->agg) { // wrong order. _DWARNING("aggregate mismatch"); continue; } else bg_print_conf_tail(c,tree,f,header); } } ///////////////////////////////////////////////////////////////////////////// #if defined (_WIN32) // [ if (stdout!=f&&stderr!=f) fputwc(L'\n',f); else #endif // ] fputc('\n',f); fflush(f); #if defined (BG_PARAM_QUIET) // [ success: #endif // ] return 0; } static int bg_print_csv_tail(bg_tree_t *tree, int depth FFUNUSED, FILE *f) { return _bg_print_csv_tail(tree,depth,f,0); } bg_print_vmt_t bg_print_csv_vmt={ .id="classic", .infix=0, .encoding=bg_print_csv_encoding, .head=bg_print_csv_head, .tail=bg_print_csv_tail, }; bs1770gain-0.9.5/libbg/bg_track_target.c0000755000175000017500000000155413671703332013352 /* * bg_track_target.c * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include bs1770gain-0.9.5/libbg/bg_print_conf.c0000755000175000017500000003040114701150772013031 /* * bg_print_conf.c * * Copyright (C) 2014 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include #if ! defined (_WIN32) // [ #include #endif // ] /////////////////////////////////////////////////////////////////////////////// double bg_print_conf_norm(bg_tree_t *tree) { return tree->param->preamp+tree->param->norm; } //////// double bg_print_conf_momentary_mean(bg_tree_t *tree) { #if 1 // [ return lib1770_stats_get_mean(tree->stats.momentary, tree->param->momentary.mean.gate); #else // ] [ double mean; _WRITELNV("%p",tree); mean=lib1770_stats_get_mean(tree->stats.momentary, tree->param->momentary.mean.gate); _WRITELNV("%p: %.02lf",tree,mean); return mean; #endif // ] } double bg_print_conf_momentary_mean_relative(bg_tree_t *tree) { double norm=bg_print_conf_norm(tree); double mean=bg_print_conf_momentary_mean(tree); #if defined (BG_TRADITIONAL) // [ return tree->param->traditional?norm-mean:mean-norm; #elif defined (BG_OPPOSITE) // ] [ return tree->param->opposite?mean-norm:norm-mean; #else // ] [ return norm-mean; #endif // ] } //////// double bg_print_conf_momentary_maximum(bg_tree_t *tree) { return lib1770_stats_get_max(tree->stats.momentary); } double bg_print_conf_momentary_maximum_relative(bg_tree_t *tree) { double norm=bg_print_conf_norm(tree); double mean=bg_print_conf_momentary_maximum(tree); #if defined (BG_TRADITIONAL) // [ return tree->param->traditional?norm-mean:mean-norm; #elif defined (BG_OPPOSITE) // ] [ return tree->param->opposite?mean-norm:norm-mean; #else // ] [ return norm-mean; #endif // ] } //////// double bg_print_conf_momentary_range(bg_tree_t *tree) { return lib1770_stats_get_range(tree->stats.momentary, tree->param->momentary.range.gate, tree->param->momentary.range.lower_bound, tree->param->momentary.range.upper_bound); } //////// double bg_print_conf_shortterm_mean(bg_tree_t *tree) { return lib1770_stats_get_mean(tree->stats.shortterm, tree->param->shortterm.mean.gate); } double bg_print_conf_shortterm_mean_relative(bg_tree_t *tree) { double norm=bg_print_conf_norm(tree); double mean=bg_print_conf_shortterm_mean(tree); #if defined (BG_TRADITIONAL) // [ return tree->param->traditional?norm-mean:mean-norm; #elif defined (BG_OPPOSITE) // ] [ return tree->param->opposite?mean-norm:norm-mean; #else // ] [ return norm-mean; #endif // ] } //////// double bg_print_conf_shortterm_maximum(bg_tree_t *tree) { return lib1770_stats_get_max(tree->stats.shortterm); } double bg_print_conf_shortterm_maximum_relative(bg_tree_t *tree) { double norm=bg_print_conf_norm(tree); double mean=bg_print_conf_shortterm_maximum(tree); #if defined (BG_TRADITIONAL) // [ return tree->param->traditional?norm-mean:mean-norm; #elif defined (BG_OPPOSITE) // ] [ return tree->param->opposite?mean-norm:norm-mean; #else // ] [ return norm-mean; #endif // ] } //////// double bg_print_conf_shortterm_range(bg_tree_t *tree) { #if 1 // [ return lib1770_stats_get_range(tree->stats.shortterm, tree->param->shortterm.range.gate, tree->param->shortterm.range.lower_bound, tree->param->shortterm.range.upper_bound); #else // ] [ double range; DWRITELN("==="); range=lib1770_stats_get_range(tree->stats.shortterm, tree->param->shortterm.range.gate, tree->param->shortterm.range.lower_bound, tree->param->shortterm.range.upper_bound); DVWRITELN("=== range:%.02f",range); return range; #endif // ] } //////// double bg_print_conf_samplepeak_absolute(bg_tree_t *tree) { return tree->stats.samplepeak; } double bg_print_conf_samplepeak_relative(bg_tree_t *tree) { return LIB1770_Q2DB(tree->stats.samplepeak); } //////// double bg_print_conf_truepeak_absolute(bg_tree_t *tree) { return tree->stats.truepeak; } double bg_print_conf_truepeak_relative(bg_tree_t *tree) { return LIB1770_Q2DB(tree->stats.truepeak); } /////////////////////////////////////////////////////////////////////////////// const char *bg_print_conf_unit_lum(bg_tree_t *tree) { return tree->param->unit->n.lu; } #if defined (_WIN32) // [ const wchar_t *bg_print_conf_unit_luw(bg_tree_t *tree) { return tree->param->unit->w.lu; } #endif // ] //////// const char *bg_print_conf_unit_lram(bg_tree_t *tree) { return tree->param->unit->n.lra; } #if defined (_WIN32) // [ const wchar_t *bg_print_conf_unit_lraw(bg_tree_t *tree) { return tree->param->unit->w.lra; } #endif // ] //////// const char *bg_print_conf_unit_spm(bg_tree_t *tree) { return tree->param->unit->n.sp; } #if defined (_WIN32) // [ const wchar_t *bg_print_conf_unit_spw(bg_tree_t *tree) { return tree->param->unit->w.sp; } #endif // ] //////// const char *bg_print_conf_unit_tpm(bg_tree_t *tree) { return tree->param->unit->n.tp; } #if defined (_WIN32) // [ const wchar_t *bg_print_conf_unit_tpw(bg_tree_t *tree) { return tree->param->unit->w.tp; } #endif // ] //////// #if defined (_WIN32) // [ #define BG_CONF(AGG,LABEL1,LABEL2,LABEL3,ARGC,FN1,FORMAT1,FN2,FORMAT2) { \ .agg=AGG, \ .w.label={ .classic=L##LABEL1, .xml=L##LABEL2, .csv=L##LABEL3 }, \ .n.label={ .classic=LABEL1, .xml=LABEL2, .csv=LABEL3 }, \ .argc=ARGC, \ \ .argv={ \ { .fn=FN1, .w={ .format=L##FORMAT1 }, .n={ .format=FORMAT1 } }, \ { .fn=FN2, .w={ .format=L##FORMAT2 }, .n={ .format=FORMAT2 } }, \ } \ } #else // ] [ #define BG_CONF(AGG,LABEL1,LABEL2,LABEL3,ARGC,FN1,FORMAT1,FN2,FORMAT2) { \ .agg=AGG, \ .n.label={ .classic=LABEL1, .xml=LABEL2, .csv=LABEL3 }, \ .argc=ARGC, \ \ .argv={ \ { .fn=FN1, .n={ .format=FORMAT1 } }, \ { .fn=FN2, .n={ .format=FORMAT2 } }, \ } \ } #endif // ] #define BG_CONF1(AGG,LABEL1,LABEL2,LABEL3,FN1,FORMAT1) \ BG_CONF(AGG,LABEL1,LABEL2,LABEL3,1,FN1,FORMAT1,NULL,"") #define BG_CONF2(AGG,LABEL1,LABEL2,LABEL3,FN1,FORMAT1,FN2,FORMAT2) \ BG_CONF(AGG,LABEL1,LABEL2,LABEL3,2,FN1,FORMAT1,FN2,FORMAT2) bg_print_conf_t bg_print_conf[BG_FLAGS_AGG_MAX_OFFSET]={ BG_CONF2(BG_FLAGS_AGG_MOMENTARY_MEAN, "integrated (momentary mean)", "integrated", "integrated", bg_print_conf_momentary_mean, "%.2f", bg_print_conf_momentary_mean_relative, "%.2f"), BG_CONF2(BG_FLAGS_AGG_MOMENTARY_MAXIMUM, "momentary maximum", "momentary-maximum", "momentary maximum", bg_print_conf_momentary_maximum, "%.2f", bg_print_conf_momentary_maximum_relative, "%.2f"), BG_CONF1(BG_FLAGS_AGG_MOMENTARY_RANGE, #if defined (BG_UNIT_LRA) // [ "momentary loudness range", "momentary-range", "momentary range", #else // ] [ "momentary lra", "momentary-lra", "momentary lra", #endif // ] bg_print_conf_momentary_range, "%.2f"), BG_CONF2(BG_FLAGS_AGG_SHORTTERM_MEAN, "shortterm mean", "shortterm-mean", "shortterm mean", bg_print_conf_shortterm_mean, "%.2f", bg_print_conf_shortterm_mean_relative, "%.2f"), BG_CONF2(BG_FLAGS_AGG_SHORTTERM_MAXIMUM, "shortterm maximum", "shortterm-maximum", "shortterm maximum", bg_print_conf_shortterm_maximum, "%.2f", bg_print_conf_shortterm_maximum_relative, "%.2f"), BG_CONF1(BG_FLAGS_AGG_SHORTTERM_RANGE, #if defined (BG_UNIT_LRA) // [ "shortterm loudness range", "shortterm-range", "shortterm range", #else // ] [ "shortterm lra", "shortterm-lra", "shortterm lra", #endif // ] bg_print_conf_shortterm_range, #if 1 // [ "%.2f" #else "%f" #endif // ] ), BG_CONF2(BG_FLAGS_AGG_SAMPLEPEAK, "sample peak", "sample-peak", "sample peak", bg_print_conf_samplepeak_relative, "%.2f", bg_print_conf_samplepeak_absolute, "%f"), BG_CONF2(BG_FLAGS_AGG_TRUEPEAK, "true peak", "true-peak", "true peak", bg_print_conf_truepeak_relative, "%.2f", bg_print_conf_truepeak_absolute, "%f"), }; #if defined (_WIN32) // [ void bg_print_conf_unitw(FILE *f, int lc FFUNUSED, bg_print_conf_t *c, bg_param_t *param, int argv) { const wchar_t *unit; if (stdout==f||stderr==f) { DMESSAGE("writing to consule"); return; } switch (c-bg_print_conf) { case BG_FLAGS_AGG_MOMENTARY_MEAN_OFFSET: unit=param->unit->w.lu; break; case BG_FLAGS_AGG_MOMENTARY_MAXIMUM_OFFSET: unit=param->unit->w.lu; break; case BG_FLAGS_AGG_MOMENTARY_RANGE_OFFSET: unit=param->unit->w.lra; break; case BG_FLAGS_AGG_SHORTTERM_MEAN_OFFSET: unit=param->unit->w.lu; break; case BG_FLAGS_AGG_SHORTTERM_MAXIMUM_OFFSET: unit=param->unit->w.lu; break; case BG_FLAGS_AGG_SHORTTERM_RANGE_OFFSET: unit=param->unit->w.lra; break; case BG_FLAGS_AGG_SAMPLEPEAK_OFFSET: unit=param->unit->w.sp; break; case BG_FLAGS_AGG_TRUEPEAK_OFFSET: unit=param->unit->w.tp; break; default: DMESSAGE("out of range"); return; } switch (c-bg_print_conf) { case BG_FLAGS_AGG_MOMENTARY_MEAN_OFFSET: case BG_FLAGS_AGG_MOMENTARY_MAXIMUM_OFFSET: case BG_FLAGS_AGG_SHORTTERM_MEAN_OFFSET: case BG_FLAGS_AGG_SHORTTERM_MAXIMUM_OFFSET: if (lc) { while (*unit) fputwc(towlower(*unit++),f); if (!argv) fputws(L"fs",f); } else { fputws(unit,f); if (!argv) fputws(L"FS",f); } break; case BG_FLAGS_AGG_MOMENTARY_RANGE_OFFSET: case BG_FLAGS_AGG_SHORTTERM_RANGE_OFFSET: if (lc) { while (*unit) fputwc(towlower(*unit++),f); } else fputws(unit,f); break; case BG_FLAGS_AGG_SAMPLEPEAK_OFFSET: case BG_FLAGS_AGG_TRUEPEAK_OFFSET: if (0unit->n.lu; break; case BG_FLAGS_AGG_MOMENTARY_MAXIMUM_OFFSET: unit=param->unit->n.lu; break; case BG_FLAGS_AGG_MOMENTARY_RANGE_OFFSET: unit=param->unit->n.lra; break; case BG_FLAGS_AGG_SHORTTERM_MEAN_OFFSET: unit=param->unit->n.lu; break; case BG_FLAGS_AGG_SHORTTERM_MAXIMUM_OFFSET: unit=param->unit->n.lu; break; case BG_FLAGS_AGG_SHORTTERM_RANGE_OFFSET: unit=param->unit->n.lra; break; case BG_FLAGS_AGG_SAMPLEPEAK_OFFSET: unit=param->unit->n.sp; break; case BG_FLAGS_AGG_TRUEPEAK_OFFSET: unit=param->unit->n.tp; break; default: DMESSAGE("out of range"); return; } switch (c-bg_print_conf) { case BG_FLAGS_AGG_MOMENTARY_MEAN_OFFSET: case BG_FLAGS_AGG_MOMENTARY_MAXIMUM_OFFSET: case BG_FLAGS_AGG_SHORTTERM_MEAN_OFFSET: case BG_FLAGS_AGG_SHORTTERM_MAXIMUM_OFFSET: if (lc) { while (*unit) fputc(tolower(*unit++),f); if (!argv) fputs("fs",f); } else { fputs(unit,f); if (!argv) fputs("FS",f); } break; case BG_FLAGS_AGG_MOMENTARY_RANGE_OFFSET: case BG_FLAGS_AGG_SHORTTERM_RANGE_OFFSET: if (lc) { while (*unit) fputc(tolower(*unit++),f); } else fputs(unit,f); break; case BG_FLAGS_AGG_SAMPLEPEAK_OFFSET: case BG_FLAGS_AGG_TRUEPEAK_OFFSET: if (0 * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include #if defined (BG_PARAM_THREADS) // [ /////////////////////////////////////////////////////////////////////////////// #if defined (_WIN32) // [ static DWORD WINAPI ThreadProc(LPVOID lpParameter); #else // ] [ static void *start_routine(void *p); #endif // ] #if defined (BG_PARAM_NODE_VMT) // [ static bg_param_node_vmt_t vmt; #endif // ] /////////////////////////////////////////////////////////////////////////////// void bg_param_request_clear(bg_param_request_t *request) { request->tag=bg_param_request_tag_null; #if defined (BG_PARAM_SCRIPT) // [ request->script=NULL; #endif // ] request->tree=NULL; request->visitor=NULL; request->dispatch=NULL; } /////////////////////////////////////////////////////////////////////////////// int bg_param_node_create(bg_param_node_t *node, bg_param_threads_t *threads) { ///////////////////////////////////////////////////////////////////////////// #if defined (BG_PARAM_NODE_VMT) // [ node->vmt=&vmt; #endif // ] node->prev=NULL; node->next=NULL; node->threads=threads; bg_param_request_clear(&node->request); if (bg_sync_create(&node->sync)<0) { _DMESSAGE("creating syncition"); goto e_sync; } #if defined (_WIN32) // [ ///////////////////////////////////////////////////////////////////////////// node->hThread=CreateThread( NULL, // LPSECURITY_ATTRIBUTES lpThreadAttributes, 0, // SIZE_T dwStackSize, ThreadProc, // LPTHREAD_START_ROUTINE lpStartAddress, node, // __drv_aliasesMem LPVOID lpParameter, 0, // DWORD dwCreationFlags, NULL // LPDWORD lpThreadId ); if (!node->hThread) { _DMESSAGEV("creating thread (%lu)",GetLastError()); goto e_thread; } #else // ] [ int err; ///////////////////////////////////////////////////////////////////////////// err=pthread_create( &node->thread, // pthread_t *thread, NULL, // const pthread_attr_t *attr, start_routine, // void *(*start_routine) (void *), node // void *arg ); if (err) { _DMESSAGEV("creating thread (%d)",err); goto e_thread; } #endif // ] return 0; //cleanup: #if ! defined (_WIN32) // [ pthread_join(node->thread,NULL); #else // ] [ WaitForSingleObject(node->hThread,INFINITE); CloseHandle(node->hThread); #endif // ] e_thread: bg_sync_destroy(&node->sync); e_sync: return -1; } #if 0 // [ void bg_param_node_destroy(bg_param_node_t *node, int destroy) #else // ] [ void bg_param_node_destroy(bg_param_node_t *node) #endif // ] { #if defined (BG_PARAM_SCRIPT) // [ bg_param_node_request(node,bg_param_request_tag_kill,NULL,NULL,NULL,NULL); #else // ] [ bg_param_node_request(node,bg_param_request_tag_kill,NULL,NULL,NULL); #endif // ] #if ! defined (_WIN32) // [ pthread_join(node->thread,NULL); #else // ] [ WaitForSingleObject(node->hThread,INFINITE); CloseHandle(node->hThread); #endif // ] #if 0 // [ if (destroy) #endif // ] bg_sync_destroy(&node->sync); } #if defined (BG_PARAM_SCRIPT) // [ void bg_param_node_request(bg_param_node_t *node, bg_param_request_tag_t tag, ffchar_t *script, bg_tree_t *tree, bg_visitor_t *visitor, bg_dispatch_t *dispatch) #else // ] [ void bg_param_node_request(bg_param_node_t *node, bg_param_request_tag_t tag, bg_tree_t *tree, bg_visitor_t *visitor, bg_dispatch_t *dispatch) #endif // ] { bg_sync_lock(&node->sync); // { node->request.tag=tag; #if defined (BG_PARAM_SCRIPT) // [ node->request.script=script; #endif // ] node->request.tree=tree; node->request.visitor=visitor; node->request.dispatch=dispatch; bg_sync_signal(&node->sync); bg_sync_unlock(&node->sync); // } } /////////////////////////////////////////////////////////////////////////////// int bg_param_list_create(bg_param_list_t *list, int n, bg_param_node_t *nodes, bg_param_threads_t *threads) { list->count=0; list->head=NULL; list->tail=NULL; while (n) { --n; if (bg_param_node_create(nodes+n,threads)<0) { _DMESSAGE("creating node"); goto e_node; } bg_param_list_push(list,nodes+n); } return 0; //clean: #if 0 // [ bg_param_list_destroy(list,1); #else // ] [ bg_param_list_destroy(list); #endif // ] e_node: return -1; } #if 0 // [ void bg_param_list_destroy(bg_param_list_t *list, int destroy) #else // ] [ void bg_param_list_destroy(bg_param_list_t *list) #endif // ] { bg_param_node_t *cur,*prev; cur=list->tail; while (cur) { prev=cur->prev; #if 0 // [ if (destroy) #endif // ] bg_param_list_unlink(list,cur); #if 0 // [ bg_param_node_destroy(cur,destroy); #else // ] [ bg_param_node_destroy(cur); #endif // ] cur=prev; } } bg_param_node_t *bg_param_list_unlink(bg_param_list_t *list, bg_param_node_t *node) { bg_param_node_t *prev=node->prev; bg_param_node_t *next=node->next; if (prev) prev->next=node->next; else list->head=node->next; node->next=NULL; if (next) next->prev=node->prev; else list->tail=node->prev; node->prev=NULL; --list->count; return prev; } bg_param_node_t *bg_param_list_pop(bg_param_list_t *list) { bg_param_node_t *node=list->tail; bg_param_list_unlink(list,node); return node; } bg_param_node_t *bg_param_list_push(bg_param_list_t *list, bg_param_node_t *node) { node->prev=list->tail; node->next=NULL; if (list->tail) list->tail->next=node; else list->head=node; ++list->count; return list->tail=node; } /////////////////////////////////////////////////////////////////////////////// int bg_param_threads_create(bg_param_threads_t *threads, int n) { ///////////////////////////////////////////////////////////////////////////// if (bg_sync_create(&threads->sync)<0) { _DMESSAGE("creating syncition"); goto e_sync; } ///////////////////////////////////////////////////////////////////////////// threads->nodes=calloc(n,sizeof *threads->nodes); if (!threads->nodes) { _DMESSAGE("allocating nodes"); goto e_nodes; } ///////////////////////////////////////////////////////////////////////////// if (bg_param_list_create(&threads->list.free,n,threads->nodes,threads)<0) { _DMESSAGE("creating free list"); goto e_free; } ///////////////////////////////////////////////////////////////////////////// if (bg_param_list_create(&threads->list.active,0,NULL,threads)<0) { _DMESSAGE("creating active list"); goto e_active; } ///////////////////////////////////////////////////////////////////////////// return 0; //cleanup: #if 0 // [ bg_param_list_destroy(&threads->list.active,1); #else // ] [ bg_param_list_destroy(&threads->list.active); #endif // ] e_active: #if 0 // [ bg_param_list_destroy(&threads->list.free,1); #else // ] [ bg_param_list_destroy(&threads->list.free); #endif // ] e_free: free(threads->nodes); e_nodes: bg_sync_destroy(&threads->sync); e_sync: return -1; } void bg_param_threads_destroy(bg_param_threads_t *threads FFUNUSED) { #if 0 // [ bg_param_list_destroy(&threads->list.active,0); bg_param_list_destroy(&threads->list.free,1); #else // ] [ bg_param_list_destroy(&threads->list.active); bg_param_list_destroy(&threads->list.free); #endif // ] free(threads->nodes); bg_sync_destroy(&threads->sync); } #if defined (BG_PARAM_SCRIPT) // [ void bg_param_threads_visitor_run(bg_param_threads_t *threads, ffchar_t *script, bg_visitor_t *visitor, bg_tree_t *tree, bg_dispatch_t *dispatch) #else // ] [ void bg_param_threads_visitor_run(bg_param_threads_t *threads, bg_visitor_t *visitor, bg_tree_t *tree, bg_dispatch_t *dispatch) #endif // ] { bg_param_node_t *node; bg_sync_lock(&threads->sync); // { #if 0 // [ while (!threads->list.free.count) { #else // ] [ while (!threads->list.free.tail) { #endif // ] if (!threads->list.active.count) { _DMESSAGE("something went wrong"); exit(1); } bg_sync_wait(&threads->sync); #if 1 // [ } if (!threads->list.free.count) { _DMESSAGEV("empty free list: %d %p",threads->list.free.count, threads->list.free.tail); exit(1); } #else // ] [ } if (!threads->list.free.tail) { _DMESSAGEV("empty free list: %d %p",threads->list.free.count, threads->list.free.tail); exit(1); } #endif // ] node=bg_param_list_pop(&threads->list.free); bg_param_list_push(&threads->list.active,node); bg_sync_unlock(&threads->sync); // } #if defined (BG_PARAM_SCRIPT) // [ bg_param_node_request(node,bg_param_request_tag_visitor_run,script, tree,visitor,dispatch); #else // ] [ bg_param_node_request(node,bg_param_request_tag_visitor_run,tree,visitor, dispatch); #endif // ] } void bg_param_threads_drain(bg_param_threads_t *threads) { bg_sync_lock(&threads->sync); // { while (threads->list.active.count) bg_sync_wait(&threads->sync); bg_sync_unlock(&threads->sync); // } } /////////////////////////////////////////////////////////////////////////////// void bg_param_threads_release(bg_param_threads_t *threads, bg_param_node_t *node) { #if 0 && defined (_WIN32) // [ bg_sync_lock(&threads->sync); #endif // ] bg_param_list_unlink(&threads->list.active,node); bg_param_list_push(&threads->list.free,node); bg_sync_signal(&threads->sync); #if 0 && defined (_WIN32) // [ bg_sync_unlock(&threads->sync); #endif // ] } #if defined (BG_PARAM_NODE_VMT) // [ #define BG_PARAM_NODE_VMT_PROC 1 #else // ] [ #define BG_PARAM_NODE_VMT_PROC 0 #endif // ] #if defined (_WIN32) // [ static DWORD WINAPI ThreadProc(LPVOID lpParameter) { bg_param_node_t *node=lpParameter; #else // ] [ static void *start_routine(void *p) { bg_param_node_t *node=p; #endif // ] bg_sync_lock(&node->sync); #if ! (BG_PARAM_NODE_VMT_PROC) // [ bg_param_threads_t *threads=node->threads; #endif // ] bg_param_request_t request; for (;;) { bg_sync_wait(&node->sync); request=node->request; bg_param_request_clear(&node->request); switch (request.tag) { case bg_param_request_tag_null: continue; case bg_param_request_tag_kill: goto e_kill; case bg_param_request_tag_visitor_run: #if (BG_PARAM_NODE_VMT_PROC) // [ bg_node_run(node,&request); #else // ] [ ///////////////////////////////////////////////////////////////////////// request.dispatch(request.tree,request.visitor); ///////////////////////////////////////////////////////////////////////// if (request.tree->parent) { bg_sync_lock(&request.tree->parent->helper.sync); --request.tree->parent->helper.nchildren; bg_sync_signal(&request.tree->parent->helper.sync); bg_sync_unlock(&request.tree->parent->helper.sync); } ///////////////////////////////////////////////////////////////////////// bg_param_threads_release(threads,node); #endif // ] continue; } } e_kill: bg_sync_unlock(&node->sync); #if ! defined (_WIN32) // [ return NULL; } #else // ] [ return 0; } #endif // ] #if defined (BG_PARAM_NODE_VMT) // [ static void run(bg_param_node_t *node, bg_param_request_t *request) { bg_tree_t *tree=request->tree; #if defined (BG_PARAM_SCRIPT) // [ if (request->script) bg_process_tree_run_script(tree); else { #endif // ] /////////////////////////////////////////////////////////////////////////// request->dispatch(tree,request->visitor); #if defined (BG_PARAM_SCRIPT) // [ } #endif // ] ///////////////////////////////////////////////////////////////////////////// if (tree->parent) { bg_sync_lock(&tree->parent->helper.sync); --tree->parent->helper.nchildren; bg_sync_signal(&tree->parent->helper.sync); bg_sync_unlock(&tree->parent->helper.sync); } ///////////////////////////////////////////////////////////////////////////// bg_param_threads_release(node->threads,node); } static bg_param_node_vmt_t vmt={ .run=run, }; #endif // ] #endif // ] bs1770gain-0.9.5/libbg/bg_analyzer.c0000755000175000017500000003553114626255363012536 /* * bg_analyzer.c * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include /////////////////////////////////////////////////////////////////////////////// static bg_visitor_vmt_t bg_analyzer_vmt; /////////////////////////////////////////////////////////////////////////////// int bg_analyzer_create(bg_visitor_t *vis) { ///////////////////////////////////////////////////////////////////////////// vis->vmt=&bg_analyzer_vmt; vis->depth=0; ///////////////////////////////////////////////////////////////////////////// return 0; } static void bg_analyzer_destroy(bg_visitor_t *vis FFUNUSED) { } /////////////////////////////////////////////////////////////////////////////// static int bg_analyzer_dispatch_file(bg_visitor_t *vis FFUNUSED, bg_tree_t *tree FFUNUSED) { // file annotation is created bottom-up from the muxer. nothing to do. #if defined (BG_PARAM_THREADS) // [ if (tree->param->nthreads&&tree->parent) { bg_sync_lock(&tree->parent->helper.sync); // { --tree->parent->helper.nchildren; bg_sync_signal(&tree->parent->helper.sync); bg_sync_unlock(&tree->parent->helper.sync); // } } #endif // ] return 0; } /////////////////////////////////////////////////////////////////////////////// static int bg_analyzer_print_prefix(bg_visitor_t *vis, bg_tree_t *tree) { FILE *f=tree->param->result.f; bg_print_vmt_t *stdout_vmt=tree->param->print.vmt; int stdout_prefix=BG_TREE_TYPE_TRACK==tree->vmt->type||stdout_vmt->infix; if (stdout_prefix) { /////////////////////////////////////////////////////////////////////////// // the header of a track is always mirrored to the shell/console // regardless wether prefix or infix. if (stdout_vmt->head(tree,vis->depth,stdout)<0) { _DMESSAGE("printing head"); goto e_print_head_stdout; } } ///////////////////////////////////////////////////////////////////////////// if (tree->param->print.vmt->infix) { if (stdout!=f&&tree->param->print.vmt->head(tree,vis->depth,f)<0) { _DMESSAGE("printing head"); goto e_print_head_file_infix; } } ///////////////////////////////////////////////////////////////////////////// return 0; //cleanup: e_print_head_file_infix: e_print_head_stdout: return -1; } static int bg_analyzer_print_postfix(bg_visitor_t *vis, bg_tree_t *tree) { FILE *f=tree->param->result.f; #if 0 // [ bg_print_vmt_t *stdout_vmt=&bg_print_classic_vmt; #else // ] [ bg_print_vmt_t *stdout_vmt=tree->param->print.vmt; #endif // ] int stdout_prefix=BG_TREE_TYPE_TRACK==tree->vmt->type||stdout_vmt->infix; //_DWRITELNVW(L"\"%s\"",tree->vmt->id); if (!stdout_prefix) { if (stdout_vmt->head(tree,vis->depth,stdout)<0) { _DMESSAGE("printing head"); goto e_print_head_stdout; } } if (!tree->param->print.vmt->infix) { if (stdout!=f&&tree->param->print.vmt->head(tree,vis->depth,f)<0) { _DMESSAGE("printing head"); goto e_print_head_file_postfix; } } if (tree->param->print.vmt->tail(tree,vis->depth,f)<0) { _DMESSAGE("printing tail"); goto e_print_tail_file; } fflush(f); if (stdout!=f) { if (tree->param->print.vmt->tail(tree,vis->depth,stdout)<0) { _DMESSAGE("printing tail"); goto e_print_tail_stdout; } fflush(stdout); } ///////////////////////////////////////////////////////////////////////////// return 0; //cleanup: e_print_tail_stdout: e_print_tail_file: e_print_head_file_postfix: e_print_head_stdout: return -1; } /////////////////////////////////////////////////////////////////////////////// #if defined (BG_PARAM_THREADS) // [ static int bg_analyzer_track(bg_tree_t *tree, bg_visitor_t *vis) { int err=-1; bg_track_t *track=&tree->track; ///////////////////////////////////////////////////////////////////////////// ++vis->depth; // [ ///////////////////////////////////////////////////////////////////////////// if (ff_input_open_analyzer(&track->input)<0) { _DMESSAGE("re-opening input"); goto e_input; } ///////////////////////////////////////////////////////////////////////////// if (ff_analyzer_create(&track->analyzer,&track->input)<0) { _DMESSAGE("creating analyzer"); goto e_analyzer; } ///////////////////////////////////////////////////////////////////////////// if (bg_analyzer_print_prefix(vis,tree)<0) { _DMESSAGE("printing prefix"); goto e_print_prefix; } ///////////////////////////////////////////////////////////////////////////// if (ff_analyzer_loop(&tree->track.analyzer)<0) { _DMESSAGE("decoding"); goto e_decode; } ///////////////////////////////////////////////////////////////////////////// if (bg_tree_merge(tree->parent,tree)<0) { _DMESSAGE("merging"); goto e_merge; } ///////////////////////////////////////////////////////////////////////////// if (bg_analyzer_print_postfix(vis,tree)<0) { _DMESSAGE("printing postfix"); goto e_print_postfix; } ///////////////////////////////////////////////////////////////////////////// err=0; //cleanup: e_print_postfix: e_merge: e_decode: e_print_prefix: ff_analyzer_destroy(&track->analyzer,0); e_analyzer: ff_input_close(&track->input); e_input: --vis->depth; // ] return err; } #endif // ] static int bg_analyzer_dispatch_track(bg_visitor_t *vis, bg_tree_t *tree) { int err=-1; #if defined (BG_PARAM_THREADS) // [ if (tree->param->nthreads) { #if defined (BG_PARAM_SCRIPT) // [ bg_param_threads_visitor_run(&tree->param->threads,NULL,vis,tree, bg_analyzer_track); #else // ] [ bg_param_threads_visitor_run(&tree->param->threads,vis,tree, bg_analyzer_track); #endif // ] err=0; } else err=bg_analyzer_track(tree,vis); #else // ] [ bg_track_t *track=&tree->track; ///////////////////////////////////////////////////////////////////////////// ++vis->depth; // [ ///////////////////////////////////////////////////////////////////////////// if (ff_input_open_analyzer(&track->input)<0) { _DMESSAGE("re-opening input"); goto e_input; } ///////////////////////////////////////////////////////////////////////////// if (ff_analyzer_create(&track->analyzer,&track->input)<0) { _DMESSAGE("creating analyzer"); goto e_analyzer; } ///////////////////////////////////////////////////////////////////////////// if (bg_analyzer_print_prefix(vis,tree)<0) { _DMESSAGE("printing prefix"); goto e_print_prefix; } ///////////////////////////////////////////////////////////////////////////// if (ff_analyzer_loop(&tree->track.analyzer)<0) { _DMESSAGE("decoding"); goto e_decode; } ///////////////////////////////////////////////////////////////////////////// if (bg_tree_merge(tree->parent,tree)<0) { _DMESSAGE("merging"); goto e_merge; } ///////////////////////////////////////////////////////////////////////////// if (bg_analyzer_print_postfix(vis,tree)<0) { _DMESSAGE("printing postfix"); goto e_print_postfix; } ///////////////////////////////////////////////////////////////////////////// err=0; //cleanup: e_print_postfix: e_merge: e_decode: e_print_prefix: ff_analyzer_destroy(&track->analyzer,0); e_analyzer: ff_input_close(&track->input); e_input: --vis->depth; // ] #endif // ] return err; } int bg_analyzer_album_prefix(bg_visitor_t *vis, bg_tree_t *tree) { int err=-1; bg_param_t *param=tree->param; ///////////////////////////////////////////////////////////////////////////// ++vis->depth; if (param->output.dirname||param->overwrite) { if (tree->vmt->annotation.create(tree)<0) { _DMESSAGE("annotating"); goto e_annotate; } } ///////////////////////////////////////////////////////////////////////////// if (bg_analyzer_print_prefix(vis,tree)<0) { _DMESSAGE("printing prefix"); goto e_print_prefix; } #if 0 // [ ///////////////////////////////////////////////////////////////////////////// tree->threads.nchildren=tree->album.nchildren.cur; _DWRITELNV("++++ %u %p \"%s\"",tree->threads.nchildren,tree->parent,tree->utf8.basename); #else // ] [ //_DWRITELNV("+++ %u %p \"%s\"",tree->album.nchildren.cur,tree->parent,tree->utf8.basename); #endif // ] ///////////////////////////////////////////////////////////////////////////// err=0; //cleanup: e_print_prefix: if (err&&(param->output.dirname||param->overwrite)) tree->vmt->annotation.destroy(tree); e_annotate: if (err) --vis->depth; return err; } int bg_analyzer_album_suffix(bg_visitor_t *vis, bg_tree_t *tree) { int err=-1; #if defined (BG_PARAM_THREADS) // [ //#if defined (BG_PARAM_QUIET) // [ // int verbose=!tree->param->quiet&&!tree->param->suppress.progress; //#else // ] [ int verbose=!tree->param->suppress.progress; //#endif // ] #endif // ] bg_param_t *param=tree->param; bg_tree_t *cur; bg_visitor_t muxer; ///////////////////////////////////////////////////////////////////////////// memset(&muxer,0,sizeof muxer); #if defined (BG_PARAM_THREADS) // [ ///////////////////////////////////////////////////////////////////////////// tree->helper.nchildren=tree->album.nchildren.cur; //_DWRITELNV(">>> %u (%u %p)",tree->helper.nchildren,tree->album.nchildren.cur,tree->album.first); #endif // ] ///////////////////////////////////////////////////////////////////////////// for (cur=tree->album.first;cur;cur=cur->next) { //_DWRITELNV(" * \"%" PBU_PRIs "\"",cur->source.path); if (cur->vmt->accept(cur,vis)<0) { _DMESSAGEV("analyzing \"%" PBU_PRIs "\"",cur->source.path); goto e_child; } } #if defined (BG_PARAM_THREADS) // [ ///////////////////////////////////////////////////////////////////////////// if (param->nthreads) { bg_sync_lock(&tree->helper.sync); // { while (tree->helper.nchildren) bg_sync_wait(&tree->helper.sync); bg_sync_unlock(&tree->helper.sync); // } #if defined (BG_VISITOR_NOTIFY_PARENT) // [ if (tree->parent) { bg_sync_lock(&tree->parent->helper.sync); // { bg_sync_signal(&tree->parent->helper.sync); bg_sync_unlock(&tree->parent->helper.sync); // } } #endif // ] } #endif // ] ///////////////////////////////////////////////////////////////////////////// if (bg_analyzer_print_postfix(vis,tree)<0) { _DMESSAGE("printing postfix"); goto e_print_postfix; } /////////////////////////////////////////////////////////////////////////// #if defined (BG_PARAM_THREADS) // [ if (param->nthreads) bg_param_threads_drain(¶m->threads); #endif // ] if (tree->album.nleafs&&(param->output.dirname||param->overwrite)) { if (bg_muxer_create(&muxer)<0) { _DMESSAGE("creating muxer"); goto e_muxer; } #if defined (BG_PARAM_QUIET) // [ if (!param->quiet&&!param->suppress.progress) { #else // ] [ if (!param->suppress.progress) { #endif // ] #if defined (FF_PROGRESS_STDERR) // [ if (bg_is_output_xml(param)) _FPRINTF(param->stdprog,""); _FPRINTF(param->stdprog,"\n"); fflush(param->stdprog); #else // ] if (bg_is_output_xml(param)) { _FPRINTF(stdout," -->"); } _FPRINTF(stdout,"\n"); fflush(stdout); #endif // ] #if ! defined (BG_PARAM_QUIET) // [ } #else // ] [ } #endif // ] #if defined (BG_PARAM_THREADS) // [ if (param->nthreads) { bg_param_threads_drain(¶m->threads); if (verbose) { if (tree->source.path) { if (bg_is_output_xml(param)) { _FPRINTF(stdout,"\n"); else _FPRINTF(stdout,"\n"); } fflush(stdout); } } #endif // ] } ///////////////////////////////////////////////////////////////////////////// #if defined (BG_PARAM_SCRIPT) // [ if (!param->script) { #endif // ] if (param->output.dirname||param->overwrite) tree->vmt->annotation.destroy(tree); #if defined (BG_PARAM_SCRIPT) // [ } #endif // ] err=0; //cleanup: e_muxer_accept: if (muxer.vmt) muxer.vmt->destroy(&muxer); e_muxer: e_print_postfix: e_child: --vis->depth; return err; } #if 0 // [ // never called. instead bg_analyzer_album_prefix() and // bg_analyzer_album_suffix(), respectively, are called from bg_param_loop() // and bg_pilot_callback_branch_leave(), respectively. static int bg_analyzer_dispatch_album(bg_visitor_t *vis, bg_tree_t *tree) { int err=-1; ///////////////////////////////////////////////////////////////////////////// if (bg_analyzer_album_prefix(vis,tree)) { _DMESSAGE("prefix"); goto e_prefix; } ///////////////////////////////////////////////////////////////////////////// if (bg_analyzer_album_suffix(vis,tree)) { _DMESSAGE("suffix"); goto e_suffix; } ///////////////////////////////////////////////////////////////////////////// if (bg_tree_merge(tree->parent,tree)<0) { _DMESSAGE("merging"); goto e_merge; } ///////////////////////////////////////////////////////////////////////////// err=0; //cleanup: e_merge: e_suffix: e_prefix: return err; } #else // ] [ static int bg_analyzer_dispatch_album(bg_visitor_t *vis FFUNUSED, bg_tree_t *tree FFUNUSED) { _DMESSAGE("non intended invocation "); return -1; } #endif // ] static bg_visitor_vmt_t bg_analyzer_vmt={ #if defined (PBU_DEBUG) // [ .id="analyzer", #endif // ] .destroy=bg_analyzer_destroy, .dispatch_file=bg_analyzer_dispatch_file, .dispatch_track=bg_analyzer_dispatch_track, .dispatch_album=bg_analyzer_dispatch_album, .dispatch_root=bg_analyzer_dispatch_album, }; bs1770gain-0.9.5/libbg/bg_threads_helper.c0000755000175000017500000000247513705072446013677 /* * bg_threads_helper.c * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include #if defined (BG_PARAM_THREADS) // [ int bg_threads_helper_create(bg_threads_helper_t *helper) { if (bg_sync_create(&helper->sync)<0) { _DMESSAGE("creating sync"); goto e_sync; } ///////////////////////////////////////////////////////////////////////////// return 0; //cleanup: bg_sync_destroy(&helper->sync); e_sync: return -1; } void bg_threads_helper_destroy(bg_threads_helper_t *helper) { bg_sync_destroy(&helper->sync); } #endif // ] bs1770gain-0.9.5/libbg/bg_root.c0000755000175000017500000000462114626242454011665 /* * bg_root.h * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include /////////////////////////////////////////////////////////////////////////////// static bg_tree_vmt_t bg_root_vmt; int bg_root_create(bg_tree_t *tree, bg_param_t *param) { ///////////////////////////////////////////////////////////////////////////// if (bg_tree_common_create(tree,param,NULL,NULL)<0) { _DMESSAGE("creating tree"); goto e_common; } ///////////////////////////////////////////////////////////////////////////// if (bg_album_content_create(tree,&bg_root_vmt)<0) { _DMESSAGE("creating content"); goto e_content; } ///////////////////////////////////////////////////////////////////////////// return 0; //cleanup: bg_album_content_destroy(tree); e_content: bg_tree_common_destroy(tree); e_common: return -1; } /////////////////////////////////////////////////////////////////////////////// static void bg_root_destroy(bg_tree_t *tree) { bg_album_content_destroy(tree); bg_tree_common_destroy(tree); } static int bg_root_accept(bg_tree_t *tree, bg_visitor_t *vis) { return vis->vmt->dispatch_root(vis,tree); } #if defined (BG_TRACK_ID) // [ static void bg_root_track_id(bg_tree_t *tree FFUNUSED, int *id FFUNUSED) { } #endif // ] static bg_tree_vmt_t bg_root_vmt={ #if defined (PBU_MESSAGE_AV_LOG) // [ .id="root", #else // ] [ .id=FFL("root"), #endif // ] .type=BG_TREE_TYPE_ROOT, .destroy=bg_root_destroy, .accept=bg_root_accept, .annotation={ .create=bg_root_annotation_create, .destroy=bg_root_annotation_destroy, }, #if defined (BG_TRACK_ID) // [ .track_id=bg_root_track_id, #endif // ] }; bs1770gain-0.9.5/libbg/bg_pilot_branch.c0000755000175000017500000001023113705073160013331 /* * bg_pilot_branch.c * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include /////////////////////////////////////////////////////////////////////////////// static bg_pilot_hist_vmt_t bg_pilot_hist_branch_vmt; /////////////////////////////////////////////////////////////////////////////// #if defined (_WIN32) // [ int bg_pilot_hist_branch_create(bg_pilot_hist_t *hist, HANDLE hFind, WIN32_FIND_DATAW *e) #else // ] [ int bg_pilot_hist_branch_create(bg_pilot_hist_t *hist, DIR *dir) #endif // ] { bg_pilot_client_t *client=&hist->pilot->client; bg_pilot_hist_branch_t *branch=&hist->branch; hist->vmt=&bg_pilot_hist_branch_vmt; #if defined (_WIN32) // [ branch->hFind=hFind; branch->e=*e; #else // ] [ branch->dir=dir; branch->e=NULL; #endif // ] ///////////////////////////////////////////////////////////////////////////// if (client->cb&&client->cb->branch.enter) { if (client->cb->branch.enter(hist,client->data)<0) { _DMESSAGE("entering branch"); goto e_enter; } } return 0; //cleanup: e_enter: #if defined (_WIN32) // [ FindClose(hFind); #else // ] [ closedir(dir); #endif // ] return -1; } static void bg_pilot_hist_branch_destroy(bg_pilot_hist_t *hist) { bg_pilot_client_t *client=&hist->pilot->client; bg_pilot_hist_branch_t *branch=&hist->branch; if (client->cb&&client->cb->branch.leave) client->cb->branch.leave(hist,client->data); #if defined (_WIN32) // [ FindClose(branch->hFind); #else // ] [ closedir(branch->dir); #endif // ] } /////////////////////////////////////////////////////////////////////////////// static int bg_pilot_hist_branch_navdir(bg_pilot_hist_t *hist) { bg_pilot_hist_branch_t *branch=&hist->branch; #if defined (_WIN32) // [ if (!wcscmp(L".",branch->e.cFileName)) return 1; else if (!wcscmp(L"..",branch->e.cFileName)) return 1; #else // ] [ if (!strcmp(".",branch->e->d_name)) return 1; else if (!strcmp("..",branch->e->d_name)) return 1; #endif // ] else return 0; } static const ffchar_t *bg_pilot_hist_branch_first(bg_pilot_hist_t *hist) { const ffchar_t *entry=NULL; bg_pilot_hist_branch_t *branch=&hist->branch; #if defined (_WIN32) // [ while (bg_pilot_hist_branch_navdir(hist)) { if (!FindNextFileW(branch->hFind,&branch->e)) goto e_readdir; } entry=branch->e.cFileName; #else // ] [ do { branch->e=readdir(branch->dir); if (!branch->e) goto e_readdir; } while (bg_pilot_hist_branch_navdir(hist)); entry=branch->e->d_name; #endif // ] //cleanup: e_readdir: return entry; } static const ffchar_t *bg_pilot_hist_branch_next(bg_pilot_hist_t *hist) { const ffchar_t *entry=NULL; bg_pilot_hist_branch_t *branch=&hist->branch; #if defined (_WIN32) // [ do { if (!FindNextFileW(branch->hFind,&branch->e)) goto e_readdir; } while (bg_pilot_hist_branch_navdir(hist)); entry=branch->e.cFileName; #else // ] [ do { branch->e=readdir(branch->dir); if (!branch->e) goto e_readdir; } while (bg_pilot_hist_branch_navdir(hist)); entry=branch->e->d_name; #endif // ] //cleanup: e_readdir: return entry; } /////////////////////////////////////////////////////////////////////////////// static bg_pilot_hist_vmt_t bg_pilot_hist_branch_vmt={ #if defined (PBU_DEBUG) // [ .id="branch", #endif // ] .destroy=bg_pilot_hist_branch_destroy, .first=bg_pilot_hist_branch_first, .next=bg_pilot_hist_branch_next, }; bs1770gain-0.9.5/libbg/bg_param.c0000755000175000017500000003126114626106574012004 /* * bg_param.c * * Copyright (C) 2014-2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include /////////////////////////////////////////////////////////////////////////////// static bg_pilot_callback_t bg_pilot_callback; /////////////////////////////////////////////////////////////////////////////// static bg_param_unit_t bg_param_unit_ebu={ .n.lu="LU", #if defined (BG_UNIT_LRA) // [ .n.lra="LRA", #else // ] [ .n.lra="LU", #endif // ] .n.sp="SP", .n.tp="TP", #if defined (_WIN32) // [ .w.lu=L"LU", #if defined (BG_UNIT_LRA) // [ .w.lra=L"LRA", #else // ] [ .w.lra=L"LU", #endif // ] .w.sp=L"SP", .w.tp=L"TP", #endif // ] }; static bg_param_unit_t bg_param_unit_db={ .n.lu="dB", .n.lra="dB", .n.sp="dB", .n.tp="dB", #if defined (_WIN32) // [ .w.lu=L"dB", .w.lra=L"dB", .w.sp=L"dB", .w.tp=L"dB", #endif // ] }; /////////////////////////////////////////////////////////////////////////////// int bg_param_create(bg_param_t *param) { memset(param,0,sizeof *param); param->count.cur=0; param->count.max=0; param->process=0; #if defined (BG_PARAM_PREAMP) // [ param->preamp=0.0; #endif // ] #if defined (BG_PARAM_SKIP_SCAN) // [ param->skip_scan=0; #endif // ] #if defined (BG_PARAM_SCRIPT) // [ param->script=NULL; #endif // ] #if defined (BG_SAMPLES_COUNT) // [ param->upsampler.threshould=0; #endif // ] param->csv.separator=FFL('\t'); #if defined (BG_PARAM_XML_CDATA) // [ param->xml.cdata=0; #endif // ] #if defined (BG_PARAM_SHELL) // [ #if defined (_WIN32) // [ param->shell.interpreter=NULL; param->shell.parameter=L"-c"; #else // ] [ param->shell.interpreter="/bin/sh"; param->shell.parameter="-c"; #endif // ] #endif // ] #if defined (FF_INPUT_LIST) // [ param->list.in=0; param->list.out=0; #endif // ] if (bg_pilot_create(¶m->pilot,20,&bg_pilot_callback,param)<0) { _DMESSAGE("creating pilot"); goto e_pilot; } if (bg_analyzer_create(¶m->analyzer)<0) { _DMESSAGE("creating analyzer"); goto e_analyzer; } param->print.vmt=&bg_print_classic_vmt; #if defined (FF_PROGRESS_STDERR) // [ if (ff_printer_create(¶m->printer,stderr)<0) { _DMESSAGE("creating printer"); goto e_printer; } #else // ] [ if (ff_printer_create(¶m->printer,stdout)<0) { _DMESSAGE("creating printer"); goto e_printer; } #endif // ] param->loglevel=AV_LOG_QUIET; #if defined (_WIN32) // [ param->codec.name[0]=L'\0'; #else // ] [ param->codec.name=NULL; #endif // ] param->temp_prefix=BG_TEMP_PREFIX; param->suppress.hierarchy=0; param->suppress.progress=0; #if defined (_WIN32) // [ // if LANG is set to e.g. "en_US.UTF-8" we assume we're run from // e.g. MSYS2 shell undestanding UTF-8 otherwise from MS console using // codepage OEM. In the latter case we need an OEM representation of // e.g. basename. param->oem=0; #endif // ] param->decode.request.sample_fmt=-1; param->decode.request.channel_layout=-1ll; param->decode.drc.enabled=0; param->decode.drc.scale=0.0; param->result.f=stdout; param->output.dirname=NULL; param->ai=-1; param->vi=-1; param->flags.extension=0; param->flags.mode=0; param->flags.aggregate=BG_FLAGS_AGG_INTEGRATED; param->flags.norm=BG_FLAGS_NORM_EBU; #if defined (BG_PARAM_DUMP) // [ param->dump=0; #endif // ] #if defined (BG_PARAM_STEREO) // [ param->stereo=0; #else // ] [ param->decode.request.channel_layout=-1ll; #endif // ] param->norm=-23.0; param->preamp=0.0; param->weight.enabled=0; param->weight.value=1.0; #if defined (BG_CLOCK) // [ param->time=0; #endif // ] #if defined (BG_PARAM_LFE) // [ #if defined (LIB1770_LFE) // [ param->lfe=LIB1770_LFE; #elif defined (BG_CHANNEL_LFE) // ] [ param->lfe=BG_CHANNEL_LFE; #else // ] [ param->lfe=-1; #endif // ] #endif // ] #if defined (_WIN32) && defined (BG_WIN32_CREATE_LOCALE) // [ param->locale=0; #endif // ] param->overwrite=0; param->unit=&bg_param_unit_ebu; strncpy(param->tag.pfx,"REPLAYGAIN_",(sizeof param->tag)-1); param->out.sfx=NULL; param->ext.audio=FFL("flac"); param->ext.video=FFL("mkv"); param->interval.begin=-1ll; param->interval.duration=-1ll; #if defined (BG_PARAM_QUIET) // [ param->quiet=0; #endif // ] #if defined (BG_PARAM_THREADS) // [ param->nthreads=0; #endif // ] #if defined (BG_PARAM_SLEEP) // [ param->sleep=0; #endif // ] //////// param->momentary.ms=400.0; param->momentary.partition=4; param->momentary.mean.gate=-10.0; param->momentary.range.gate=-20.0; param->momentary.range.lower_bound=0.1; param->momentary.range.upper_bound=0.95; //////// param->shortterm.ms=3000.0; param->shortterm.partition=3; param->shortterm.mean.gate=-10.0; param->shortterm.range.gate=-20.0; param->shortterm.range.lower_bound=0.1; param->shortterm.range.upper_bound=0.95; #if defined (FF_PROGRESS_STDERR) // [ param->stdprog=stderr; #endif // ] ///////////////////////////////////////////////////////////////////////////// return 0; //cleanup: ff_printer_destroy(¶m->printer); e_printer: if (param->analyzer.vmt) param->analyzer.vmt->destroy(¶m->analyzer); e_analyzer: bg_pilot_destroy(¶m->pilot); e_pilot: return -1; } void bg_param_destroy(bg_param_t *param) { ff_printer_destroy(¶m->printer); if (param->analyzer.vmt) param->analyzer.vmt->destroy(¶m->analyzer); bg_pilot_destroy(¶m->pilot); } int bg_param_alloc_arguments(bg_param_t *param, size_t size) { ///////////////////////////////////////////////////////////////////////////// if (!size) { _DMESSAGE("nothing to analyze"); goto e_size; } ///////////////////////////////////////////////////////////////////////////// param->argv.min=malloc(size*sizeof *param->argv.min); if (!param->argv.min) { _DMESSAGE("allocating"); goto e_alloc; } memset(param->argv.min,0,size*sizeof *param->argv.min); param->argv.cur=param->argv.min; param->argv.max=param->argv.min+size; ///////////////////////////////////////////////////////////////////////////// return 0; //cleanup: free(param->argv.min); e_alloc: e_size: return -1; } void bg_param_free_argumets(bg_param_t *param) { free(param->argv.min); } void bg_param_set_unit_ebu(bg_param_t *param) { param->unit=&bg_param_unit_ebu; } void bg_param_set_unit_db(bg_param_t *param) { param->unit=&bg_param_unit_db; } void bg_param_set_process(bg_param_t *param) { ff_printer_clear(¶m->printer); param->process=1; param->count.max=param->count.cur; param->count.cur=0u; } //#define BG_PARAM_LOOP_INNER #if defined (BG_PARAM_LOOP_INNER) // [ static int bg_param_loop_inner(bg_param_t *param, ffchar_t const *argv) { int err=-1; ///////////////////////////////////////////////////////////////////////////// if (bg_root_create(¶m->root,param)<0) { _DMESSAGE("creating root"); goto e_root; } param->tos=¶m->root; if (param->process) { /////////////////////////////////////////////////////////////////////////// if (bg_analyzer_album_prefix(¶m->analyzer,¶m->root)<0) { _DMESSAGE("prefix"); goto e_prefix; } } ///////////////////////////////////////////////////////////////////////////// if (bg_pilot_loop(¶m->pilot,argv)<0) { _DMESSAGE("looping"); goto e_loop; } if (param->process) { /////////////////////////////////////////////////////////////////////////// if (bg_analyzer_album_suffix(¶m->analyzer,¶m->root)<0) { _DMESSAGE("suffix"); goto e_suffix; } } ///////////////////////////////////////////////////////////////////////////// err=0; //cleanup: e_suffix: e_loop: e_prefix: param->root.vmt->destroy(¶m->root); e_root: return err; } #endif // ] int bg_param_loop(bg_param_t *param, ffchar_t *const *argv) { int err=-1; #if ! defined (BG_PARAM_LOOP_INNER) // [ ///////////////////////////////////////////////////////////////////////////// if (bg_root_create(¶m->root,param)<0) { _DMESSAGE("creating root"); goto e_root; } param->tos=¶m->root; if (param->process) { /////////////////////////////////////////////////////////////////////////// if (bg_analyzer_album_prefix(¶m->analyzer,¶m->root)<0) { _DMESSAGE("prefix"); goto e_prefix; } } #endif // ] for (param->argv.cur=param->argv.min;param->argv.curargv.max; ++param->argv.cur) { #if defined (BG_PARAM_LOOP_INNER) // [ /////////////////////////////////////////////////////////////////////////// if (bg_param_loop_inner(param,*argv++)<0) { _DMESSAGE("inner loop"); goto e_inner; } #else // ] [ /////////////////////////////////////////////////////////////////////////// if (bg_pilot_loop(¶m->pilot,*argv++)<0) { _DMESSAGE("looping"); goto e_loop; } #endif // ] } #if ! defined (BG_PARAM_LOOP_INNER) // [ if (param->process) { /////////////////////////////////////////////////////////////////////////// if (bg_analyzer_album_suffix(¶m->analyzer,¶m->root)<0) { _DMESSAGE("suffix"); goto e_suffix; } } #endif // ] ///////////////////////////////////////////////////////////////////////////// err=0; //cleanup: #if defined (BG_PARAM_LOOP_INNER) // [ e_inner: #else // ] [ e_suffix: e_loop: e_prefix: param->root.vmt->destroy(¶m->root); e_root: #endif // ] return err; } /////////////////////////////////////////////////////////////////////////////// static int bg_pilot_callback_leaf_enter(bg_pilot_hist_t *hist, void *data) { bg_param_t *param=data; bg_tree_t *parent=param->tos; bg_tree_t *tree; ///////////////////////////////////////////////////////////////////////////// if (bg_leaf_create(&tree,param,parent,hist->path)<0) { #if defined (BG_TREE_CREATE_CHILD_WARNING) // [ _DWARNING("creating leaf"); #endif // ] hist->data=NULL; goto success; } ///////////////////////////////////////////////////////////////////////////// hist->data=tree; param->tos=tree; ///////////////////////////////////////////////////////////////////////////// success: return 0; } static void bg_pilot_callback_leaf_leave(bg_pilot_hist_t *hist, void *data) { bg_param_t *param=data; bg_tree_t *tree=hist->data; if (tree) { // unlink. hist->data=NULL; param->tos=tree->parent; } } //////// static int bg_pilot_callback_branch_enter(bg_pilot_hist_t *hist, void *data) { bg_param_t *param=data; bg_tree_t *parent=param->tos; bg_tree_t *tree; ///////////////////////////////////////////////////////////////////////////// if (bg_album_create(&tree,param,parent,hist->path)<0) { _DMESSAGE("creating album"); goto e_album; } ///////////////////////////////////////////////////////////////////////////// if (param->process&&bg_analyzer_album_prefix(¶m->analyzer,tree)<0) { _DMESSAGE("analyzer prefix"); goto e_prefix; } ///////////////////////////////////////////////////////////////////////////// hist->data=tree; param->tos=tree; ///////////////////////////////////////////////////////////////////////////// return 0; //cleanup: e_prefix: // just an indirect call to bg_album_destroy(). tree->vmt->destroy(tree); e_album: return -1; } static void bg_pilot_callback_branch_leave(bg_pilot_hist_t *hist, void *data) { bg_param_t *param=data; bg_tree_t *tree=hist->data; ///////////////////////////////////////////////////////////////////////////// if (tree) { if (param->process) { if (bg_analyzer_album_suffix(¶m->analyzer,tree)<0) { _DMESSAGE("analyzing"); goto e_analyze; } if (tree->parent&&bg_tree_merge(tree->parent,tree)<0) { _DMESSAGE("merging"); goto e_merge; } } e_merge: e_analyze: // unlink. hist->data=NULL; param->tos=tree->parent; // just an indirect call to bg_album_destroy(). tree->vmt->destroy(tree); } } static bg_pilot_callback_t bg_pilot_callback={ .leaf.enter=bg_pilot_callback_leaf_enter, .leaf.leave=bg_pilot_callback_leaf_leave, .branch.enter=bg_pilot_callback_branch_enter, .branch.leave=bg_pilot_callback_branch_leave, }; bs1770gain-0.9.5/libbg/bg_annotator.c0000755000175000017500000010075713707211443012707 /* * bg_annotator.c * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is PBU_FREE_GUARDED software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #if defined (_WIN32) // [ #include #else // ] [ #include #include #include #include #include #endif // ] #include /////////////////////////////////////////////////////////////////////////////// static bg_tree_t *bg_tree_annotation_parent(bg_tree_t *tree) { bg_param_t *param=tree->param; return tree->argv->liftdepth?tree->parent :tree->argv->lift==tree->depth?¶m->root:NULL; } /////////////////////////////////////////////////////////////////////////////// int bg_file_annotation_create(bg_tree_t *tree) { const bg_param_t *param=tree->param; bg_tree_t *parent=bg_tree_annotation_parent(tree); size_t len1,len2; ssize_t size; ffchar_t *tp; ///////////////////////////////////////////////////////////////////////////// len1=parent&&parent->target.path?FFSTRLEN(parent->target.path):0u; len2=tree->source.basename?FFSTRLEN(tree->source.basename):0u; size=(len1?len1+1u:0u)+(len2?len2+1u:0u); tree->target.path=tp=malloc(size*sizeof tp[0]); if (!tree->target.path) { _DMESSAGE("allocating output path"); goto e_path; } if (parent&&parent->target.path) { FFSTRCPY(tp,parent->target.path); tp+=len1; if (tree->source.basename) *tp++=FFPATHSEP; } tree->target.basename=tp; if (tree->source.basename) { FFSTRCPY(tp,tree->source.basename); tp+=len2; } else *tp=0; ///////////////////////////////////////////////////////////////////////////// len2=FFSTRLEN(param->temp_prefix); tree->temp.path=tp=malloc((size+len2)*sizeof tp[0]); if (!tree->temp.path) { _DMESSAGE("allocating temporary path"); goto e_temp; } if (parent&&parent->target.path) { FFSTRCPY(tp,parent->target.path); tp+=len1; if (tree->source.basename) *tp++=FFPATHSEP; } tree->temp.basename=tp; FFSTRCPY(tp,param->temp_prefix); tp+=len2; FFSTRCPY(tp,tree->target.basename); if (ff_fexists(tree->temp.path)) { #if defined (_WIN32) // [ _DMESSAGEV("file \"%S\" exists; either remove it or define another" " prefix for temporary files by means of option --temp-prefix", tree->temp.path); #else // ] [ _DMESSAGEV("file \"%s\" exists; either remove it or define another" " prefix for temporary files by means of option --temp-prefix", tree->temp.path); #endif // ] goto e_temp_exists; } ///////////////////////////////////////////////////////////////////////////// #if 0 // [ success: #endif // ] return 0; //cleanup: e_temp_exists: PBU_FREE_GUARDED(tree->temp.path); e_temp: PBU_FREE_GUARDED(tree->target.path); e_path: return -1; } void bg_file_annotation_destroy(bg_tree_t *tree FFUNUSED) { PBU_FREE_GUARDED(tree->temp.path); PBU_FREE_GUARDED(tree->target.path); } /////////////////////////////////////////////////////////////////////////////// #define BG_TRACK_AUDIO_SFX #if defined (BG_TRACK_AUDIO_SFX) // [ static const ffchar_t *bg_track_audio_sfx(const bg_track_t *track FFUNUSED, const bg_tree_t *tree, const ffchar_t *default_sfx) { const ffchar_t *sp,*sfx; // get the suffix from the input. sfx=sp=FFSTRSTR(tree->source.path,FFL(".")); // find the right-most dot '.'. while (sp) { sfx=++sp; sp=FFSTRSTR(sp,FFL(".")); } if (!sfx) return default_sfx; else if (track->input.audio.ctx) { if (!FFSTRCMP(FFL("flac"),sfx)) return sfx; else return default_sfx; } else { if (!FFSTRCMP(FFL("flac"),sfx)) return sfx; else if (!FFSTRCMP(FFL("wv"),sfx)) return sfx; else if (!FFSTRCMP(FFL("mp3"),sfx)) return sfx; else if (!FFSTRCMP(FFL("ogg"),sfx)) return sfx; #if 0 // [ else if (!FFSTRCMP(FFL("m4a"),sfx)) return sfx; else if (!FFSTRCMP(FFL("aac"),sfx)) return sfx; #endif // ] else return default_sfx; } } #endif // ] #define BG_ALBUM_ART static const ffchar_t *bg_track_out_sfx(const bg_track_t *track, const bg_tree_t *tree) { const bg_param_t *param=tree->param; #if defined (BG_ALBUM_ART) // [ AVStream *vstream FFUNUSED=0input.vi? track->input.fmt.ctx->streams[track->input.vi]:NULL; #endif // ] #if defined (BG_TRACK_AUDIO_SFX) // [ if (param->out.sfx&&*param->out.sfx) { // in case a sfx is provided choose it. return param->out.sfx; } else { return bg_track_audio_sfx(track,tree, 0<=track->input.vi?FFL("mkv"):FFL("mka")); } #else // ] [ if ((BG_FLAGS_MODE_APPLY¶m->flags.mode) &¶m->out.sfx&&*param->out.sfx) { // in case a sfx is provided choose it. return param->out.sfx; } #if defined (BG_ALBUM_ART) // [ else if (vstream&&!(vstream->disposition&AV_DISPOSITION_ATTACHED_PIC)) { #else // ] [ else if (0<=track->input.vi) { #endif // ] // in case of a video: if (track->input.audio.ctx) { // when transcoding we choose MKV as the container. #if defined (BG_TRACK_AUDIO_SFX) // [ return bg_track_audio_sfx(track,tree,FFL("mkv")); #else // ] [ return FFL("mkv"); #endif // ] } else { // we always remux to mkv. return FFL("mkv"); } #if ! defined (BG_ALBUM_ART) // [ } #else // ] [ } #endif // ] else if (track->input.audio.ctx) { // we always transcode to FLAC. return FFL("flac"); } else { #if defined (BG_TRACK_AUDIO_SFX) // [ return bg_track_audio_sfx(track,tree,FFL("mka")); #else // ] [ // get the suffix from the input. sfx=sp=FFSTRSTR(tree->source.path,FFL(".")); // find the right-most dot '.'. while (sp) { sfx=++sp; sp=FFSTRSTR(sp,FFL(".")); } if (!sfx) return FFL("mka"); else if (!FFSTRCMP(FFL("flac"),sfx)) return sfx; else if (!FFSTRCMP(FFL("wv"),sfx)) return sfx; else if (!FFSTRCMP(FFL("mp3"),sfx)) return sfx; else if (!FFSTRCMP(FFL("ogg"),sfx)) return sfx; else return FFL("mka"); #endif // ] } #endif // ] } #define BG_TRACK_BASENAME_TRACK #if 0 // [ static int bg_track_basename(bg_track_t *track, bg_tree_t *tree, ffchar_t **opath, size_t len) { #if defined (_WIN32) && defined (BG_TRACK_BASENAME_TRACK) // [ enum { TRACK_SIZE=64 }; #endif // ] bg_param_t *param=tree->param; AVDictionary *metadata=track->input.fmt.ctx->metadata; struct { const AVDictionaryEntry *title; #if defined (BG_TRACK_BASENAME_TRACK) // [ const AVDictionaryEntry *track; #endif // ] } tag={ #if 0 // [ .title=av_dict_get(metadata,"TITLE",NULL,AV_DICT_IGNORE_SUFFIX), #if defined (BG_TRACK_BASENAME_TRACK) // [ .track=av_dict_get(metadata,"TRACK",NULL,AV_DICT_IGNORE_SUFFIX), #endif // ] #else // ] [ .title=av_dict_get(metadata,"TITLE",NULL,0), #if defined (BG_TRACK_BASENAME_TRACK) // [ .track=av_dict_get(metadata,"TRACK",NULL,0), #endif // ] #endif // ] }; #if defined (BG_TRACK_ID) // [ int id=tag.track?atoi(tag.track->value):track->album.id; #else // ] [ int id=tag.track?atoi(tag.track->value):-1; #endif // ] #if defined (_WIN32) && ! defined (BG_WIN32_CREATE_LOCALE) // [ const char *locale=NULL; #endif // ] // NOTE: under Linux sizeof(wchar_t) is 4 bytes and under Windows // it is 2 bytes. wchar_t *op; const ffchar_t *ipath,*sfx,*sp; if ((BG_FLAGS_EXT_RENAME¶m->flags.extension)&&tag.title) { #if defined (_WIN32) // [ if (opath) { // swprintf() in any case writes a trailing '\0', hence (1+len). #if defined (BG_TRACK_BASENAME_TRACK) // [ if (0target.pfx.len,L"%02d_",id); else len=0; #else // ] [ swprintf(*opath,1+track->target.pfx.len, track->album.id<100?L"%02lu_":L"%lu_",track->album.id); #endif // ] wcscpy(*opath+track->target.pfx.len,track->target.title); PBU_FREE_GUARDED(track->target.title); track->target.title=NULL; } else { // claculate the length of the intermediate representation. len=MultiByteToWideChar( CP_UTF8, // UINT CodePage, 0ul, // DWORD dwFlags, tag.title->value, // _In_NLS_string_(cbMultiByte)LPCCH lpMultiByteStr, strlen(tag.title->value), // int cbMultiByte, NULL, // LPWSTR lpWideCharStr, 0 // int cchWideChar ); // allocate sufficient memory to hold the intermediate representatiion. track->target.title=malloc((len+1)*sizeof *track->target.title); if (!track->target.title) { _DMESSAGE("allocating intermediate path"); // set error. len=-1; goto e_path; } // transform into the intermediate representation. MultiByteToWideChar( CP_UTF8, // UINT CodePage, 0ul, // DWORD dwFlags, tag.title->value, // _In_NLS_string_(cbMultiByte)LPCCH lpMultiByteStr, strlen(tag.title->value), // int cbMultiByte, track->target.title, // LPWSTR lpWideCharStr, len // int cchWideChar ); // add a trailing '\0' to the intermediate representation. track->target.title[len]=L'\0'; // do some transformations, i.e. replace some characters by '_' // and transform to lower case. op=track->target.title; #if ! defined (BG_WIN32_CREATE_LOCALE) // [ // we need to temporarily switch locale in order that towlower() works // as expected because unfortunately on our system _create_locale() // isn't availabe and hence we have to rely on towlower(). locale=setlocale(LC_ALL,NULL); setlocale(LC_ALL,""); #endif // ] while (*op) { switch (*op) { case L'.': case L',': case L'/': case L'\\': case L'(': case L')': case L'[': case L']': case L'&': case L':': case L' ': case L'?': case L'\'': if (track->target.titleparam->locale); #else // ] [ // our system _create_locale() isn't availabe. *op=towlower(*op); #endif // ] op=CharNextW(op); break; } } // if necessary shorten the intermediate representation. if (track->target.titlealbum.id<100?L"%02lu_":L"%lu_",track->album.id); #endif // ] track->target.pfx.len=len; len+=wcslen(track->target.title); } #else // ] [ if (opath) { // snprintf() in any case writes a trailing '\0', hence (1+len). // I.e. we assume enough memory is allocated for holding a // trailing '\0'. #if defined (BG_TRACK_BASENAME_TRACK) // [ if (0target.pfx.len,"%02d_",id); #else // ] [ snprintf(*opath,1+track->target.pfx.len, track->album.id<100?"%02lu_":"%lu_",track->album.id); #endif // ] // we convert the intermediate representation back into utf-8. wcstombs(*opath+track->target.pfx.len,track->target.title, len-track->target.pfx.len); PBU_FREE_GUARDED(track->target.title); track->target.title=NULL; } else { // calculate the length for holding the intermediate representation. len=mbstowcs(NULL,tag.title->value,0); // allocate sufficient memory in order to hold the intermediate // representation. track->target.title=malloc((len+1)*sizeof track->target.title[0]); if (!track->target.title) { _DMESSAGE("allocating intermediate path"); // set error. len=-1; goto e_path; } // convert the title tag into the intermediate representation // including a trailing '\0'. mbstowcs(track->target.title,tag.title->value,len+1); // do some transformations. op=track->target.title; while (*op) { switch (*op) { case L'.': case L',': case L'/': case L'\\': case L'(': case L')': case L'[': case L']': case L'&': case L':': case L' ': case L'?': case L'\'': if (track->target.titletarget.titlealbum.id<100?"%02lu_":"%lu_",track->album.id); #endif // ] track->target.pfx.len=len; // add the length for holding the title (transformed to lower case.) len+=wcstombs(NULL,track->target.title,0); } #endif // ] } else { if (tree->source.basename) { ipath=tree->source.basename; if (opath) memcpy(*opath,ipath,len*sizeof **opath); else { sfx=NULL; sp=FFSTRSTR(ipath,FFL(".")); while (sp) { sfx=sp; sp=FFSTRSTR(++sp,FFL(".")); } len=sfx?(size_t)(sfx-ipath):FFSTRLEN(ipath); } } else len=0; } e_path: return len; } #else // ] [ #if defined (BG_UTF8_ITER) // [ #if ! defined (_WIN32) // [ #define BG_TITLE_NEXT_UTF8_ITER #endif // ] // TODO: consider // https://www.gnu.org/software/libunistring/manual/libunistring.html #endif // ] #if 0 // [ static int bg_title_next(const char *title, int special) { int len=0; #if defined (BG_TITLE_NEXT_UTF8_ITER) // [ const char *next; size_t size; bg_utf8_iter_t i; #elif defined (_WIN32) // ] [ const char *next; #endif // ] #if ! defined (BG_TITLE_NEXT_UTF8_ITER) // ] [ while (*title) { #else // ] [ size=0; bg_utf8_iter_first(&i,title,NULL,&size); while (i.vmt->valid(&i)) { i.vmt->apply(&i); if (1==size) { #endif // ] switch (*title) { case '.': case ',': case '/': case '\\': case '(': case ')': case '[': case ']': case '&': case ':': case ' ': case '?': case '\'': if (special) return len; break; default: if (!special) return len; break; } #if defined (BG_TITLE_NEXT_UTF8_ITER) // [ } else if (!special) return len; size=0; next=(const char *)i.vmt->next(&i); len+=next-title; title=next; } #else // ] [ #if defined (_WIN32) // [ next=CharNextA(title); len+=next-title; title=next; #else // ] [ ++len; ++title; #endif // ] } #endif // ] return len; } #else // ] [ static int bg_title_next(const char *title, int special) { int len=0; const char *next; while (*title) { next=bg_char_nexta(title); if (1==next-title) { switch (*title) { case '.': case ',': case '/': case '\\': case '(': case ')': case '[': case ']': case '&': case ':': case ' ': case '?': case '\'': if (special) return len; break; default: if (!special) return len; break; } } else if (!special) return len; len+=next-title; title=next; } return len; } #endif // ] static int bg_title_length(char *title, wchar_t *wtitle, size_t leni) { wchar_t *op=wtitle; int leno=0; int next,ch,len; for (;;) { if (!*title) break; /////////////////////////////////////////////////////////////////////////// next=bg_title_next(title,0); title+=next; if (*title) { if (next) { if (wtitle) { *wtitle++=L'_'; *wtitle=L'\0'; --leni; } ++leno; } } else return leno; /////////////////////////////////////////////////////////////////////////// next=bg_title_next(title,1); ch=title[next]; title[next]=0; #if defined (_WIN32) // [ len=MultiByteToWideChar( CP_UTF8, // UINT CodePage, 0ul, // DWORD dwFlags, title, // _In_NLS_string_(cbMultiByte)LPCCH lpMultiByteStr, next, // int cbMultiByte, wtitle, // LPWSTR lpWideCharStr, leni // int cchWideChar ); #else // ] [ len=mbstowcs(wtitle,title,leni); #endif // ] if (wtitle) { wtitle+=len; *wtitle=L'\0'; leni-=len; } leno+=len; title+=next; *title=ch; } if (op) { #if defined (_WIN32) // [ _wcslwr(op); #else // ] [ while (*op) { #if 0 && defined (_WIN32) // [ #if defined (BG_WIN32_CREATE_LOCALE) // [ *op=_towlower_l(*op,tree->param->locale); #else // ] [ // our system _create_locale() isn't availabe. *op=towlower(*op); #endif // ] op=CharNextW(op); #else // ] [ *op=towlower(*op); ++op; #endif // ] } #endif // ] } return leno; } static int bg_track_basename(bg_track_t *track, bg_tree_t *tree, ffchar_t **opath, size_t len) { #if defined (_WIN32) && defined (BG_TRACK_BASENAME_TRACK) // [ enum { TRACK_SIZE=64 }; #endif // ] bg_param_t *param=tree->param; AVDictionary *metadata=track->input.fmt.ctx->metadata; struct { const AVDictionaryEntry *title; #if defined (BG_TRACK_BASENAME_TRACK) // [ const AVDictionaryEntry *track; #endif // ] } tag={ #if 0 // [ .title=av_dict_get(metadata,"TITLE",NULL,AV_DICT_IGNORE_SUFFIX), #if defined (BG_TRACK_BASENAME_TRACK) // [ .track=av_dict_get(metadata,"TRACK",NULL,AV_DICT_IGNORE_SUFFIX), #endif // ] #else // ] [ .title=av_dict_get(metadata,"TITLE",NULL,0), #if defined (BG_TRACK_BASENAME_TRACK) // [ .track=av_dict_get(metadata,"TRACK",NULL,0), #endif // ] #endif // ] }; #if defined (BG_TRACK_ID) // [ int id=tag.track?atoi(tag.track->value):track->album.id; #else // ] [ int id=tag.track?atoi(tag.track->value):-1; #endif // ] #if defined (_WIN32) && ! defined (BG_WIN32_CREATE_LOCALE) // [ const char *locale=NULL; #endif // ] // NOTE: under Linux sizeof(wchar_t) is 4 bytes and under Windows // it is 2 bytes. #if 0 // [ wchar_t *op; #endif // ] const ffchar_t *ipath,*sfx,*sp; if ((BG_FLAGS_EXT_RENAME¶m->flags.extension)&&tag.title) { #if defined (_WIN32) // [ if (opath) { // swprintf() in any case writes a trailing '\0', hence (1+len). #if defined (BG_TRACK_BASENAME_TRACK) // [ if (0target.pfx.len,L"%02d_",id); else len=0; #else // ] [ swprintf(*opath,1+track->target.pfx.len, track->album.id<100?L"%02lu_":L"%lu_",track->album.id); #endif // ] wcscpy(*opath+track->target.pfx.len,track->target.title); PBU_FREE_GUARDED(track->target.title); track->target.title=NULL; } else { // claculate the length of the intermediate representation. len=bg_title_length(tag.title->value,NULL,0); // allocate sufficient memory to hold the intermediate representatiion. track->target.title=malloc((len+1)*sizeof *track->target.title); if (!track->target.title) { _DMESSAGE("allocating intermediate path"); // set error. len=-1; goto e_path; } // transform into the intermediate representation. bg_title_length(tag.title->value,track->target.title,len); #if ! defined (BG_WIN32_CREATE_LOCALE) // [ // we need to switch back locale. setlocale(LC_ALL,locale); #endif // ] #if defined (BG_TRACK_BASENAME_TRACK) // [ if (0album.id<100?L"%02lu_":L"%lu_",track->album.id); #endif // ] track->target.pfx.len=len; len+=wcslen(track->target.title); } #else // ] [ if (opath) { // snprintf() in any case writes a trailing '\0', hence (1+len). // I.e. we assume enough memory is allocated for holding a // trailing '\0'. #if defined (BG_TRACK_BASENAME_TRACK) // [ if (0target.pfx.len,"%02d_",id); #else // ] [ snprintf(*opath,1+track->target.pfx.len, track->album.id<100?"%02lu_":"%lu_",track->album.id); #endif // ] // we convert the intermediate representation back into utf-8. wcstombs(*opath+track->target.pfx.len,track->target.title, len-track->target.pfx.len); PBU_FREE_GUARDED(track->target.title); track->target.title=NULL; } else { // calculate the length for holding the intermediate representation. len=bg_title_length(tag.title->value,NULL,0); // allocate sufficient memory in order to hold the intermediate // representation. track->target.title=malloc((len+1)*sizeof track->target.title[0]); if (!track->target.title) { _DMESSAGE("allocating intermediate path"); // set error. len=-1; goto e_path; } bg_title_length(tag.title->value,track->target.title,len); #if defined (BG_TRACK_BASENAME_TRACK) // [ if (0album.id<100?"%02lu_":"%lu_",track->album.id); #endif // ] track->target.pfx.len=len; // add the length for holding the title (transformed to lower case.) len+=wcstombs(NULL,track->target.title,0); } #endif // ] } else { if (tree->source.basename) { ipath=tree->source.basename; if (opath) memcpy(*opath,ipath,len*sizeof **opath); else { sfx=NULL; sp=FFSTRSTR(ipath,FFL(".")); while (sp) { sfx=sp; sp=FFSTRSTR(++sp,FFL(".")); } len=sfx?(size_t)(sfx-ipath):FFSTRLEN(ipath); } } else len=0; } e_path: return len; } #endif // ] /////////////////////////////////////////////////////////////////////////////// int bg_track_annotation_create(bg_tree_t *tree) { bg_param_t *param=tree->param; bg_track_t *track=&tree->track; bg_tree_t *parent=bg_tree_annotation_parent(tree); size_t len1,len2; // before determining the suffix we need to have the file re-opened. const ffchar_t *sfx; size_t len3; size_t size; ffchar_t *tp; ///////////////////////////////////////////////////////////////////////////// if (param->overwrite) { // including the path separator! #if 0 // [ // pointer arithmetics takes into account the element's size! len1/=sizeof tree->source.path[0]; #else // ] [ len1=tree->source.basename-tree->source.path; #endif // ] len2=bg_track_basename(track,tree,NULL,0); // before determining the suffix we need to have the file re-opened. sfx=bg_track_out_sfx(track,tree); len3=sfx?FFSTRLEN(sfx):0u; size=len1+(len2?len2+1u:0u)+(len3?len3+2u:0u); tree->target.path=tp=malloc(size*sizeof tp[0]); if (!tree->target.path) { _DMESSAGE("allocating output path"); goto e_path; } // we copy the path separator! memcpy(tp,tree->source.path,len1*sizeof tree->source.path[0]); tp+=len1; tree->target.basename=tp; bg_track_basename(track,tree,&tp,len2); tp+=len2; *tp=0; if (sfx) { *tp++=FFL('.'); FFSTRCPY(tp,sfx); tp+=len3; } *tp=0; } else { len1=parent&&parent->target.path?FFSTRLEN(parent->target.path):0u; len2=bg_track_basename(track,tree,NULL,0); // before determining the suffix we need to have the file re-opened. sfx=bg_track_out_sfx(track,tree); len3=sfx?FFSTRLEN(sfx):0u; size=(len1?len1+1u:0u)+(len2?len2+1u:0u)+(len3?len3+2u:0u); tree->target.path=tp=malloc(size*sizeof tp[0]); if (!tree->target.path) { _DMESSAGE("allocating output path"); goto e_path; } if (parent&&parent->target.path) { FFSTRCPY(tp,parent->target.path); tp+=len1; *tp++=FFPATHSEP; } tree->target.basename=tp; bg_track_basename(track,tree,&tp,len2); tp+=len2; *tp=0; if (sfx) { *tp++=FFL('.'); FFSTRCPY(tp,sfx); tp+=len3; } *tp=0; } if (!param->overwrite&&!ff_fcmp(tree->source.path,tree->target.path)) { _DMESSAGE("overwriting not permitted. Use option --overwrite"); goto e_overwrite_target; } ///////////////////////////////////////////////////////////////////////////// len2=FFSTRLEN(param->temp_prefix); tree->temp.path=tp=malloc((size+len2)*sizeof tp[0]); if (!tree->temp.path) { _DMESSAGE("allocating temporary path"); goto e_temp; } memcpy(tp,tree->target.path,len1*sizeof tp[0]); tp+=len1; // Guarding by "len1" proposed by Hadrien Lacour . if (len1&&FFPATHSEP!=tp[-1]) *tp++=FFPATHSEP; tree->temp.basename=tp; FFSTRCPY(tp,param->temp_prefix); tp+=len2; FFSTRCPY(tp,tree->target.basename); ///////////////////////////////////////////////////////////////////////////// if (!ff_fcmp(tree->source.path,tree->temp.path)) { _DMESSAGE("attempt to overwrite source file"); goto e_overwrite_temp; } if (ff_fexists(tree->temp.path)) { #if defined (_WIN32) // [ _DMESSAGEV("file \"%S\" exists; either remove it or by means of" " option --temp-prefix define a prefix for temporary files different" " from \"%S\"", tree->temp.path,param->temp_prefix); #else // ] [ _DMESSAGEV("file \"%s\" exists; either remove it or by means of" " option --temp-prefix define a prefix for temporary files different" " from \"%s\"", tree->temp.path,param->temp_prefix); #endif // ] goto e_temp_exists; } #if defined (_WIN32) // [ // if LANG is set to e.g. "en_US.UTF-8" we assume we're run from // e.g. MSYS2 shell undestanding UTF-8 otherwise from MS console using // codepage OEM. In the latter case we need an OEM representation of // the basename. if (tree->param->oem&&tree->target.basename) { /////////////////////////////////////////////////////////////////////////// track->target.oem.basename=bg_wcs2str(tree->target.basename,CP_OEMCP); if (!track->target.oem.basename) { _DMESSAGE("creating oem basename"); goto e_basename; } } else track->target.oem.basename=NULL; ///////////////////////////////////////////////////////////////////////////// #if defined (BG_WIN32_TARGET_UTF8) // [ track->target.utf8.path=bg_wcs2str(tree->target.path,CP_UTF8); if (!track->target.utf8.path) { _DMESSAGE("creating utf-8 representation of path"); goto e_patha; } track->target.utf8.basename=bg_basenamea(track->target.utf8.path); #else // ] [ track->target.path=bg_wcs2str(tree->target.path,CP_UTF8); if (!track->target.path) { _DMESSAGE("creating utf-8 representation of path"); goto e_patha; } track->target.basename=bg_basenamea(track->target.path); #endif // ] ///////////////////////////////////////////////////////////////////////////// track->temp.path=bg_wcs2str(tree->temp.path,CP_UTF8); if (!track->temp.path) { _DMESSAGE("creating utf-8 representation of temporary path"); goto e_tempa; } #endif // ] return 0; //cleanup: #if defined (_WIN32) // [ PBU_FREE_GUARDED(track->temp.path); e_tempa: #if defined (BG_WIN32_TARGET_UTF8) // [ PBU_FREE_GUARDED(track->target.utf8.path); #else // ] [ PBU_FREE_GUARDED(track->target.path); #endif // ] e_patha: if (track->target.oem.basename) PBU_FREE_GUARDED(track->target.oem.basename); e_basename: #endif // ] e_temp_exists: e_overwrite_temp: PBU_FREE_GUARDED(tree->temp.path); e_temp: e_overwrite_target: PBU_FREE_GUARDED(tree->target.path); e_path: return -1; } FFUNUSED static void bg_PBU_FREE_GUARDED_guarded(void **p) { if (*p) { PBU_FREE_GUARDED(*p); *p=NULL; } } void bg_track_annotation_destroy(bg_tree_t *tree FFUNUSED) { #if defined (_WIN32) // [ bg_track_t *track=&tree->track; PBU_FREE_GUARDED(track->temp.path); #if defined (BG_WIN32_TARGET_UTF8) // [ PBU_FREE_GUARDED(track->target.utf8.path); #else // ] [ PBU_FREE_GUARDED(track->target.path); #endif // ] if (track->target.oem.basename) PBU_FREE_GUARDED(track->target.oem.basename); #endif // ] PBU_FREE_GUARDED(tree->temp.path); PBU_FREE_GUARDED(tree->target.path); } /////////////////////////////////////////////////////////////////////////////// int bg_album_annotation_create(bg_tree_t *tree) { bg_tree_t *parent=bg_tree_annotation_parent(tree); const ffchar_t *basename=tree->source.basename; size_t len1,len2,size; ffchar_t *tp; ///////////////////////////////////////////////////////////////////////////// if (!parent) goto success; if (tree->param->output.dirname) { /////////////////////////////////////////////////////////////////////////// len1=parent&&parent->target.path?FFSTRLEN(parent->target.path):0u; len2=basename?FFSTRLEN(basename):0u; size=(len1?len1+1u:0u)+(len2?len2+1u:0u); /////////////////////////////////////////////////////////////////////////// if (0utarget.path=tp=malloc(size*sizeof tp[0]); if (!tree->target.path) { _DMESSAGE("allocating output path"); goto e_path; } if (parent&&parent->target.path) { FFSTRCPY(tp,parent->target.path); tp+=len1; if (basename) *tp++=FFPATHSEP; else *tp=FFL('\0'); } if (basename) { tree->target.basename=tp; FFSTRCPY(tp,basename); tp+=len2; } else tree->target.basename=NULL; ///////////////////////////////////////////////////////////////////////// if (!tree->param->overwrite&&ff_mkdir(tree->target.path)<0) { _DMESSAGE("creating directory"); goto e_mkdir; } } else { tree->target.basename=NULL; tree->target.path=NULL; } } else { tree->target.basename=NULL; tree->target.path=NULL; } ///////////////////////////////////////////////////////////////////////////// success: return 0; //cleanup: #if 1 // [ e_mkdir: #endif // ] if (tree->target.path) PBU_FREE_GUARDED(tree->target.path); e_path: return -1; } void bg_album_annotation_destroy(bg_tree_t *tree FFUNUSED) { if (tree->target.path) PBU_FREE_GUARDED(tree->target.path); } /////////////////////////////////////////////////////////////////////////////// int bg_root_annotation_create(bg_tree_t *tree) { if (tree->param->output.dirname) { /////////////////////////////////////////////////////////////////////////// tree->target.path=tree->param->output.dirname; if (!tree->param->overwrite&&ff_mkdir(tree->target.path)<0) { ///////////////////////////////////////////////////////////////////////// _DMESSAGE("creating directory"); goto e_mkdir; } tree->target.basename=NULL; } else { tree->target.path=NULL; tree->target.basename=NULL; } ///////////////////////////////////////////////////////////////////////////// return 0; // cleanup: e_mkdir: return -1; } void bg_root_annotation_destroy(bg_tree_t *tree FFUNUSED) { } bs1770gain-0.9.5/libbg/bg_pilot.h0000755000175000017500000000733513671703331012036 /* * bg_pilot.h * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #if ! defined (__BG_PILOT_H__) // [ #define __BG_PILOT_H__ #if defined (_WIN32) // [ #include #else // ] [ #include #endif // ] #include #if defined (__cplusplus) // [ extern "C" { #endif // ] /////////////////////////////////////////////////////////////////////////////// /* * The purpose of this data structure reminds us on De Broglie–Bohm theory's * pilot wave (https://en.wikipedia.org/wiki/De_Broglie–Bohm_theory.) Hence * we called it "pilot". */ typedef const struct bg_pilot_hist_vmt bg_pilot_hist_vmt_t; typedef struct bg_pilot_hist_leaf bg_pilot_hist_leaf_t; typedef struct bg_pilot_hist_branch bg_pilot_hist_branch_t; typedef struct bg_pilot_hist bg_pilot_hist_t; typedef const struct bg_pilot_callback bg_pilot_callback_t; typedef struct bg_pilot_client bg_pilot_client_t; typedef struct bg_pilot bg_pilot_t; /////////////////////////////////////////////////////////////////////////////// struct bg_pilot_hist_vmt { #if defined (PBU_DEBUG) // [ const char *id; #endif // ] void (*destroy)(bg_pilot_hist_t *hist); const ffchar_t *(*first)(bg_pilot_hist_t *hist); const ffchar_t *(*next)(bg_pilot_hist_t *hist); }; //////// struct bg_pilot_hist_leaf { #if defined (_MSC_VER) // [ // just to make msc happy ... int __noop; #endif // ] }; int bg_pilot_hist_leaf_create(bg_pilot_hist_t *hist); //////// struct bg_pilot_hist_branch { #if defined (_WIN32) // [ HANDLE hFind; WIN32_FIND_DATAW e; #else // ] [ DIR *dir; struct dirent *e; #endif // ] }; #if defined (_WIN32) // [ int bg_pilot_hist_branch_create(bg_pilot_hist_t *hist, HANDLE hFind, WIN32_FIND_DATAW *e); #else // ] [ int bg_pilot_hist_branch_create(bg_pilot_hist_t *hist, DIR *dir); #endif // ] //////// struct bg_pilot_hist { bg_pilot_hist_vmt_t *vmt; // common data are ceated (destroyed) in bg_pilot::push (bg_pilot::pop.) [ ffchar_t *path; bg_pilot_t *pilot; void *data; // ] union { bg_pilot_hist_leaf_t leaf; bg_pilot_hist_branch_t branch; }; }; //////// struct bg_pilot_callback { struct { int (*enter)(bg_pilot_hist_t *hist, void *data); void (*leave)(bg_pilot_hist_t *hist, void *data); } leaf; struct { int (*enter)(bg_pilot_hist_t *hist, void *data); void (*leave)(bg_pilot_hist_t *hist, void *data); } branch; }; //////// struct bg_pilot_client { bg_pilot_callback_t *cb; void *data; }; //////// struct bg_pilot { bg_pilot_client_t client; bg_pilot_hist_t *min; bg_pilot_hist_t *nxt; bg_pilot_hist_t *max; }; int bg_pilot_create(bg_pilot_t *pilot, size_t size, bg_pilot_callback_t *cb, void *data); void bg_pilot_destroy(bg_pilot_t *pilot); int bg_pilot_first(bg_pilot_t *pilot, const ffchar_t *path); int bg_pilot_next(bg_pilot_t *pilot, int size); int bg_pilot_loop(bg_pilot_t *pilot, const ffchar_t *path); int bg_pilot_empty(const bg_pilot_t *pilot); #if defined (__cplusplus) // [ } #endif // ] #endif // __BG_PILOT_H__ ] bs1770gain-0.9.5/libbg/bg_tree_patha.c0000755000175000017500000000320313705073066013007 /* * bg_tree_patha.c * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include #if defined (_WIN32) // [ int bg_tree_patha_create(bg_tree_patha_t *p, const wchar_t *path, unsigned int codepage) { if (path) { /////////////////////////////////////////////////////////////////////////// p->path=bg_wcs2str(path,codepage); if (!p->path) { _DMESSAGE("creating utf-8 representation of path"); goto epath; } /////////////////////////////////////////////////////////////////////////// p->basename=bg_basenamea(p->path); } else { p->path=NULL; p->basename=NULL; } ///////////////////////////////////////////////////////////////////////////// return 0; //cleanup: if (p->path) free(p->path); epath: return -1; } void bg_tree_patha_destroy(bg_tree_patha_t *p) { if (p->path) free(p->path); } #endif // ] bs1770gain-0.9.5/libbg/bg_pilot.c0000755000175000017500000001673513705073226012036 /* * bg_pilot.c * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include /////////////////////////////////////////////////////////////////////////////// int bg_pilot_create(bg_pilot_t *pilot, size_t size, bg_pilot_callback_t *cb, void *data) { ///////////////////////////////////////////////////////////////////////////// pilot->client.cb=cb; pilot->client.data=data; ///////////////////////////////////////////////////////////////////////////// pilot->min=malloc(size*sizeof pilot->min[0]); if (!pilot->min) { _DMESSAGE("allocating"); goto e_malloc; } ///////////////////////////////////////////////////////////////////////////// pilot->nxt=pilot->min; pilot->max=pilot->min+size; ///////////////////////////////////////////////////////////////////////////// return 0; //cleanup: free(pilot->min); e_malloc: return -1; } static int bg_pilot_realloc(bg_pilot_t *pilot) { size_t size=pilot->max-pilot->min; size_t offs=pilot->nxt-pilot->min; bg_pilot_hist_t *min; ///////////////////////////////////////////////////////////////////////////// size<<=1; if (!size) { _DMESSAGE("overflow"); goto e_overflow; } ///////////////////////////////////////////////////////////////////////////// min=realloc(pilot->min,size*sizeof min[0]); if (!min) { _DMESSAGE("reallocating"); goto e_realloc; } pilot->min=min; pilot->nxt=min+offs; pilot->max=min+size; ///////////////////////////////////////////////////////////////////////////// return 0; //cleanup: e_realloc: e_overflow: return -1; } void bg_pilot_destroy(bg_pilot_t *pilot) { while (pilot->minnxt) { --pilot->nxt; pilot->nxt->vmt->destroy(pilot->nxt); } free(pilot->min); } /////////////////////////////////////////////////////////////////////////////// #if defined (_WIN32) // [ static wchar_t *pathcpyw(wchar_t *target, const wchar_t *source) { wchar_t *tp=target; while (*source) { switch (*source) { case L'/': *tp++=L'\\'; ++source; break; default: *tp++=*source++; break; } } *tp=0; return target; } #endif // ] static int bg_pilot_push(bg_pilot_t *pilot, const ffchar_t *path) { bg_pilot_hist_t *cur=pilot->minnxt?pilot->nxt-1:NULL; const ffchar_t *root=cur?cur->path:NULL; size_t len1=root?FFSTRLEN(root):0u; size_t len2=path?FFSTRLEN(path):0u; size_t size=(len1?len1+1:0)+(len2?len2+1:0); ffchar_t *pp; #if defined (_WIN32) // [ wchar_t *mask,*mp; HANDLE hFind; WIN32_FIND_DATAW e; #else // ] [ DIR *dir; #endif // ] ///////////////////////////////////////////////////////////////////////////// if (!size) { _DMESSAGE("size"); goto e_size; } ///////////////////////////////////////////////////////////////////////////// if (pilot->max==pilot->nxt&&bg_pilot_realloc(pilot)<0) { _DMESSAGE("reallocating"); goto e_realloc; } cur=pilot->nxt; ++pilot->nxt; ///////////////////////////////////////////////////////////////////////////// cur->path=pp=malloc(size*sizeof cur->path[0]); if (!cur->path) { _DMESSAGE("allocatig path"); goto e_path; } cur->pilot=pilot; #if defined (_WIN32) // [ if (len1) { pathcpyw(pp,root); pp+=len1; if (len2) *pp++=FFPATHSEP; } if (len2) { pathcpyw(pp,path); pp+=len2; } while (cur->pathpath); mp+=wcslen(mask); *mp++=FFPATHSEP; *mp++=L'*'; *mp++=L'\0'; memset(&e,0,sizeof e); hFind=FindFirstFileW(mask,&e); free(mask); if (INVALID_HANDLE_VALUE==hFind) { if (bg_pilot_hist_leaf_create(cur)<0) { _DMESSAGE("creating leaf"); goto e_entry; } } else { if (bg_pilot_hist_branch_create(cur,hFind,&e)<0) { _DMESSAGE("creating branch"); goto e_entry; } } #else // ] [ if (len1) { strcpy(pp,root); pp+=len1; if (len2) *pp++=FFPATHSEP; } if (len2) { strcpy(pp,path); pp+=len2; } while (cur->pathpath); if (dir) { if (bg_pilot_hist_branch_create(cur,dir)<0) { _DMESSAGE("creating branch"); goto e_entry; } } else { if (bg_pilot_hist_leaf_create(cur)<0) { _DMESSAGE("creating leaf"); goto e_entry; } } #endif // ] ///////////////////////////////////////////////////////////////////////////// return 0; //cleanup: e_entry: #if defined (_WIN32) // [ e_mask: #endif // ] if (cur) free(cur->path); e_path: --pilot->nxt; e_realloc: e_size: return -1; } static void bg_pilot_pop(bg_pilot_t *pilot) { bg_pilot_hist_t *cur=pilot->minnxt?pilot->nxt-1:NULL; if (cur) { cur->vmt->destroy(cur); if (cur->path) free(cur->path); --pilot->nxt; } } int bg_pilot_first(bg_pilot_t *pilot, const ffchar_t *path) { int err=-1; bg_pilot_hist_t *cur; ///////////////////////////////////////////////////////////////////////////// do { if (bg_pilot_push(pilot,path)<0) { _DMESSAGE("pushing"); goto e_push; } cur=pilot->nxt-1; path=cur->vmt->first(cur); } while (path); ///////////////////////////////////////////////////////////////////////////// err=0; //cleanup: e_push: return err; } int bg_pilot_next(bg_pilot_t *pilot, int size) { int err=-1; bg_pilot_hist_t *cur; const ffchar_t *entry; ///////////////////////////////////////////////////////////////////////////// while (sizenxt-pilot->min) { cur=pilot->nxt-1; entry=cur->vmt->next(cur); if (entry) { do { if (bg_pilot_push(pilot,entry)<0) { _DMESSAGE("pushing"); goto e_push; } cur=pilot->nxt-1; entry=cur->vmt->first(cur); } while (entry); break; } else bg_pilot_pop(pilot); } ///////////////////////////////////////////////////////////////////////////// err=0; //cleanup: e_push: return err; } int bg_pilot_loop(bg_pilot_t *pilot, const ffchar_t *path) { int err=-1; int size=pilot->nxt-pilot->min; ///////////////////////////////////////////////////////////////////////////// if (bg_pilot_first(pilot,path)<0) { _DMESSAGE("first"); goto e_first; } ///////////////////////////////////////////////////////////////////////////// while (sizenxt-pilot->min) { if (bg_pilot_next(pilot,size)<0) { _DMESSAGE("next"); goto e_next; } } ///////////////////////////////////////////////////////////////////////////// err=0; //cleanup: e_next: e_first: return err; } int bg_pilot_empty(const bg_pilot_t *pilot) { return pilot->min==pilot->nxt; } bs1770gain-0.9.5/libbg/bg_muxer.c0000755000175000017500000006620714441320223012034 /* * bg_muxer.c * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #if defined (_WIN32) // [ #include #else // ] [ #include #include #include #include #endif // ] #include /////////////////////////////////////////////////////////////////////////////// static ff_output_callback_t bg_output_callback; static bg_visitor_vmt_t bg_muxer_vmt; /////////////////////////////////////////////////////////////////////////////// int bg_muxer_create(bg_visitor_t *vis) { ///////////////////////////////////////////////////////////////////////////// vis->vmt=&bg_muxer_vmt; vis->depth=0; ///////////////////////////////////////////////////////////////////////////// return 0; } static void bg_muxer_destroy(bg_visitor_t *vis FFUNUSED) { } /////////////////////////////////////////////////////////////////////////////// static int bg_muxer_copy_file(ffchar_t *source, ffchar_t *target) { int err=-1; #if defined (_WIN32) // [ DeleteFileW(target); CopyFileW( source, // LPCTSTR lpExistingFileName, target, // LPCTSTR lpNewFileName, 0 // BOOL bFailIfExists ); err=0; #else // ] [ // https://stackoverflow.com/questions/2180079/how-can-i-copy-a-file-on-unix-using-c struct { int source,target; } fd; char buf[4096],*bp; ssize_t size,written; fd.source=open(source,O_RDONLY); if (fd.source<0) { #if 0 // [ #if defined (_WIN32) // [ _DMESSAGEV("opening source \"%S\"",source); #else // ] [ _DMESSAGEV("opening source \"%s\"",source); #endif // ] #else // ] [ _DMESSAGEV("opening source \"%" PBU_PRIs "\"",source); #endif // ] goto e_source; } remove(target); fd.target=open(target,O_WRONLY|O_CREAT|O_EXCL,0666); if (fd.target<0) { #if 0 // [ #if defined (_WIN32) // [ _DMESSAGEV("opening target \"%S\"",target); #else // ] [ _DMESSAGEV("opening target \"%s\"",target); #endif // ] #else // ] [ _DMESSAGEV("opening target \"%" PBU_PRIs "\"",target); #endif // ] goto e_target; } for (;;) { size=read(fd.source,buf,sizeof buf); if (size<=0) break; bp=buf; while (0param; if (!(BG_FLAGS_EXT_COPY&tree->param->flags.extension)) goto success; else if (tree->param->overwrite) goto success; // file annotation is created in each case. if (param->output.dirname||param->overwrite) { if (tree->vmt->annotation.create(tree)<0) { _DMESSAGE("annotating"); goto e_annotate; } } if (bg_muxer_copy_file(tree->source.path,tree->temp.path)<0) { _DMESSAGE("copying"); goto e_copy; } ff_mv(tree->temp.path,tree->target.path); ///////////////////////////////////////////////////////////////////////////// success: err=0; //cleanup: e_copy: if (param->output.dirname||param->overwrite) tree->vmt->annotation.destroy(tree); e_annotate: return err; } #endif // ] static int bg_muxer_dispatch_file(bg_visitor_t *vis FFUNUSED, bg_tree_t *tree) { #if defined (BG_PARAM_THREADS) // [ int err=-1; if (tree->param->nthreads) { #if defined (BG_PARAM_SCRIPT) // [ bg_param_threads_visitor_run(&tree->param->threads,tree->param->script, vis,tree,bg_muxer_file); #else // ] [ bg_param_threads_visitor_run(&tree->param->threads,vis,tree, bg_muxer_file); #endif // ] err=0; } else err=bg_muxer_file(tree,vis); return err; #else // ] [ int err=-1; bg_param_t *param=tree->param; if (!(BG_FLAGS_EXT_COPY&tree->param->flags.extension)) goto success; else if (tree->param->overwrite) goto success; // file annotation is created in each case. if (param->output.dirname||param->overwrite) { if (tree->vmt->annotation.create(tree)<0) { _DMESSAGE("annotating"); goto e_annotate; } } if (bg_muxer_copy_file(tree->source.path,tree->temp.path)<0) { _DMESSAGE("copying"); goto e_copy; } ff_mv(tree->temp.path,tree->target.path); ///////////////////////////////////////////////////////////////////////////// success: err=0; //cleanup: e_copy: if (param->output.dirname||param->overwrite) tree->vmt->annotation.destroy(tree); e_annotate: return err; #endif // ] } #if defined (BG_PARAM_THREADS) // [ //#define BG_MUXER_PARENT static int bg_muxer_track(bg_tree_t *tree, bg_visitor_t *vis) { int err=-1; bg_track_t *track=&tree->track; #if defined (BG_MUXER_PARENT) // [ bg_tree_t *parent=tree->parent; #endif // ] bg_param_t *param=tree->param; int apply=BG_FLAGS_MODE_APPLY¶m->flags.mode; #if defined (FF_FLAC_HACK) // [ int hack; AVCodecParameters *codecpar; //enum AVSampleFormat sample_fmt; #endif // ] enum AVSampleFormat sample_fmt; ff_inout_t output; double gain_track,gain_album,gain,volume; char filter[128]={}; ff_muxer_t muxer; ///////////////////////////////////////////////////////////////////////////// ++vis->depth; // [ ///////////////////////////////////////////////////////////////////////////// //_DWRITELNV("\"%s\"",tree->source.path); #if defined (FF_FLAC_HACK) // [ if (ff_input_open_muxer(&track->input,&hack)<0) { _DMESSAGE("re-opening input"); goto e_input; } //fprintf(stderr,"(%s,%d,%s) %d\n",pbu_basename(__FILE__),__LINE__,__func__,hack);fflush(stderr);exit(1); #else // ] [ if (ff_input_open_muxer(&track->input)<0) { _DMESSAGE("re-opening input"); goto e_input; } #endif // ] //_DWRITELNV("\"%s\"",tree->source.path); ///////////////////////////////////////////////////////////////////////////// // track annotation is created in each case. if (param->output.dirname||param->overwrite) { if (tree->vmt->annotation.create(tree)<0) { _DMESSAGE("annotating"); goto e_annotate; } } //_DWRITELNV("\"%s\"",tree->source.path); ///////////////////////////////////////////////////////////////////////////// #if defined (BG_PARAM_QUIET) // [ if (!param->quiet) { #endif // ] #if defined (BG_PARAM_SKIP_SCAN) // [ if (param->skip_scan) _FPRINTFV(stdout,"%s\n",bg_tree_out_basename(tree)); else { #endif // ] _FPRINTFV(stdout,"[%lu/%lu] %s\n",track->root.id,param->count.max, bg_tree_out_basename(tree)); #if defined (BG_PARAM_SKIP_SCAN) // [ } #endif // ] fflush(stdout); #if defined (BG_PARAM_QUIET) // [ } #endif // ] //_DWRITELNV("\"%s\"",tree->source.path); //#if defined (_WIN32) // [ //fprintf(stderr,"\"%S\"\n",tree->source.path); fflush(stderr); //#endif // ] ///////////////////////////////////////////////////////////////////////////// #if defined (FF_FLAC_HACK) // [ codecpar=track->input.fmt.ctx->streams[track->input.ai]->codecpar; sample_fmt=hack?codecpar->format:AV_SAMPLE_FMT_NONE; // as it seems it is impossible to pass through a partial flac stream // (cf. "https://trac.ffmpeg.org/ticket/7864".) our hack consists in // reading/decoding and re-encoding/writing./ hence we've need to tell // the output the format from decoding. //codecpar=track->input.fmt.ctx->streams[track->input.ai]->codecpar; //sample_fmt=hack?codecpar->format:AV_SAMPLE_FMT_NONE; #if defined (FF_INPUT_LIST) // [ err=ff_output_create(&output,&bg_output_callback,tree,sample_fmt, param->process&¶m->list.out); #else // ] [ err=ff_output_create(&output,&bg_output_callback,tree,sample_fmt); #endif // ] if (err<0) { _DMESSAGE("creating output"); goto e_output; } #else // ] [ sample_fmt=AV_SAMPLE_FMT_NONE; if (ff_output_create(&output,&bg_output_callback,tree,sample_fmt)<0) { _DMESSAGE("creating output streams"); goto e_output; } #endif // ] //_DWRITELNV("\"%s\"",tree->source.path); ///////////////////////////////////////////////////////////////////////////// #if defined (FF_FLAC_HACK) // [ apply=apply&&!hack; #endif // ] if (apply) { if (param->weight.enabled) { #if defined (BG_MUXER_PARENT) // [ gain_album=param->norm-lib1770_stats_get_mean(parent->stats.momentary, param->momentary.mean.gate); #else // ] [ gain_album=param->norm-lib1770_stats_get_mean(tree->stats.momentary, param->momentary.mean.gate); #endif // ] gain_track=param->norm-lib1770_stats_get_mean(tree->stats.momentary, param->momentary.mean.gate); gain=gain_album+param->weight.value*(gain_track-gain_album); _DWRITELNV("gain1=%1.2f",gain); } else { #if defined (BG_MUXER_PARENT) // [ gain=param->norm-lib1770_stats_get_mean(parent->stats.momentary, param->momentary.mean.gate); #else // ] [ gain=param->norm-lib1770_stats_get_mean(tree->stats.momentary, param->momentary.mean.gate); #endif // ] _DWRITELNV("gain2=%1.2f",gain); } volume=LIB1770_DB2Q(gain); snprintf(filter,sizeof filter,"volume=%1.2f",volume); fprintf(stderr,"filter:\"%s\"\n",filter);fflush(stderr); } #if 0 // [ _DWRITELNV("\"%" PBU_PRIs "\"",tree->source.path); _DWRITELNV("filter=\"%s\"",filter); #else // ] [ //fprintf(stderr,"filter:\"%s\"\n",filter);fflush(stderr); #endif // ] /////////////////////////////////////////////////////////////////////////// if (ff_muxer_create(&muxer,&track->input,&output,apply?filter:NULL)<0) { _DMESSAGE("creating muxer"); goto e_muxer; } //_DWRITELNV("\"%" PBU_PRIs "\"",tree->source.path); ///////////////////////////////////////////////////////////////////////////// if (ff_muxer_loop(&muxer)<0) { _DMESSAGE("re-encoder looping"); goto e_loop; } //_DWRITELNV("\"%" PBU_PRIs "\"",tree->source.path); ///////////////////////////////////////////////////////////////////////////// err=0; //cleanup: e_loop: //_DWRITELNV("\"%" PBU_PRIs "\"",tree->source.path); ff_muxer_destroy(&muxer); e_muxer: //_DWRITELNV("\"%" PBU_PRIs "\"",tree->source.path); ff_output_destroy(&output); e_output: //_DWRITELNV("\"%" PBU_PRIs "\"",tree->source.path); if (err) ff_rm(tree->temp.path); else { // before moving/renaming the newley created file we first must have // closed the muxer/output/input!!! //_DWRITELNV("\"%" PBU_PRIs "\"",tree->source.path); ff_input_close(&track->input); #if defined (BG_PARAM_SLEEP) // [ if (0sleep) { #if defined (_WIN32) // [ Sleep(param->sleep); #else // ] [ sleep(param->sleep); #endif // ] } #endif // ] //_DWRITELNV("\"%s\"",tree->source.path); err=ff_mv(tree->temp.path,tree->target.path); //_DWRITELNV("\"%s\"",tree->source.path); if (err<0) _DMESSAGE("moving"); } //_DWRITELNV("\"%s\"",tree->source.path); if (param->output.dirname||param->overwrite) tree->vmt->annotation.destroy(tree); e_annotate: //_DWRITELNV("\"%s\"",tree->source.path); ff_input_close(&track->input); e_input: --vis->depth; // ] //_DWRITELNV("\"%s\" err:%d",tree->source.path,err); return err; } #endif // ] static int bg_muxer_dispatch_track(bg_visitor_t *vis FFUNUSED, bg_tree_t *tree) { int err=-1; #if defined (BG_PARAM_THREADS) // [ if (tree->param->nthreads) { #if defined (BG_PARAM_SCRIPT) // [ bg_param_threads_visitor_run(&tree->param->threads,tree->param->script, vis,tree,bg_muxer_track); #else // ] [ bg_param_threads_visitor_run(&tree->param->threads,vis,tree, bg_muxer_track); #endif // ] err=0; } else { #if defined (BG_PARAM_SCRIPT) // [ if (tree->param->script) err=bg_process_tree_run_script(tree); else #endif // ] err=bg_muxer_track(tree,vis); return err; } #else // ] [ bg_track_t *track=&tree->track; bg_tree_t *parent=tree->parent; bg_param_t *param=tree->param; //FILE *f=param->result.f; int apply=BG_FLAGS_MODE_APPLY¶m->flags.mode; #if defined (FF_FLAC_HACK) // [ int hack; AVCodecParameters *codecpar; enum AVSampleFormat sample_fmt; #endif // ] ff_inout_t output; double gain_track,gain_album,gain,volume; char filter[128]; ff_muxer_t muxer; ///////////////////////////////////////////////////////////////////////////// #if defined (FF_FLAC_HACK) // [ if (ff_input_open_muxer(&track->input,&hack)<0) { _DMESSAGE("re-opening input"); goto e_input; } #else // ] [ if (ff_input_open_muxer(&track->input)<0) { _DMESSAGE("re-opening input"); goto e_input; } #endif // ] ///////////////////////////////////////////////////////////////////////////// // track annotation is created in each case. if (param->output.dirname||param->overwrite) { if (tree->vmt->annotation.create(tree)<0) { _DMESSAGE("annotating"); goto e_annotate; } } ///////////////////////////////////////////////////////////////////////////// #if defined (BG_PARAM_QUIET) // [ if (!param->quiet) { #endif // ] #if defined (BG_PARAM_SKIP_SCAN) // [ if (param->skip_scan) fprintf(stdout,"%s\n",bg_tree_out_basename(tree)); else { #endif // ] fprintf(stdout,"[%lu/%lu] %s\n",track->root.id,param->count.max, bg_tree_out_basename(tree)); #if defined (BG_PARAM_SKIP_SCAN) // [ } #endif // ] fflush(stdout); #if defined (BG_PARAM_QUIET) // [ } #endif // ] ///////////////////////////////////////////////////////////////////////////// #if defined (FF_FLAC_HACK) // [ // as it seems it is impossible to pass through a partial flac stream // (cf. "https://trac.ffmpeg.org/ticket/7864".) our hack consists in // reading/decoding and re-encoding/writing./ hence we've need to tell // the output the format from decoding. codecpar=track->input.fmt.ctx->streams[track->input.ai]->codecpar; sample_fmt=hack?codecpar->format:AV_SAMPLE_FMT_NONE; if (ff_output_create(&output,&bg_output_callback,tree,sample_fmt)<0) { _DMESSAGE("creating output"); goto e_output; } #else // ] [ if (ff_output_streams_create(&output)<0) { _DMESSAGE("creating output streams"); goto e_output_streams; } #endif // ] ///////////////////////////////////////////////////////////////////////////// #if defined (FF_FLAC_HACK) // [ apply=apply&&!hack; #endif // ] if (apply) { if (param->weight.enabled) { gain_album=param->norm-lib1770_stats_get_mean(parent->stats.momentary, param->momentary.mean.gate); gain_track=param->norm-lib1770_stats_get_mean(tree->stats.momentary, param->momentary.mean.gate); gain=gain_album+param->weight.value*(gain_track-gain_album); } else { gain=param->norm-lib1770_stats_get_mean(parent->stats.momentary, param->momentary.mean.gate); } volume=LIB1770_DB2Q(gain); snprintf(filter,sizeof filter,"volume=%1.2f",volume); } /////////////////////////////////////////////////////////////////////////// if (ff_muxer_create(&muxer,&track->input,&output,apply?filter:NULL)<0) { _DMESSAGE("creating muxer"); goto e_muxer; } ///////////////////////////////////////////////////////////////////////////// if (ff_muxer_loop(&muxer)<0) { _DMESSAGE("re-encoder looping"); goto e_loop; } ///////////////////////////////////////////////////////////////////////////// err=0; //cleanup: e_loop: ff_muxer_destroy(&muxer); e_muxer: ff_output_destroy(&output); e_output: if (err) ff_rm(tree->temp.path); else { // before moving/renaming the newley created file we first must have // closed the muxer/output/input!!! ff_input_close(&track->input); #if defined (BG_PARAM_SLEEP) // [ if (0sleep) { #if defined (_WIN32) // [ Sleep(param->sleep); #else // ] [ sleep(param->sleep); #endif // ] } #endif // ] err=ff_mv(tree->temp.path,tree->target.path); if (err<0) _DMESSAGE("moving"); } if (param->output.dirname||param->overwrite) tree->vmt->annotation.destroy(tree); e_annotate: ff_input_close(&track->input); e_input: #endif // ] return err; } static int bg_muxer_dispatch_album(bg_visitor_t *vis, bg_tree_t *tree) { int err=-1; bg_tree_t *cur; #if defined (BG_PARAM_THREADS) // [ ///////////////////////////////////////////////////////////////////////////// tree->helper.nchildren=tree->album.nchildren.cur; _DWRITELNV(">>> %u (%u %p)",tree->helper.nchildren,tree->album.nchildren.cur,tree->album.first); #endif // ] ///////////////////////////////////////////////////////////////////////////// for (cur=tree->album.first;cur;cur=cur->next) { #if 0 // [ #if defined (_WIN32) // [ _DWRITELNV(" * \"%S\"",cur->source.path); #else // ] [ _DWRITELNV(" * \"%s\"",cur->source.path); #endif // ] #else // ] [ _DWRITELNV(" * \"%" PBU_PRIs "\"",cur->source.path); #endif // ] if (cur->vmt->accept(cur,vis)<0) { _DMESSAGE("child accepting muxer"); goto e_child; } } #if defined (BG_PARAM_THREADS) // [ ///////////////////////////////////////////////////////////////////////////// if (tree->param->nthreads) { bg_sync_lock(&tree->helper.sync); // { while (tree->helper.nchildren) bg_sync_wait(&tree->helper.sync); bg_sync_unlock(&tree->helper.sync); // } #if defined (BG_VISITOR_NOTIFY_PARENT) // [ if (tree->parent) { bg_sync_lock(&tree->helper.sync); // { bg_sync_signal(&tree->helper.sync); bg_sync_unlock(&tree->helper.sync); // } } #endif // ] } #endif // ] ///////////////////////////////////////////////////////////////////////////// err=0; //cleanup: e_child: return err; } static int bg_muxer_dispatch_root(bg_visitor_t *vis, bg_tree_t *tree) { int err=-1; bg_tree_t *cur; ///////////////////////////////////////////////////////////////////////////// for (cur=tree->album.first;cur;cur=cur->next) { if (cur->vmt->accept(cur,vis)<0) { _DMESSAGE("accepting visitor"); goto e_child; } } ///////////////////////////////////////////////////////////////////////////// err=0; // cleanup: e_child: return err; } static bg_visitor_vmt_t bg_muxer_vmt={ #if defined (PBU_DEBUG) // [ .id="muxer", #endif // ] .destroy=bg_muxer_destroy, .dispatch_file=bg_muxer_dispatch_file, .dispatch_track=bg_muxer_dispatch_track, .dispatch_album=bg_muxer_dispatch_album, .dispatch_root=bg_muxer_dispatch_root, }; /////////////////////////////////////////////////////////////////////////////// enum bg_muxer_tag_bit { BG_MUXER_TAG_BIT_ALGORITHM=1ul<<0ul, BG_MUXER_TAG_BIT_REFERENCE_LOUDNESS=1ul<<1ul, BG_MUXER_TAG_BIT_TRACK_GAIN=1ul<<2ul, BG_MUXER_TAG_BIT_TRACK_PEAK=1ul<<3ul, BG_MUXER_TAG_BIT_ALBUM_GAIN=1ul<<4ul, BG_MUXER_TAG_BIT_ALBUM_PEAK=1ul<<5ul, BG_MUXER_TAG_BIT_MAX=1ul<<6ul, }; #if defined (FF_MUXER_CALLBACK_TAG_BIT_MAX) // [ static unsigned int bg_muxer_tag_bit_max(void *data FFUNUSED) { return BG_MUXER_TAG_BIT_MAX; } #endif // ] static const char *bg_muxer_path(const void *data) { #if defined (_WIN32) // [ return ((const bg_tree_t *)data)->track.temp.path; #else // ] [ return ((const bg_tree_t *)data)->temp.path; #endif // ] } static const ff_analyzer_t *bg_muxer_analyzer(const void *data) { return &((const bg_tree_t *)data)->track.analyzer; } static enum AVSampleFormat bg_muxer_sample_fmt(const void *data FFUNUSED) { return AV_SAMPLE_FMT_S32; } #if defined (_WIN32) // [ #define STRCASECMP(s1,s2) stricmp(s1,s2) #define STRNCASECMP(s1,s2,n) strnicmp(s1,s2,n) #else // ] [ #define STRCASECMP(s1,s2) strcasecmp(s1,s2) #define STRNCASECMP(s1,s2,n) strncasecmp(s1,s2,n) #endif // ] static void bg_tag(void *data, bg_bits_t *bits, const char *key, const char *ivalue, AVDictionary **om) { enum { #if 0 // [ BG_MUXER_FLAGS=AV_DICT_IGNORE_SUFFIX, #else // ] [ BG_MUXER_FLAGS=0, #endif // ] }; bg_tree_t *tree=data; bg_tree_t *parent=tree->parent; bg_param_t *param=tree->param; size_t len=strlen(param->tag.pfx); char ovalue[128]; double gain; if (!key) { _DMESSAGE("missing key"); return; } if (STRNCASECMP(param->tag.pfx,key,len)) { if (!ivalue) { _DMESSAGE("missing value"); return; } // plain copy. av_dict_set(om,key,ivalue,BG_MUXER_FLAGS); } else if (!STRCASECMP(key+len,"ALGORITHM")) { if (!(*bits&BG_MUXER_TAG_BIT_ALGORITHM)) { // modified copy. strncpy(ovalue,"BS.1770",(sizeof ovalue)-1); av_dict_set(om,key,ovalue,BG_MUXER_FLAGS); *bits|=BG_MUXER_TAG_BIT_ALGORITHM; } } else if (!STRCASECMP(key+len,"REFERENCE_LOUDNESS")) { if (!(*bits&BG_MUXER_TAG_BIT_REFERENCE_LOUDNESS)) { // modified copy. snprintf(ovalue,sizeof ovalue,"%1.1f %sFS",param->norm, param->unit->n.lu); av_dict_set(om,key,ovalue,BG_MUXER_FLAGS); *bits|=BG_MUXER_TAG_BIT_REFERENCE_LOUDNESS; } } else if (!STRCASECMP(key+len,"TRACK_GAIN")) { if (BG_FLAGS_MODE_TAGS_TRACK¶m->flags.mode) { if (BG_FLAGS_MODE_APPLY¶m->flags.mode||!tree->stats.momentary) { // suppress. } else if (!(*bits&BG_MUXER_TAG_BIT_TRACK_GAIN)) { // modified copy. gain=param->norm-lib1770_stats_get_mean(tree->stats.momentary, param->momentary.mean.gate); snprintf(ovalue,sizeof ovalue,"%1.1f %s",gain,param->unit->n.lu); av_dict_set(om,key,ovalue,BG_MUXER_FLAGS); *bits|=BG_MUXER_TAG_BIT_TRACK_GAIN; } } } else if (!STRCASECMP(key+len,"TRACK_PEAK")) { if (BG_FLAGS_MODE_TAGS_TRACK¶m->flags.mode) { if ((BG_FLAGS_MODE_APPLY¶m->flags.mode) ||!(BG_FLAGS_AGG_PEAK¶m->flags.aggregate)) { // suppress. } else if (!(*bits&BG_MUXER_TAG_BIT_TRACK_PEAK)) { // modified copy. if (BG_FLAGS_AGG_TRUEPEAK¶m->flags.aggregate) snprintf(ovalue,sizeof ovalue,"%f",tree->stats.truepeak); else snprintf(ovalue,sizeof ovalue,"%f",tree->stats.samplepeak); av_dict_set(om,key,ovalue,BG_MUXER_FLAGS); *bits|=BG_MUXER_TAG_BIT_TRACK_PEAK; } } } else if (!STRCASECMP(key+len,"ALBUM_GAIN")) { if (BG_FLAGS_MODE_TAGS_ALBUM¶m->flags.mode) { if (BG_FLAGS_MODE_APPLY¶m->flags.mode||!parent ||!parent->stats.momentary) { // suppress. } else if (!(*bits&BG_MUXER_TAG_BIT_ALBUM_GAIN)) { // modified copy. gain=param->norm-lib1770_stats_get_mean(parent->stats.momentary, param->momentary.mean.gate); snprintf(ovalue,sizeof ovalue,"%1.1f %s",gain,param->unit->n.lu); av_dict_set(om,key,ovalue,BG_MUXER_FLAGS); *bits|=BG_MUXER_TAG_BIT_ALBUM_GAIN; } } } else if (!STRCASECMP(key+len,"ALBUM_PEAK")) { if (BG_FLAGS_MODE_TAGS_ALBUM¶m->flags.mode) { if ((BG_FLAGS_MODE_APPLY¶m->flags.mode)||!parent ||!(BG_FLAGS_AGG_PEAK¶m->flags.aggregate)) { // suppress. } else if (!(*bits&BG_MUXER_TAG_BIT_ALBUM_PEAK)) { // modified copy. if (BG_FLAGS_AGG_TRUEPEAK¶m->flags.aggregate) snprintf(ovalue,sizeof ovalue,"%f",parent->stats.truepeak); else /*if (BG_FLAGS_AGG_SAMPLEPEAK¶m->flags.aggregate)*/ snprintf(ovalue,sizeof ovalue,"%f",parent->stats.samplepeak); av_dict_set(om,key,ovalue,BG_MUXER_FLAGS); *bits|=BG_MUXER_TAG_BIT_ALBUM_PEAK; } } } else { // suppress. } } #if defined (FF_STREAM_METADATA) // [ static void bg_muxer_metadata(void *data, AVDictionary **om, const AVDictionary *im, ff_metadata_type_t type FFUNUSED) #else // ] [ static void bg_muxer_metadata(void *data, AVDictionary **om, const AVDictionary *im) #endif // ] { bg_param_t *param=((bg_tree_t *)data)->param; size_t len=strlen(param->tag.pfx); const AVDictionaryEntry *opt=NULL; bg_bits_t bits=0ul; char key[128]; #if 0 // [ // it makes no sense to first copy all tags over. for (;;) { opt=av_dict_get(im,"",opt,AV_DICT_IGNORE_SUFFIX); if (!opt) break; bg_tag(data,&bits,opt->key,opt->value,om); } #endif // ] #if defined (FF_STREAM_METADATA) // [ if (FF_METADATA_TYPE_VIDEO!=type) { #endif // ] // set tags with results from analysis. strcpy(key,param->tag.pfx); //if (!(BG_MUXER_TAG_BIT_ALGORITHM&bits)) { strcpy(key+len,"ALGORITHM"); bg_tag(data,&bits,key,NULL,om); //} //if (!(BG_MUXER_TAG_BIT_REFERENCE_LOUDNESS&bits)) { strcpy(key+len,"REFERENCE_LOUDNESS"); bg_tag(data,&bits,key,NULL,om); //} //if (!(BG_MUXER_TAG_BIT_TRACK_GAIN&bits)) { strcpy(key+len,"TRACK_GAIN"); bg_tag(data,&bits,key,NULL,om); //} //if (!(BG_MUXER_TAG_BIT_TRACK_PEAK&bits)) { strcpy(key+len,"TRACK_PEAK"); bg_tag(data,&bits,key,NULL,om); //} //if (!(BG_MUXER_TAG_BIT_ALBUM_GAIN&bits)) { strcpy(key+len,"ALBUM_GAIN"); bg_tag(data,&bits,key,NULL,om); //} //if (!(BG_MUXER_TAG_BIT_ALBUM_PEAK&bits)) { strcpy(key+len,"ALBUM_PEAK"); bg_tag(data,&bits,key,NULL,om); //} #if defined (FF_STREAM_METADATA) // [ } #endif // ] #if 1 // [ // it makes make more sense to copy remaining tags over. for (;;) { opt=av_dict_get(im,"",opt,AV_DICT_IGNORE_SUFFIX); if (!opt) break; bg_tag(data,&bits,opt->key,opt->value,om); } #endif // ] } static enum AVCodecID bg_muxer_codec_id(const void *data, const AVOutputFormat *oformat) { const bg_tree_t *tree=(const bg_tree_t *)data; const bg_param_t *param=tree->param; FF_CONST AVCodec *codec; #if defined (BG_COMPILE_TIME_EXPR) // [ if (*param->codec.name) { #else // ] [ if (param->codec.name&&*param->codec.name) { #endif // ] codec=avcodec_find_encoder_by_name(param->codec.name); if (!codec) { _DWARNINGV("audio codec \"%s\" does not exist;" " falling back to \"FLAC\"",param->codec.name); return AV_CODEC_ID_FLAC; } else if (codec->idcodec.name); return AV_CODEC_ID_FLAC; } else if (AV_CODEC_ID_FIRST_SUBTITLE<=codec->id) { _DWARNINGV("codec \"%s\" is not an audio codec;" " falling back to \"FLAC\"",param->codec.name); return AV_CODEC_ID_FLAC; } else return codec->id; } else { if (!param->out.sfx&&avformat_query_codec(oformat,AV_CODEC_ID_FLAC, FF_COMPLIANCE_EXPERIMENTAL)) { return AV_CODEC_ID_FLAC; } return oformat->audio_codec; } } static ff_output_callback_t bg_output_callback={ .path=bg_muxer_path, .analyzer=bg_muxer_analyzer, .sample_fmt=bg_muxer_sample_fmt, .metadata=bg_muxer_metadata, .codec_id=bg_muxer_codec_id, }; bs1770gain-0.9.5/libbg/bg_parse_time.c0000755000175000017500000000353414701773017013032 /* * bg_parse_time.c * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #if ! defined (_WIN32) // [ #include #endif // ] #include // parse timestamp in AV_TIME_BASE units. int64_t bg_parse_time(const ffchar_t *s) { enum { BASE=AV_TIME_BASE }; int64_t ts=0ll; int64_t num=0ll; int64_t den=1ll; int ncolon=0; for (;*s;++s) { if (FFL(':'==*s)) { if (2==ncolon) { _DMESSAGEV("more than %d colons in timestamp not supported",ncolon); goto exit; } ++ncolon; ts*=60ll; } else if (FFISDIGIT(*s)) { ts*=10ll; ts+=*s-FFL('0'); } #if 0 // [ else { _DMESSAGEV("unexpected character '\\x%x' in timestamp",*s); goto exit; } #else // ] [ else break; #endif // ] } if (FFL('.'==*s)) { for (++s;*s;++s) { if (FFISDIGIT(*s)) { num*=10ll; num+=*s-FFL('0'); den*=10ll; } else { _DMESSAGEV("unexpected character '\\x%x' in timestamp",*s); goto exit; } } } exit: ts*=BASE; ts+=BASE*num/den; return ts; } bs1770gain-0.9.5/libbg/Makefile.am0000755000175000017500000000455114636462747012136 AM_CPPFLAGS= #AM_CPPFLAGS+=-g AM_CPPFLAGS+=-I$(top_srcdir)/libpbutil AM_CPPFLAGS+=-I$(top_srcdir)/libff AM_CPPFLAGS+=-I$(top_srcdir)/lib1770-2 bin_PROGRAMS= bin_PROGRAMS+=bs1770gain bs1770gain_SOURCES=bgx.c #bs1770gain_LDFLAGS= #bs1770gain_LDFLAGS+=-g bs1770gain_LDADD= bs1770gain_LDADD+=libbg.a bs1770gain_LDADD+=$(top_builddir)/libff/libff.a bs1770gain_LDADD+=$(top_builddir)/lib1770-2/lib1770_2.a bs1770gain_LDADD+=$(top_builddir)/libpbutil/libpbutil.a if FF_DYNLOAD nodist_bs1770gain_SOURCES=bg_version.h endif noinst_PROGRAMS= #noinst_PROGRAMS+=pilot #pilot_SOURCES= #pilot_SOURCES+=bg.h #pilot_SOURCES+=bg_pilot.h #pilot_SOURCES+=$(top_srcdir)/libff/ff.h #pilot_SOURCES+=pilot.c #pilot_LDADD= #pilot_LDADD+=libbg.a #pilot_LDADD+=$(top_builddir)/libff/libff.a #pilot_LDADD+=$(top_builddir)/lib1770-2/lib1770_2.a #pilot_LDADD+=$(top_builddir)/libpbutil/libpbutil.a if FF_DYNLOAD noinst_PROGRAMS+=bg_version bg_version_SOURCES=bg_version.c endif noinst_LIBRARIES=libbg.a libbg_a_SOURCES= libbg_a_SOURCES+=$(CONFIG_HEADER) libbg_a_SOURCES+=bg.h libbg_a_SOURCES+=bg_pilot.h libbg_a_SOURCES+=$(top_srcdir)/libff/ff.h libbg_a_SOURCES+=$(top_srcdir)/lib1770-2/lib1770.h libbg_a_SOURCES+=$(top_srcdir)/libpbutil/pbutil.h libbg_a_SOURCES+=$(top_srcdir)/libpbutil/pbutil_priv.h libbg_a_SOURCES+=bg_process.c libbg_a_SOURCES+=bg_sync.c libbg_a_SOURCES+=bg_utf8_iter.c libbg_a_SOURCES+=bg_threads_helper.c libbg_a_SOURCES+=bg_param_threads.c libbg_a_SOURCES+=bg_param.c libbg_a_SOURCES+=bg_print_conf.c libbg_a_SOURCES+=bg_print_csv.c libbg_a_SOURCES+=bg_print_xml.c libbg_a_SOURCES+=bg_print_classic.c libbg_a_SOURCES+=bg_annotator.c libbg_a_SOURCES+=bg_muxer.c libbg_a_SOURCES+=bg_analyzer.c libbg_a_SOURCES+=bg_tree.c libbg_a_SOURCES+=bg_tree_path.c libbg_a_SOURCES+=bg_file.c libbg_a_SOURCES+=bg_track.c libbg_a_SOURCES+=bg_track_target.c libbg_a_SOURCES+=bg_tree_patha.c libbg_a_SOURCES+=bg_album.c libbg_a_SOURCES+=bg_root.c libbg_a_SOURCES+=bg_pilot_branch.c libbg_a_SOURCES+=bg_pilot_leaf.c libbg_a_SOURCES+=bg_pilot.c libbg_a_SOURCES+=bg_basenamea.c libbg_a_SOURCES+=bg_basename.c libbg_a_SOURCES+=bg_wcs2str.c libbg_a_SOURCES+=bg_pathnorm.c libbg_a_SOURCES+=bg_parse_time.c libbg_a_SOURCES+=bg_char_nexta.c if FF_DYNLOAD # https://www.gnu.org/software/automake/manual/html_node/Built-Sources-Example.html BUILT_SOURCES=bg_version.h CLEANFILES=bg_version.h bg_version.h: bg_version ./$< > ./$@ endif bs1770gain-0.9.5/libbg/bg_process.c0000755000175000017500000006647014425114101012352 /* * bg_process.c * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include #if defined (BG_PARAM_SCRIPT) // [ #if defined (_WIN32) // [ #include #include #else // ] [ #include #include #include #endif // ] //#define BG_ENVIR_DEBUG typedef const ffchar_t *ffenvir_t[2]; #if defined (_WIN32) // [ static void path2posix(ffchar_t *p) { while ((p=wcsstr(p,L"\\"))) *p=L'/'; } static size_t envira2envirp(const ffenvir_t *envira, ffchar_t *envirp, int posix) { wchar_t *envir=GetEnvironmentStringsW(),*rp=envir; size_t size=0; size_t size_loop; if (envir) { // for Windows, we need to clone the environment. while (*rp) { size_loop=wcslen(rp)+1; if (envirp) { wcscpy(envirp,rp); envirp+=size_loop; #if defined (BG_ENVIR_DEBUG) // [ envirp[-1]=L'#'; #endif // ] } rp+=size_loop; size+=size_loop*sizeof *envirp; } size+=rp-envir; FreeEnvironmentStringsW(envir); } while ((*envira)[0]) { if ((*envira)[1][0]) { if (envirp) { wcscpy(envirp,(*envira)[0]); envirp+=wcslen(envirp)+1; envirp[-1]=L'='; wcscpy(envirp,(*envira)[1]); if (posix) path2posix(envirp); envirp+=wcslen(envirp)+1; #if defined (BG_ENVIR_DEBUG) // [ envirp[-1]=L'#'; #endif // ] } size_loop=wcslen((*envira)[0])*sizeof *envirp; size_loop+=sizeof *envirp; size_loop=wcslen((*envira)[1])*sizeof *envirp; size_loop+=sizeof *envirp; size+=size_loop; } ++envira; } size+=sizeof *envirp; if (envirp) *envirp++=L'\0'; return size; } #else // ] [ static size_t envira2envirpp(const ffenvir_t *envira, ffchar_t **envirpp) { int size=0; const ffenvir_t *rp=envira; ffchar_t **wpp=envirpp; ffchar_t *wp; while ((*rp)[0]) { if ((*rp)[1]&&wpp) ++wpp; ++rp; } // we need to allocate space for a terminating NULL!!! [ if (wpp) *wpp++=NULL; size+=sizeof wpp; // ] wp=(ffchar_t *)wpp; rp=envira; wpp=envirpp; while ((*rp)[0]) { if ((*rp)[1]) { if (wpp) { *wpp=wp; strcpy(wp,(*rp)[0]); wp+=strlen(wp); *wp++='='; strcpy(wp,(*rp)[1]); wp+=strlen(wp); ++wp; ++wpp; } size+=strlen((*rp)[0]); ++size; size+=strlen((*rp)[1]); ++size; size+=sizeof wpp; } ++rp; } return size; } #endif // ] static int bg_process_muxer_track_annotation_create(bg_tree_t *tree) { int err=-1; #if defined (FF_FLAC_HACK) // [ int hack; #endif // ] if (tree->param->output.dirname||tree->param->overwrite) { #if defined (FF_FLAC_HACK) // [ if (ff_input_open_muxer(&tree->track.input,&hack)<0) { _DMESSAGE("re-opening input"); goto e_input; } #else // ] [ if (ff_input_open_muxer(&tree->track.input)<0) { _DMESSAGE("re-opening input"); goto e_input; } #endif // ] if (tree->vmt->annotation.create(tree)<0) { _DMESSAGE("annotating"); goto e_annotate; } } err=0; e_annotate: ff_input_close(&tree->track.input); e_input: return err; } static void bg_process_muxer_track_annotation_destroy(bg_tree_t *tree) { if (tree->param->output.dirname||tree->param->overwrite) tree->vmt->annotation.destroy(tree); } static void bg_process_muxer_track_comment(bg_tree_t *tree) { bg_param_t *param=tree->param; bg_track_t *track=&tree->track; #if defined (BG_PARAM_QUIET) // [ if (!param->quiet) { #endif // ] #if defined (BG_PARAM_SKIP_SCAN) // [ if (param->skip_scan) fprintf(stdout,"%s\n",bg_tree_out_basename(tree)); else { #endif // ] fprintf(stdout,"[%lu/%lu] %s\n",track->root.id,param->count.max, bg_tree_out_basename(tree)); #if defined (BG_PARAM_SKIP_SCAN) // [ } #endif // ] fflush(stdout); #if defined (BG_PARAM_QUIET) // [ } #endif // ] } #define BG_ENVIR_ALBUM #if defined (_WIN32) // [ static ffchar_t *bg_process_get_envirp(bg_tree_t *tree, int posix) #else // ] [ static ffchar_t **bg_process_get_envirpp(bg_tree_t *tree) #endif // ] { #if defined (BG_ENVIR_ALBUM) // [ bg_tree_t *parent=tree->parent; #endif // ] ffchar_t norm[32]; ///////////////////////////////////////////////////////////////////////////// ffchar_t track_momentary_mean[32]; ffchar_t track_momentary_mean_relative[32]; ffchar_t track_momentary_maximum[32]; ffchar_t track_momentary_maximum_relative[32]; ffchar_t track_momentary_range[32]; //////// ffchar_t track_shortterm_mean[32]; ffchar_t track_shortterm_mean_relative[32]; ffchar_t track_shortterm_maximum[32]; ffchar_t track_shortterm_maximum_relative[32]; ffchar_t track_shortterm_range[32]; ///////////////////////////////////////////////////////////////////////////// ffchar_t track_samplepeak_absolute[32]; ffchar_t track_samplepeak_relative[32]; ffchar_t track_truepeak_absolute[32]; ffchar_t track_truepeak_relative[32]; #if defined (BG_ENVIR_ALBUM) // [ //////// ffchar_t album_momentary_mean[32]; ffchar_t album_momentary_mean_relative[32]; ffchar_t album_momentary_maximum[32]; ffchar_t album_momentary_maximum_relative[32]; ffchar_t album_momentary_range[32]; //////// ffchar_t album_shortterm_mean[32]; ffchar_t album_shortterm_mean_relative[32]; ffchar_t album_shortterm_maximum[32]; ffchar_t album_shortterm_maximum_relative[32]; ffchar_t album_shortterm_range[32]; ///////////////////////////////////////////////////////////////////////////// ffchar_t album_samplepeak_absolute[32]; ffchar_t album_samplepeak_relative[32]; ffchar_t album_truepeak_absolute[32]; ffchar_t album_truepeak_relative[32]; #endif // ] const ffenvir_t envir[]={ {FFL("BS1770GAIN_SOURCE"),tree->source.path}, {FFL("BS1770GAIN_TARGET"),tree->target.path}, //{FFL("BS1770GAIN_TARGET_DIRECTORY"),tree->parent->target.path}, #if defined (_WIN32) // [ {FFL("BS1770GAIN_LU"),bg_print_conf_unit_luw(tree)}, {FFL("BS1770GAIN_LRA"),bg_print_conf_unit_lraw(tree)}, #else // ] [ {FFL("BS1770GAIN_LU"),bg_print_conf_unit_lum(tree)}, {FFL("BS1770GAIN_LRA"),bg_print_conf_unit_lram(tree)}, #endif // ] {FFL("BS1770GAIN_OVERWRITE"),tree->param->overwrite?FFL("yes"):FFL("")}, {FFL("BS1770GAIN_NORM"),norm}, /////////////////////////////////////////////////////////////////////////// {FFL("BS1770GAIN_INTEGRATED"), track_momentary_mean}, {FFL("BS1770GAIN_INTEGRATED_RELATIVE"), track_momentary_mean_relative}, {FFL("BS1770GAIN_MOMENTARY_MEAN"), track_momentary_mean}, {FFL("BS1770GAIN_MOMENTARY_MEAN_RELATIVE"), track_momentary_mean_relative}, {FFL("BS1770GAIN_MOMENTARY_MAXIMUM"), track_momentary_maximum}, {FFL("BS1770GAIN_MOMENTARY_MAXIMUM_RELATIVE"), track_momentary_maximum_relative}, {FFL("BS1770GAIN_MOMENTARY_RANGE"), track_momentary_range}, //////// {FFL("BS1770GAIN_SHORTTERM"), track_shortterm_mean}, {FFL("BS1770GAIN_SHORTTERM_RELATIVE"), track_shortterm_mean_relative}, {FFL("BS1770GAIN_SHORTTERM_MEAN"), track_shortterm_mean}, {FFL("BS1770GAIN_SHORTTERM_MEAN_RELATIVE"), track_shortterm_mean_relative}, {FFL("BS1770GAIN_SHORTTERM_MAXIMUM"), track_shortterm_maximum}, {FFL("BS1770GAIN_SHORTTERM_MAXIMUM_RELATIVE"), track_shortterm_maximum_relative}, {FFL("BS1770GAIN_SHORTTERM_RANGE"), track_shortterm_range}, //////// {FFL("BS1770GAIN_SAMPLEPEAK_ABSOLUTE"), track_samplepeak_absolute}, {FFL("BS1770GAIN_SAMPLEPEAK_RELATIVE"), track_samplepeak_relative}, {FFL("BS1770GAIN_TRUEPEAK_ABSOLUTE"), track_truepeak_absolute}, {FFL("BS1770GAIN_TRUEPEAK_RELATIVE"), track_truepeak_relative}, /////////////////////////////////////////////////////////////////////////// {FFL("BS1770GAIN_TRACK_INTEGRATED"), track_momentary_mean}, {FFL("BS1770GAIN_TRACK_INTEGRATED_RELATIVE"), track_momentary_mean_relative}, {FFL("BS1770GAIN_TRACK_MOMENTARY_MEAN"), track_momentary_mean}, {FFL("BS1770GAIN_TRACK_MOMENTARY_MEAN_RELATIVE"), track_momentary_mean_relative}, {FFL("BS1770GAIN_TRACK_MOMENTARY_MAXIMUM"), track_momentary_maximum}, {FFL("BS1770GAIN_TRACK_MOMENTARY_MAXIMUM_RELATIVE"), track_momentary_maximum_relative}, {FFL("BS1770GAIN_TRACK_MOMENTARY_RANGE"), track_momentary_range}, //////// {FFL("BS1770GAIN_TRACK_SHORTTERM"), track_shortterm_mean}, {FFL("BS1770GAIN_TRACK_SHORTTERM_RELATIVE"), track_shortterm_mean_relative}, {FFL("BS1770GAIN_TRACK_SHORTTERM_MEAN"), track_shortterm_mean}, {FFL("BS1770GAIN_TRACK_SHORTTERM_MEAN_RELATIVE"), track_shortterm_mean_relative}, {FFL("BS1770GAIN_TRACK_SHORTTERM_MAXIMUM"), track_shortterm_maximum}, {FFL("BS1770GAIN_TRACK_SHORTTERM_MAXIMUM_RELATIVE"), track_shortterm_maximum_relative}, {FFL("BS1770GAIN_TRACK_SHORTTERM_RANGE"), track_shortterm_range}, //////// {FFL("BS1770GAIN_TRACK_SAMPLEPEAK_ABSOLUTE"), track_samplepeak_absolute}, {FFL("BS1770GAIN_TRACK_SAMPLEPEAK_RELATIVE"), track_samplepeak_relative}, {FFL("BS1770GAIN_TRACK_TRUEPEAK_ABSOLUTE"), track_truepeak_absolute}, {FFL("BS1770GAIN_TRACK_TRUEPEAK_RELATIVE"), track_truepeak_relative}, #if defined (BG_ENVIR_ALBUM) // [ /////////////////////////////////////////////////////////////////////////// {FFL("BS1770GAIN_ALBUM_INTEGRATED"), album_momentary_mean}, {FFL("BS1770GAIN_ALBUM_INTEGRATED_RELATIVE"), album_momentary_mean_relative}, {FFL("BS1770GAIN_ALBUM_MOMENTARY_MEAN"), album_momentary_mean}, {FFL("BS1770GAIN_ALBUM_MOMENTARY_MEAN_RELATIVE"), album_momentary_mean_relative}, {FFL("BS1770GAIN_ALBUM_MOMENTARY_MAXIMUM"), album_momentary_maximum}, {FFL("BS1770GAIN_ALBUM_MOMENTARY_MAXIMUM_RELATIVE"), album_momentary_maximum_relative}, {FFL("BS1770GAIN_ALBUM_MOMENTARY_RANGE"), album_momentary_range}, //////// {FFL("BS1770GAIN_ALBUM_SHORTTERM"), album_shortterm_mean}, {FFL("BS1770GAIN_ALBUM_SHORTTERM_RELATIVE"), album_shortterm_mean_relative}, {FFL("BS1770GAIN_ALBUM_SHORTTERM_MEAN"), album_shortterm_mean}, {FFL("BS1770GAIN_ALBUM_SHORTTERM_MEAN_RELATIVE"), album_shortterm_mean_relative}, {FFL("BS1770GAIN_ALBUM_SHORTTERM_MAXIMUM"), album_shortterm_maximum}, {FFL("BS1770GAIN_ALBUM_SHORTTERM_MAXIMUM_RELATIVE"), album_shortterm_maximum_relative}, {FFL("BS1770GAIN_ALBUM_SHORTTERM_RANGE"), album_shortterm_range}, //////// {FFL("BS1770GAIN_ALBUM_SAMPLEPEAK_ABSOLUTE"), album_samplepeak_absolute}, {FFL("BS1770GAIN_ALBUM_SAMPLEPEAK_RELATIVE"), album_samplepeak_relative}, {FFL("BS1770GAIN_ALBUM_TRUEPEAK_ABSOLUTE"), album_truepeak_absolute}, {FFL("BS1770GAIN_ALBUM_TRUEPEAK_RELATIVE"), album_truepeak_relative}, #endif // ] /////////////////////////////////////////////////////////////////////////// {NULL,NULL} }; size_t size; #if defined (_WIN32) // [ ffchar_t *envirp; #else // ] [ ffchar_t **envirpp; #endif // ] ///////////////////////////////////////////////////////////////////////////// _SNPRINTF(norm,(sizeof norm)/(sizeof norm[0]),"%0.2lf", bg_print_conf_norm(tree)); ///////////////////////////////////////////////////////////////////////////// if (BG_FLAGS_AGG_MOMENTARY_MEAN&tree->param->flags.aggregate) { size=(sizeof track_momentary_mean)/(sizeof track_momentary_mean[0]); _SNPRINTF(track_momentary_mean,size,"%0.2f", bg_print_conf_momentary_mean(tree)); //////// size=(sizeof track_momentary_mean_relative) /(sizeof track_momentary_mean_relative[0]), _SNPRINTF(track_momentary_mean_relative,size,"%0.2f", bg_print_conf_momentary_mean_relative(tree)); #if defined (BG_ENVIR_ALBUM) // [ /////////////////////////////////////////////////////////////////////////// size=(sizeof album_momentary_mean)/(sizeof album_momentary_mean[0]); _SNPRINTF(album_momentary_mean,size,"%0.2f", bg_print_conf_momentary_mean(parent)); //////// size=(sizeof album_momentary_mean_relative) /(sizeof album_momentary_mean_relative[0]), _SNPRINTF(album_momentary_mean_relative,size,"%0.2f", bg_print_conf_momentary_mean_relative(parent)); #endif // ] } else { size=sizeof track_momentary_mean; memset(track_momentary_mean,0,size); //////// size=sizeof track_momentary_mean_relative; memset(track_momentary_mean_relative,0,size); #if defined (BG_ENVIR_ALBUM) // [ //////// size=sizeof album_momentary_mean; memset(album_momentary_mean,0,size); //////// size=sizeof album_momentary_mean_relative; memset(album_momentary_mean_relative,0,size); #endif // ] } if (BG_FLAGS_AGG_MOMENTARY_MAXIMUM&tree->param->flags.aggregate) { size=(sizeof track_momentary_maximum) /(sizeof track_momentary_maximum[0]); _SNPRINTF(track_momentary_maximum,size,"%0.2f", bg_print_conf_momentary_maximum(tree)); //////// size=(sizeof track_momentary_maximum_relative) /(sizeof track_momentary_maximum_relative[0]), _SNPRINTF(track_momentary_maximum_relative,size,"%0.2f", bg_print_conf_momentary_maximum_relative(tree)); #if defined (BG_ENVIR_ALBUM) // [ //////// size=(sizeof album_momentary_maximum) /(sizeof album_momentary_maximum[0]); _SNPRINTF(album_momentary_maximum,size,"%0.2f", bg_print_conf_momentary_maximum(parent)); //////// size=(sizeof album_momentary_maximum_relative) /(sizeof album_momentary_maximum_relative[0]), _SNPRINTF(album_momentary_maximum_relative,size,"%0.2f", bg_print_conf_momentary_maximum_relative(parent)); #endif // ] } else { size=sizeof track_momentary_maximum; memset(track_momentary_maximum,0,size); //////// size=sizeof track_momentary_maximum_relative; memset(track_momentary_maximum_relative,0,size); #if defined (BG_ENVIR_ALBUM) // [ //////// size=sizeof album_momentary_maximum; memset(album_momentary_maximum,0,size); //////// size=sizeof album_momentary_maximum_relative; memset(album_momentary_maximum_relative,0,size); #endif // ] } if (BG_FLAGS_AGG_MOMENTARY_RANGE&tree->param->flags.aggregate) { size=(sizeof track_momentary_range)/(sizeof track_momentary_range[0]); _SNPRINTF(track_momentary_range,size,"%0.2f", bg_print_conf_momentary_range(tree)); #if defined (BG_ENVIR_ALBUM) // [ //////// size=(sizeof album_momentary_range)/(sizeof album_momentary_range[0]); _SNPRINTF(album_momentary_range,size,"%0.2f", bg_print_conf_momentary_range(parent)); #endif // ] } else { size=sizeof track_momentary_range; memset(track_momentary_range,0,size); #if defined (BG_ENVIR_ALBUM) // [ //////// size=sizeof album_momentary_range; memset(album_momentary_range,0,size); #endif // ] } ///////////////////////////////////////////////////////////////////////////// if (BG_FLAGS_AGG_SHORTTERM_MEAN&tree->param->flags.aggregate) { size=(sizeof track_shortterm_mean)/(sizeof track_shortterm_mean[0]); _SNPRINTF(track_shortterm_mean,size,"%0.2f", bg_print_conf_shortterm_mean(tree)); //////// size=(sizeof track_shortterm_mean_relative) /(sizeof track_shortterm_mean_relative[0]), _SNPRINTF(track_shortterm_mean_relative,size,"%0.2f", bg_print_conf_shortterm_mean_relative(tree)); #if defined (BG_ENVIR_ALBUM) // [ //////// size=(sizeof album_shortterm_mean)/(sizeof album_shortterm_mean[0]); _SNPRINTF(album_shortterm_mean,size,"%0.2f", bg_print_conf_shortterm_mean(parent)); //////// size=(sizeof album_shortterm_mean_relative) /(sizeof album_shortterm_mean_relative[0]), _SNPRINTF(album_shortterm_mean_relative,size,"%0.2f", bg_print_conf_shortterm_mean_relative(parent)); #endif // ] } else { size=sizeof track_shortterm_mean; memset(track_shortterm_mean,0,sizeof track_shortterm_mean); //////// size=sizeof track_shortterm_mean_relative; memset(track_shortterm_mean_relative,0,size); } if (BG_FLAGS_AGG_SHORTTERM_MAXIMUM&tree->param->flags.aggregate) { size=(sizeof track_shortterm_maximum)/(sizeof track_shortterm_maximum[0]), _SNPRINTF(track_shortterm_maximum,size,"%0.2f", bg_print_conf_shortterm_maximum(tree)); //////// size=(sizeof track_shortterm_maximum_relative) /(sizeof *track_shortterm_maximum_relative); _SNPRINTF(track_shortterm_maximum_relative,size,"%0.2f", bg_print_conf_shortterm_maximum_relative(tree)); #if defined (BG_ENVIR_ALBUM) // [ //////// size=(sizeof album_shortterm_maximum)/(sizeof album_shortterm_maximum[0]), _SNPRINTF(album_shortterm_maximum,size,"%0.2f", bg_print_conf_shortterm_maximum(parent)); //////// size=(sizeof album_shortterm_maximum_relative) /(sizeof *album_shortterm_maximum_relative); _SNPRINTF(album_shortterm_maximum_relative,size,"%0.2f", bg_print_conf_shortterm_maximum_relative(parent)); #endif // ] } else { size=sizeof track_shortterm_maximum; memset(track_shortterm_maximum,0,size); //////// size=sizeof track_shortterm_maximum_relative; memset(track_shortterm_maximum_relative,0,size); #if defined (BG_ENVIR_ALBUM) // [ //////// size=sizeof album_shortterm_maximum; memset(album_shortterm_maximum,0,size); //////// size=sizeof album_shortterm_maximum_relative; memset(album_shortterm_maximum_relative,0,size); #endif // ] } if (BG_FLAGS_AGG_SHORTTERM_RANGE&tree->param->flags.aggregate) { size=(sizeof track_shortterm_range)/(sizeof track_shortterm_range[0]); _SNPRINTF(track_shortterm_range,size,"%0.2f", bg_print_conf_shortterm_range(tree)); #if defined (BG_ENVIR_ALBUM) // [ //////// size=(sizeof album_shortterm_range)/(sizeof album_shortterm_range[0]); _SNPRINTF(album_shortterm_range,size,"%0.2f", bg_print_conf_shortterm_range(parent)); #endif // ] } else { size=sizeof track_shortterm_range; memset(track_shortterm_range,0,size); #if defined (BG_ENVIR_ALBUM) // [ //////// size=sizeof album_shortterm_range; memset(album_shortterm_range,0,size); #endif // ] } ///////////////////////////////////////////////////////////////////////////// if (BG_FLAGS_AGG_SAMPLEPEAK&tree->param->flags.aggregate) { size=(sizeof track_samplepeak_absolute) /(sizeof track_samplepeak_absolute[0]); _SNPRINTF(track_samplepeak_absolute,size,"%0.2f", bg_print_conf_samplepeak_absolute(tree)); //////// size=(sizeof track_samplepeak_relative) /(sizeof track_samplepeak_relative[0]); _SNPRINTF(track_samplepeak_relative,size,"%0.2f", bg_print_conf_samplepeak_relative(tree)); #if defined (BG_ENVIR_ALBUM) // [ //////// size=(sizeof album_samplepeak_absolute) /(sizeof album_samplepeak_absolute[0]); _SNPRINTF(album_samplepeak_absolute,size,"%0.2f", bg_print_conf_samplepeak_absolute(parent)); //////// size=(sizeof album_samplepeak_relative) /(sizeof album_samplepeak_relative[0]); _SNPRINTF(album_samplepeak_relative,size,"%0.2f", bg_print_conf_samplepeak_relative(parent)); #endif // ] } else { size=sizeof track_samplepeak_absolute; memset(track_samplepeak_absolute,0,sizeof track_samplepeak_absolute); //////// size=sizeof track_samplepeak_relative; memset(track_samplepeak_relative,0,sizeof track_samplepeak_relative); #if defined (BG_ENVIR_ALBUM) // [ //////// size=sizeof album_samplepeak_absolute; memset(album_samplepeak_absolute,0,sizeof album_samplepeak_absolute); //////// size=sizeof album_samplepeak_relative; memset(album_samplepeak_relative,0,sizeof album_samplepeak_relative); #endif // ] } if (BG_FLAGS_AGG_TRUEPEAK&tree->param->flags.aggregate) { size=(sizeof track_truepeak_absolute) /(sizeof track_truepeak_absolute[0]); _SNPRINTF(track_truepeak_absolute,size,"%0.2f", bg_print_conf_truepeak_absolute(tree)); //////// size=(sizeof track_truepeak_relative) /(sizeof track_truepeak_relative[0]); _SNPRINTF(track_truepeak_relative,size,"%0.2f", bg_print_conf_truepeak_relative(tree)); #if defined (BG_ENVIR_ALBUM) // [ //////// size=(sizeof album_truepeak_absolute) /(sizeof album_truepeak_absolute[0]); _SNPRINTF(album_truepeak_absolute,size,"%0.2f", bg_print_conf_truepeak_absolute(parent)); //////// size=(sizeof album_truepeak_relative) /(sizeof album_truepeak_relative[0]); _SNPRINTF(album_truepeak_relative,size,"%0.2f", bg_print_conf_truepeak_relative(parent)); #endif // ] } else { size=sizeof track_truepeak_absolute; memset(track_truepeak_absolute,0,size); //////// size=sizeof track_truepeak_relative; memset(track_truepeak_relative,0,size); #if defined (BG_ENVIR_ALBUM) // [ //////// size=sizeof album_truepeak_absolute; memset(album_truepeak_absolute,0,size); //////// size=sizeof album_truepeak_relative; memset(album_truepeak_relative,0,size); #endif // ] } #if defined (_WIN32) // [ size=envira2envirp(envir,NULL,posix); if (!size||!(envirp=malloc(size))) { _DMESSAGE("allocating envirp"); goto e_envirp_alloc; } if (envira2envirp(envir,envirp,posix)!=size) { _DMESSAGE("initilizing envirp"); goto e_envirp_init; } return envirp; e_envirp_init: free(envirp); e_envirp_alloc: #else // ] [ size=envira2envirpp(envir,NULL); if (!size||!(envirpp=malloc(size))) { _DMESSAGE("allocating envirpp"); goto e_envirpp_alloc; } if (envira2envirpp(envir,envirpp)!=size) { _DMESSAGE("initilizing envirpp"); goto e_envirpp_init; } return envirpp; e_envirpp_init: free(envirpp); e_envirpp_alloc: #endif // ] return NULL; } static int _bg_process_tree_run_script(bg_tree_t *tree) { #if defined (_WIN32) // [ static const wchar_t CMD_EXEC[]=L"C:\\Windows\\system32\\cmd.exe /C "; static const wchar_t CMD_CALL[]=L"C:\\Windows\\system32\\cmd.exe /C call "; #endif // ] int err=-1; bg_param_t *param=tree->param; #if defined (_WIN32) // [ struct _stat buf; const wchar_t *CMD; STARTUPINFOW startup_info; PROCESS_INFORMATION process_info; wchar_t *cmd,*wp; ffchar_t *envirp=NULL; int bRes; #if defined (BG_PARAM_SHELL) // [ int posix; #endif // ] memset(&startup_info,0,sizeof startup_info); startup_info.cb=sizeof startup_info; memset(&process_info,0,sizeof process_info); #if defined (BG_PARAM_SHELL) // [ if (param->shell.interpreter) { posix=1; wp=cmd=malloc((wcslen(param->shell.interpreter) +1 +wcslen(param->shell.parameter) +1 +1+wcslen(param->script)+1)*sizeof *cmd); if (!cmd) { DMESSAGE("allocating cmd"); goto e_cmd; } wcscpy(wp,param->shell.interpreter); wp+=wcslen(wp); *wp++=L' '; wcscpy(wp,param->shell.parameter); wp+=wcslen(wp); *wp++=L' '; *wp++=L'"'; wcscpy(wp,param->script); path2posix(wp); wp+=wcslen(wp); *wp++=L'"'; *wp=L'\0'; } else { #endif // ] posix=0; CMD=_wstat(param->script,&buf)?CMD_EXEC:CMD_CALL; wp=cmd=malloc((wcslen(CMD)+wcslen(param->script)+2)*sizeof *cmd); if (!cmd) { DMESSAGE("allocating cmd"); goto e_cmd; } wcscpy(wp,CMD); wp+=wcslen(wp); *wp++=L'"'; wcscpy(wp,param->script); wp+=wcslen(wp); *wp++=L'"'; *wp=L'\0'; #if defined (BG_PARAM_SHELL) // [ } #endif // ] if (!(envirp=bg_process_get_envirp(tree,posix))) { _DMESSAGE("creating envirp"); goto e_envirp; } #if defined (BG_ENVIR_DEBUG) // [ _DWRITELNV("envirp:\"%" PBU_PRIs "\"",envirp); exit(1); #endif // ] for (;;) { bRes=CreateProcessW( NULL, // LPCWSTR lpApplicationName, cmd, // LPWSTR lpCommandLine, NULL, // LPSECURITY_ATTRIBUTES lpProcessAttributes, NULL, // LPSECURITY_ATTRIBUTES lpThreadAttributes, TRUE, // BOOL bInheritHandles, CREATE_UNICODE_ENVIRONMENT, // DWORD dwCreationFlags, envirp, // LPVOID lpEnvironment, NULL, // LPCWSTR lpCurrentDirectory, &startup_info, // LPSTARTUPINFOW lpStartupInfo, &process_info // LPPROCESS_INFORMATION lpProcessInformation ); if (bRes) { DWORD dwExitCode; WaitForSingleObject(process_info.hProcess,INFINITE); GetExitCodeProcess(process_info.hProcess,&dwExitCode); //_WRITELNV("dwExitCode:%lu",dwExitCode); CloseHandle(process_info.hProcess); CloseHandle(process_info.hThread); bg_process_muxer_track_comment(tree); free(envirp); if (!dwExitCode) { err=0; break; } } else { _DMESSAGE("creating process"); free(envirp); break; } //cleanup: e_envirp: free(cmd); e_cmd: #else // ] [ for (;;) { pid_t pid=fork(); if (pid<0) { // something went wrong. _DMESSAGE("forking"); break; } else if (0shell.interpreter,param->shell.parameter, param->script,NULL}; #else // ] [ char *argv[]={"/bin/sh","-c",param->script,NULL}; #endif // ] ffchar_t **envirpp; if (!(envirpp=bg_process_get_envirpp(tree))) { _DMESSAGE("creating envirpp"); goto e_envirpp; } err=execve(argv[0],argv,envirpp); // we should never go here ... free(envirpp); e_envirpp: _exit(EXIT_FAILURE); } } #endif // ] #if defined (_WIN32) // [ } #endif // ] return err; } int bg_process_tree_run_script(bg_tree_t *tree) { int err=-1; if (!tree->param->script) { _DMESSAGE("missing script"); goto e_script; } if (BG_TREE_TYPE_TRACK!=tree->vmt->type) { _DMESSAGEV("attempt to run script on \"%s\"",tree->vmt->id); goto e_type; } if (tree->param->script) { if (bg_process_muxer_track_annotation_create(tree)<0) { _DMESSAGE("annotating"); goto e_annotate; } err=_bg_process_tree_run_script(tree); bg_process_muxer_track_annotation_destroy(tree); e_annotate: ; } e_type: e_script: return err; } #endif // ] bs1770gain-0.9.5/libbg/bg_tree.c0000755000175000017500000002251614624041523011634 /* * bg_tree.c * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include /////////////////////////////////////////////////////////////////////////////// int bg_tree_common_create(bg_tree_t *tree, bg_param_t *param, bg_tree_t *parent, const ffchar_t *path) { ///////////////////////////////////////////////////////////////////////////// memset(tree,0,sizeof *tree); ///////////////////////////////////////////////////////////////////////////// tree->vmt=NULL; tree->param=param; tree->argv=param->argv.cur; tree->parent=parent; tree->depth=parent?1u+parent->depth:0u; tree->next=NULL; tree->prev=NULL; ///////////////////////////////////////////////////////////////////////////// if (bg_tree_source_create(&tree->source,path)<0) { _DMESSAGE("creating source path"); goto e_path; } #if defined (_WIN32) // [ // if LANG is set to e.g. "en_US.UTF-8" we assume we're run from // e.g. MSYS2 shell undestanding UTF-8 otherwise from MS console using // codepage OEM. In the latter case we need an OEM representation of // the basename. if (param->oem&&tree->source.basename) { tree->oem.basename=bg_wcs2str(tree->source.basename,CP_OEMCP); if (!tree->oem.basename) { _DMESSAGE("creating oem basename"); goto e_basename; } } else tree->oem.basename=NULL; // in any case we need an utf-8 representation of path (end basaname.) if (bg_tree_patha_create(&tree->utf8,tree->source.path,CP_UTF8)<0) { _DMESSAGE("creating patha"); goto e_patha; } #endif // ] ///////////////////////////////////////////////////////////////////////////// if (bg_tree_stats_create(tree)<0) { _DMESSAGE("creating stats"); goto e_stats; } #if defined (BG_PARAM_THREADS) // [ if (param->nthreads&&bg_threads_helper_create(&tree->helper)<0) { _DMESSAGE("creating threads"); goto e_threads; } #endif // ] ///////////////////////////////////////////////////////////////////////////// return 0; //cleanup: #if defined (BG_PARAM_THREADS) // [ if (param->nthreads) bg_threads_helper_destroy(&tree->helper); e_threads: #endif // ] bg_tree_stats_destroy(tree); e_stats: #if defined (_WIN32) // [ bg_tree_patha_destroy(&tree->utf8); e_patha: if (tree->oem.basename) free(tree->oem.basename); e_basename: #endif // ] bg_tree_path_destroy(&tree->source); e_path: return -1; } void bg_tree_common_destroy(bg_tree_t *tree) { #if defined (BG_PARAM_THREADS) // [ if (tree->param->nthreads) bg_threads_helper_destroy(&tree->helper); #endif // ] bg_tree_stats_destroy(tree); #if defined (_WIN32) // [ bg_tree_patha_destroy(&tree->utf8); if (tree->oem.basename) free(tree->oem.basename); #endif // ] bg_tree_path_destroy(&tree->source); } int bg_tree_stats_create(bg_tree_t *tree) { bg_param_t *param=tree->param; if (param->process) { /////////////////////////////////////////////////////////////////////////// if (BG_FLAGS_AGG_MOMENTARY¶m->flags.aggregate) { tree->stats.momentary=lib1770_stats_new(); if (!tree->stats.momentary) { _DMESSAGE("creating momentary statistics"); goto emomentary; } } else tree->stats.momentary=NULL; /////////////////////////////////////////////////////////////////////////// if (BG_FLAGS_AGG_SHORTTERM¶m->flags.aggregate) { tree->stats.shortterm=lib1770_stats_new(); if (!tree->stats.shortterm) { _DMESSAGE("creating shortterm statistics"); goto eshortterm; } } else tree->stats.shortterm=NULL; } else { tree->stats.momentary=NULL; tree->stats.shortterm=NULL; } tree->stats.samplepeak=0.0; tree->stats.truepeak=0.0; return 0; //cleanup: if (tree->stats.shortterm) lib1770_stats_close(tree->stats.shortterm); eshortterm: if (tree->stats.momentary) lib1770_stats_close(tree->stats.momentary); emomentary: return -1; } void bg_tree_stats_destroy(bg_tree_t *tree) { if (tree->stats.shortterm) { lib1770_stats_close(tree->stats.shortterm); tree->stats.shortterm=NULL; } if (tree->stats.momentary) { lib1770_stats_close(tree->stats.momentary); tree->stats.momentary=NULL; } } int bg_leaf_create(bg_tree_t **tree, bg_param_t *param, bg_tree_t *parent, const ffchar_t *path) { ///////////////////////////////////////////////////////////////////////////// *tree=malloc(sizeof **tree); if (!*tree) { #if defined (BG_TREE_CREATE_CHILD_WARNING) // [ _DWARNING("allocating tree"); #endif // ] goto e_malloc; } ///////////////////////////////////////////////////////////////////////////// if (bg_tree_common_create(*tree,param,parent,path)<0) { #if defined (BG_TREE_CREATE_CHILD_WARNING) // [ _DWARNING("creating tree"); #endif // ] goto e_common; } ///////////////////////////////////////////////////////////////////////////// if (0<=bg_track_content_create(*tree)) { ; } else if (!param->overwrite &&(BG_FLAGS_EXT_COPY¶m->flags.extension) &&0<=bg_file_content_create(*tree)) { ; } else { #if defined (BG_TREE_CREATE_CHILD_WARNING) // [ #if defined (_WIN32) // [ _DWARNING("creating leaf \"%S\"",(*tree)->path.source); #else // ] [ _DWARNING("creating leaf \"%s\"",(*tree)->path.source); #endif // ] #endif // ] goto e_child; } if (parent&&bg_album_push(parent,*tree)<0) { _DMESSAGE("pushing"); goto e_push; } ///////////////////////////////////////////////////////////////////////////// return 0; //cleanup: if (parent) bg_album_pop(parent); e_push: e_child: bg_tree_common_destroy(*tree); e_common: free(*tree); *tree=NULL; e_malloc: return -1; } double *bg_tree_samplepeak(bg_tree_t *tree) { return tree->param->flags.aggregate&BG_FLAGS_AGG_SAMPLEPEAK ?&tree->stats.samplepeak:NULL; } double *bg_tree_truepeak(bg_tree_t *tree) { return tree->param->flags.aggregate&BG_FLAGS_AGG_TRUEPEAK ?&tree->stats.truepeak:NULL; } int bg_tree_merge(bg_tree_t *lhs, const bg_tree_t *rhs) { bg_flags_agg_t aggregate=lhs->param->flags.aggregate; if (aggregate!=rhs->param->flags.aggregate) { _DMESSAGE("trying to merge incompatible trees"); goto emerge; } if (BG_TREE_TYPE_FILE==lhs->vmt->type||BG_TREE_TYPE_FILE==rhs->vmt->type) goto success; if (lhs->param->process) { #if 1 // [ if (0!=(BG_FLAGS_AGG_MOMENTARY&aggregate)) lib1770_stats_merge(lhs->stats.momentary,rhs->stats.momentary); if (0!=(BG_FLAGS_AGG_SHORTTERM&aggregate)) lib1770_stats_merge(lhs->stats.shortterm,rhs->stats.shortterm); if (0!=(BG_FLAGS_AGG_SAMPLEPEAK&aggregate)) { if (lhs->stats.samplepeakstats.samplepeak) lhs->stats.samplepeak=rhs->stats.samplepeak; } if (0!=(BG_FLAGS_AGG_TRUEPEAK&aggregate)) { if (lhs->stats.truepeakstats.truepeak) lhs->stats.truepeak=rhs->stats.truepeak; } #else // ] [ if (lhs->stats.momentary&&rhs->stats.momentary) lib1770_stats_merge(lhs->stats.momentary,rhs->stats.momentary); if (lhs->stats.shortterm&&rhs->stats.shortterm) lib1770_stats_merge(lhs->stats.shortterm,rhs->stats.shortterm); if (0!=(BG_FLAGS_AGG_SAMPLEPEAK&aggregate)) { if (lhs->stats.samplepeakstats.samplepeak) lhs->stats.samplepeak=rhs->stats.samplepeak; } if (0!=(BG_FLAGS_AGG_TRUEPEAK&aggregate)) { if (lhs->stats.truepeakstats.truepeak) lhs->stats.truepeak=rhs->stats.truepeak; } #endif // ] } success: return 0; emerge: return -1; } #if defined (_WIN32) // [ const char *bg_tree_in_basename(bg_tree_t *tree) { #if 0 // [ fprintf(stdout,"oem: %d %p (%s:%d:%s)\n",tree->param->oem,tree->oem.basename, __FILE__,__LINE__,__func__); fflush(stdout); #endif // ] return tree->oem.basename?tree->oem.basename:tree->utf8.basename; } const wchar_t *bg_tree_in_basenamew(bg_tree_t *tree) { return tree->source.basename; } const char *bg_tree_out_basename(bg_tree_t *tree) { bg_track_t *track=&tree->track; // just needed for tracks. if (BG_TREE_TYPE_TRACK!=tree->vmt->type) { _DMESSAGEV("unexpected tree type %d",tree->vmt->type); return ""; } else { #if defined (BG_WIN32_TARGET_UTF8) // [ return track->target.oem.basename ?track->target.oem.basename:track->target.utf8.basename; #else // ] [ return track->target.oem.basename ?track->target.oem.basename:track->target.basename; #endif // ] } } const wchar_t *bg_tree_out_basanamew(bg_tree_t *tree) { return tree->target.basename; } #else // ] [ const char *bg_tree_in_basename(bg_tree_t *tree) { return tree->source.basename; } const char *bg_tree_out_basename(bg_tree_t *tree) { return tree->target.basename; } #endif // ] bs1770gain-0.9.5/libbg/bg_track.c0000755000175000017500000003037614626255305012013 /* * bg_track.c * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include #if 1 // { #if defined (FF_BITMASK_BASED_CHANNEL_LAYOUT) // [ #undef FF_BITMASK_BASED_CHANNEL_LAYOUT #endif // ] #if defined (FF_HOLZHAMMER) // [ #undef FF_HOLZHAMMER #endif // ] #endif // } #if defined (FF_HOLZHAMMER) // { FF_DISABLE_DEPRECATION_WARNINGS // [ #endif // } /////////////////////////////////////////////////////////////////////////////// static bg_tree_vmt_t bg_track_vmt; static ff_input_callback_t bg_input_callback; int bg_track_content_create(bg_tree_t *tree) { int err=-1; bg_param_t *param=tree->param; ff_printer_t *p=¶m->printer; bg_track_t *track=&tree->track; ///////////////////////////////////////////////////////////////////////////// #if 0 // [ // DON'T do this!!! bg_track_create() is called from bg_child_create() // which in front already has called bg_tree_common_create() and just // leaves us with setting the vmt! if (bg_tree_common_create(tree,param,param,path,&bg_track_vmt)<0) { _DMESSAGE("creating tree"); goto etree; } #else // ] [ tree->vmt=&bg_track_vmt; #endif // ] ///////////////////////////////////////////////////////////////////////////// memset(&track->input,0,sizeof track->input); memset(&track->analyzer,0,sizeof track->analyzer); track->target.title=NULL; ///////////////////////////////////////////////////////////////////////////// #if defined (BG_TREE_CREATE_CHILD_WARNING) // [ #if defined (FF_SERGEY_INDEX_BUGFIX) // [ err=ff_input_create(&track->input,&bg_input_callback,tree,1,param->ai, param->vi); #else // ] [ err=ff_input_create(&track->input,&bg_input_callback,tree,1); #endif // ] if (err<0) { #if defined (_WIN32) // [ _DWARNINGV("opening track \"%S\"",pathw); #else // ] [ _DWARNINGV("opening track \"%s\"",path); #endif // ] goto e_input; } #else // ] [ #if defined (FF_SERGEY_INDEX_BUGFIX) // [ #if defined (FF_INPUT_LIST) // [ err=ff_input_create(&track->input,&bg_input_callback,tree,0,p, param->process&¶m->list.in,param->ai,param->vi); #else // ] [ err=ff_input_create(&track->input,&bg_input_callback,tree,0,p,param->ai); #endif // ] #else // ] [ #if defined (FF_INPUT_LIST) // [ err=ff_input_create(&track->input,&bg_input_callback,tree,0,p, param->process&¶m->list.in); #else // ] [ err=ff_input_create(&track->input,&bg_input_callback,tree,0,p); #endif // ] #endif // ] if (err<0) goto e_input; #endif // ] ///////////////////////////////////////////////////////////////////////////// #if defined (FF_BITMASK_BASED_CHANNEL_LAYOUT) // [ if (!track->input.audio.ctx->channel_layout) { _DMESSAGE("missing input channel layout"); goto e_channel_layout; } #else // ] [ if (!track->input.audio.ctx->ch_layout.nb_channels) { _DMESSAGE("missing input channel layout"); goto e_channel_layout; } #endif // ] ///////////////////////////////////////////////////////////////////////////// track->root.id=++param->count.cur; ///////////////////////////////////////////////////////////////////////////// #if defined (BG_PARAM_QUIET) // [ if (!param->quiet&&!param->process&&!param->suppress.progress) { #else // ] [ if (!param->process&&!param->suppress.progress) { #endif // ] #if defined (FF_PROGRESS_STDERR) // [ ff_printer_reset(p,stderr); #else // ] [ ff_printer_reset(p); #endif // ] _FF_PRINTER_PRINTF(p,"%d",track->root.id); #if ! defined (BG_PARAM_QUIET) // [ } #else // ] [ } #endif // ] ++tree->parent->album.nleafs; ff_input_close(&track->input); return 0; //cleanup: e_channel_layout: ff_input_destroy(&track->input); e_input: return err; } /////////////////////////////////////////////////////////////////////////////// static void bg_track_destroy(bg_tree_t *tree) { bg_param_t *param=tree->param; bg_track_t *track=&tree->track; if (tree->parent) bg_album_pop(tree->parent); if (!param->process) tree->argv->lift=tree->depth; track->input.cb.in->stats.destroy(tree); ff_input_destroy(&track->input); bg_tree_common_destroy(tree); free(tree); } static int bg_track_accept(bg_tree_t *tree, bg_visitor_t *vis) { return vis->vmt->dispatch_track(vis,tree); } #if defined (BG_TRACK_ID) // [ static void bg_track_track_id(bg_tree_t *tree, int *id) { if (id) tree->track.album.id=++*id; } #endif // ] static bg_tree_vmt_t bg_track_vmt={ #if defined (PBU_MESSAGE_AV_LOG) // [ .id="track", #else // ] [ .id=FFL("track"), #endif // ] .type=BG_TREE_TYPE_TRACK, .destroy=bg_track_destroy, .accept=bg_track_accept, .annotation={ .create=bg_track_annotation_create, .destroy=bg_track_annotation_destroy, }, #if defined (BG_TRACK_ID) // [ .track_id=bg_track_track_id, #endif // ] }; /////////////////////////////////////////////////////////////////////////////// static const char *input_path(const void *data) { #if defined (_WIN32) // [ return ((const bg_tree_t *)data)->utf8.path; #else // ] [ return ((const bg_tree_t *)data)->source.path; #endif // ] } #if defined (_WIN32) // [ static const wchar_t *input_pathw(const void *data) { return ((const bg_tree_t *)data)->source.path; } #endif // ] static const ff_param_decode_t *input_decode(const void *data) { return &((const bg_tree_t *)data)->param->decode; } static int input_upsample(const void *data) { const bg_tree_t *tree=data; return BG_FLAGS_AGG_TRUEPEAK&tree->param->flags.aggregate?4:0; } static int input_transcode(const void *data) { return BG_FLAGS_MODE_APPLY&((const bg_tree_t *)data)->param->flags.mode; } static int input_csv(const void *data) { return BG_FLAGS_EXT_CSV&((const bg_tree_t *)data)->param->flags.extension; } static int input_suppress_progress(const void *data) { #if defined (BG_PARAM_QUIET) // [ bg_param_t *param=((const bg_tree_t *)data)->param; return param->quiet||param->suppress.progress; #else // ] [ return ((const bg_tree_t *)data)->param->suppress.progress; #endif // ] } static int64_t input_interval_begin(const void *data) { const bg_param_t *param=((const bg_tree_t *)data)->param; return param->interval.begin; } static int64_t input_interval_duration(const void *data) { const bg_param_t *param=((const bg_tree_t *)data)->param; return param->interval.duration; } static int input_stats_create(void *data, const AVCodecParameters *codecpar) { bg_tree_t *tree=data; bg_track_t *track=&tree->track; #if defined (FF_BITMASK_BASED_CHANNEL_LAYOUT) // [ int channels=codecpar->channelschannels :codecpar->channels-1; #else // ] [ int channels=codecpar->ch_layout.nb_channelsch_layout.nb_channels :codecpar->ch_layout.nb_channels-1; #endif // ] ///////////////////////////////////////////////////////////////////////////// if (tree->stats.momentary||tree->stats.shortterm) { track->filter.pre=lib1770_pre_new(codecpar->sample_rate,channels); if (!track->filter.pre) { _DMESSAGE("creating pre-filter"); goto epre; } } ///////////////////////////////////////////////////////////////////////////// if (tree->stats.momentary) { track->block.momentary=lib1770_block_new(codecpar->sample_rate, tree->param->momentary.ms,tree->param->momentary.partition); if (!track->block.momentary) { _DMESSAGE("creating momentary block"); goto emomentary; } lib1770_block_add_stats(track->block.momentary,tree->stats.momentary); lib1770_pre_add_block(track->filter.pre,track->block.momentary); } else track->block.momentary=NULL; ///////////////////////////////////////////////////////////////////////////// if (tree->stats.shortterm) { track->block.shortterm=lib1770_block_new(codecpar->sample_rate, tree->param->shortterm.ms,tree->param->shortterm.partition); if (!track->block.shortterm) { _DMESSAGE("creating shortterm block"); goto eshortterm; } lib1770_block_add_stats(track->block.shortterm,tree->stats.shortterm); lib1770_pre_add_block(track->filter.pre,track->block.shortterm); } else track->block.shortterm=NULL; ///////////////////////////////////////////////////////////////////////////// return 0; //cleanup: if (track->block.shortterm) lib1770_block_close(track->block.shortterm); eshortterm: if (track->block.momentary) lib1770_block_close(track->block.momentary); emomentary: if (track->filter.pre) lib1770_pre_close(track->filter.pre); epre: return -1; } static void input_stats_destroy(void *data) { bg_track_t *track=&((bg_tree_t *)data)->track; if (track->block.shortterm) lib1770_block_close(track->block.shortterm); if (track->block.momentary) lib1770_block_close(track->block.momentary); if (track->filter.pre) lib1770_pre_close(track->filter.pre); } static int input_stats_add(void *data FFUNUSED, int upsampled FFUNUSED, AVFrame *frame FFUNUSED) { bg_tree_t *tree=data; bg_track_t *track=&tree->track; lib1770_sample_t sample={ 0 }; ff_iter_t i={ 0 }; #if defined (BG_SAMPLES_COUNT) // [ int count=0; #endif // ] if (frame) { for (ff_iter_first(&i,frame);i.vmt->valid(&i);i.vmt->next(&i)) { //DWRITELN("{"); if (upsampled) { #if defined (BG_SAMPLES_COUNT) // [ if (countparam->upsampler.threshould) { ++count; continue; } #endif // ] #if defined (FF_UPSAMPLE_MODIFYX) // [ i.vmt->norm(&i,NULL,&tree->stats.truepeak,upsampled); #else // ] [ i.vmt->norm(&i,NULL,&tree->stats.truepeak); #endif // ] //DVWRITELN("peak: %lf",tree->stats.truepeak); } else if (track->filter.pre) { //DWRITELN(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); #if defined (FF_UPSAMPLE_MODIFYX) // [ i.vmt->norm(&i,sample,&tree->stats.samplepeak,upsampled); #else // ] [ i.vmt->norm(&i,sample,&tree->stats.samplepeak); #endif // ] //DWRITELN("================================================"); lib1770_pre_add_sample(track->filter.pre,sample); //DWRITELN("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); } else { #if defined (FF_UPSAMPLE_MODIFYX) // [ i.vmt->norm(&i,NULL,&tree->stats.samplepeak,0); #else // ] [ i.vmt->norm(&i,NULL,&tree->stats.samplepeak); #endif // ] } //DWRITELN("}"); } } #if ! defined (FF_INPUT_CALLBACK_FLUSH) // [ #if defined (FF_UPSAMPLE_MODIFY) // [ else if (upsampled) tree->stats.truepeak*=upsampled; else lib1770_pre_flush(track->filter.pre); #else // ] [ else if (!upsampled&&track->filter.pre) lib1770_pre_flush(track->filter.pre); #endif // ] #endif // ] return 0; } #if defined (FF_INPUT_CALLBACK_FLUSH) // [ static int input_stats_flush(void *data, int upsampled) { bg_tree_t *tree=data; bg_track_t *track=&tree->track; #if defined (FF_UPSAMPLE_MODIFY) // [ if (upsampled) tree->stats.truepeak*=upsampled; else lib1770_pre_flush(track->filter.pre); else #else // ] [ if (!upsampled&&track->filter.pre) lib1770_pre_flush(track->filter.pre); #endif // ] return 0; } #endif // ] static ff_input_callback_t bg_input_callback={ .path=input_path, #if defined (_WIN32) // [ .pathw=input_pathw, #endif // ] .decode=input_decode, .upsample=input_upsample, .transcode=input_transcode, .csv=input_csv, .suppress_progress=input_suppress_progress, .interval.begin=input_interval_begin, .interval.duration=input_interval_duration, .stats.create=input_stats_create, .stats.destroy=input_stats_destroy, .stats.add=input_stats_add, #if defined (FF_INPUT_CALLBACK_FLUSH) // [ .stats.flush=input_stats_flush, #endif // ] }; #if defined (FF_HOLZHAMMER) // { FF_ENABLE_DEPRECATION_WARNINGS // ] #endif // } bs1770gain-0.9.5/libbg/Makefile.in0000664000175000017500000006763114710620513012132 # 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@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = bs1770gain$(EXEEXT) noinst_PROGRAMS = $(am__EXEEXT_1) #noinst_PROGRAMS+=pilot #pilot_SOURCES= #pilot_SOURCES+=bg.h #pilot_SOURCES+=bg_pilot.h #pilot_SOURCES+=$(top_srcdir)/libff/ff.h #pilot_SOURCES+=pilot.c #pilot_LDADD= #pilot_LDADD+=libbg.a #pilot_LDADD+=$(top_builddir)/libff/libff.a #pilot_LDADD+=$(top_builddir)/lib1770-2/lib1770_2.a #pilot_LDADD+=$(top_builddir)/libpbutil/libpbutil.a @FF_DYNLOAD_TRUE@am__append_1 = bg_version subdir = libbg ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" @FF_DYNLOAD_TRUE@am__EXEEXT_1 = bg_version$(EXEEXT) PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) LIBRARIES = $(noinst_LIBRARIES) ARFLAGS = cru AM_V_AR = $(am__v_AR_@AM_V@) am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) am__v_AR_0 = @echo " AR " $@; am__v_AR_1 = libbg_a_AR = $(AR) $(ARFLAGS) libbg_a_LIBADD = am__objects_1 = am_libbg_a_OBJECTS = $(am__objects_1) bg_process.$(OBJEXT) \ bg_sync.$(OBJEXT) bg_utf8_iter.$(OBJEXT) \ bg_threads_helper.$(OBJEXT) bg_param_threads.$(OBJEXT) \ bg_param.$(OBJEXT) bg_print_conf.$(OBJEXT) \ bg_print_csv.$(OBJEXT) bg_print_xml.$(OBJEXT) \ bg_print_classic.$(OBJEXT) bg_annotator.$(OBJEXT) \ bg_muxer.$(OBJEXT) bg_analyzer.$(OBJEXT) bg_tree.$(OBJEXT) \ bg_tree_path.$(OBJEXT) bg_file.$(OBJEXT) bg_track.$(OBJEXT) \ bg_track_target.$(OBJEXT) bg_tree_patha.$(OBJEXT) \ bg_album.$(OBJEXT) bg_root.$(OBJEXT) bg_pilot_branch.$(OBJEXT) \ bg_pilot_leaf.$(OBJEXT) bg_pilot.$(OBJEXT) \ bg_basenamea.$(OBJEXT) bg_basename.$(OBJEXT) \ bg_wcs2str.$(OBJEXT) bg_pathnorm.$(OBJEXT) \ bg_parse_time.$(OBJEXT) bg_char_nexta.$(OBJEXT) libbg_a_OBJECTS = $(am_libbg_a_OBJECTS) am__bg_version_SOURCES_DIST = bg_version.c @FF_DYNLOAD_TRUE@am_bg_version_OBJECTS = bg_version.$(OBJEXT) bg_version_OBJECTS = $(am_bg_version_OBJECTS) bg_version_LDADD = $(LDADD) am_bs1770gain_OBJECTS = bgx.$(OBJEXT) nodist_bs1770gain_OBJECTS = bs1770gain_OBJECTS = $(am_bs1770gain_OBJECTS) \ $(nodist_bs1770gain_OBJECTS) bs1770gain_DEPENDENCIES = libbg.a $(top_builddir)/libff/libff.a \ $(top_builddir)/lib1770-2/lib1770_2.a \ $(top_builddir)/libpbutil/libpbutil.a 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)/bg_album.Po \ ./$(DEPDIR)/bg_analyzer.Po ./$(DEPDIR)/bg_annotator.Po \ ./$(DEPDIR)/bg_basename.Po ./$(DEPDIR)/bg_basenamea.Po \ ./$(DEPDIR)/bg_char_nexta.Po ./$(DEPDIR)/bg_file.Po \ ./$(DEPDIR)/bg_muxer.Po ./$(DEPDIR)/bg_param.Po \ ./$(DEPDIR)/bg_param_threads.Po ./$(DEPDIR)/bg_parse_time.Po \ ./$(DEPDIR)/bg_pathnorm.Po ./$(DEPDIR)/bg_pilot.Po \ ./$(DEPDIR)/bg_pilot_branch.Po ./$(DEPDIR)/bg_pilot_leaf.Po \ ./$(DEPDIR)/bg_print_classic.Po ./$(DEPDIR)/bg_print_conf.Po \ ./$(DEPDIR)/bg_print_csv.Po ./$(DEPDIR)/bg_print_xml.Po \ ./$(DEPDIR)/bg_process.Po ./$(DEPDIR)/bg_root.Po \ ./$(DEPDIR)/bg_sync.Po ./$(DEPDIR)/bg_threads_helper.Po \ ./$(DEPDIR)/bg_track.Po ./$(DEPDIR)/bg_track_target.Po \ ./$(DEPDIR)/bg_tree.Po ./$(DEPDIR)/bg_tree_path.Po \ ./$(DEPDIR)/bg_tree_patha.Po ./$(DEPDIR)/bg_utf8_iter.Po \ ./$(DEPDIR)/bg_version.Po ./$(DEPDIR)/bg_wcs2str.Po \ ./$(DEPDIR)/bgx.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libbg_a_SOURCES) $(bg_version_SOURCES) \ $(bs1770gain_SOURCES) $(nodist_bs1770gain_SOURCES) DIST_SOURCES = $(libbg_a_SOURCES) $(am__bg_version_SOURCES_DIST) \ $(bs1770gain_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AVCODEC_SO = @AVCODEC_SO@ AVFILTER_SO = @AVFILTER_SO@ AVFORMAT_SO = @AVFORMAT_SO@ AVUTIL_SO = @AVUTIL_SO@ AWK = @AWK@ BS1770GAIN_LDFLAGS = @BS1770GAIN_LDFLAGS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FFMPEG_PREFIX = @FFMPEG_PREFIX@ FF_AVCODEC_V = @FF_AVCODEC_V@ FF_AVFILTER_V = @FF_AVFILTER_V@ FF_AVFORMAT_V = @FF_AVFORMAT_V@ FF_AVUTIL_V = @FF_AVUTIL_V@ FF_POSTPROC_V = @FF_POSTPROC_V@ FF_SWRESAMPLE_V = @FF_SWRESAMPLE_V@ FF_SWSCALE_V = @FF_SWSCALE_V@ GETOPTW_PREFIX = @GETOPTW_PREFIX@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ POSTPROC_SO = @POSTPROC_SO@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SODIR = @SODIR@ STRIP = @STRIP@ SWRESAMPLE_SO = @SWRESAMPLE_SO@ SWSCALE_SO = @SWSCALE_SO@ 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@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ #AM_CPPFLAGS+=-g AM_CPPFLAGS = -I$(top_srcdir)/libpbutil -I$(top_srcdir)/libff \ -I$(top_srcdir)/lib1770-2 bs1770gain_SOURCES = bgx.c #bs1770gain_LDFLAGS= #bs1770gain_LDFLAGS+=-g bs1770gain_LDADD = libbg.a $(top_builddir)/libff/libff.a \ $(top_builddir)/lib1770-2/lib1770_2.a \ $(top_builddir)/libpbutil/libpbutil.a @FF_DYNLOAD_TRUE@nodist_bs1770gain_SOURCES = bg_version.h @FF_DYNLOAD_TRUE@bg_version_SOURCES = bg_version.c noinst_LIBRARIES = libbg.a libbg_a_SOURCES = $(CONFIG_HEADER) bg.h bg_pilot.h \ $(top_srcdir)/libff/ff.h $(top_srcdir)/lib1770-2/lib1770.h \ $(top_srcdir)/libpbutil/pbutil.h \ $(top_srcdir)/libpbutil/pbutil_priv.h bg_process.c bg_sync.c \ bg_utf8_iter.c bg_threads_helper.c bg_param_threads.c \ bg_param.c bg_print_conf.c bg_print_csv.c bg_print_xml.c \ bg_print_classic.c bg_annotator.c bg_muxer.c bg_analyzer.c \ bg_tree.c bg_tree_path.c bg_file.c bg_track.c \ bg_track_target.c bg_tree_patha.c bg_album.c bg_root.c \ bg_pilot_branch.c bg_pilot_leaf.c bg_pilot.c bg_basenamea.c \ bg_basename.c bg_wcs2str.c bg_pathnorm.c bg_parse_time.c \ bg_char_nexta.c # https://www.gnu.org/software/automake/manual/html_node/Built-Sources-Example.html @FF_DYNLOAD_TRUE@BUILT_SOURCES = bg_version.h @FF_DYNLOAD_TRUE@CLEANFILES = bg_version.h all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libbg/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign libbg/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): install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p \ ; then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' \ -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' \ `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) clean-noinstPROGRAMS: -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libbg.a: $(libbg_a_OBJECTS) $(libbg_a_DEPENDENCIES) $(EXTRA_libbg_a_DEPENDENCIES) $(AM_V_at)-rm -f libbg.a $(AM_V_AR)$(libbg_a_AR) libbg.a $(libbg_a_OBJECTS) $(libbg_a_LIBADD) $(AM_V_at)$(RANLIB) libbg.a bg_version$(EXEEXT): $(bg_version_OBJECTS) $(bg_version_DEPENDENCIES) $(EXTRA_bg_version_DEPENDENCIES) @rm -f bg_version$(EXEEXT) $(AM_V_CCLD)$(LINK) $(bg_version_OBJECTS) $(bg_version_LDADD) $(LIBS) bs1770gain$(EXEEXT): $(bs1770gain_OBJECTS) $(bs1770gain_DEPENDENCIES) $(EXTRA_bs1770gain_DEPENDENCIES) @rm -f bs1770gain$(EXEEXT) $(AM_V_CCLD)$(LINK) $(bs1770gain_OBJECTS) $(bs1770gain_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_album.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_analyzer.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_annotator.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_basename.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_basenamea.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_char_nexta.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_file.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_muxer.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_param.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_param_threads.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_parse_time.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_pathnorm.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_pilot.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_pilot_branch.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_pilot_leaf.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_print_classic.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_print_conf.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_print_csv.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_print_xml.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_process.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_root.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_sync.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_threads_helper.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_track.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_track_target.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_tree.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_tree_path.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_tree_patha.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_utf8_iter.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_version.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_wcs2str.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bgx.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` 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: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-am all-am: Makefile $(PROGRAMS) $(LIBRARIES) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) install-am install-exec: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-am clean-am: clean-binPROGRAMS clean-generic clean-noinstLIBRARIES \ clean-noinstPROGRAMS mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/bg_album.Po -rm -f ./$(DEPDIR)/bg_analyzer.Po -rm -f ./$(DEPDIR)/bg_annotator.Po -rm -f ./$(DEPDIR)/bg_basename.Po -rm -f ./$(DEPDIR)/bg_basenamea.Po -rm -f ./$(DEPDIR)/bg_char_nexta.Po -rm -f ./$(DEPDIR)/bg_file.Po -rm -f ./$(DEPDIR)/bg_muxer.Po -rm -f ./$(DEPDIR)/bg_param.Po -rm -f ./$(DEPDIR)/bg_param_threads.Po -rm -f ./$(DEPDIR)/bg_parse_time.Po -rm -f ./$(DEPDIR)/bg_pathnorm.Po -rm -f ./$(DEPDIR)/bg_pilot.Po -rm -f ./$(DEPDIR)/bg_pilot_branch.Po -rm -f ./$(DEPDIR)/bg_pilot_leaf.Po -rm -f ./$(DEPDIR)/bg_print_classic.Po -rm -f ./$(DEPDIR)/bg_print_conf.Po -rm -f ./$(DEPDIR)/bg_print_csv.Po -rm -f ./$(DEPDIR)/bg_print_xml.Po -rm -f ./$(DEPDIR)/bg_process.Po -rm -f ./$(DEPDIR)/bg_root.Po -rm -f ./$(DEPDIR)/bg_sync.Po -rm -f ./$(DEPDIR)/bg_threads_helper.Po -rm -f ./$(DEPDIR)/bg_track.Po -rm -f ./$(DEPDIR)/bg_track_target.Po -rm -f ./$(DEPDIR)/bg_tree.Po -rm -f ./$(DEPDIR)/bg_tree_path.Po -rm -f ./$(DEPDIR)/bg_tree_patha.Po -rm -f ./$(DEPDIR)/bg_utf8_iter.Po -rm -f ./$(DEPDIR)/bg_version.Po -rm -f ./$(DEPDIR)/bg_wcs2str.Po -rm -f ./$(DEPDIR)/bgx.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/bg_album.Po -rm -f ./$(DEPDIR)/bg_analyzer.Po -rm -f ./$(DEPDIR)/bg_annotator.Po -rm -f ./$(DEPDIR)/bg_basename.Po -rm -f ./$(DEPDIR)/bg_basenamea.Po -rm -f ./$(DEPDIR)/bg_char_nexta.Po -rm -f ./$(DEPDIR)/bg_file.Po -rm -f ./$(DEPDIR)/bg_muxer.Po -rm -f ./$(DEPDIR)/bg_param.Po -rm -f ./$(DEPDIR)/bg_param_threads.Po -rm -f ./$(DEPDIR)/bg_parse_time.Po -rm -f ./$(DEPDIR)/bg_pathnorm.Po -rm -f ./$(DEPDIR)/bg_pilot.Po -rm -f ./$(DEPDIR)/bg_pilot_branch.Po -rm -f ./$(DEPDIR)/bg_pilot_leaf.Po -rm -f ./$(DEPDIR)/bg_print_classic.Po -rm -f ./$(DEPDIR)/bg_print_conf.Po -rm -f ./$(DEPDIR)/bg_print_csv.Po -rm -f ./$(DEPDIR)/bg_print_xml.Po -rm -f ./$(DEPDIR)/bg_process.Po -rm -f ./$(DEPDIR)/bg_root.Po -rm -f ./$(DEPDIR)/bg_sync.Po -rm -f ./$(DEPDIR)/bg_threads_helper.Po -rm -f ./$(DEPDIR)/bg_track.Po -rm -f ./$(DEPDIR)/bg_track_target.Po -rm -f ./$(DEPDIR)/bg_tree.Po -rm -f ./$(DEPDIR)/bg_tree_path.Po -rm -f ./$(DEPDIR)/bg_tree_patha.Po -rm -f ./$(DEPDIR)/bg_utf8_iter.Po -rm -f ./$(DEPDIR)/bg_version.Po -rm -f ./$(DEPDIR)/bg_wcs2str.Po -rm -f ./$(DEPDIR)/bgx.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: all check install install-am install-exec install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-binPROGRAMS clean-generic clean-noinstLIBRARIES \ clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \ distclean-compile distclean-generic distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-binPROGRAMS install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am uninstall-binPROGRAMS .PRECIOUS: Makefile @FF_DYNLOAD_TRUE@bg_version.h: bg_version @FF_DYNLOAD_TRUE@ ./$< > ./$@ # 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: bs1770gain-0.9.5/libbg/bg_char_nexta.c0000755000175000017500000000311013705073523013002 /* * charnexta.c * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include #if defined (BG_CHAR_NEXTA) // [ enum { // cf. e.g. "https://en.wikipedia.org/wiki/UTF-8#Description". MASK_ONE_BYTE=~(1u<<7u), MASK_TWO_BYTES=~(1u<<5u), MASK_THREE_BYTES=~(1u<<4u), MASK_FOUR_BYTES=~(1u<<3u), }; const char *bg_char_nexta(const char *str) { if (*(const uint8_t *)str==(MASK_ONE_BYTE&*(const uint8_t *)str)) return str+1; else if (*(const uint8_t *)str==(MASK_TWO_BYTES&*(const uint8_t *)str)) return str+2; else if (*(const uint8_t *)str==(MASK_THREE_BYTES&*(const uint8_t *)str)) return str+3; else if (*(const uint8_t *)str==(MASK_FOUR_BYTES&*(const uint8_t *)str)) return str+4; else { _DMESSAGEV("unexpected byte: %02x",*str); exit(1); return NULL; } } #endif // ] bs1770gain-0.9.5/libbg/bg_print_classic.c0000755000175000017500000001643113747505257013547 /* * bg_print_classic.c * * Copyright (C) 2014 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include static void bg_print_classic_indent(FILE *f, int width) { enum { SIZE=128 }; union { #if defined (_WIN32) // [ // wide string representation. wchar_t w[SIZE]; #endif // ] // narrow string representation. char n[SIZE]; } format; width+=2; // indentation. #if defined (_WIN32) // [ if (stdout!=f&&stderr!=f) { _snwprintf(format.w,SIZE,L"%%%ds",width); fwprintf(f,format.w,L""); } else { #endif // ] snprintf(format.n,SIZE,"%%%ds",width); fprintf(f,format.n,""); #if defined (_WIN32) // [ } #endif // ] } static void bg_print_conf_tail(bg_print_conf_t *c, bg_tree_t *tree FFUNUSED, int width FFUNUSED, FILE *f FFUNUSED) { switch (c->argc) { case 1: if (c->argv[0].fn) { #if defined (_WIN32) // [ if (stdout!=f&&stderr!=f) { bg_print_classic_indent(f,width-wcslen(c->w.label.classic)); fwprintf(f,L"%S: ",c->w.label.classic); fwprintf(f,c->argv[0].w.format,c->argv[0].fn(tree)); fputwc(L' ',f); bg_print_conf_unitw(f,0,c,tree->param,0); fputwc(L'\n',f); } else { #endif // ] bg_print_classic_indent(f,width-strlen(c->n.label.classic)); fprintf(f,"%s: ",c->n.label.classic); fprintf(f,c->argv[0].n.format,c->argv[0].fn(tree)); fputc(' ',f); bg_print_conf_unit(f,0,c,tree->param,0); fputc('\n',f); #if defined (_WIN32) // [ } #endif // ] } else _DWARNING("argv[0]"); break; case 2: if (c->argv[0].fn&&c->argv[1].fn) { #if defined (_WIN32) // [ if (stdout!=f&&stderr!=f) { bg_print_classic_indent(f,width-wcslen(c->w.label.classic)); fwprintf(f,L"%S: ",c->w.label); fwprintf(f,c->argv[0].w.format,c->argv[0].fn(tree)); fputwc(L' ',f); bg_print_conf_unitw(f,0,c,tree->param,0); fwprintf(f,L" / "); fwprintf(f,c->argv[1].w.format,c->argv[1].fn(tree)); fputwc(L' ',f); bg_print_conf_unitw(f,0,c,tree->param,1); fputwc(L'\n',f); } else { #endif // ] bg_print_classic_indent(f,width-strlen(c->n.label.classic)); fprintf(f,"%s: ",c->n.label.classic); fprintf(f,c->argv[0].n.format,c->argv[0].fn(tree)); fputc(' ',f); bg_print_conf_unit(f,0,c,tree->param,0); fprintf(f," / "); fprintf(f,c->argv[1].n.format,c->argv[1].fn(tree)); fputc(' ',f); bg_print_conf_unit(f,0,c,tree->param,1); fputc('\n',f); #if defined (_WIN32) // [ } #endif // ] fflush(f); } else _DWARNING("argv[0]/argv[1]"); break; default: _DWARNING("argc"); break; } } /////////////////////////////////////////////////////////////////////////////// static void bg_print_classic_encoding(bg_param_t *param, int bits) { param->result.bits=bits; } static int bg_print_conf_len(bg_print_conf_t *c, FILE *f FFUNUSED) { #if defined (_WIN32) // [ if (stdout!=f&&stderr!=f) return wcslen(c->w.label.classic); else #endif // ] return strlen(c->n.label.classic); } static int bg_print_classic_width(bg_tree_t *tree, FILE *f) { // path 1: determine the maximum length of the involved labels. int width=-1; bg_flags_agg_t agg; bg_print_conf_t *c; int len; for (agg=1,c=bg_print_conf;aggparam->flags.aggregate)) { // this aggregation isn't involved. continue; } else if (agg!=c->agg) { // wrong order. _DWARNING("aggregate mismatch"); continue; } else if ((len=bg_print_conf_len(c,f))<0) { _DWARNING("getting length"); continue; } else if (widthparam->quiet) goto success; #endif // ] switch (tree->vmt->type) { case BG_TREE_TYPE_FILE: // nothing to do. break; case BG_TREE_TYPE_TRACK: track=&tree->track; #if defined (_WIN32) // [ if (stdout!=f&&stderr!=f) { fwprintf(f,L"[%lu/%lu] %S\n",track->root.id,tree->param->count.max, tree->source.basename); } else { #endif // ] fprintf(f,"[%lu/%lu] %s\n",track->root.id,tree->param->count.max, bg_tree_in_basename(tree)); #if defined (_WIN32) // [ } #endif // ] break; case BG_TREE_TYPE_ALBUM: if (!tree->param->suppress.hierarchy) { #if defined (_WIN32) // [ if (stdout!=f&&stderr!=f) fwprintf(f,L"[ALBUM] %S\n",tree->source.basename); else #endif // ] fprintf(f,"[ALBUM] %s\n",bg_tree_in_basename(tree)); } break; case BG_TREE_TYPE_ROOT: if (!tree->param->suppress.hierarchy) { #if defined (_WIN32) // [ if (stdout!=f&&stderr!=f) fwprintf(f,L"[COLLECTION]\n"); else #endif // ] fprintf(f,"[COLLECTION]\n"); } break; default: _DMESSAGEV("tree type %d unexpected",tree->vmt->type); goto e_type; } ///////////////////////////////////////////////////////////////////////////// fflush(f); #if defined (BG_PARAM_QUIET) // [ success: #endif // ] return 0; e_type: return -1; } static int bg_print_classic_tail(bg_tree_t *tree, int depth FFUNUSED, FILE *f) { int suppress_hierarchy=tree->param->suppress.hierarchy; // path 1: determine the maximum length of the involved labels. int width=bg_print_classic_width(tree,f); // path 2: print out the results aligned according to the maximum length // of the involved labels. bg_flags_agg_t agg; bg_print_conf_t *c; #if defined (BG_PARAM_QUIET) // [ if (tree->param->quiet) goto success; #endif // ] if (width<=0) { _DWARNING("width"); goto e_width; } if (!suppress_hierarchy||BG_TREE_TYPE_TRACK==tree->vmt->type) { for (agg=1,c=bg_print_conf;aggparam->flags.aggregate)) { // the aggregation isn't involved. continue; } else if (agg!=c->agg) { // wrong order. _DWARNING("aggregate mismatch"); continue; } else bg_print_conf_tail(c,tree,width,f); } } ///////////////////////////////////////////////////////////////////////////// fflush(f); #if defined (BG_PARAM_QUIET) // [ success: #endif // ] return 0; e_width: return -1; } bg_print_vmt_t bg_print_classic_vmt={ .id="classic", .infix=0, .encoding=bg_print_classic_encoding, .head=bg_print_classic_head, .tail=bg_print_classic_tail, }; bs1770gain-0.9.5/libbg/bg_tree_path.c0000755000175000017500000000273513705073007012652 /* * bg_tree_path.c * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include int bg_tree_source_create(bg_tree_path_t *tp, const ffchar_t *path) { if (path) { tp->path=FFSTRDUP(path); if (!tp->path) { _DMESSAGE("duplicating path"); goto e_path; } /////////////////////////////////////////////////////////////////////////// tp->basename=bg_basename(tp->path); } else { tp->path=NULL; tp->basename=NULL; } ///////////////////////////////////////////////////////////////////////////// return 0; //cleanup: if (tp->path) free(tp->path); e_path: return -1; } void bg_tree_path_destroy(bg_tree_path_t *tp) { if (tp->path) free(tp->path); } bs1770gain-0.9.5/libbg/bg_pilot_leaf.c0000755000175000017500000000466113705073203013013 /* * bg_pivot_leaf.c * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include /////////////////////////////////////////////////////////////////////////////// static bg_pilot_hist_vmt_t bg_pilot_hist_leaf_vmt; /////////////////////////////////////////////////////////////////////////////// int bg_pilot_hist_leaf_create(bg_pilot_hist_t *hist) { bg_pilot_client_t *client=&hist->pilot->client; ///////////////////////////////////////////////////////////////////////////// hist->vmt=&bg_pilot_hist_leaf_vmt; ///////////////////////////////////////////////////////////////////////////// if (client->cb&&client->cb->leaf.enter) { if (client->cb->leaf.enter(hist,client->data)<0) { _DMESSAGE("entering leaf"); goto e_enter; } } ///////////////////////////////////////////////////////////////////////////// return 0; //cleanup: e_enter: return -1; } static void bg_pilot_hist_leaf_destroy(bg_pilot_hist_t *hist FFUNUSED) { bg_pilot_client_t *client=&hist->pilot->client; if (client->cb&&client->cb->leaf.leave) client->cb->leaf.leave(hist,client->data); } /////////////////////////////////////////////////////////////////////////////// static const ffchar_t *bg_pilot_hist_leaf_first(bg_pilot_hist_t *hist FFUNUSED) { return NULL; } static const ffchar_t *bg_pilot_hist_leaf_next(bg_pilot_hist_t *hist FFUNUSED) { return NULL; } /////////////////////////////////////////////////////////////////////////////// static bg_pilot_hist_vmt_t bg_pilot_hist_leaf_vmt={ #if defined (PBU_DEBUG) // [ .id="leaf", #endif // ] .destroy=bg_pilot_hist_leaf_destroy, .first=bg_pilot_hist_leaf_first, .next=bg_pilot_hist_leaf_next, }; bs1770gain-0.9.5/libbg/bg_utf8_iter.c0000755000175000017500000001374013705073446012615 /* * bg_utf8_iter.c * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include #if 1 && defined (BG_UTF8_ITER) // [ #include // Iterate backwards through a utf8 multibyte string: // https://stackoverflow.com/questions/22257486/iterate-backwards-through-a-utf8-multibyte-string /////////////////////////////////////////////////////////////////////////////// static bg_utf8_iter_vmt_t bg_iter_utf8_le_vmt; //#define BG_UTF8_ITER_BE #if defined (BG_UTF8_ITER_BE) // [ static bg_utf8_iter_vmt_t bg_utf8_iter_be_vmt; #endif // ] /////////////////////////////////////////////////////////////////////////////// #if defined (BG_UTF8_ITER_BE) // [ static int le(void) { // decide whether we're on little endian or on big endian: // https://www.geeksforgeeks.org/little-and-big-endian-mystery/ // big endian is not defined yet!!! uint32_t i=1ul; const uint8_t *p=(const uint8_t *)&i; return *p; } #endif // ] void bg_utf8_iter_first(bg_utf8_iter_t *i, const char *rp, char *wp, size_t *size) { #if defined (BG_UTF8_ITER_BE) // [ i->vmt=le()?&bg_iter_utf8_le_vmt:&bg_utf8_iter_be_vmt; #else // ] [ i->vmt=&bg_iter_utf8_le_vmt; #endif // ] i->rp=(const uint8_t *)rp; i->wp=(uint8_t *)wp; i->size=size; return; } /////////////////////////////////////////////////////////////////////////////// static int bg_utf8_iter_le_valid(bg_utf8_iter_t *i) { // cf. e.g. "https://en.wikipedia.org/wiki/UTF-8#Description". const uint8_t *rp=i->rp; uint8_t *wp=i->mbs; #if defined (BG_UTF8_ITER_WCS) // [ i->wcs=0u; #else // ] [ //memset(wp,0,sizeof i->mbs); #endif // ] if (!*i->rp) goto exit; else if (*i->rp==(BG_UTF8_ITER_MASK_ONE_BYTE&*i->rp)) { #if 0 // [ memcpy(wp,i->rp,1); #else // ] [ *wp++=*rp++; #endif // ] } else if (*i->rp==(BG_UTF8_ITER_MASK_TWO_BYTES&*i->rp)) { #if 0 // [ memcpy(wp,i->rp,2); #else // ] [ *wp++=*rp++; *wp++=*rp++; #endif // ] } else if (*i->rp==(BG_UTF8_ITER_MASK_THREE_BYTES&*i->rp)) { #if 0 // [ memcpy(wp,i->rp,3); #else // ] [ *wp++=*rp++; *wp++=*rp++; *wp++=*rp++; #endif // ] } else if (*i->rp==(BG_UTF8_ITER_MASK_FOUR_BYTES&*i->rp)) { #if 0 // [ memcpy(wp,i->rp,4); #else // ] [ *wp++=*rp++; *wp++=*rp++; *wp++=*rp++; *wp++=*rp++; #endif // ] } else goto exit; ///////////////////////////////////////////////////////////////////////////// return 1; exit: return 0; } #if 0 // [ static const uint8_t *bg_utf8_iter_le_next(bg_utf8_iter_t *i) { // cf. e.g. "https://en.wikipedia.org/wiki/UTF-8#Description". if (*i->rp==(BG_UTF8_ITER_MASK_ONE_BYTE&*i->rp)) i->rp+=1; else if (*i->rp==(BG_UTF8_ITER_MASK_TWO_BYTES&*i->rp)) i->rp+=2; else if (*i->rp==(BG_UTF8_ITER_MASK_THREE_BYTES&*i->rp)) i->rp+=3; else if (*i->rp==(BG_UTF8_ITER_MASK_FOUR_BYTES&*i->rp)) i->rp+=4; return i->rp; } #else // ] [ static const uint8_t *bg_utf8_iter_le_next(bg_utf8_iter_t *i) { uint8_t *wp=i->mbs; // cf. e.g. "https://en.wikipedia.org/wiki/UTF-8#Description". if (*i->rp==(BG_UTF8_ITER_MASK_ONE_BYTE&*i->rp)) *wp++=*i->rp++; else if (*i->rp==(BG_UTF8_ITER_MASK_TWO_BYTES&*i->rp)) { *wp++=*i->rp++; *wp++=*i->rp++; } else if (*i->rp==(BG_UTF8_ITER_MASK_THREE_BYTES&*i->rp)) { *wp++=*i->rp++; *wp++=*i->rp++; *wp++=*i->rp++; } else if (*i->rp==(BG_UTF8_ITER_MASK_FOUR_BYTES&*i->rp)) { *wp++=*i->rp++; *wp++=*i->rp++; *wp++=*i->rp++; *wp++=*i->rp++; } return i->rp; } #endif // ] static void bg_utf8_iter_le_apply(bg_utf8_iter_t *i) { // cf. e.g. "https://en.wikipedia.org/wiki/UTF-8#Description". const uint8_t *rp=i->mbs; if (*rp==(BG_UTF8_ITER_MASK_ONE_BYTE&*rp)) { if (i->wp) *i->wp++=*rp++; if (i->size) *i->size+=1; } else if (*rp==(BG_UTF8_ITER_MASK_TWO_BYTES&*rp)) { if (i->wp) { memcpy(i->wp,rp,2); i->wp+=2; } if (i->size) *i->size+=2; } else if (*rp==(BG_UTF8_ITER_MASK_THREE_BYTES&*rp)) { if (i->wp) { memcpy(i->wp,rp,3); i->wp+=3; } if (i->size) *i->size+=3; } else if (*rp==(BG_UTF8_ITER_MASK_FOUR_BYTES&*rp)) { if (i->wp) { memcpy(i->wp,rp,4); i->wp+=4; } if (i->size) *i->size+=4; } } static void bg_utf8_iter_le_flush(bg_utf8_iter_t *i) { if (i->wp) *i->wp++=0; if (i->size) ++*i->size; } static bg_utf8_iter_vmt_t bg_iter_utf8_le_vmt={ .valid=bg_utf8_iter_le_valid, .next=bg_utf8_iter_le_next, .apply=bg_utf8_iter_le_apply, .flush=bg_utf8_iter_le_flush, }; #if defined (BG_UTF8_ITER_BE) // [ /////////////////////////////////////////////////////////////////////////////// static int bg_utf8_iter_be_valid(bg_utf8_iter_t *i FFUNUSED) { _DMESSAGE("not implemented yet"); return 0; } static const uint8_t *bg_utf8_iter_be_next(bg_utf8_iter_t *i) { _DMESSAGE("not implemented yet"); return i->rp; } static void bg_utf8_iter_be_apply(bg_utf8_iter_t *i FFUNUSED) { _DMESSAGE("not implemented yet"); } static void bg_utf8_iter_be_flush(bg_utf8_iter_t *i FFUNUSED) { _DMESSAGE("not implemented yet"); } static bg_utf8_iter_vmt_t bg_utf8_iter_be_vmt={ .valid=bg_utf8_iter_be_valid, .next=bg_utf8_iter_be_next, .apply=bg_utf8_iter_be_apply, .flush=bg_utf8_iter_be_flush, }; #endif // ] #endif // ] bs1770gain-0.9.5/libbg/bg_file.c0000755000175000017500000000523514416455605011624 /* * bg_file.c * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include /////////////////////////////////////////////////////////////////////////////// static bg_tree_vmt_t bg_file_vmt; /////////////////////////////////////////////////////////////////////////////// int bg_file_content_create(bg_tree_t *tree) { ///////////////////////////////////////////////////////////////////////////// #if 0 // [ // DON'T do this!!! bg_file_create() is called from bg_child_create() // which in front already has called bg_tree_common_create() and just // leaves us with setting the vmt! if (bg_tree_common_create(tree,param,param,path,&bg_file_vmt)<0) { _DMESSAGE("creating tree"); goto etree; } #else // ] [ if ((BG_FLAGS_EXT_CSV&tree->param->flags.extension) &&!FFSTRCMP(FFL("folder.csv"),tree->source.basename)) goto e_basename; tree->vmt=&bg_file_vmt; #endif // ] ++tree->parent->album.nleafs; return 0; //cleanup: e_basename: return -1; } /////////////////////////////////////////////////////////////////////////////// static void bg_file_destroy(bg_tree_t *tree) { bg_param_t *param=tree->param; if (tree->parent) bg_album_pop(tree->parent); if (!param->process) tree->argv->lift=tree->depth; bg_tree_common_destroy(tree); free(tree); } static int bg_file_accept(bg_tree_t *tree, bg_visitor_t *vis) { return vis->vmt->dispatch_file(vis,tree); } #if defined (BG_TRACK_ID) // [ static void bg_file_track_id(bg_tree_t *tree FFUNUSED, int *id FFUNUSED) { } #endif // ] static bg_tree_vmt_t bg_file_vmt={ #if defined (PBU_MESSAGE_AV_LOG) // [ .id="file", #else // ] [ .id=FFL("file"), #endif // ] .type=BG_TREE_TYPE_FILE, .destroy=bg_file_destroy, .accept=bg_file_accept, .annotation={ .create=bg_file_annotation_create, .destroy=bg_file_annotation_destroy, }, #if defined (BG_TRACK_ID) // [ .track_id=bg_file_track_id, #endif // ] }; bs1770gain-0.9.5/libbg/bg_version.c0000755000175000017500000000734714623615117012374 /* * bg_version.c * * Copyright (C) 2014-2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ /* * Explore some constants at compile time and make them available at runtime. */ #if defined (__GNUC__) // [ #define UNUSED __attribute__((__unused__)) #else // ] [ #define UNUSED #endif // ] #define BG_COMMAND #if defined (_WIN32) // [ #include #include int wmain(int argc UNUSED, wchar_t *const *argv UNUSED) #else // ] [ #include #if defined (__linux__) && defined (__GNUC__) // [ #include #endif // ] #include #include #include #if defined (BG_COMMAND) && defined (__GNUC__) // [ char *bg_command(const char *command,char *buf, size_t size) { char *bp=buf; FILE *p=popen(command,"r"); for (;;) { int count=fread(buf,1,size,p); if (0 * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include /////////////////////////////////////////////////////////////////////////////// static bg_tree_vmt_t bg_album_vmt; int bg_album_create(bg_tree_t **tree, bg_param_t *param, bg_tree_t *parent, const ffchar_t *path) { ///////////////////////////////////////////////////////////////////////////// *tree=malloc(sizeof **tree); if (!*tree) { _DMESSAGE("allocating"); goto e_alloc; } ///////////////////////////////////////////////////////////////////////////// if (bg_tree_common_create(*tree,param,parent,path)<0) { _DMESSAGE("creating common"); goto e_common; } ///////////////////////////////////////////////////////////////////////////// if (bg_album_content_create(*tree,&bg_album_vmt)<0) { _DMESSAGE("creating content"); goto e_content; } ///////////////////////////////////////////////////////////////////////////// if (parent&&bg_album_push(parent,*tree)<0) { _DMESSAGE("pushing"); goto e_push; } ///////////////////////////////////////////////////////////////////////////// return 0; //cleanup: if (parent) bg_album_pop(parent); e_push: bg_album_content_destroy(*tree); e_content: bg_tree_common_destroy(*tree); e_common: free(*tree); e_alloc: return -1; } void bg_album_destroy(bg_tree_t *tree) { if (tree->parent&&tree!=bg_album_pop(tree->parent)) _DWARNING("tree not at end of list"); if (!tree->param->process&&1ualbum.nchildren.max) { // it's getting bottom-up. if (!tree->param->process) tree->argv->lift=tree->depth+1; } bg_album_content_destroy(tree); bg_tree_common_destroy(tree); free(tree); } int bg_album_content_create(bg_tree_t *tree, bg_tree_vmt_t *vmt) { bg_album_t *album=&tree->album; tree->vmt=vmt; album->nchildren.max=0u; album->nchildren.cur=0u; album->nleafs=0u; #if defined (BG_TRACK_ID) // [ album->track.id=0u; #endif // ] album->first=NULL; album->last=NULL; return 0; } void bg_album_content_destroy(bg_tree_t *tree) { bg_tree_t *cur; while (tree->album.last) { cur=bg_album_pop(tree); if (cur) cur->vmt->destroy(cur); else _DWARNING("empty list"); } } /////////////////////////////////////////////////////////////////////////////// int bg_album_push(bg_tree_t *tree, bg_tree_t *child) { bg_album_t *album=&tree->album; if (album->last) { child->prev=album->last; album->last->next=child; } else album->first=child; album->last=child; #if defined (BG_TRACK_ID) // [ child->vmt->track_id(child,&album->track.id); #endif // ] ++album->nchildren.max; ++album->nchildren.cur; return 0; } bg_tree_t *bg_album_pop(bg_tree_t *tree) { bg_album_t *album=&tree->album; bg_tree_t *last=album->last; --album->nchildren.cur; if (last) { last->parent=NULL; album->last=last->prev; if (album->last) album->last->next=NULL; else album->first=NULL; } else album->first=NULL; return last; } /////////////////////////////////////////////////////////////////////////////// static int bg_album_accept(bg_tree_t *tree, bg_visitor_t *vis) { return vis->vmt->dispatch_album(vis,tree); } #if defined (BG_TRACK_ID) // [ static void bg_album_track_id(bg_tree_t *tree FFUNUSED, int *id FFUNUSED) { } #endif // ] static bg_tree_vmt_t bg_album_vmt={ #if defined (PBU_MESSAGE_AV_LOG) // [ .id="album", #else // ] [ .id=FFL("album"), #endif // ] .type=BG_TREE_TYPE_ALBUM, .destroy=bg_album_destroy, .accept=bg_album_accept, .annotation={ .create=bg_album_annotation_create, .destroy=bg_album_annotation_destroy, }, #if defined (BG_TRACK_ID) // [ .track_id=bg_album_track_id, #endif // ] }; bs1770gain-0.9.5/libbg/bg_pathnorm.c0000755000175000017500000000206213671703331012522 /* * bg_pathnorm.c * * Copyright (C) 2014-2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include ffchar_t *bg_pathnorm(ffchar_t *path) { #if defined (_WIN32) // [ wchar_t *pp=path; while (*pp) { if (L'/'==*pp) *pp=L'\\'; pp=CharNextW(pp); } #endif // ] return path; } bs1770gain-0.9.5/libbg/bg_wcs2str.c0000755000175000017500000000426513705073267012316 /* * bg_wcs2str.c * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include #if defined (_WIN32) // [ char *bg_wcs2str(const wchar_t *wcs, unsigned int codepage) { size_t size; char *str; /////////////////////////////////////////////////////////////////////////// size=WideCharToMultiByte( codepage, // _In_ UINT CodePage, 0, // _In_ DWORD dwFlags, wcs, // _In_ LPCWSTR lpWideCharStr, -1, // _In_ int cchWideChar, NULL, // _Out_opt_ LPSTR lmultiByteStr, 0, // _In_ int cbMultiByte, NULL, // _In_opt_ LPCSTR lpDefaultChar, NULL // _Out_opt_ LPBOOL lpUsedDefaultChar ); str=malloc(size*sizeof *str); if (!str) { _DMESSAGE("allocating"); goto ealloc; } /////////////////////////////////////////////////////////////////////////// WideCharToMultiByte( codepage, // _In_ UINT CodePage, 0, // _In_ DWORD dwFlags, wcs, // _In_ LPCWSTR lpWideCharStr, -1, // _In_ int cchWideChar, str, // _Out_opt_ LPSTR lmultiByteStr, size, // _In_ int cbMultiByte, NULL, // _In_opt_ LPCSTR lpDefaultChar, NULL // _Out_opt_ LPBOOL lpUsedDefaultChar ); return str; ealloc: return NULL; } #endif // ] bs1770gain-0.9.5/libbg/bg.h0000755000175000017500000006435414701643231010630 /* * bg.h * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #if ! defined (__BG_H__) // [ #define __BG_H__ #if defined (HAVE_CONFIG_H) // [ #include #endif // ] #include //#define BG_PRINT_PARAM_CLASSIC //#define BG_UNIT_LRA //#define BG_LOUDNESS_ALL #define BG_TRADITIONAL #if ! defined(BG_TRADITIONAL) // [ #define BG_OPPOSITE #endif // ] #define BG_ESCAPE_XML #if defined (_WIN32) // [ #define BG_COMPILE_TIME_EXPR #endif // ] #define BG_SAMPLES_COUNT #define BG_SERGEY_XML_FIX #define BG_PARAM_QUIET //#define BG_PARAM_PREAMP #if defined (BG_PARAM_QUIET) // [ #if defined (HAVE_PTHREAD) || defined (_WIN32) // [ #define BG_PARAM_THREADS #endif // ] #if defined (BG_PARAM_THREADS) // [ // don't define! //#define BG_VISITOR_NOTIFY_PARENT #endif // ] #if defined (HAVE_PTHREAD) // [ #include #endif // ] #endif // ] #include #include #include #include #if defined (__cplusplus) // [ extern "C" { #endif // ] #if defined (FF_WARN_CHANNEL_OVERFLOW_DISABLE) // [ #define BG_WARN_CHANNEL_OVERFLOW_DISABLE #endif // ] /////////////////////////////////////////////////////////////////////////////// #if ! defined (_WIN32) // [ //#define BG_UTF8_ITER #if defined (BG_UTF8_ITER) // [ //#define BG_UTF8_ITER_WCS #define BG_UTF8_ITER_MASK #else // ] [ #define BG_CHAR_NEXTA #endif // ] #endif // ] #define BG_PARAM_XML_CDATA #define BG_PARAM_SKIP_SCAN #define BG_PARAM_REFERENCE //#define BG_PARAM_NODE_VMT #define BG_PARAM_NODE_VMT #if defined (BG_PARAM_NODE_VMT) // [ #define BG_PARAM_SCRIPT #if defined (BG_PARAM_SCRIPT) // [ #define BG_PARAM_SHELL #endif // ] #endif // ] #define BG_TEMP_PREFIX FFL(".") #define BG_CLOCK #define BG_TRACK_ID #if defined (_WIN32) // [ //#define BG_UNICODE #if defined (BG_UNICODE) // [ //#define BG_NUTF16 #endif // ] #endif // ] //#define BG_PARAM_SLEEP //#define BG_BWF_TAGS //#define BG_TREE_CREATE_CHILD_WARNING //#define BG_PARAM_LFE #if defined (BG_PARAM_LFE) // [ #define BG_CHANNEL_LFE 3 #endif // ] #if defined (_WIN32) // [ #define BG_WIN32_TARGET_UTF8 // WARNING: define BG_WIN32_CREATE_LOCALE at your own risk: at the run-time // of our system _create_locale() doesn't exist and hence you're compiling // un-tested code. //#define BG_WIN32_CREATE_LOCALE #endif // ] /////////////////////////////////////////////////////////////////////////////// typedef unsigned long bg_bits_t; typedef struct bg_album bg_album_t; typedef enum bg_track_tag bg_track_tag_t; typedef struct bg_track_target bg_track_target_t; typedef struct bg_track bg_track_t; typedef enum bg_tree_type bg_tree_type_t; typedef const struct bg_annotation_vmt bg_annotation_vmt_t; typedef const struct bg_tree_vmt bg_tree_vmt_t; typedef struct bg_tree_path bg_tree_path_t; #if defined (_WIN32) // [ typedef struct bg_tree_patha bg_tree_patha_t; #endif // ] typedef struct bg_tree bg_tree_t; typedef const struct bg_visitor_vmt bg_visitor_vmt_t; typedef struct bg_visitor bg_visitor_t; typedef struct bg_param_block bg_param_block_t; typedef enum bg_flags_agg bg_flags_agg_t; typedef enum bg_flags_ext bg_flags_ext_t; typedef enum bg_flags_mode bg_flags_mode_t; typedef enum bg_flags_norm bg_flags_norm_t; typedef const struct bg_print_vmt bg_print_vmt_t; typedef const struct bg_print_conf bg_print_conf_t; typedef const struct bg_param_unit bg_param_unit_t; #if defined (BG_UTF8_ITER) // [ typedef const struct bg_utf8_iter_vmt bg_utf8_iter_vmt_t; #if defined (BG_UTF8_ITER_MASK) // [ typedef enum bg_utf8_iter_mask bg_utf8_iter_mask_t; #endif // ] typedef struct bg_utf8_iter bg_utf8_iter_t; #endif // ] #if defined (BG_PARAM_THREADS) // [ typedef struct bg_sync bg_sync_t; typedef struct bg_threads_helper bg_threads_helper_t; typedef int (bg_dispatch_t)(bg_tree_t *tree, bg_visitor_t *vis); typedef enum bg_param_request_tag bg_param_request_tag_t; typedef struct bg_param_request bg_param_request_t; #if defined (BG_PARAM_NODE_VMT) // [ typedef struct bg_param_node_vmt bg_param_node_vmt_t; #endif // ] typedef struct bg_param_node bg_param_node_t; typedef struct bg_param_list bg_param_list_t; typedef struct bg_param_threads bg_param_threads_t; #endif // ] typedef struct bg_param bg_param_t; typedef struct bg_param_argv bg_param_argv_t; /////////////////////////////////////////////////////////////////////////////// void bg_set_output_xml(bg_param_t *param); int bg_is_output_xml(const bg_param_t *param); /////////////////////////////////////////////////////////////////////////////// int64_t bg_parse_time(const ffchar_t *s); ffchar_t *bg_pathnorm(ffchar_t *path); const ffchar_t *bg_basename(const ffchar_t *path); #if defined (_WIN32) // [ char *bg_wcs2str(const wchar_t *wcs, unsigned int codepage); const char *bg_basenamea(const char *path); #endif // ] /////////////////////////////////////////////////////////////////////////////// enum bg_tree_type { BG_TREE_TYPE_NULL=0, BG_TREE_TYPE_FILE=1<<0, BG_TREE_TYPE_TRACK=1<<1, BG_TREE_TYPE_ALBUM=1<<2, BG_TREE_TYPE_ROOT=1<<3, BG_TREE_TYPE_LEAF=BG_TREE_TYPE_FILE|BG_TREE_TYPE_TRACK, BG_TREE_TYPE_BRANCH=BG_TREE_TYPE_ALBUM|BG_TREE_TYPE_ROOT, }; struct bg_annotation_vmt { int (*create)(bg_tree_t *tree); void (*destroy)(bg_tree_t *tree); }; struct bg_tree_vmt { #if defined (PBU_MESSAGE_AV_LOG) // [ const char *id; #else // ] [ const ffchar_t *id; #endif // ] const bg_tree_type_t type; void (*destroy)(bg_tree_t *tree); int (*accept)(bg_tree_t *tree, bg_visitor_t *vis); bg_annotation_vmt_t annotation; #if defined (BG_TRACK_ID) // [ void (*track_id)(bg_tree_t *tree, int *id); #endif // ] }; //////// int bg_root_create(bg_tree_t *tree, bg_param_t *param); int bg_root_annotation_create(bg_tree_t *tree); void bg_root_annotation_destroy(bg_tree_t *tree); //////// struct bg_album { // counts BG_TREE_TYPE_FILEs and BG_TREE_TYPE_TRACKs. struct { unsigned max,cur; } nchildren; unsigned nleafs; #if defined (BG_TRACK_ID) // [ struct { int id; } track; #endif // ] bg_tree_t *first; bg_tree_t *last; }; int bg_album_create(bg_tree_t **tree, bg_param_t *param, bg_tree_t *parent, const ffchar_t *path); void bg_album_destroy(bg_tree_t *tree); int bg_album_content_create(bg_tree_t *tree, bg_tree_vmt_t *vmt); void bg_album_content_destroy(bg_tree_t *tree); int bg_album_push(bg_tree_t *tree, bg_tree_t *child); bg_tree_t *bg_album_pop(bg_tree_t *tree); int bg_album_annotation_create(bg_tree_t *tree); void bg_album_annotation_destroy(bg_tree_t *tree); //////// enum bg_track_tag { BG_TRACK_TAG_ALGORITHM=1<<0, BG_TRACK_TAG_REFERENCE_LOUDNESS=1<<1, BG_TRACK_TAG_TRACK_GAIN=1<<2, BG_TRACK_TAG_TRACK_PEAK=1<<3, BG_TRACK_TAG_ALBUM_GAIN=1<<4, BG_TRACK_TAG_ALBUM_PEAK=1<<5, BG_TRACK_TAG_MAX=1<<6, }; //////// struct bg_track_target { #if defined (_WIN32) // [ #if defined (BG_WIN32_TARGET_UTF8) // [ struct { #endif // ] char *path; const char *basename; #if defined (BG_WIN32_TARGET_UTF8) // [ } utf8; #endif // ] // if LANG is set to e.g. "en_US.UTF-8" we assume we're run from // e.g. MSYS2 shell undestanding UTF-8 otherwise from MS console using // codepage OEM. In the latter case we need an OEM representation of // e.g. basename. struct { char *basename; } oem; #endif // ] wchar_t *title; struct { size_t len; } pfx; }; //////// struct bg_track { ff_inout_t input; ff_analyzer_t analyzer; bg_track_target_t target; // an utf-8 representation of the target path. struct { char *path; } temp; struct { unsigned long id; } root; struct { #if defined (BG_TRACK_ID) // [ int id; #else // ] [ unsigned long id; #endif // ] } album; struct { lib1770_pre_t *pre; } filter; struct { lib1770_block_t *momentary; lib1770_block_t *shortterm; } block; }; int bg_track_content_create(bg_tree_t *tree); int bg_track_annotation_create(bg_tree_t *tree); void bg_track_annotation_destroy(bg_tree_t *tree); int bg_file_content_create(bg_tree_t *tree); int bg_file_annotation_create(bg_tree_t *tree); void bg_file_annotation_destroy(bg_tree_t *tree); //////// struct bg_tree_path { ffchar_t *path; const ffchar_t *basename; }; int bg_tree_source_create(bg_tree_path_t *tp, const ffchar_t *path); void bg_tree_path_destroy(bg_tree_path_t *tp); #if defined (_WIN32) // [ //////// struct bg_tree_patha { char *path; const char *basename; }; int bg_tree_patha_create(bg_tree_patha_t *p, const wchar_t *path, unsigned int codepage); void bg_tree_patha_destroy(bg_tree_patha_t *p); #endif // ] #if defined (BG_UTF8_ITER) // [ /////////////////////////////////////////////////////////////////////////////// struct bg_utf8_iter_vmt { int (*valid)(bg_utf8_iter_t *i); const uint8_t *(*next)(bg_utf8_iter_t *i); void (*apply)(bg_utf8_iter_t *i); void (*flush)(bg_utf8_iter_t *i); }; #if defined (BG_UTF8_ITER_MASK) // [ enum bg_utf8_iter_mask { // cf. e.g. "https://en.wikipedia.org/wiki/UTF-8#Description". BG_UTF8_ITER_MASK_ONE_BYTE=~(1u<<7u), BG_UTF8_ITER_MASK_TWO_BYTES=~(1u<<5u), BG_UTF8_ITER_MASK_THREE_BYTES=~(1u<<4u), BG_UTF8_ITER_MASK_FOUR_BYTES=~(1u<<3u), BG_UTF8_ITER_MBS_SIZE=4, }; #else // ] [ #error not implemented yet #endif // ] struct bg_utf8_iter { bg_utf8_iter_vmt_t *vmt; #if defined (BG_UTF8_ITER_MASK) // [ uint8_t mbs[BG_UTF8_ITER_MBS_SIZE]; #endif // ] const uint8_t *rp; uint8_t *wp; size_t *size; #if defined (BG_UTF8_ITER_WCS) // [ uint8_t wcs; #endif // ] }; void bg_utf8_iter_first(bg_utf8_iter_t *i, const char *rp, char *wp, size_t *size); #elif defined (BG_CHAR_NEXTA) // ] [ const char *bg_char_nexta(const char *str); #elif defined (_WIN32) // ] [ #define bg_char_nexta(str) CharNextA(str) #endif // ] #if defined (BG_PARAM_THREADS) // [ //////// struct bg_sync { #if defined (HAVE_PTHREAD) // [ pthread_mutex_t mutex; pthread_cond_t cond; #elif defined (_WIN32) // ] [ CRITICAL_SECTION cs; HANDLE hEvent; #endif // ] }; int bg_sync_create(bg_sync_t *sync); void bg_sync_destroy(bg_sync_t *sync); void bg_sync_lock(bg_sync_t *sync); void bg_sync_unlock(bg_sync_t *sync); void bg_sync_signal(bg_sync_t *sync); void bg_sync_wait(bg_sync_t *sync); //////// struct bg_threads_helper { unsigned nchildren; bg_sync_t sync; }; int bg_threads_helper_create(bg_threads_helper_t *helper); void bg_threads_helper_destroy(bg_threads_helper_t *helper); #endif // ] struct bg_tree { bg_tree_vmt_t *vmt; bg_param_t *param; bg_param_argv_t *argv; bg_tree_path_t source; #if defined (_WIN32) // [ // if LANG is set to e.g. "en_US.UTF-8" we assume we're run from // e.g. MSYS2 shell undestanding UTF-8 otherwise from MS console using // codepage OEM. In the latter case we need an OEM representation of // e.g. basename. struct { char *basename; } oem; bg_tree_patha_t utf8; #endif // ] bg_tree_path_t target; bg_tree_path_t temp; bg_tree_t *parent; unsigned depth; bg_tree_t *next; bg_tree_t *prev; struct { lib1770_stats_t *momentary; lib1770_stats_t *shortterm; double samplepeak; double truepeak; } stats; #if defined (BG_PARAM_THREADS) // [ bg_threads_helper_t helper; #endif // ] union { bg_album_t album; bg_track_t track; }; }; int bg_tree_common_create(bg_tree_t *tree, bg_param_t *param, bg_tree_t *parent, const ffchar_t *path); void bg_tree_common_destroy(bg_tree_t *tree); int bg_tree_stats_create(bg_tree_t *tree); void bg_tree_stats_destroy(bg_tree_t *tree); // narrow character representation of the basename. const char *bg_tree_in_basename(bg_tree_t *tree); const char *bg_tree_out_basename(bg_tree_t *tree); #if defined (_WIN32) // [ // wide character representation of the basename. const wchar_t *bg_tree_in_basenamew(bg_tree_t *tree); const wchar_t *bg_tree_out_basenamew(bg_tree_t *tree); #endif // ] #if defined (BG_PARAM_SCRIPT) // [ int bg_process_tree_run_script(bg_tree_t *tree); #endif // ] int bg_leaf_create(bg_tree_t **tree, bg_param_t *param, bg_tree_t *parent, const ffchar_t *path); double *bg_tree_samplepeak(bg_tree_t *tree); double *bg_tree_truepeak(bg_tree_t *tree); int bg_tree_merge(bg_tree_t *lhs, const bg_tree_t *rhs); /////////////////////////////////////////////////////////////////////////////// // from "bg_print_conf.c" [ double bg_print_conf_norm(bg_tree_t *tree); double bg_print_conf_momentary_mean(bg_tree_t *tree); double bg_print_conf_momentary_mean_relative(bg_tree_t *tree); double bg_print_conf_momentary_maximum(bg_tree_t *tree); double bg_print_conf_momentary_maximum_relative(bg_tree_t *tree); double bg_print_conf_momentary_range(bg_tree_t *tree); double bg_print_conf_shortterm_mean(bg_tree_t *tree); double bg_print_conf_shortterm_mean_relative(bg_tree_t *tree); double bg_print_conf_shortterm_maximum(bg_tree_t *tree); double bg_print_conf_shortterm_maximum_relative(bg_tree_t *tree); double bg_print_conf_shortterm_range(bg_tree_t *tree); double bg_print_conf_samplepeak_absolute(bg_tree_t *tree); double bg_print_conf_samplepeak_relative(bg_tree_t *tree); double bg_print_conf_truepeak_absolute(bg_tree_t *tree); double bg_print_conf_truepeak_relative(bg_tree_t *tree); const char *bg_print_conf_unit_lum(bg_tree_t *tree); const char *bg_print_conf_unit_lram(bg_tree_t *tree); const char *bg_print_conf_unit_spm(bg_tree_t *tree); const char *bg_print_conf_unit_tpm(bg_tree_t *tree); #if defined (_WIN32) // [ const wchar_t *bg_print_conf_unit_luw(bg_tree_t *tree); const wchar_t *bg_print_conf_unit_lraw(bg_tree_t *tree); const wchar_t *bg_print_conf_unit_spw(bg_tree_t *tree); const wchar_t *bg_print_conf_unit_tpw(bg_tree_t *tree); #endif // ] // ] /////////////////////////////////////////////////////////////////////////////// // several phases are implemented by means of the visitor pattern (cf. e.g. // https://en.wikipedia.org/wiki/Visitor_pattern.) we've got the following // phases: // 1) annotation (cf. below), // 2) analysis, and // 3) re-muxing/transcoding. struct bg_visitor_vmt { #if defined (PBU_DEBUG) // [ const char *id; #endif // ] void (*destroy)(bg_visitor_t *vis); int (*dispatch_file)(bg_visitor_t *vis, bg_tree_t *tree); int (*dispatch_track)(bg_visitor_t *vis, bg_tree_t *tree); int (*dispatch_album)(bg_visitor_t *vis, bg_tree_t *tree); int (*dispatch_root)(bg_visitor_t *vis, bg_tree_t *tree); }; int bg_analyzer_create(bg_visitor_t *vis); int bg_analyzer_album_prefix(bg_visitor_t *vis, bg_tree_t *tree); int bg_analyzer_album_suffix(bg_visitor_t *vis, bg_tree_t *tree); #if 0 && defined (BG_PARAM_THREADS) // [ int bg_analyzer_track(bg_visitor_t *vis, bg_tree_t *tree); #endif // ] int bg_muxer_create(bg_visitor_t *vis); #if 0 && defined (BG_PARAM_THREADS) // [ int bg_muxer_track(bg_visitor_t *vis FFUNUSED, bg_tree_t *tree); #endif // ] //////// struct bg_visitor { bg_visitor_vmt_t *vmt; int depth; }; /////////////////////////////////////////////////////////////////////////////// struct bg_print_vmt { const char *id; int infix; void (*encoding)(bg_param_t *param, int bits); int (*head)(bg_tree_t *tree, int depth, FILE *f); int (*tail)(bg_tree_t *tree, int depth, FILE *f); }; extern bg_print_vmt_t bg_print_classic_vmt; #if defined (HAVE_BG_XML) // [ extern bg_print_vmt_t bg_print_xml_vmt; #endif // ] extern bg_print_vmt_t bg_print_csv_vmt; //////// struct bg_param_block { double ms; int partition; struct { double gate; } mean; struct { double gate; double lower_bound; double upper_bound; } range; }; //////// enum { BG_FLAGS_AGG_MOMENTARY_MEAN_OFFSET, BG_FLAGS_AGG_MOMENTARY_MAXIMUM_OFFSET, BG_FLAGS_AGG_MOMENTARY_RANGE_OFFSET, BG_FLAGS_AGG_SHORTTERM_MEAN_OFFSET, BG_FLAGS_AGG_SHORTTERM_MAXIMUM_OFFSET, BG_FLAGS_AGG_SHORTTERM_RANGE_OFFSET, BG_FLAGS_AGG_SAMPLEPEAK_OFFSET, BG_FLAGS_AGG_TRUEPEAK_OFFSET, BG_FLAGS_AGG_MAX_OFFSET, }; enum bg_flags_agg { #if 1 // [ BG_FLAGS_AGG_MOMENTARY_MEAN=1<vmt->run(node,request)) #endif // ] int bg_param_node_create(bg_param_node_t *node, bg_param_threads_t *threads); #if 0 // [ void bg_param_node_destroy(bg_param_node_t *node, int destroy); #else // ] [ void bg_param_node_destroy(bg_param_node_t *node); #endif // ] #if defined (BG_PARAM_SCRIPT) // [ void bg_param_node_request(bg_param_node_t *node, bg_param_request_tag_t tag, ffchar_t *script, bg_tree_t *tree, bg_visitor_t *visitor, bg_dispatch_t *dispatch); #else // ] [ void bg_param_node_request(bg_param_node_t *node, bg_param_request_tag_t tag, bg_tree_t *tree, bg_visitor_t *visitor, bg_dispatch_t *dispatch); #endif // ] //////// struct bg_param_list { int count; bg_param_node_t *head,*tail; }; int bg_param_list_create(bg_param_list_t *list, int n, bg_param_node_t *nodes, bg_param_threads_t *threads); #if 0 // [ void bg_param_list_destroy(bg_param_list_t *list, int destroy); #else void bg_param_list_destroy(bg_param_list_t *list); #endif // ] bg_param_node_t *bg_param_list_unlink(bg_param_list_t *list, bg_param_node_t *node); bg_param_node_t *bg_param_list_pop(bg_param_list_t *list); bg_param_node_t *bg_param_list_push(bg_param_list_t *list, bg_param_node_t *node); //////// struct bg_param_threads { bg_sync_t sync; bg_param_node_t *nodes; struct { bg_param_list_t free; bg_param_list_t active; } list; }; int bg_param_threads_create(bg_param_threads_t *threads, int n); void bg_param_threads_destroy(bg_param_threads_t *threads); #if defined (BG_PARAM_SCRIPT) // [ void bg_param_threads_visitor_run(bg_param_threads_t *threads, ffchar_t *script, bg_visitor_t *visitor, bg_tree_t *tree, bg_dispatch_t *dispatch); #else // ] [ void bg_param_threads_visitor_run(bg_param_threads_t *threads, bg_visitor_t *visitor, bg_tree_t *tree, bg_dispatch_t *dispatch); #endif // ] void bg_param_threads_drain(bg_param_threads_t *threads); #endif // ] //////// struct bg_param { struct { bg_param_argv_t *min; bg_param_argv_t *cur; bg_param_argv_t *max; } argv; struct count { unsigned long cur; unsigned long max; } count; int process; #if defined (BG_PARAM_PREAMP) // [ float preamp; #endif // ] #if defined (FF_INPUT_LIST) // [ struct { int in,out; } list; #endif // ] #if defined (BG_PARAM_SKIP_SCAN) // [ int skip_scan; #endif // ] #if defined (BG_PARAM_REFERENCE) // [ ffchar_t *reference; #endif // ] #if defined (BG_PARAM_SCRIPT) // [ ffchar_t *script; #endif // ] #if defined (BG_SAMPLES_COUNT) // [ struct { int threshould; } upsampler; #endif // ] struct { int separator; struct { int console; int file; } header; } csv; #if defined (BG_PARAM_XML_CDATA) // [ struct { int cdata; } xml; #endif // ] #if defined (BG_PARAM_SHELL) // [ struct { ffchar_t *interpreter; ffchar_t *parameter; } shell; #endif // ] bg_pilot_t pilot; bg_visitor_t analyzer; bg_tree_t root,*tos; struct { bg_print_vmt_t *vmt; } print; ff_printer_t printer; int loglevel; struct { #if defined (_WIN32) // [ char name[64]; #else // ] [ char *name; #endif // ] } codec; const ffchar_t *temp_prefix; struct { int hierarchy; int progress; } suppress; #if defined (_WIN32) // [ // if LANG is set to e.g. "en_US.UTF-8" we assume we're run from // e.g. MSYS2 shell undestanding UTF-8 otherwise from MS console using // codepage OEM. In the latter case we need an OEM representation of // e.g. basename. int oem; #endif // ] ff_param_decode_t decode; struct { FILE *f; int bits; } result; struct { ffchar_t *dirname; } output; int ai,vi; struct { bg_flags_ext_t extension; bg_flags_mode_t mode; bg_flags_agg_t aggregate; bg_flags_norm_t norm; } flags; #if defined (BG_PARAM_DUMP) // [ int dump; #endif // ] #if defined (BG_PARAM_STEREO) // [ int stereo; #endif // ] double norm; double preamp; #if defined (BG_TRADITIONAL) // [ int traditional; #elif defined (BG_OPPOSITE) // ] [ int opposite; #endif // ] struct { int enabled; double value; } weight; #if defined (BG_CLOCK) // [ int time; #endif // ] #if defined (BG_PARAM_LFE) // [ int lfe; #endif // ] #if defined (_WIN32) && defined (BG_WIN32_CREATE_LOCALE) // [ _locale_t locale; #endif // ] int overwrite; bg_param_unit_t *unit; struct { char pfx[128]; } tag; struct { ffchar_t *sfx; } out; struct { const ffchar_t *audio; const ffchar_t *video; } ext; struct { int64_t begin; int64_t duration; } interval; #if defined (BG_PARAM_QUIET) // [ int quiet; #endif // ] #if defined (BG_PARAM_THREADS) // [ int nthreads; bg_param_threads_t threads; #endif // ] #if defined (BG_PARAM_SLEEP) // [ int sleep; #endif // ] bg_param_block_t momentary; bg_param_block_t shortterm; #if defined (FF_PROGRESS_STDERR) // [ FILE *stdprog; #endif // ] #if defined (FF_WARN_CHANNEL_OVERFLOW_DISABLE) // [ int warn_channel_overflow_disable; #endif // ] }; int bg_param_create(bg_param_t *param); void bg_param_destroy(bg_param_t *param); int bg_param_alloc_arguments(bg_param_t *param, size_t size); void bg_param_free_argumets(bg_param_t *param); void bg_param_set_unit_ebu(bg_param_t *param); void bg_param_set_unit_db(bg_param_t *param); void bg_param_set_process(bg_param_t *param); int bg_param_loop(bg_param_t *param, ffchar_t *const *argv); /////////////////////////////////////////////////////////////////////////////// struct bg_print_conf { bg_flags_agg_t agg; struct { #if defined (_WIN32) // [ struct { struct { const wchar_t *classic; const wchar_t *xml; const wchar_t *csv; } label; } w; #endif // ] struct { struct { const char *classic; const char *xml; const char *csv; } label; } n; }; struct { int argc; struct { double (*fn)(bg_tree_t *tree); #if defined (_WIN32) // [ struct { const wchar_t *format; const wchar_t *(*unit)(bg_param_t *param); } w; #endif // ] struct { const char *format; const char *(*unit)(bg_param_t *param); } n; } argv[2]; }; }; #if defined (_WIN32) // [ void bg_print_conf_unitw(FILE *f, int lc, bg_print_conf_t *c, bg_param_t *param, int argv); #endif // ] void bg_print_conf_unit(FILE *f, int lc, bg_print_conf_t *c, bg_param_t *param, int argv); extern bg_print_conf_t bg_print_conf[BG_FLAGS_AGG_MAX_OFFSET]; #if defined (__cplusplus) // [ } #endif // ] #endif // __BG_H__ ] bs1770gain-0.9.5/libbg/bg_sync.c0000755000175000017500000000751213705072325011653 /* * bg_sync.c * * Copyright (C) 2019 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include #if defined (BG_PARAM_THREADS) // [ int bg_sync_create(bg_sync_t *sync) { #if defined (HAVE_PTHREAD) // [ pthread_mutexattr_t mutexattr; int err; ///////////////////////////////////////////////////////////////////////////// memset(&mutexattr,0,sizeof mutexattr); err=pthread_mutexattr_settype(&mutexattr,PTHREAD_MUTEX_RECURSIVE); if (err<0) { _DMESSAGEV("setting mutex attribute (%d)",err); goto e_mutexattr; } ///////////////////////////////////////////////////////////////////////////// err=pthread_mutex_init( &sync->mutex, // pthread_mutex_t *mutex, &mutexattr // const pthread_mutexattr_t *mutexattr ); if (err<0) { _DMESSAGEV("creating mutex (%d)",err); goto e_mutex; } ///////////////////////////////////////////////////////////////////////////// err=pthread_cond_init( &sync->cond, // pthread_cond_t *cv, NULL // const pthread_condattr_t *cattr ); if (err<0) { _DMESSAGEV("creating condition variable (%d)",err); goto e_cond; } #elif defined (_WIN32) // ] [ ///////////////////////////////////////////////////////////////////////////// InitializeCriticalSection(&sync->cs); ///////////////////////////////////////////////////////////////////////////// sync->hEvent=CreateEventW( NULL, // LPSECURITY_ATTRIBUTES lpEventAttributes, FALSE, // BOOL bManualReset, FALSE, // BOOL bInitialState, NULL // LPCSTR lpName ); if (!sync->hEvent) { _DMESSAGEV("creating event (%lu)",GetLastError()); goto e_event; } #endif // ] return 0; //cleanup: #if defined (HAVE_PTHREAD) // [ pthread_cond_destroy(&sync->cond); e_cond: pthread_mutex_destroy(&sync->mutex); e_mutex: e_mutexattr: #elif defined (_WIN32) // ] [ CloseHandle(sync->hEvent); e_event: DeleteCriticalSection(&sync->cs); #endif // ] return -1; } void bg_sync_destroy(bg_sync_t *sync) { #if defined (HAVE_PTHREAD) // [ pthread_cond_destroy(&sync->cond); pthread_mutex_destroy(&sync->mutex); #elif defined (_WIN32) // ] [ CloseHandle(sync->hEvent); DeleteCriticalSection(&sync->cs); #endif // ] } void bg_sync_lock(bg_sync_t *sync) { #if defined (HAVE_PTHREAD) // [ pthread_mutex_lock(&sync->mutex); #elif defined (_WIN32) // ] [ EnterCriticalSection(&sync->cs); #endif // ] } void bg_sync_unlock(bg_sync_t *sync) { #if defined (HAVE_PTHREAD) // [ pthread_mutex_unlock(&sync->mutex); #elif defined (_WIN32) // ] [ LeaveCriticalSection(&sync->cs); #endif // ] } void bg_sync_signal(bg_sync_t *sync) { #if defined (HAVE_PTHREAD) // [ pthread_cond_signal(&sync->cond); #elif defined (_WIN32) // ] [ SetEvent(sync->hEvent); #endif // ] } void bg_sync_wait(bg_sync_t *sync) { #if defined (HAVE_PTHREAD) // [ pthread_cond_wait(&sync->cond,&sync->mutex); #elif defined (_WIN32) // ] [ LeaveCriticalSection(&sync->cs); WaitForSingleObject(&sync->hEvent,INFINITE); EnterCriticalSection(&sync->cs); #endif // ] } #endif // ] bs1770gain-0.9.5/libbg/bgx.c0000755000175000017500000036012614701653773011023 /* * bgx.c * * Copyright (C) 2014-2024 Peter Belkner * Nanos gigantum humeris insidentes #TeamWhite * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.0 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #if defined (_WIN32) // [ #include #include #include #else // ] [ #include #include #if defined (__linux__) && defined (__GNUC__) // [ #include #endif // ] #endif // ] #include #include #if defined (HAVE_FF_DYNLOAD) // [ #include "bg_version.h" #endif // ] /////////////////////////////////////////////////////////////////////////////// /* * once meant as an example program on how to deal with "libbg.a" (and in * turn with "libff.a") finally serving as bs1770gain's implementation. */ #if 1 // [ #if 1 // [ #define BG_TEAM_WHITE \ " #WLM" #else // ] [ #define BG_TEAM_WHITE \ "" #endif // ] #define BG_NANOS_GIGANTUM_HUMERIS_INSIDENTES \ "Nanos gigantum humeris insidentes." BG_TEAM_WHITE "\n" #endif // ] /////////////////////////////////////////////////////////////////////////////// #if defined (HAVE_BG_XML) // [ void bg_set_output_xml(bg_param_t *param) { param->print.vmt=&bg_print_xml_vmt; } int bg_is_output_xml(const bg_param_t *param) { return param->print.vmt==&bg_print_xml_vmt; } #else // ] [ void bg_set_output_xml(bg_param_t *param FFUNUSED) { } int bg_is_output_xml(const bg_param_t *param FFUNUSED) { return 0; } #endif // ] /////////////////////////////////////////////////////////////////////////////// static const ffchar_t *bg_version(const ffchar_t *path, FILE *f) { path=FFBASENAME(path); _FPRINTFV(f,"%" PBU_PRIs,path); #if defined (PACKAGE_VERSION) // [ _FPRINTFV(f," %s",PACKAGE_VERSION); #endif // ] _FPRINTF(f,", Copyright (C) Peter Belkner 2014-2024.\n"), #if defined (BG_NANOS_GIGANTUM_HUMERIS_INSIDENTES) // [ _FPRINTFV(f,"%s",BG_NANOS_GIGANTUM_HUMERIS_INSIDENTES); #endif // ] #if defined (PACKAGE_URL) // [ _FPRINTFV(f,"%s\n",PACKAGE_URL); #endif // ] #if defined (_WIN32) // [ #if defined (_WIN64) // [ _FPRINTFV(f,"%s","Compiled for Windows 64 bit"); #else // ] [ _FPRINTFV(f,"%s","Compiled for Windows 32 bit"); #endif // ] #elif defined (HAVE_FF_DYNLOAD) && defined (BG_POSIX_SYSNAME) // ] [ _FPRINTFV(f,"Compiled for %s",BG_POSIX_SYSNAME); #else // ] [ _FPRINTFV(f,"%s","Compiled"); #endif // ] #if defined (__GNUC__) // [ _FPRINTFV(f," by means of gcc %d.%d.%d",__GNUC__,__GNUC_MINOR__, __GNUC_PATCHLEVEL__); #endif // ] #if defined (BG_WINDOWS_MAJOR) // [ #if defined (BG_WINDOWS_CSD_VESIONA) // [ if (BG_WINDOWS_CSD_VESIONA[0]) { _FPRINTFV(f," on Windows %d.%d.%d\n(%s) expecting\n", BG_WINDOWS_MAJOR, BG_WINDOWS_MINOR, BG_WINDOWS_BUILD_NUMBER, BG_WINDOWS_CSD_VESIONA); } else { #endif // ] _FPRINTFV(f," on Windows %d.%d.%d\nexpecting\n", BG_WINDOWS_MAJOR, BG_WINDOWS_MINOR, BG_WINDOWS_BUILD_NUMBER); #if defined (BG_WINDOWS_CSD_VESIONA) // [ } #endif // ] #elif defined (HAVE_FF_DYNLOAD) // ] [ _FPRINTF(f," on\n"); if (BG_POSIX_NODENAME[0]) _FPRINTFV(f," nodename: %s,\n",BG_POSIX_NODENAME); if (BG_POSIX_RELEASE[0]) _FPRINTFV(f," release: %s,\n",BG_POSIX_RELEASE); if (BG_POSIX_VERSION[0]) _FPRINTFV(f," version: %s,\n",BG_POSIX_VERSION); if (BG_POSIX_MACHINE[0]) _FPRINTFV(f," machine: %s,\n",BG_POSIX_MACHINE); #if defined (BG_POSIX_DOMAINNAME) // [ if (BG_POSIX_DOMAINNAME[0]) _FPRINTFV(f," domainname: %s,\n",BG_POSIX_DOMAINNAME); #endif // ] _FPRINTF(f,"expecting\n"); #else // ] [ _FPRINTF(f," expecting\n"); #endif // ] #if defined (HAVE_FF_DYNLOAD) && defined (BG_GNU_LIBC_VERSION) // [ _FPRINTFV(f," libc: %s (%s),\n", BG_GNU_LIBC_VERSION,BG_GNU_LIBC_RELEASE); #endif // ] _FPRINTFV(f," libavutil: %d.%d.%d,\n", LIBAVUTIL_VERSION_MAJOR, LIBAVUTIL_VERSION_MINOR, LIBAVUTIL_VERSION_MICRO); _FPRINTFV(f," libswresample: %d.%d.%d,\n", LIBSWRESAMPLE_VERSION_MAJOR, LIBSWRESAMPLE_VERSION_MINOR, LIBSWRESAMPLE_VERSION_MICRO); _FPRINTFV(f," libavcodec: %d.%d.%d,\n", LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO); _FPRINTFV(f," libavformat: %d.%d.%d,\n", LIBAVFORMAT_VERSION_MAJOR, LIBAVFORMAT_VERSION_MINOR, LIBAVFORMAT_VERSION_MICRO); _FPRINTFV(f," libswscale: %d.%d.%d,\n", LIBSWSCALE_VERSION_MAJOR, LIBSWSCALE_VERSION_MINOR, LIBSWSCALE_VERSION_MICRO); _FPRINTFV(f," libpostproc: %d.%d.%d, and\n", LIBPOSTPROC_VERSION_MAJOR, LIBPOSTPROC_VERSION_MINOR, LIBPOSTPROC_VERSION_MICRO); _FPRINTFV(f," libavfilter: %d.%d.%d.\n", LIBAVFILTER_VERSION_MAJOR, LIBAVFILTER_VERSION_MINOR, LIBAVFILTER_VERSION_MICRO); _FPRINTF(f,"This is free software; see the source for copying conditions." " There is NO\n" "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR" " PURPOSE.\n"); return path; } #if defined (BG_SAMPLES_COUNT) // [ //#define UPSAMPLER_THRESHOULD #endif // ] static void bg_usage(const ffchar_t *path, FILE *f) { path=bg_version(path,f); _FPRINTFV(f,"\nUsage: %" PBU_PRIs,path); _FPRINTF(f," [options] [ ...]\n\n"); _FPRINTF(f,"Options:\n"); _FPRINTF(f," -v,--version: print this message and exit\n"); _FPRINTF(f," -h,--help[=]?: print this message and exit\n" " (optional argument out of \"codec\" or \"suffix\")\n"); ///////////////////////////////////////////////////////////////////////////// _FPRINTF(f," -i,--integrated: calculate integrated loudness\n"); _FPRINTF(f," -s,--shortterm: calculate maximum shortterm loudness\n"); _FPRINTF(f," -m,--momentary: calculate maximum momentary loudness\n"); #if defined (BG_LOUDNESS_ALL) // [ _FPRINTF(f," --loudness-all: the same as -ism --shortterm-mean\n"); #endif // ] _FPRINTF(f," -r,--range: calculate loudness range\n"); _FPRINTF(f," -p,--sample-peak: calculate maximum sample peak\n"); #if defined (BG_SAMPLES_COUNT) // [ #if defined (UPSAMPLER_THRESHOULD) // [ _FPRINTF(f," -t,--true-peak: calculate maximum true peak\n"); #else // ] [ _FPRINTF(f," -t,--true-peak[=]?: calculate\n" " maximum true peak after having skipped the specified number\n" " of samples from the up-sampler (default=0)\n"); #endif // ] #endif // ] _FPRINTF(f," -b ,--begin=: begin decoding at\n" " timestamp (in microseconds, format: hh:mm:ss.ms)\n"); _FPRINTF(f," -d ,--duration=: let decoding\n" " last duration (in microseconds, format: hh:mm:ss.ms)\n"); _FPRINTF(f," -u ,--use=: base replaygain calculation on\n" " (with respect to the -a/--apply and -o/--output\n" " options. available methods:\n" " integrated (default),\n" " momentary, or\n" " shortterm\n" " experimental methods:\n" " momentary-mean (synonym for \"integrated\"),\n" " momentary-maximum (synonym for \"momentary\"),\n" " shortterm-mean, or\n" " shortterm-maximum (synonym for \"shortterm\")\n"); _FPRINTF(f," -a []/--apply[=]: apply the EBU/ATSC/RG\n" " album gain (in conjunction with the -o/--output option.)\n" " when out of [0.0 .. 1.0] is provided: album gain\n" " plus *(track gain - album gain).\n"); _FPRINTF(f," -o ,--output=: write replaygain tags\n" " or apply the EBU/ATSC/RG gain, respectively,\n" " and output to .\n" " specify either option -o/--output or option --overwrite\n" " but not both.\n"); #if defined (BG_PARAM_PREAMP) // [ _FPRINTF(f," --preamp=\n"); #endif // ] #if ! defined (BG_UNICODE) // [ _FPRINTF(f," -f ,--file=: write analysis to an utf-8 log" " file\n"); _FPRINTF(f," --utf-16[=]: write an utf-16 log file instead of an" " utf-8\n" " log file ( can be omitted when provided by means of the\n" " -f/--file option.)\n"); #else // ] [ _FPRINTF(f," -f ,--file=: write analysis to a log file\n"); #endif // ] #if defined (BG_PARAM_REFERENCE) // [ _FPRINTF(f," --reference=: path to a tree\n" " structural equivalent to the input tree and its's leafes may\n" " serve as a reference to it's correponding input leafes.\n"); #endif // ] #if defined (BG_PARAM_SKIP_SCAN) // [ _FPRINTF(f," --skip-scan: skip counting files.\n"); #endif // ] #if defined (BG_SAMPLES_COUNT) && defined (UPSAMPLER_THRESHOULD) // [ _FPRINTF(f," --upsampler-threshould=: number of\n" " samples to skip when upsampling for true peak calculation\n"); #endif // ] #if defined (BG_PARAM_SCRIPT) // [ _FPRINTF(f," --script=