[SCM] bs1770gain/master: Imported Upstream version 0.4.8

pere at users.alioth.debian.org pere at users.alioth.debian.org
Sat Dec 19 13:03:55 UTC 2015


The following commit has been merged in the master branch:
commit 4e3882f3e096c9c9dcda21516b2cf6c4c79217a2
Author: Petter Reinholdtsen <pere at hungry.com>
Date:   Sat Dec 19 13:25:36 2015 +0100

    Imported Upstream version 0.4.8

diff --git a/bs1770gain/Makefile.am b/bs1770gain/Makefile.am
index cfaf359..7227a94 100755
--- a/bs1770gain/Makefile.am
+++ b/bs1770gain/Makefile.am
@@ -20,6 +20,9 @@ CPPFLAGS+=-I$(top_srcdir)/libffsox-2
 #CFLAGS+=-ggdb
 #LDFLAGS+=-static-libgcc
 #LDFLAGS+=-static-libstdc++
+if WIN32
+LDFLAGS+=-municode
+endif
 
 FFMPEG_PREFIX=@FFMPEG_PREFIX@
 SOX_PREFIX=@SOX_PREFIX@
diff --git a/bs1770gain/Makefile.in b/bs1770gain/Makefile.in
index 7251838..0dd0037 100755
--- a/bs1770gain/Makefile.in
+++ b/bs1770gain/Makefile.in
@@ -50,6 +50,12 @@ POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+
+#CFLAGS+=-g
+#CFLAGS+=-ggdb
+#LDFLAGS+=-static-libgcc
+#LDFLAGS+=-static-libstdc++
+ at WIN32_TRUE@am__append_1 = -municode
 bin_PROGRAMS = bs1770gain$(EXEEXT)
 subdir = bs1770gain
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
@@ -127,11 +133,6 @@ ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
-
-#CFLAGS+=-g
-#CFLAGS+=-ggdb
-#LDFLAGS+=-static-libgcc
-#LDFLAGS+=-static-libstdc++
 FFMPEG_PREFIX = @FFMPEG_PREFIX@
 FFSOX_AVCODEC_V = @FFSOX_AVCODEC_V@
 FFSOX_AVFORMAT_V = @FFSOX_AVFORMAT_V@
@@ -144,7 +145,7 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LDFLAGS = @LDFLAGS@ @BS1770GAIN_LDFLAGS@
+LDFLAGS = @LDFLAGS@ $(am__append_1) @BS1770GAIN_LDFLAGS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LTLIBOBJS = @LTLIBOBJS@
diff --git a/bs1770gain/bs1770gain.c b/bs1770gain/bs1770gain.c
index 83bc83a..55112c8 100755
--- a/bs1770gain/bs1770gain.c
+++ b/bs1770gain/bs1770gain.c
@@ -137,7 +137,7 @@ void bs1770gain_usage(char **argv, int code)
       "   \"info\", \"verbose\", \"debug\"\n");
   fprintf(stderr," --xml:  print results in xml format\n");
   fprintf(stderr," --time:  print out duration of program invocation\n");
-  //fprintf(stderr," --level:\n");
+  fprintf(stderr," --norm <float>:  norm loudness to float.\n");
   //fprintf(stderr," --preamp <preamp>:\n");
   //fprintf(stderr," --stero:\n");
   //fprintf(stderr," --rg-tags:\n");
@@ -188,6 +188,9 @@ void bs1770gain_usage(char **argv, int code)
   /////////////////////////////////////////////////////////////////////////////
   fprintf(stderr,"\n");
   fprintf(stderr,"Command line arguments can appear in any order.\n");
+#if defined (_WIN32) // {
+  free(argv);
+#endif // }
   exit(code);
 }
 
@@ -199,7 +202,7 @@ enum {
   DRC,
   FORMAT,
   LOGLEVEL,
-  LEVEL,
+  NORM,
   PREAMP,
   ////////////////
   TIME,
@@ -262,7 +265,7 @@ static struct option bs1770gain_opts[]={
   { "extension",required_argument,NULL,EXTENSION },
   { "format",required_argument,NULL,FORMAT },
   { "loglevel",required_argument,NULL,LOGLEVEL },
-  { "level",required_argument,NULL,LEVEL },
+  { "norm",required_argument,NULL,NORM },
   { "preamp",required_argument,NULL,PREAMP },
   { "video",required_argument,NULL,VIDEO },
   ////
@@ -318,8 +321,67 @@ static struct option bs1770gain_opts[]={
 };
 
 ///////////////////////////////////////////////////////////////////////////////
+#if defined (_WIN32) // {
+static char **bs1770gain_wargv2argv(int argc, wchar_t **wargv)
+{
+  size_t size;
+  wchar_t **rp,**mp1;
+  char **argv,**wp1,*wp2,*mp2;
+
+  mp1=wargv+argc;
+  size=0;
+
+  for (rp=wargv;rp<mp1;++rp) {
+    size+=WideCharToMultiByte(
+      CP_UTF8,    // _In_      UINT    CodePage,
+      0,          // _In_      DWORD   dwFlags,
+      *rp,        // _In_      LPCWSTR lpWideCharStr,
+      -1,         // _In_      int     cchWideChar,
+      NULL,       // _Out_opt_ LPSTR   lpMultiByteStr,
+      0,          // _In_      int     cbMultiByte,
+      NULL,       // _In_opt_  LPCSTR  lpDefaultChar,
+      NULL        // _Out_opt_ LPBOOL  lpUsedDefaultChar
+    );
+  }
+
+
+  if (NULL==(argv=malloc((argc*sizeof *argv)+size))) {
+    DMESSAGE("allocating argv");
+    goto malloc;
+  }
+
+  wp1=argv;
+  wp2=(char *)(argv+argc);
+  mp2=wp2+size;
+
+  for (rp=wargv;rp<mp1;++rp) {
+    *wp1++=wp2;
+
+    wp2+=WideCharToMultiByte(
+      CP_UTF8,    // _In_      UINT    CodePage,
+      0,          // _In_      DWORD   dwFlags,
+      *rp,        // _In_      LPCWSTR lpWideCharStr,
+      -1,         // _In_      int     cchWideChar,
+      wp2,        // _Out_opt_ LPSTR   lpMultiByteStr,
+      mp2-wp2,    // _In_      int     cbMultiByte,
+      NULL,       // _In_opt_  LPCSTR  lpDefaultChar,
+      NULL        // _Out_opt_ LPBOOL  lpUsedDefaultChar
+    );
+  }
+
+  return argv;
+malloc:
+  return NULL;
+}
+
+int wmain(int argc, wchar_t **wargv)
+#else // } {
 int main(int argc, char **argv)
+#endif // }
 {
+#if defined (_WIN32) // {
+  char **argv;
+#endif // }
   options_t options;
   FILE *f=stdout;
   tree_t root;
@@ -330,6 +392,13 @@ int main(int argc, char **argv)
   double t1,t2;
   int c;
 
+#if defined (_WIN32) // {
+  if (NULL==(argv=bs1770gain_wargv2argv(argc,wargv))) {
+    DMESSAGE("converting arguments");
+    goto argv;
+  }
+#endif // }
+
   if (1==argc)
     bs1770gain_usage(argv,-1);
 
@@ -340,7 +409,7 @@ int main(int argc, char **argv)
   options.unit="LU";
   options.audio=-1;
   options.video=-1;
-  options.level=-23.0;
+  options.norm=-23.0;
   options.audio_ext="flac";
   options.video_ext="mkv";
 #if defined (BS1770GAIN_TAG_PREFIX) // {
@@ -502,21 +571,21 @@ int main(int argc, char **argv)
       else
         bs1770gain_usage(argv,-1);
       break;
-    case LEVEL:
-      options.level=atof(optarg);
+    case NORM:
+      options.norm=atof(optarg);
       break;
     case PREAMP:
       options.preamp=atof(optarg);
       break;
     /// without flag //////////////////////////////////////////////////////////
     case ATSC:
-      options.level=-24.0;
+      options.norm=-24.0;
       break;
     case EBU:
-      options.level=-23.0;
+      options.norm=-23.0;
       break;
     case REPLAYGAIN:
-      options.level=-18.0;
+      options.norm=-18.0;
       options.unit="dB";
       break;
     case RG_TAGS:
@@ -697,6 +766,10 @@ dynload:
 file:
   TRACE_POP();
   PBU_HEAP_PRINT();
+#if defined (_WIN32) // {
+  free(argv);
+argv:
+#endif // }
 
   return 0;
 }
diff --git a/bs1770gain/bs1770gain.h b/bs1770gain/bs1770gain.h
index 9be50fc..b5d1e9f 100755
--- a/bs1770gain/bs1770gain.h
+++ b/bs1770gain/bs1770gain.h
@@ -148,7 +148,7 @@ struct bs1770gain_options {
   bs1770gain_print_t p;
   int xml;
   const char *unit;
-  double level;
+  double norm;
   double preamp;
   double drc;
   int64_t begin;
@@ -210,7 +210,11 @@ struct bs1770gain_tree {
 
     struct {
       const char *root;
+#if defined (_WIN32) // {
+      _WDIR *d;
+#else // } {
       DIR *d;
+#endif // }
       char *path;
     } dir;
   };
diff --git a/bs1770gain/bs1770gain_print_classic.c b/bs1770gain/bs1770gain_print_classic.c
index 69f1c29..6e1c27a 100755
--- a/bs1770gain/bs1770gain_print_classic.c
+++ b/bs1770gain/bs1770gain_print_classic.c
@@ -19,6 +19,8 @@
  */
 #include <bs1770gain_priv.h>
 
+#define DBFMT "%.2f"
+
 ///////////////////////////////////////////////////////////////////////////////
 static const bs1770gain_print_vmt_t *get_vmt(void);
 
@@ -143,7 +145,7 @@ static void track_body(bs1770gain_print_t *p, aggregate_t *aggregate,
 {
   int flags=aggregate->flags;
   FILE *f=p->f;
-  double level=options->preamp+options->level;
+  double norm=options->preamp+options->norm;
   int width=bs1770gain_print_width(flags);
   double q,db;
 
@@ -153,16 +155,24 @@ static void track_body(bs1770gain_print_t *p, aggregate_t *aggregate,
   if (0!=(flags&AGGREGATE_MOMENTARY_MEAN)) {
     db=lib1770_stats_get_mean(aggregate->momentary,
         options->momentary.mean_gate);
-    //fprintf(f,"       integrated:  %.1f LUFS / %.1f LU\n",db,level-db);
+    //fprintf(f,"       integrated:  %.1f LUFS / %.1f LU\n",db,norm-db);
     bs1770gain_print_label("integrated",width,f);
-    fprintf(f,"%.1f LUFS / %.1f LU\n",db,level-db);
+#if defined (DBFMT) // {
+    fprintf(f,DBFMT " LUFS / " DBFMT " LU\n",db,norm-db);
+#else // } {
+    fprintf(f,"%.1f LUFS / %.1f LU\n",db,norm-db);
+#endif // }
   }
 
   if (0!=(flags&AGGREGATE_MOMENTARY_MAXIMUM)) {
     db=lib1770_stats_get_max(aggregate->momentary);
-    //fprintf(f,"        momentary:  %.1f LUFS / %.1f LU\n",db,level-db);
+    //fprintf(f,"        momentary:  %.1f LUFS / %.1f LU\n",db,norm-db);
     bs1770gain_print_label("momentary maximum",width,f);
-    fprintf(f,"%.1f LUFS / %.1f LU\n",db,level-db);
+#if defined (DBFMT) // {
+    fprintf(f,DBFMT " LUFS / " DBFMT " LU\n",db,norm-db);
+#else // } {
+    fprintf(f,"%.1f LUFS / %.1f LU\n",db,norm-db);
+#endif // }
   }
 
   if (0!=(flags&AGGREGATE_MOMENTARY_RANGE)) {
@@ -172,23 +182,35 @@ static void track_body(bs1770gain_print_t *p, aggregate_t *aggregate,
         options->momentary.range_upper_bound);
     //fprintf(f,"            range:  %.1f LUFS\n",db);
     bs1770gain_print_label("momentary range",width,f);
+#if defined (DBFMT) // {
+    fprintf(f,DBFMT " LUFS\n",db);
+#else // } {
     fprintf(f,"%.1f LUFS\n",db);
+#endif // }
   }
 
   ////////
   if (0!=(flags&AGGREGATE_SHORTTERM_MEAN)) {
     db=lib1770_stats_get_mean(aggregate->shortterm,
         options->shortterm.mean_gate);
-    //fprintf(f,"       integrated:  %.1f LUFS / %.1f LU\n",db,level-db);
+    //fprintf(f,"       integrated:  %.1f LUFS / %.1f LU\n",db,norm-db);
     bs1770gain_print_label("shortterm mean",width,f);
-    fprintf(f,"%.1f LUFS / %.1f LU\n",db,level-db);
+#if defined (DBFMT) // {
+    fprintf(f,DBFMT " LUFS / " DBFMT " LU\n",db,norm-db);
+#else // } {
+    fprintf(f,"%.1f LUFS / %.1f LU\n",db,norm-db);
+#endif // }
   }
 
   if (0!=(flags&AGGREGATE_SHORTTERM_MAXIMUM)) {
     db=lib1770_stats_get_max(aggregate->shortterm);
-    //fprintf(f,"       shortterm:  %.1f LUFS / %.1f LU\n",db,level-db);
+    //fprintf(f,"       shortterm:  %.1f LUFS / %.1f LU\n",db,norm-db);
     bs1770gain_print_label("shortterm maximum",width,f);
-    fprintf(f,"%.1f LUFS / %.1f LU\n",db,level-db);
+#if defined (DBFMT) // {
+    fprintf(f,DBFMT " LUFS / " DBFMT " LU\n",db,norm-db);
+#else // } {
+    fprintf(f,"%.1f LUFS / %.1f LU\n",db,norm-db);
+#endif // }
   }
 
   if (0!=(flags&AGGREGATE_SHORTTERM_RANGE)) {
@@ -198,7 +220,11 @@ static void track_body(bs1770gain_print_t *p, aggregate_t *aggregate,
         options->shortterm.range_upper_bound);
     //fprintf(f,"            range:  %.1f LUFS\n",db);
     bs1770gain_print_label("range",width,f);
+#if defined (DBFMT) // {
+    fprintf(f,DBFMT " LUFS\n",db);
+#else // } {
     fprintf(f,"%.1f LUFS\n",db);
+#endif // }
   }
 
   ////////
@@ -207,7 +233,11 @@ static void track_body(bs1770gain_print_t *p, aggregate_t *aggregate,
     db=LIB1770_Q2DB(q);
     //fprintf(f,"      sample peak:  %.1f SPFS / %f\n",db,q);
     bs1770gain_print_label("sample peak",width,f);
+#if defined (DBFMT) // {
+    fprintf(f,DBFMT " SPFS / %f\n",db,q);
+#else // } {
     fprintf(f,"%.1f SPFS / %f\n",db,q);
+#endif // }
   }
 
   if (0!=(flags&AGGREGATE_TRUEPEAK)) {
@@ -215,7 +245,11 @@ static void track_body(bs1770gain_print_t *p, aggregate_t *aggregate,
     db=LIB1770_Q2DB(q);
     //fprintf(f,"        true peak:  %.1f TPFS / %f\n",db,q);
     bs1770gain_print_label("true peak",width,f);
+#if defined (DBFMT) // {
+    fprintf(f,DBFMT " TPFS / %f\n",db,q);
+#else // } {
     fprintf(f,"%.1f TPFS / %f\n",db,q);
+#endif // }
   }
 }
 
diff --git a/bs1770gain/bs1770gain_print_xml.c b/bs1770gain/bs1770gain_print_xml.c
index fa4c671..85cdacc 100755
--- a/bs1770gain/bs1770gain_print_xml.c
+++ b/bs1770gain/bs1770gain_print_xml.c
@@ -19,6 +19,8 @@
  */
 #include <bs1770gain_priv.h>
 
+#define DBFMT "%.2f"
+
 ///////////////////////////////////////////////////////////////////////////////
 static const bs1770gain_print_vmt_t *get_vmt(void);
 
@@ -90,19 +92,29 @@ static void track_body(bs1770gain_print_t *p, aggregate_t *aggregate,
 {
   int flags=aggregate->flags;
   FILE *f=p->f;
-  double level=options->preamp+options->level;
+  double norm=options->preamp+options->norm;
   double q,db;
 
   ////////
   if (0!=(flags&AGGREGATE_MOMENTARY_MEAN)) {
     db=lib1770_stats_get_mean(aggregate->momentary,
         options->momentary.mean_gate);
-    fprintf(f,"      <integrated lufs=\"%.1f\" lu=\"%.1f\" />\n",db,level-db);
+#if defined (DBFMT) // {
+    fprintf(f,"      <integrated lufs=\"" DBFMT "\" lu=\"" DBFMT "\" />\n",
+        db,norm-db);
+#else // } {
+    fprintf(f,"      <integrated lufs=\"%.1f\" lu=\"%.1f\" />\n",db,norm-db);
+#endif // }
   }
 
   if (0!=(flags&AGGREGATE_MOMENTARY_MAXIMUM)) {
     db=lib1770_stats_get_max(aggregate->momentary);
-    fprintf(f,"      <momentary lufs=\"%.1f\" lu=\"%.1f\" />\n",db,level-db);
+#if defined (DBFMT) // {
+    fprintf(f,"      <momentary lufs=\"" DBFMT "\" lu=\"" DBFMT "\" />\n",
+        db,norm-db);
+#else // } {
+    fprintf(f,"      <momentary lufs=\"%.1f\" lu=\"%.1f\" />\n",db,norm-db);
+#endif // }
   }
 
   if (0!=(flags&AGGREGATE_MOMENTARY_RANGE)) {
@@ -110,21 +122,35 @@ static void track_body(bs1770gain_print_t *p, aggregate_t *aggregate,
         options->momentary.range_gate,
         options->momentary.range_lower_bound,
         options->momentary.range_upper_bound);
+#if defined (DBFMT) // {
+    fprintf(f,"      <momentary-range lufs=\"" DBFMT "\" />\n",db);
+#else // } {
     fprintf(f,"      <momentary-range lufs=\"%.1f\" />\n",db);
+#endif // }
   }
 
   ////////
   if (0!=(flags&AGGREGATE_SHORTTERM_MEAN)) {
     db=lib1770_stats_get_mean(aggregate->shortterm,
         options->shortterm.mean_gate);
+#if defined (DBFMT) // {
+    fprintf(f,"      <shortterm-mean lufs=\"" DBFMT "\" lu=\"" DBFMT "\" />\n",
+        db,norm-db);
+#else // } {
     fprintf(f,"      <shortterm-mean lufs=\"%.1f\" lu=\"%.1f\" />\n",
-        db,level-db);
+        db,norm-db);
+#endif // }
   }
 
   if (0!=(flags&AGGREGATE_SHORTTERM_MAXIMUM)) {
     db=lib1770_stats_get_max(aggregate->shortterm);
+#if defined (DBFMT) // {
+    fprintf(f,"      <shortterm-maximum lufs=\"" DBFMT "\""
+        " lu=\"" DBFMT "\" />\n",db,norm-db);
+#else // } {
     fprintf(f,"      <shortterm-maximum lufs=\"%.1f\" lu=\"%.1f\" />\n",
-        db,level-db);
+        db,norm-db);
+#endif // }
   }
 
   if (0!=(flags&AGGREGATE_SHORTTERM_RANGE)) {
@@ -132,20 +158,32 @@ static void track_body(bs1770gain_print_t *p, aggregate_t *aggregate,
         options->shortterm.range_gate,
         options->shortterm.range_lower_bound,
         options->shortterm.range_upper_bound);
+#if defined (DBFMT) // {
+    fprintf(f,"      <range lufs=\"" DBFMT "\" />\n",db);
+#else // } {
     fprintf(f,"      <range lufs=\"%.1f\" />\n",db);
+#endif // }
   }
 
   ////////
   if (0!=(flags&AGGREGATE_SAMPLEPEAK)) {
     q=aggregate->samplepeak;
     db=LIB1770_Q2DB(q);
+#if defined (DBFMT) // {
+    fprintf(f,"      <sample-peak spfs=\"" DBFMT "\" factor=\"%f\" />\n",db,q);
+#else // } {
     fprintf(f,"      <sample-peak spfs=\"%.1f\" factor=\"%f\" />\n",db,q);
+#endif // }
   }
 
   if (0!=(flags&AGGREGATE_TRUEPEAK)) {
     q=aggregate->truepeak;
     db=LIB1770_Q2DB(q);
+#if defined (DBFMT) // {
+    fprintf(f,"      <true-peak tpfs=\"" DBFMT "\" factor=\"%f\" />\n",db,q);
+#else // } {
     fprintf(f,"      <true-peak tpfs=\"%.1f\" factor=\"%f\" />\n",db,q);
+#endif // }
   }
 
   fflush(p->f);
diff --git a/bs1770gain/bs1770gain_transcode.c b/bs1770gain/bs1770gain_transcode.c
index cfc1e2d..5efb749 100755
--- a/bs1770gain/bs1770gain_transcode.c
+++ b/bs1770gain/bs1770gain_transcode.c
@@ -23,9 +23,9 @@
 static void bs1770gain_tags_rg(tag_t *tags, const aggregate_t *track,
     const aggregate_t *album, const options_t *options)
 {
-  double db,level;
+  double db,norm;
 
-  level=options->preamp+options->level;
+  norm=options->preamp+options->norm;
 
   while (NULL!=tags->key) {
     ///////////////////////////////////////////////////////////////////////////
@@ -34,7 +34,7 @@ static void bs1770gain_tags_rg(tag_t *tags, const aggregate_t *track,
       goto next;
     }
     else if (0==strcasecmp("REPLAYGAIN_REFERENCE_LOUDNESS",tags->key)) {
-      sprintf(tags->val,"%.2f",level);
+      sprintf(tags->val,"%.2f",norm);
       goto next;
     }
 
@@ -42,7 +42,7 @@ static void bs1770gain_tags_rg(tag_t *tags, const aggregate_t *track,
     if (BS1770GAIN_IS_MODE_TRACK_TAGS(options->mode)) {
       if (0==strcasecmp("REPLAYGAIN_TRACK_GAIN",tags->key)) {
         db=bs1770gain_aggregate_get_loudness(track,options);
-        sprintf(tags->val,"%.2f %s",level-db,options->unit);
+        sprintf(tags->val,"%.2f %s",norm-db,options->unit);
         goto next;
       }
       else if (0==strcasecmp("REPLAYGAIN_TRACK_PEAK",tags->key)) {
@@ -70,7 +70,7 @@ static void bs1770gain_tags_rg(tag_t *tags, const aggregate_t *track,
     if (BS1770GAIN_IS_MODE_ALBUM_TAGS(options->mode)) {
       if (0==strcasecmp("REPLAYGAIN_ALBUM_GAIN",tags->key)) {
         db=bs1770gain_aggregate_get_loudness(album,options);
-        sprintf(tags->val,"%.2f %s",level-db,options->unit);
+        sprintf(tags->val,"%.2f %s",norm-db,options->unit);
         goto next;
       }
       else if (0==strcasecmp("REPLAYGAIN_ALBUM_PEAK",tags->key)) {
@@ -103,13 +103,13 @@ static void bs1770gain_tags_rg(tag_t *tags, const aggregate_t *track,
 static void bs1770gain_tags_bwf(tag_t *tags, const aggregate_t *aggregate,
     const options_t *options)
 {
-  double db,level;
+  double db,norm;
 
   while (NULL!=tags->key) { 
     if (0==strcasecmp("LoudnessValue",tags->key)) {
-      level=options->preamp+options->level;
+      norm=options->preamp+options->norm;
       db=bs1770gain_aggregate_get_loudness(aggregate,options);
-      sprintf(tags->val,"%d",(int)floor(100.0*(level-db)+0.5));
+      sprintf(tags->val,"%d",(int)floor(100.0*(norm-db)+0.5));
     }
     else if (0==strcasecmp("MaxTruePeakLevel",tags->key)) {
       if (0!=(aggregate->flags&AGGREGATE_TRUEPEAK))
@@ -395,7 +395,7 @@ int bs1770gain_transcode(track_t *t, options_t *options)
   }
 
   if (BS1770GAIN_IS_MODE_APPLY(options->mode)) {
-    q=options->preamp+options->level;
+    q=options->preamp+options->norm;
     q-=(1.0-options->apply)*bs1770gain_aggregate_get_loudness(&a->aggregate,
         options);
     q-=options->apply*bs1770gain_aggregate_get_loudness(&t->aggregate,
diff --git a/bs1770gain/bs1770gain_tree.c b/bs1770gain/bs1770gain_tree.c
index 127e0d3..fe2b198 100755
--- a/bs1770gain/bs1770gain_tree.c
+++ b/bs1770gain/bs1770gain_tree.c
@@ -21,6 +21,14 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
+#if defined (_WIN32) // {
+#define CLOSEDIR(d)   _wclosedir(d)
+#define READDIR(d)    _wreaddir(d)
+#else // } {
+#define CLOSEDIR(d)   closedir(d)
+#define READDIR(d)    readdir(d)
+#endif // }
+
 ///////////////////////////////////////////////////////////////////////////////
 bs1770gain_tree_t *bs1770gain_tree_init(bs1770gain_tree_t *tree,
     const bs1770gain_tree_vmt_t *vmt, bs1770gain_tree_t *root,
@@ -412,42 +420,92 @@ bs1770gain_tree_t *bs1770gain_tree_dir_init(bs1770gain_tree_t *tree,
     bs1770gain_tree_t *cli, const bs1770gain_tree_t *parent,
     const char *root)
 {
+#if defined (_WIN32) // {
+  wchar_t *wroot;
+#endif // }
+
   bs1770gain_tree_init(tree,bs1770gain_tree_dir_vmt(),cli,parent);
   tree->dir.root=root;
   tree->dir.path=NULL;
 
-  if (NULL==(tree->dir.d=opendir(root)))
+#if defined (_WIN32) // {
+  if (NULL==(wroot=pbu_s2w(root))) {
+    DMESSAGE("converting string");
+    goto s2w;
+  }
+
+  if (NULL==(tree->dir.d=_wopendir(wroot))) {
+    DMESSAGE("opening directory");
+    goto dir;
+  }
+
+  free(wroot);
+#else // } {
+  if (NULL==(tree->dir.d=opendir(root))) {
+    DMESSAGE("opening directory");
     goto dir;
+  }
+#endif // }
 
   return tree;
 dir:
+#if defined (_WIN32) // {
+  free(wroot);
+s2w:
+#endif // }
   return NULL;
 }
 
 void bs1770gain_tree_dir_cleanup(bs1770gain_tree_t *tree)
 {
   bs1770gain_tree_free_path(tree);
-  closedir(tree->dir.d);
+  CLOSEDIR(tree->dir.d);
 }
 
 int bs1770gain_tree_dir_next(bs1770gain_tree_t *tree,
     const bs1770gain_options_t *options)
 {
+#if defined (_WIN32) // {
+  struct _wdirent *e;
+#else // } {
   struct dirent *e;
+#endif // }
+  char *d_name;
 
   bs1770gain_tree_free_path(tree);
 
-  while (NULL!=(e=readdir(tree->dir.d))) {
-    if (0==strcmp(".",e->d_name)||0==strcmp("..",e->d_name))
-      continue;
-    else if (NULL==(tree->dir.path=pbu_extend_path(tree->dir.root,e->d_name)))
-      continue;
-    else if (0<bs1770gain_tree_stat(tree,tree->dir.path,options))
+  while (NULL!=(e=READDIR(tree->dir.d))) {
+#if defined (_WIN32) // {
+    if (NULL==(d_name=pbu_w2s(e->d_name))) {
+      DMESSAGE("converting string");
+      goto invalid;
+    }
+#else // } {
+    d_name=e->d_name;
+#endif // }
+    if (0==strcmp(".",d_name)||0==strcmp("..",d_name))
+      goto next;
+    else if (NULL==(tree->dir.path=pbu_extend_path(tree->dir.root,d_name)))
+      goto next;
+    else if (0<bs1770gain_tree_stat(tree,tree->dir.path,options)) {
+#if defined (_WIN32) // {
+      free(d_name);
+#endif // }
       return tree->state;
+    }
 
     bs1770gain_tree_free_path(tree);
+  next:
+#if defined (_WIN32) // {
+    free(d_name);
+#else // } {
+    ;
+#endif // }
   }
 
+#if defined (_WIN32) // {
+invalid:
+#endif // }
   return BS1770GAIN_TREE_STATE_INV;
 }
 
diff --git a/configure b/configure
index a987c63..2a8e8c7 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for bs1770gain 0.4.7.
+# Generated by GNU Autoconf 2.69 for bs1770gain 0.4.8.
 #
 # Report bugs to <pbelkner at users.sf.net>.
 #
@@ -580,8 +580,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='bs1770gain'
 PACKAGE_TARNAME='bs1770gain'
-PACKAGE_VERSION='0.4.7'
-PACKAGE_STRING='bs1770gain 0.4.7'
+PACKAGE_VERSION='0.4.8'
+PACKAGE_STRING='bs1770gain 0.4.8'
 PACKAGE_BUGREPORT='pbelkner at users.sf.net'
 PACKAGE_URL='http://bs1770gain.sourceforge.net/'
 
@@ -641,6 +641,8 @@ FFMPEG_PREFIX
 BS1770GAIN_LDFLAGS
 SOLIB
 SODIR
+WIN32_FALSE
+WIN32_TRUE
 RANLIB
 am__fastdepCC_FALSE
 am__fastdepCC_TRUE
@@ -1278,7 +1280,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures bs1770gain 0.4.7 to adapt to many kinds of systems.
+\`configure' configures bs1770gain 0.4.8 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1344,7 +1346,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of bs1770gain 0.4.7:";;
+     short | recursive ) echo "Configuration of bs1770gain 0.4.8:";;
    esac
   cat <<\_ACEOF
 
@@ -1440,7 +1442,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-bs1770gain configure 0.4.7
+bs1770gain configure 0.4.8
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1696,7 +1698,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by bs1770gain $as_me 0.4.7, which was
+It was created by bs1770gain $as_me 0.4.8, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2511,7 +2513,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='bs1770gain'
- VERSION='0.4.7'
+ VERSION='0.4.8'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -3644,6 +3646,14 @@ _ACEOF
 
 win32="`$tmp`"
 rm -f "$tmp"
+ if test x$win32 = xyes; then
+  WIN32_TRUE=
+  WIN32_FALSE='#'
+else
+  WIN32_TRUE='#'
+  WIN32_FALSE=
+fi
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $win32" >&5
 $as_echo "$win32" >&6; }
 # }
@@ -4770,6 +4780,10 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
   as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${WIN32_TRUE}" && test -z "${WIN32_FALSE}"; then
+  as_fn_error $? "conditional \"WIN32\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 
 : "${CONFIG_STATUS=./config.status}"
 ac_write_fail=0
@@ -5167,7 +5181,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by bs1770gain $as_me 0.4.7, which was
+This file was extended by bs1770gain $as_me 0.4.8, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -5234,7 +5248,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-bs1770gain config.status 0.4.7
+bs1770gain config.status 0.4.8
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index 500669e..0582694 100755
--- a/configure.ac
+++ b/configure.ac
@@ -26,7 +26,7 @@
 # AC_CHECK_HEADER (header-file, [action-if-found], [action-if-not-found], [includes = `default-includes'])
 # AC_CHECK_LIB (library, function, [action-if-found], [action-if-not-found], [other-libraries])
 
-AC_INIT([bs1770gain], [0.4.7], [pbelkner at users.sf.net], [], [http://bs1770gain.sourceforge.net/])
+AC_INIT([bs1770gain], [0.4.8], [pbelkner at users.sf.net], [], [http://bs1770gain.sourceforge.net/])
 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
 AC_PROG_CC
 AC_PROG_RANLIB
@@ -50,6 +50,7 @@ _ACEOF
 
 win32="`$tmp`"
 rm -f "$tmp"
+AM_CONDITIONAL([WIN32], [test x$win32 = xyes])
 AC_MSG_RESULT($win32)
 # }
 
diff --git a/libpbutil/Makefile.am b/libpbutil/Makefile.am
index 2bf653c..12f1cf9 100755
--- a/libpbutil/Makefile.am
+++ b/libpbutil/Makefile.am
@@ -32,6 +32,7 @@ libpbutil_a_SOURCES+=pbu_malloc.c
 libpbutil_a_SOURCES+=pbu_mkdir.c
 libpbutil_a_SOURCES+=pbu_msvcrt.c
 libpbutil_a_SOURCES+=pbu_s2w.c
+libpbutil_a_SOURCES+=pbu_w2s.c
 libpbutil_a_SOURCES+=pbu_same_file.c
 libpbutil_a_SOURCES+=pbu_strtok.c
 libpbutil_a_SOURCES+=pbu_trace.c
diff --git a/libpbutil/Makefile.in b/libpbutil/Makefile.in
index 4eabd9a..27f74a8 100755
--- a/libpbutil/Makefile.in
+++ b/libpbutil/Makefile.in
@@ -68,8 +68,8 @@ am_libpbutil_a_OBJECTS = pbu_basename.$(OBJEXT) \
 	pbu_copy_file.$(OBJEXT) pbu_ext.$(OBJEXT) \
 	pbu_extend_path.$(OBJEXT) pbu_list.$(OBJEXT) \
 	pbu_malloc.$(OBJEXT) pbu_mkdir.$(OBJEXT) pbu_msvcrt.$(OBJEXT) \
-	pbu_s2w.$(OBJEXT) pbu_same_file.$(OBJEXT) pbu_strtok.$(OBJEXT) \
-	pbu_trace.$(OBJEXT) pbu_wcstok.$(OBJEXT)
+	pbu_s2w.$(OBJEXT) pbu_w2s.$(OBJEXT) pbu_same_file.$(OBJEXT) \
+	pbu_strtok.$(OBJEXT) pbu_trace.$(OBJEXT) pbu_wcstok.$(OBJEXT)
 libpbutil_a_OBJECTS = $(am_libpbutil_a_OBJECTS)
 DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -195,7 +195,7 @@ noinst_LIBRARIES = libpbutil.a
 #libpbutil_a_SOURCES+=pbu_dirent.c
 libpbutil_a_SOURCES = pbutil.h pbutil_priv.h pbu_basename.c \
 	pbu_copy_file.c pbu_ext.c pbu_extend_path.c pbu_list.c \
-	pbu_malloc.c pbu_mkdir.c pbu_msvcrt.c pbu_s2w.c \
+	pbu_malloc.c pbu_mkdir.c pbu_msvcrt.c pbu_s2w.c pbu_w2s.c \
 	pbu_same_file.c pbu_strtok.c pbu_trace.c pbu_wcstok.c
 all: all-am
 
@@ -257,6 +257,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pbu_same_file.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pbu_strtok.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pbu_trace.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pbu_w2s.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pbu_wcstok.Po at am__quote@
 
 .c.o:
diff --git a/libpbutil/pbu_w2s.c b/libpbutil/pbu_w2s.c
new file mode 100755
index 0000000..baf31f7
--- /dev/null
+++ b/libpbutil/pbu_w2s.c
@@ -0,0 +1,60 @@
+/*
+ * pbu_s2w.c
+ * Copyright (C) 2014 Peter Belkner <pbelkner at users.sf.net>
+ *
+ * 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 <pbutil_priv.h>
+
+char *pbu_w2s(const wchar_t *w)
+{
+  size_t size;
+  char *s;
+
+  s=NULL;
+
+  if (NULL==w)
+    goto s;
+
+  size=WideCharToMultiByte(
+    CP_UTF8,      // _In_      UINT    CodePage,
+    0,            // _In_      DWORD   dwFlags,
+    w,            // _In_      LPCWSTR lpWideCharStr,
+    -1,           // _In_      int     cchWideChar,
+    NULL,         // _Out_opt_ LPSTR   lpMultiByteStr,
+    0,            // _In_      int     cbMultiByte,
+    NULL,         // _In_opt_  LPCSTR  lpDefaultChar,
+    NULL          // _Out_opt_ LPBOOL  lpUsedDefaultChar
+  );
+
+  if (NULL==(s=MALLOC(size*(sizeof *s))))
+    goto s;
+
+  size=WideCharToMultiByte(
+    CP_UTF8,      // _In_      UINT    CodePage,
+    0,            // _In_      DWORD   dwFlags,
+    w,            // _In_      LPCWSTR lpWideCharStr,
+    -1,           // _In_      int     cchWideChar,
+    s,            // _Out_opt_ LPSTR   lpMultiByteStr,
+    size,         // _In_      int     cbMultiByte,
+    NULL,         // _In_opt_  LPCSTR  lpDefaultChar,
+    NULL          // _Out_opt_ LPBOOL  lpUsedDefaultChar
+  );
+s:
+  return s;
+}
+#endif // }
diff --git a/libpbutil/pbutil.h b/libpbutil/pbutil.h
index 338b3f8..17d069f 100755
--- a/libpbutil/pbutil.h
+++ b/libpbutil/pbutil.h
@@ -188,6 +188,7 @@ wchar_t *pbu_wcstok_r(wchar_t *str, const wchar_t *delim, wchar_t **saveptr);
 char *pbu_strtok_r(char *str, const char *delim, char **saveptr);
 int pbu_copy_file(const wchar_t *src, const wchar_t *dst);
 wchar_t *pbu_s2w(const char *s);
+char *pbu_w2s(const wchar_t *w);
 const char *pbu_message(const char *format, ...);
 #else // } {
 int pbu_copy_file(const char *src, const char *dst);

-- 
bs1770gain packaging



More information about the pkg-multimedia-commits mailing list