shithub: aacenc

Download patch

ref: b83f41c9cd91e348ce825521d6ba10b4ef31e8b8
parent: f90c83531213d267c8c46f014b0c9dccd455d1b6
author: lenox <lenox>
date: Wed Mar 22 14:22:54 EST 2000

added new parameters for 'block' mode

--- a/aacenc.h
+++ b/aacenc.h
@@ -3,43 +3,45 @@
 
 typedef struct RCBufStruct RCBuf;	/* buffer handle */
 
-#define PROFILE         1
-#define HEADER_TYPE     2
-#define MS_STEREO       3
-#define IS_STEREO       4
-#define BITRATE         5         // default: 128
-#define CUT_OFF         6         // default: 0
-#define OUT_SAMPLING_RATE       7 // default: 0
-#define RAW_AUDIO       8         // default: 0
-#define TNS             9
-#define LTP             10
-#define PNS             11
+#define PROFILE                 1
+#define HEADER_TYPE             2
+#define MS_STEREO               3
+#define IS_STEREO               4
+#define BITRATE                 5
+#define CUT_OFF                 6
+#define OUT_SAMPLING_RATE       7
+#define RAW_AUDIO               8
+#define TNS                     9
+#define LTP                     10
+#define PNS                     11
+#define IN_SAMPLING_RATE        12
+#define NUMBER_OF_CHANNELS      13
 
-#define MAIN_PROFILE 0           // default
+#define MAIN_PROFILE 0
 #define LOW_PROFILE 1
 
 #define NO_HEADER	0
 #define ADIF_HEADER     1
-#define ADTS_HEADER     2        // default
+#define ADTS_HEADER     2
 
 #define NO_MS           -1
 #define FORCE_MS        1
-#define SWITCHING_MS    0        // default
+#define SWITCHING_MS    0
 
 #define USE_IS          1
-#define NO_IS           0        // default
+#define NO_IS           0
 
 #define USE_TNS         1
-#define NO_TNS          0        // default
+#define NO_TNS          0
 
-#define USE_LTP         1        // default
+#define USE_LTP         1
 #define NO_LTP          0
 
 #define USE_PNS         1
-#define NO_PNS          0        // default
+#define NO_PNS          0
 
 #define USE_RAW_AUDIO   1
-#define NO_RAW_AUDIO    0        //default
+#define NO_RAW_AUDIO    0
 
 #define FNO_ERROR 0
 #define FERROR 1
--- a/encoder.c
+++ b/encoder.c
@@ -81,35 +81,37 @@
 {
   int frameNumSample,delayNumSample;
   int ch, frames, startupNumFrame;
-  SF_INFO sf_info;
 
-  if (as->raw_audio) {
-    sf_info.format =  SF_FORMAT_RAW;
-    sf_info.format |= SF_FORMAT_PCM_BE;
-    sf_info.channels = 2;
-    sf_info.pcmbitwidth = 16;
-    sf_info.samplerate = 44100;
-  }
-
   if ( strcmp(in_file,"") ) {
+    SF_INFO sf_info;
+
     as->in_file = sf_open_read(in_file, &sf_info);
     if (as->in_file == NULL)
       return -1;
+    if (as->raw_audio) {
+      sf_info.format =  SF_FORMAT_RAW;
+      sf_info.format |= SF_FORMAT_PCM_BE;
+      sf_info.channels = 2;
+      sf_info.pcmbitwidth = 16;
+      sf_info.samplerate = 44100;
     }
-  else
+    frames = (int)(sf_info.samples/1024+0.5);
+    as->channels = sf_info.channels;
+    as->in_sampling_rate = sf_info.samplerate;
+    as->out_sampling_rate = (as->out_sampling_rate) ? (as->out_sampling_rate) : (sf_info.samplerate);
+  }
+  else {
     as->in_file = NULL;
+    frames = 0;
+    as->out_sampling_rate = (as->out_sampling_rate) ? (as->out_sampling_rate) : (as->in_sampling_rate);
+  }
+  as->cut_off = (as->cut_off) ? (as->cut_off) : ((as->out_sampling_rate)>>1);
 
   as->out_file = fopen(out_file, "wb");
   if (as->out_file == NULL)
     return -2;
 
-  frames = (int)(sf_info.samples/1024+0.5);
 
-  as->channels = sf_info.channels;
-  as->in_sampling_rate = sf_info.samplerate;
-  as->out_sampling_rate = (as->out_sampling_rate) ? (as->out_sampling_rate) : sf_info.samplerate;
-  as->cut_off = (as->cut_off) ? (as->cut_off) : ((as->out_sampling_rate)>>1);
-
   if ((as->inputBuffer = (double**)malloc( as->channels*sizeof(double*))) == NULL)
     return -3;
   for (ch=0; ch < as->channels; ch++){
@@ -425,6 +427,12 @@
       break;
     case PNS:
       as->use_PNS = value;
+      break;
+    case IN_SAMPLING_RATE:
+      as->in_sampling_rate = value;
+      break;
+    case NUMBER_OF_CHANNELS:
+      as->channels = value;
       break;
   }
 }
--- a/faac.c
+++ b/faac.c
@@ -309,8 +309,7 @@
 
     } while (result != F_FINISH);
 
-    /* finishing last frames and destroying internal data */
-//    faac_EncodeFinish(as);
+    /* destroying internal data */
     faac_EncodeFree(as);
 #ifdef _WIN32
     end = GetTickCount();