shithub: aacenc

Download patch

ref: 52380769a70085c4e33827b90c1ec09dfe5b70b7
parent: 5f37017272bdef856b8a2ac8fb054a4794c37222
author: knik <knik@users.sourceforge.net>
date: Sat Jul 8 06:04:55 EDT 2017

added option --ignorelength (support for WAV files over 4 GB)

--- a/frontend/main.c
+++ b/frontend/main.c
@@ -107,6 +107,7 @@
   "  -C\t\tRaw PCM input channels.\n"
   "  -X\t\tRaw PCM swap input bytes\n"
   "  -I <C,LF>\tInput channel config, default is 3,4 (Center third, LF fourth)\n"
+  "  --ignorelength\tIgnore wav length from header (useful with files over 4 GB)\n"
   "\n"
   "MP4 specific options:\n"
 #ifdef HAVE_LIBMP4V2
@@ -304,24 +305,25 @@
 
 enum flags {
   SHORTCTL_FLAG = 300,
-  TNS_FLAG = 301,
-  NO_TNS_FLAG = 302,
-  MPEGVERS_FLAG = 303,
-  OBJTYPE_FLAG = 304,
-  NO_MIDSIDE_FLAG = 306,
+  TNS_FLAG,
+  NO_TNS_FLAG,
+  MPEGVERS_FLAG,
+  OBJTYPE_FLAG,
+  NO_MIDSIDE_FLAG,
+  IGNORELEN_FLAG,
 
 #ifdef HAVE_LIBMP4V2
-  ARTIST_FLAG = 320,
-  TITLE_FLAG = 321,
-  GENRE_FLAG = 322,
-  ALBUM_FLAG = 323,
-  COMPILATION_FLAG = 324,
-  TRACK_FLAG = 325,
-  DISC_FLAG = 326,
-  YEAR_FLAG = 327,
-  COVER_ART_FLAG = 328,
-  COMMENT_FLAG = 329,
-  WRITER_FLAG = 330,
+  ARTIST_FLAG,
+  TITLE_FLAG,
+  GENRE_FLAG,
+  ALBUM_FLAG,
+  COMPILATION_FLAG,
+  TRACK_FLAG,
+  DISC_FLAG,
+  YEAR_FLAG,
+  COVER_ART_FLAG,
+  COMMENT_FLAG,
+  WRITER_FLAG,
 #endif
 };
 
@@ -455,6 +457,7 @@
     u_int64_t total_samples = 0;
     char *faac_id_string;
     char *faac_copyright_string;
+    int ignorelen = FALSE;
 
 #ifndef _WIN32
     // install signal handler
@@ -509,6 +512,7 @@
         { "compilation", 0, 0, COMPILATION_FLAG},
 #endif
         { "pcmswapbytes", 0, 0, 'X'},
+        { "ignorelength", 0, 0, IGNORELEN_FLAG},
             { 0, 0, 0, 0}
         };
         int c = -1;
@@ -690,6 +694,9 @@
         case NO_TNS_FLAG:
             useTns = 0;
             break;
+        case IGNORELEN_FLAG:
+            ignorelen = TRUE;
+            break;
     case MPEGVERS_FLAG:
             mpegVersion = atoi(optarg);
             switch(mpegVersion)
@@ -1085,6 +1092,8 @@
         {
             int bytesWritten;
 
+          if (!ignorelen)
+          {
             if (total_samples < infile->samples || infile->samples == 0)
                 samplesRead = wav_read_float32(infile, pcmbuf, samplesInput,
                                                chanmap);
@@ -1093,6 +1102,9 @@
 
             if (total_samples + (samplesRead / infile->channels) > infile->samples && infile->samples != 0)
                 samplesRead = (infile->samples - total_samples) * infile->channels;
+          }
+          else
+            samplesRead = wav_read_float32(infile, pcmbuf, samplesInput, chanmap);
 
             total_samples += samplesRead / infile->channels;