shithub: aacdec

Download patch

ref: edf72d4467ff564a5f8676d8eda51eea33655f70
parent: 0aa2ca7ee392ce54ca6273409165a3febb59e1a9
author: menno <menno>
date: Tue Sep 9 14:37:32 EDT 2003

wrong patches applied from Ahead CVS: fixed

--- a/libfaad/sbr_dec.c
+++ b/libfaad/sbr_dec.c
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_dec.c,v 1.7 2003/09/09 18:09:52 menno Exp $
+** $Id: sbr_dec.c,v 1.8 2003/09/09 18:37:32 menno Exp $
 **/
 
 
--- a/libfaad/sbr_e_nf.c
+++ b/libfaad/sbr_e_nf.c
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_e_nf.c,v 1.3 2003/09/09 18:09:52 menno Exp $
+** $Id: sbr_e_nf.c,v 1.4 2003/09/09 18:37:32 menno Exp $
 **/
 
 #include "common.h"
@@ -171,8 +171,8 @@
 void unmap_envelope_noise(sbr_info *sbr)
 {
     uint8_t l, k;
-    uint8_t amp0 = (sbr->amp_res[0]) ? 0 : 1;
-    uint8_t amp1 = (sbr->amp_res[1]) ? 0 : 1;
+    real_t amp0 = (sbr->amp_res[0]) ? (real_t)1.0 : (real_t)0.5;
+    real_t amp1 = (sbr->amp_res[1]) ? (real_t)1.0 : (real_t)0.5;
 
     for (l = 0; l < sbr->L_E[0]; l++)
     {
--- a/libfaad/sbr_hfadj.c
+++ b/libfaad/sbr_hfadj.c
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_hfadj.c,v 1.3 2003/09/09 18:09:52 menno Exp $
+** $Id: sbr_hfadj.c,v 1.4 2003/09/09 18:37:32 menno Exp $
 **/
 
 /* High Frequency adjustment */
--- a/libfaad/sbr_hfgen.c
+++ b/libfaad/sbr_hfgen.c
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_hfgen.c,v 1.3 2003/09/09 18:09:52 menno Exp $
+** $Id: sbr_hfgen.c,v 1.4 2003/09/09 18:37:32 menno Exp $
 **/
 
 /* High Frequency generation */
@@ -180,6 +180,10 @@
     int8_t j, jminus1, jminus2;
     uint8_t offset;
     const real_t rel = COEF_CONST(0.9999999999999); // 1 / (1 + 1e-6f);
+#ifdef FIXED_POINT
+    uint32_t maxi = 0;
+    uint32_t pow2, exp;
+#endif
 #ifdef DRM
     if (sbr->Is_DRM_SBR)
         offset = sbr->tHFGen;
@@ -189,6 +193,27 @@
         offset = sbr->tHFAdj;
     }
 
+#ifdef FIXED_POINT
+    /*
+     *  For computing the covariance matrix and the filter coefficients
+     *  in fixed point, all values are normalised so that the fixed point
+     *  values don't overflow.
+     */
+    for (j = offset-2; j < len + offset; j++)
+    {
+        maxi = max(SBR_ABS(QMF_RE(buffer[j*32 + bd])>>REAL_BITS), maxi);
+    }
+
+    /* find the first power of 2 bigger than max to avoid division */
+    pow2 = 1;
+    exp = 0;
+    while (maxi > pow2)
+    {
+        pow2 <<= 1;
+        exp++;
+    }
+#endif
+
     memset(ac, 0, sizeof(acorr_coef));
 
     for (j = offset; j < len + offset; j++)
@@ -197,11 +222,20 @@
         jminus2 = jminus1 - 1;
 
 #ifdef SBR_LOW_POWER
+#ifdef FIXED_POINT
+        /* normalisation with rounding */
+        RE(ac->r01) += MUL(((QMF_RE(buffer[j*32 + bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[jminus1*32 + bd])+(1<<(exp-1)))>>exp));
+        RE(ac->r02) += MUL(((QMF_RE(buffer[j*32 + bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[jminus2*32 + bd])+(1<<(exp-1)))>>exp));
+        RE(ac->r11) += MUL(((QMF_RE(buffer[jminus1*32 + bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[jminus1*32 + bd])+(1<<(exp-1)))>>exp));
+        RE(ac->r12) += MUL(((QMF_RE(buffer[jminus1*32 + bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[jminus2*32 + bd])+(1<<(exp-1)))>>exp));
+        RE(ac->r22) += MUL(((QMF_RE(buffer[jminus2*32 + bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[jminus2*32 + bd])+(1<<(exp-1)))>>exp));
+#else
         RE(ac->r01) += QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]);
         RE(ac->r02) += QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]);
         RE(ac->r11) += QMF_RE(buffer[jminus1*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]);
         RE(ac->r12) += QMF_RE(buffer[jminus1*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]);
         RE(ac->r22) += QMF_RE(buffer[jminus2*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]);
+#endif
 #else
         /* RE(ac[0][1]) */
         RE(ac->r01) += QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]) +
--- a/libfaad/sbr_huff.c
+++ b/libfaad/sbr_huff.c
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_huff.c,v 1.6 2003/09/09 18:09:52 menno Exp $
+** $Id: sbr_huff.c,v 1.11 2003/11/12 20:47:58 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/sbr_qmf.c
+++ b/libfaad/sbr_qmf.c
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_qmf.c,v 1.6 2003/09/09 18:09:52 menno Exp $
+** $Id: sbr_qmf.c,v 1.7 2003/09/09 18:37:32 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/sbr_syntax.c
+++ b/libfaad/sbr_syntax.c
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_syntax.c,v 1.8 2003/09/09 18:09:52 menno Exp $
+** $Id: sbr_syntax.c,v 1.9 2003/09/09 18:37:32 menno Exp $
 **/
 
 #include "common.h"