[FFmpeg-soc] [soc]: r2423 - aacenc/aacenc.c

kostya subversion at mplayerhq.hu
Wed Jun 11 07:15:46 CEST 2008


Author: kostya
Date: Wed Jun 11 07:15:45 2008
New Revision: 2423

Log:
Quantize coefficients and flip their sign as needed by AAC. 


Modified:
   aacenc/aacenc.c

Modified: aacenc/aacenc.c
==============================================================================
--- aacenc/aacenc.c	(original)
+++ aacenc/aacenc.c	Wed Jun 11 07:15:45 2008
@@ -204,13 +204,10 @@ static int aac_encode_init(AVCodecContex
 static void apply_psychoacoustics(AVCodecContext *avctx, int channel)
 {
     AACEncContext *s = avctx->priv_data;
-    int i, val;
+    int i;
 
-    for(i = 0; i < 1024; i++){
-        val = pow(FFABS(s->coefs[channel][i]), 0.75);
-        if(s->coefs[channel][i] > 0.0) val = -val;
-        s->icoefs[channel][i] = val;
-    }
+    for(i = 0; i < 1024; i++)
+        s->icoefs[channel][i] = (int)s->coefs[channel][i];
 }
 
 static void analyze(AVCodecContext *avctx, AACEncContext *s, short *audio, int channel)
@@ -225,6 +222,9 @@ static void analyze(AVCodecContext *avct
         s->frame_out[channel][i] = audio[j] / 512 * s->kbd_long_1024[i];
     }
     ff_mdct_calc(&s->mdct, s->coefs[channel], s->output, s->tmp);
+    //convert coefficients into form used by AAC
+    for(i = 0; i < 1024; i++)
+        s->coefs[channel][i] = -copysignf(pow(fabsf(s->coefs[channel][i]), 0.75f), s->coefs[channel][i]);
 
     apply_psychoacoustics(avctx, channel);
 }



More information about the FFmpeg-soc mailing list