[FFmpeg-soc] [soc]: r2809 - aacenc/aacpsy.c

kostya subversion at mplayerhq.hu
Thu Jul 17 07:50:30 CEST 2008


Author: kostya
Date: Thu Jul 17 07:50:30 2008
New Revision: 2809

Log:
Better scalefactor calculation

Modified:
   aacenc/aacpsy.c

Modified: aacenc/aacpsy.c
==============================================================================
--- aacenc/aacpsy.c	(original)
+++ aacenc/aacpsy.c	Thu Jul 17 07:50:30 2008
@@ -577,16 +577,15 @@ static void psy_3gpp_process(AACPsyConte
     }
 
     //determine scalefactors - 5.6.2
-    //TODO: quantization optimization, scalefactor difference reduction
     for(ch = 0; ch < apc->avctx->channels; ch++){
         int min_scale = 256;
         prev_scale = -1;
         cpe->ch[ch].gain = 0;
         for(g = 0; g < apc->num_bands1024; g++){
+            cpe->ch[ch].zeroes[0][g] = pctx->band[ch][g].thr >= pctx->band[ch][g].energy;
             if(cpe->ch[ch].zeroes[0][g]) continue;
             //spec gives constant for lg() but we scaled it for log2()
             cpe->ch[ch].sf_idx[0][g] = (int)(2.66667 * (log2(6.75*pctx->band[ch][g].thr) - log2(pctx->band[ch][g].ffac)));
-            cpe->ch[ch].sf_idx[0][g] = av_clip(cpe->ch[ch].sf_idx[0][g], 0, 255);
             if(prev_scale != -1)
                 cpe->ch[ch].sf_idx[0][g] = av_clip(cpe->ch[ch].sf_idx[0][g], prev_scale - SCALE_MAX_DIFF, prev_scale + SCALE_MAX_DIFF);
             prev_scale = cpe->ch[ch].sf_idx[0][g];
@@ -599,6 +598,10 @@ static void psy_3gpp_process(AACPsyConte
         for(g = 0; g < apc->num_bands1024; g++){
             if(cpe->ch[ch].zeroes[0][g]) continue;
             cpe->ch[ch].sf_idx[0][g] = FFMIN(cpe->ch[ch].sf_idx[0][g], min_scale + SCALE_MAX_DIFF);
+        }
+        for(g = 0; g < apc->num_bands1024; g++){
+            if(cpe->ch[ch].zeroes[0][g]) continue;
+            cpe->ch[ch].sf_idx[0][g] = SCALE_ONE_POS + cpe->ch[ch].sf_idx[0][g];
             if(!cpe->ch[ch].gain) cpe->ch[ch].gain = cpe->ch[ch].sf_idx[0][g];
         }
     }



More information about the FFmpeg-soc mailing list