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

kostya subversion at mplayerhq.hu
Thu Jul 17 07:49:43 CEST 2008


Author: kostya
Date: Thu Jul 17 07:49:43 2008
New Revision: 2808

Log:
Make M/S detection close to specification

Modified:
   aacenc/aacpsy.c

Modified: aacenc/aacpsy.c
==============================================================================
--- aacenc/aacpsy.c	(original)
+++ aacenc/aacpsy.c	Thu Jul 17 07:49:43 2008
@@ -512,7 +512,7 @@ static void psy_3gpp_process(AACPsyConte
             float m, s;
 
             cpe->ms.mask[0][g] = 0;
-            if(pctx->band[0][g].energy + pctx->band[1][g].energy == 0.0)
+            if(pctx->band[0][g].energy == 0.0 || pctx->band[1][g].energy == 0.0)
                 continue;
             for(i = 0; i < cpe->ch[0].ics.swb_sizes[g]; i++){
                 m = (cpe->ch[0].coeffs[start+i] + cpe->ch[1].coeffs[start+i]) / 2.0;
@@ -521,9 +521,14 @@ static void psy_3gpp_process(AACPsyConte
                 en_s += s*s;
             }
             l1 = FFMIN(pctx->band[0][g].thr, pctx->band[1][g].thr);
-            l1 = l1*l1 / (en_m + en_s);
-            if(l1 >= (pctx->band[0][g].thr * pctx->band[1][g].thr / (pctx->band[0][g].energy + pctx->band[1][g].energy)))
+            if(en_m == 0.0 || en_s == 0.0 || l1*l1 / (en_m * en_s) >= (pctx->band[0][g].thr * pctx->band[1][g].thr / (pctx->band[0][g].energy * pctx->band[1][g].energy))){
                 cpe->ms.mask[0][g] = 1;
+                pctx->band[0][g].energy = en_m;
+                pctx->band[1][g].energy = en_s;
+                pctx->band[0][g].thr = en_m * 0.001258925f;
+                pctx->band[1][g].thr = en_s * 0.001258925f;
+                //TODO: minSnr update
+            }
         }
     }
 



More information about the FFmpeg-soc mailing list