shithub: aacenc

Download patch

ref: 741746a7782b44a4592760b814b565226f9ef039
parent: f12918fbb3750599399505d4dbf6ff4027d0c8eb
author: menno <menno>
date: Tue Oct 3 15:58:14 EDT 2000

Multichannel fixes. All working now, except LFE channels

--- a/enc_tf.c
+++ b/enc_tf.c
@@ -59,16 +59,7 @@
 /* AAC shorter windows 960-480-120 */
 int useShortWindows=0;  /* don't use shorter windows */
 
-// TEMPORARY HACK
 
-int srate_idx;
-
-int sampling_rate;
-int bit_rate;
-
-// END OF HACK
-
-
 /* EncTfFree() */
 /* Free memory allocated by t/f-based encoder core. */
 
@@ -112,15 +103,13 @@
 {
   int chanNum, i;
   int SampleRates[] = { 96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,0};
+  int srate_idx;
 //	int BitRates[] = {
 //		64000,80000,96000,112000,128000,160000,192000,224000,256000,0
 //	};
 
-  sampling_rate = as->out_sampling_rate;
-  bit_rate = as->bit_rate;
-
   for (i = 0; ; i++) {
-    if (SampleRates[i] == sampling_rate) {
+    if (SampleRates[i] == as->out_sampling_rate) {
       srate_idx = i;
       break;
     }
@@ -170,7 +159,7 @@
 
   /* Init TNS */
   for (chanNum=0;chanNum<MAX_TIME_CHANNELS;chanNum++) {
-    TnsInit(sampling_rate,profile,&tnsInfo[chanNum]);
+    TnsInit(as->out_sampling_rate,profile,&tnsInfo[chanNum]);
     quantInfo[chanNum].tnsInfo = &tnsInfo[chanNum];         /* Set pointer to TNS data */
   }
 
@@ -301,7 +290,7 @@
   /* psychoacoustics */
   /*****************************************************************************/
   EncTf_psycho_acoustic(
-	  sampling_rate,
+	  as->out_sampling_rate,
 	  max_ch,
 	  channelInfo,
 	  DTimeSigLookAheadBuf,
@@ -368,7 +357,7 @@
         case ONLY_SHORT_WINDOW  :
 //      no_sub_win   = short_win_in_long;
 //      sub_win_size = block_size_samples/short_win_in_long;
-        quantInfo[chanNum].max_sfb = max_sfb_s[srate_idx];
+        quantInfo[chanNum].max_sfb = max_sfb_s[quantInfo[chanNum].srate_idx];
 #if 0
         quantInfo[chanNum].num_window_groups = 4;
         quantInfo[chanNum].window_group_length[0] = 1;
@@ -391,7 +380,7 @@
         default:
 //      no_sub_win   = 1;
 //      sub_win_size = block_size_samples;
-        quantInfo[chanNum].max_sfb = max_sfb_l[srate_idx];
+        quantInfo[chanNum].max_sfb = max_sfb_l[quantInfo[chanNum].srate_idx];
         quantInfo[chanNum].num_window_groups = 1;
         quantInfo[chanNum].window_group_length[0]=1;
         break;
--- a/encoder.c
+++ b/encoder.c
@@ -118,13 +118,13 @@
       return -4;
   }
 
-  if((as->bit_rate % 1000)||(as->bit_rate < 16000))
+  if((as->bit_rate % 1000)||(as->bit_rate < 8000))
     return -5;
   if (as->channels != 2)
       if(as->channels == 1)
         as->use_MS=-1;
-      else
-        return -6;
+//      else
+//        return -6;
   if ((as->profile != MAIN_PROFILE)&&(as->profile != LOW_PROFILE))
     return -7;
 
@@ -145,7 +145,7 @@
 
   as->samplesToRead = frameNumSample * as->channels;
 
-  as->frame_bits = (int)(as->bit_rate*frameNumSample/as->out_sampling_rate+0.5);
+  as->frame_bits = (int)((as->bit_rate*as->channels)*frameNumSample/as->out_sampling_rate+0.5);
   as->bitBufferSize = (int)(((as->frame_bits * 5) + 7)/8);
 
 
@@ -256,7 +256,7 @@
     continue;
   }
 
-  bitBuf = BsOpenWrite(as->frame_bits * 10);
+  bitBuf = BsOpenWrite(as->frame_bits * as->channels * 10);
 
   /* compute available number of bits */
   /* frameAvailNumBit contains number of bits in reservoir */
@@ -265,7 +265,7 @@
     as->available_bits = 8184;
 
   /* Add to frameAvailNumBit the number of bits for this frame */
-  as->available_bits += as->frame_bits;
+  as->available_bits += (as->frame_bits * as->channels);
 
   /* Encode frame */
   error = EncTfFrame(as, bitBuf);
@@ -390,7 +390,7 @@
   as->use_PNS = 0;
   as->lfePresent = 0;
   as->cut_off = 0;
-  as->bit_rate = 128000;
+  as->bit_rate = 64000;
   as->out_sampling_rate = 0;
   as->raw_audio = 0;
 }
--- a/faac.c
+++ b/faac.c
@@ -56,7 +56,7 @@
   printf("Options:\n");
   printf(" -?    Shows this help screen.\n");
   printf(" -pX   AAC profile (X can be LOW, or MAIN (default).\n");
-  printf(" -bX   Bitrate in kbps (in steps of 1kbps, min. 16kbps)\n");
+  printf(" -bX   Bitrate in kbps/channel (in steps of 1kbps, min. 16kbps)\n");
   printf(" -pns  Use PNS (Perceptual Noise Substitution).\n");
   printf(" -nt   Don't use TNS (Temporal Noise Shaping).\n");
   printf(" -ms   Use mid/side stereo coding.\n");
@@ -240,7 +240,7 @@
   printf("AAC configuration:\n");
   printf("----------------------------------------------\n");
   printf("AAC profile: %s.\n", (as->profile==MAIN_PROFILE)?"MAIN":"LOW");
-  printf("Bitrate: %dkbps.\n", as->bit_rate/1000);
+  printf("Bitrate: %dkbps/ch.\n", as->bit_rate/1000);
   printf("Mid/Side (MS) stereo coding: %s.\n",
  	(as->use_MS==1)?"Always (If CPE)":((as->use_MS==0)?"Switching (If CPE)":"Off"));
   printf("Temporal Noise Shaping: %s.\n", as->use_TNS?"On":"Off");
--- a/nok_ltp_enc.c
+++ b/nok_ltp_enc.c
@@ -34,9 +34,9 @@
 /**************************************************************************
   Version Control Information			Method: CVS
   Identifiers:
-  $Revision: 1.10 $
-  $Date: 2000/02/28 12:18:36 $ (check in)
-  $Author: lenox $
+  $Revision: 1.12 $
+  $Date: 2000/10/04 19:45:33 $ (check in)
+  $Author: menno $
   *************************************************************************/
 
 
@@ -296,9 +296,9 @@
 		for (i = 0; i < BLOCK_LEN_LONG; i++)
 		{
 			lt_status->buffer[i + j] =
-				double_to_int (predicted_samples[i] + lt_status->buffer[i + j]);
+				(short)double_to_int (predicted_samples[i] + lt_status->buffer[i + j]);
 			lt_status->buffer[NOK_LT_BLEN - BLOCK_LEN_LONG + i] =
-				double_to_int (predicted_samples[i + BLOCK_LEN_LONG]);
+				(short)double_to_int (predicted_samples[i + BLOCK_LEN_LONG]);
 		}
 		break;
 
--- a/psych.c
+++ b/psych.c
@@ -632,7 +632,7 @@
 
 			} else if (channelInfo[chanNum].lfe) { /* LFE */
 
-				// LFE psych ratios are set to -24 dB
+				// LFE psych ratios are set to -24 dB for low frequencies
 				for (i = 0; i < 4; i++) {
 					psy_stvar_long[chanNum].ismr[i] = 0.004; /* -24 dB */
 				}
--- a/rateconv.c
+++ b/rateconv.c
@@ -1,7 +1,7 @@
 /**********************************************************************
 audio sample rate converter
 
-$Id: rateconv.c,v 1.3 2000/02/18 09:18:27 lenox Exp $
+$Id: rateconv.c,v 1.5 2000/10/04 19:45:33 menno Exp $
 
 Source file: rateconv.c
 
@@ -591,14 +591,14 @@
     {
       if ( fd<0.0 )
 	{
-	  fc=1.0/d1-trw2;
-	  if ( fc<0.5-0.5*trw2 ) { numode=1; fc=2.0/d1-trw2; }
-	  if ( fc>1.0-trw2 ) fc=1.0-trw2;
+	  fc=(float)(1.0/d1-trw2);
+	  if ( fc<0.5-0.5*trw2 ) { numode=1; fc=(float)(2.0/d1-trw2); }
+	  if ( fc>1.0-trw2 ) fc=(float)(1.0-trw2);
 	}
       else
 	{
-	  fc=fd-trw2;
-	  if ( fd<=0.5 ) { numode=1; fc=2.0*fd-trw2; }
+	  fc=(float)(fd-trw2);
+	  if ( fd<=0.5 ) { numode=1; fc=(float)(2.0*fd-trw2); }
 	}
     }
   else
--- a/tf_main.h
+++ b/tf_main.h
@@ -108,7 +108,7 @@
 /* if static memory allocation is used, this value tells the max. nr of
    audio channels to be supported */
 /*#define MAX_TIME_CHANNELS (MAX_CHANNELS)*/
-#define MAX_TIME_CHANNELS 2 //6
+#define MAX_TIME_CHANNELS 6
 
 /* max. number of scale factor bands */
 #define MAX_SCFAC_BANDS ((NSFB_SHORT+1)*MAX_SHORT_IN_LONG_BLOCK)