[FFmpeg-soc] [soc]: r2452 - in aacenc: aacpsy.c aacpsy.h

kostya subversion at mplayerhq.hu
Sun Jun 15 12:08:41 CEST 2008


Author: kostya
Date: Sun Jun 15 12:08:41 2008
New Revision: 2452

Log:
Add another dummy psychoacoustic model to test encoder in 8SS mode

Modified:
   aacenc/aacpsy.c
   aacenc/aacpsy.h

Modified: aacenc/aacpsy.c
==============================================================================
--- aacenc/aacpsy.c	(original)
+++ aacenc/aacpsy.c	Sun Jun 15 12:08:41 2008
@@ -100,6 +100,79 @@ static void psy_null_process(AACPsyConte
     }
 }
 
+static void psy_null8_window(AACPsyContext *apc, int16_t *audio, int channel, cpe_struct *cpe)
+{
+    int ch, i;
+
+    for(ch = 0; ch < apc->avctx->channels; ch++){
+        cpe->ch[ch].ics.window_sequence = EIGHT_SHORT_SEQUENCE;
+        cpe->ch[ch].ics.window_shape = 1;
+        cpe->ch[ch].ics.num_windows = 8;
+        cpe->ch[ch].ics.swb_sizes = apc->bands128;
+        cpe->ch[ch].ics.num_swb = apc->num_bands128;
+        for(i = 0; i < cpe->ch[ch].ics.num_windows; i++)
+            cpe->ch[ch].ics.group_len[i] = 0;
+    }
+    cpe->common_window = cpe->ch[0].ics.window_shape == cpe->ch[1].ics.window_shape;
+}
+
+static void psy_null8_process(AACPsyContext *apc, int16_t *audio, int channel, cpe_struct *cpe)
+{
+    int start, sum, cmaxsfb, maxsfb;
+    int w, ch, g, i;
+
+    //detect M/S
+    if(apc->avctx->channels > 1 && cpe->common_window){
+        start = 0;
+        for(w = 0; w < cpe->ch[0].ics.num_windows; w++){
+            for(g = 0; g < cpe->ch[0].ics.num_swb; g++){
+                float diff = 0.0f;
+
+                for(i = 0; i < cpe->ch[0].ics.swb_sizes[g]; i++)
+                    diff += fabs(cpe->ch[0].coeffs[start+i] - cpe->ch[1].coeffs[start+i]);
+                cpe->ms.mask[w][g] = diff == 0.0;
+            }
+        }
+    }
+    for(ch = 0; ch < apc->avctx->channels; ch++){
+        start = 0;
+        cpe->ch[ch].gain = SCALE_ONE_POS;
+        maxsfb = 0;
+        for(w = 0; w < cpe->ch[ch].ics.num_windows; w++){
+            for(g = 0; g < cpe->ch[ch].ics.num_swb; g++){
+                sum = 0;
+                cpe->ch[ch].sf_idx[w][g] = SCALE_ONE_POS;
+                //apply M/S
+                if(!ch && cpe->ms.mask[w][g]){
+                    for(i = 0; i < cpe->ch[ch].ics.swb_sizes[g]; i++){
+                        cpe->ch[0].coeffs[start+i] = (cpe->ch[0].coeffs[start+i] + cpe->ch[1].coeffs[start+i]) / 2.0;
+                        cpe->ch[1].coeffs[start+i] =  cpe->ch[0].coeffs[start+i] - cpe->ch[1].coeffs[start+i];
+                    }
+                }
+                for(i = 0; i < cpe->ch[ch].ics.swb_sizes[g]; i++){
+                    cpe->ch[ch].icoefs[start+i] = av_clip((int)(roundf(cpe->ch[ch].coeffs[start+i] / pow2sf_tab[cpe->ch[ch].sf_idx[w][g]+60])), -8191, 8191);
+                    sum += !!cpe->ch[ch].icoefs[start+i];
+                }
+                cpe->ch[ch].zeroes[w][g] = !sum;
+                start += cpe->ch[ch].ics.swb_sizes[g];
+            }
+            for(cmaxsfb = cpe->ch[ch].ics.num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[0][cmaxsfb-1]; cmaxsfb--);
+            maxsfb = FFMAX(maxsfb, cmaxsfb);
+        }
+        cpe->ch[ch].ics.max_sfb = maxsfb;
+    }
+    if(apc->avctx->channels > 1 && cpe->common_window){
+        int msc = 0;
+        cpe->ch[0].ics.max_sfb = FFMAX(cpe->ch[0].ics.max_sfb, cpe->ch[1].ics.max_sfb);
+        cpe->ch[1].ics.max_sfb = cpe->ch[0].ics.max_sfb;
+        for(w = 0; w < cpe->ch[0].ics.num_windows; w++)
+            for(i = 0; i < cpe->ch[0].ics.max_sfb; i++)
+                if(cpe->ms.mask[w][i]) msc++;
+        if(msc == 0 || cpe->ch[0].ics.max_sfb == 0) cpe->ms.present = 0;
+        else cpe->ms.present = msc < cpe->ch[0].ics.max_sfb ? 1 : 2;
+    }
+}
+
 static const AACPsyModel psy_models[AAC_NB_PSY_MODELS] =
 {
     {
@@ -109,6 +182,13 @@ static const AACPsyModel psy_models[AAC_
         psy_null_process,
         NULL,
     },
+    {
+       "Null model - short windows",
+        NULL,
+        psy_null8_window,
+        psy_null8_process,
+        NULL,
+    },
 };
 
 int ff_aac_psy_init(AACPsyContext *ctx, AVCodecContext *avctx, int model, int flags,

Modified: aacenc/aacpsy.h
==============================================================================
--- aacenc/aacpsy.h	(original)
+++ aacenc/aacpsy.h	Sun Jun 15 12:08:41 2008
@@ -27,6 +27,7 @@
 
 enum AACPsyModelType{
     AAC_PSY_NULL,              // do nothing on frequencies
+    AAC_PSY_NULL8,             // do nothing on frequencies but work with short windows
 
     AAC_NB_PSY_MODELS
 };



More information about the FFmpeg-soc mailing list