shithub: aacdec

Download patch

ref: 42ce0306d62d795bb9ead55d71c1ae418657d048
parent: 800c0a082a7e7aeb011752439bf882eede33b2a3
author: menno <menno>
date: Mon Oct 20 09:57:33 EDT 2003

added SBR changes for DRM

--- a/libfaad/sbr_dct.c
+++ b/libfaad/sbr_dct.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_dct.c,v 1.5 2003/10/09 20:04:25 menno Exp $
+** $Id: sbr_dct.c,v 1.7 2003/11/02 20:24:04 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/sbr_dct.h
+++ b/libfaad/sbr_dct.h
@@ -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_dct.h,v 1.4 2003/10/09 20:04:25 menno Exp $
+** $Id: sbr_dct.h,v 1.8 2003/11/12 20:47:58 menno Exp $
 **/
 
 #ifndef __SBR_DCT_H__
--- a/libfaad/sbr_dec.c
+++ b/libfaad/sbr_dec.c
@@ -1,19 +1,19 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
 ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
-**
+**  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
 ** the Free Software Foundation; either version 2 of the License, or
 ** (at your option) any later version.
-**
+** 
 ** This program is distributed in the hope that it will be useful,
 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ** GNU General Public License for more details.
-**
+** 
 ** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
+** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
 ** Any non-GPL usage of this software or parts of this software is strictly
@@ -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.14 2003/10/14 16:56:26 menno Exp $
+** $Id: sbr_dec.c,v 1.16 2003/11/02 20:24:05 menno Exp $
 **/
 
 
@@ -43,7 +43,7 @@
 
 sbr_info *sbrDecodeInit(uint16_t framelength
 #ifdef DRM
-                        , uint8_t IsDRM
+						, uint8_t IsDRM
 #endif
                         )
 {
@@ -158,7 +158,7 @@
 
 void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel,
                     real_t *right_channel,
-                    uint8_t just_seeked, uint8_t upsample_only)
+                    const uint8_t just_seeked, const uint8_t upsample_only)
 {
     int16_t i, k, l;
 
@@ -166,7 +166,7 @@
     uint8_t ch, channels, ret;
     real_t *ch_buf;
 
-    qmf_t X[32][64];
+    qmf_t X[MAX_NTSR][64];
 #ifdef SBR_LOW_POWER
     real_t deg[64];
 #endif
@@ -219,7 +219,7 @@
             uint8_t j;
             sbr->qmfa[ch] = qmfa_init(32);
             sbr->qmfs[ch] = qmfs_init(64);
-
+            
             for (j = 0; j < 5; j++)
             {
                 sbr->G_temp_prev[ch][j] = malloc(64*sizeof(real_t));
@@ -301,8 +301,8 @@
                     xover_band = sbr->kx;
 
 #ifdef DRM
-                if (sbr->Is_DRM_SBR)
-                    xover_band = sbr->kx;
+				if (sbr->Is_DRM_SBR)
+					xover_band = sbr->kx;
 #endif
 
                 for (k = 0; k < xover_band; k++)
--- a/libfaad/sbr_dec.h
+++ b/libfaad/sbr_dec.h
@@ -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.h,v 1.8 2003/10/09 20:04:25 menno Exp $
+** $Id: sbr_dec.h,v 1.11 2003/11/04 21:43:30 menno Exp $
 **/
 
 #ifndef __SBR_DEC_H__
@@ -32,6 +32,16 @@
 extern "C" {
 #endif
 
+
+/* MAX_NTSRHFG: maximum of number_time_slots * rate + HFGen. DRM: 15*2+32, else 16*2+8 */
+#ifdef DRM
+# define MAX_NTSRHFG 62
+#else
+# define MAX_NTSRHFG 40
+#endif
+#define MAX_NTSR     32 /* max number_time_slots * rate, ok for DRM and not DRM mode */
+
+
 typedef struct {
     real_t *x;
     uint8_t channels;
@@ -138,8 +148,8 @@
     qmfa_info *qmfa[2];
     qmfs_info *qmfs[2];
 
-    qmf_t Xsbr[2][40][64];
-    qmf_t Xcodec[2][40][32];
+    qmf_t Xsbr[2][MAX_NTSRHFG][64];
+    qmf_t Xcodec[2][MAX_NTSRHFG][32];
 
 #ifdef DRM
 	int8_t lcstereo_flag;
@@ -201,7 +211,7 @@
 
 void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel,
                     real_t *right_channel,
-                    uint8_t just_seeked, uint8_t upsample_only);
+                    const uint8_t just_seeked, const uint8_t upsample_only);
 
 
 #ifdef __cplusplus
--- 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.5 2003/10/09 20:04:25 menno Exp $
+** $Id: sbr_e_nf.c,v 1.7 2003/11/02 20:24:05 menno Exp $
 **/
 
 #include "common.h"
@@ -159,8 +159,9 @@
             for (k = 0; k < sbr->N_Q; k++)
             {
                 if (sbr->Q[ch][k][l] < 0 || sbr->Q[ch][k][l] > 30)
+                {
                     sbr->Q_orig[ch][k][l] = 0;
-                else {
+                } else {
                     sbr->Q_orig[ch][k][l] = (real_t)pow(2, NOISE_FLOOR_OFFSET - sbr->Q[ch][k][l]);
                 }
             }
@@ -186,12 +187,6 @@
             r_temp = (real_t)pow(2, sbr->E[1][k][l]*amp1 - 12);
 
             sbr->E_orig[1][k][l] = l_temp / ((real_t)1.0 + r_temp);
-
-            /*
-               E_orig[1]: integer
-               r_temp: fixed point
-               fixed point multiplication gives integer
-             */
             sbr->E_orig[0][k][l] = MUL(r_temp, sbr->E_orig[1][k][l]);
         }
     }
@@ -200,7 +195,7 @@
         for (k = 0; k < sbr->N_Q; k++)
         {
             if ((sbr->Q[0][k][l] < 0 || sbr->Q[0][k][l] > 30) ||
-                (sbr->Q[1][k][l] < 0 || sbr->Q[1][k][l] > 30))
+                (sbr->Q[1][k][l] < 0 || sbr->Q[1][k][l] > 24 /* 2*panOffset(1) */))
             {
                 sbr->Q_orig[0][k][l] = 0;
                 sbr->Q_orig[1][k][l] = 0;
--- a/libfaad/sbr_fbt.c
+++ b/libfaad/sbr_fbt.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_fbt.c,v 1.4 2003/10/09 20:04:25 menno Exp $
+** $Id: sbr_fbt.c,v 1.6 2003/11/02 20:24:05 menno Exp $
 **/
 
 /* Calculate frequency band tables */
--- 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.5 2003/10/09 20:04:25 menno Exp $
+** $Id: sbr_hfadj.c,v 1.6 2003/10/20 13:57:32 menno Exp $
 **/
 
 /* High Frequency adjustment */
@@ -37,7 +37,7 @@
 
 #include "sbr_noise.h"
 
-void hf_adjustment(sbr_info *sbr, qmf_t Xsbr[40][64]
+void hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64]
 #ifdef SBR_LOW_POWER
                    ,real_t *deg /* aliasing degree */
 #endif
@@ -186,8 +186,8 @@
     }
 }
 
-static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t Xsbr[40][64],
-                                      uint8_t ch)
+static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj,
+                                      qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch)
 {
     uint8_t m, l, j, k, k_l, k_h, p;
     real_t nrg, div;
@@ -262,7 +262,6 @@
     }
 }
 
-
 #define EPS (1e-12)
 
 #define ONE (1)
@@ -473,7 +472,6 @@
                 acc = 0;
             else
                 acc = E_total / (acc + EPS);
-
             for(m = sbr->f_group[l][(k<<1)]; m < sbr->f_group[l][(k<<1) + 1]; m++)
             {
                 adj->G_lim_boost[l][m-sbr->kx] = MUL(acc, adj->G_lim_boost[l][m-sbr->kx]);
@@ -496,7 +494,7 @@
 #endif
 
 static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj,
-                        qmf_t Xsbr[40][64], uint8_t ch)
+                        qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch)
 {
     static real_t h_smooth[] = {
         COEF_CONST(0.03183050093751), COEF_CONST(0.11516383427084),
--- a/libfaad/sbr_hfadj.h
+++ b/libfaad/sbr_hfadj.h
@@ -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.h,v 1.3 2003/10/09 20:04:25 menno Exp $
+** $Id: sbr_hfadj.h,v 1.6 2003/11/04 21:43:30 menno Exp $
 **/
 
 #ifndef __SBR_HFADJ_H__
@@ -46,7 +46,7 @@
 } sbr_hfadj_info;
 
 
-void hf_adjustment(sbr_info *sbr, qmf_t Xsbr[40][64]
+void hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64]
 #ifdef SBR_LOW_POWER
                    ,real_t *deg
 #endif
@@ -56,8 +56,8 @@
 static void map_envelope_data(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch);
 static void map_noise_data(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch);
 static void map_sinusoids(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch);
-static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t Xsbr[40][64],
-                                      uint8_t ch);
+static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj,
+                                      qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch);
 static void additional_component_levels(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch);
 static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch);
 #ifdef SBR_LOW_POWER
@@ -64,7 +64,7 @@
 static void calc_gain_groups(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch);
 static void aliasing_reduction(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch);
 #endif
-static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t Xsbr[40][64], uint8_t ch);
+static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch);
 
 
 #ifdef __cplusplus
--- 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.7 2003/10/09 20:04:25 menno Exp $
+** $Id: sbr_hfgen.c,v 1.8 2003/10/20 13:57:32 menno Exp $
 **/
 
 /* High Frequency generation */
@@ -36,8 +36,8 @@
 #include "sbr_hfgen.h"
 #include "sbr_fbt.h"
 
-void hf_generation(sbr_info *sbr, const qmf_t Xlow[40][32],
-                   qmf_t Xhigh[40][64]
+void hf_generation(sbr_info *sbr, const qmf_t Xlow[MAX_NTSRHFG][32],
+                   qmf_t Xhigh[MAX_NTSRHFG][64]
 #ifdef SBR_LOW_POWER
                    ,real_t *deg
 #endif
@@ -176,7 +176,8 @@
 #define SBR_ABS(A) ((A) < 0) ? -(A) : (A)
 
 #ifdef SBR_LOW_POWER
-static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t buffer[40][32],
+static void auto_correlation(sbr_info *sbr, acorr_coef *ac,
+                             const qmf_t buffer[MAX_NTSRHFG][32],
                              uint8_t bd, uint8_t len)
 {
     int8_t j;
@@ -212,7 +213,7 @@
     ac->det = MUL(RE(ac->r11), RE(ac->r22)) - MUL_R_C(MUL(RE(ac->r12), RE(ac->r12)), rel);
 }
 #else
-static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t buffer[40][32],
+static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t buffer[MAX_NTSRHFG][32],
                              uint8_t bd, uint8_t len)
 {
     int8_t j;
@@ -262,7 +263,7 @@
 }
 #endif
 
-static void calc_prediction_coef(sbr_info *sbr, const qmf_t Xlow[40][32],
+static void calc_prediction_coef(sbr_info *sbr, const qmf_t Xlow[MAX_NTSRHFG][32],
                                  complex_t *alpha_0, complex_t *alpha_1
 #ifdef SBR_LOW_POWER
                                  , real_t *rxx
--- a/libfaad/sbr_hfgen.h
+++ b/libfaad/sbr_hfgen.h
@@ -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.h,v 1.4 2003/10/09 20:04:25 menno Exp $
+** $Id: sbr_hfgen.h,v 1.7 2003/11/04 21:43:30 menno Exp $
 **/
 
 #ifndef __SBR_HFGEN_H__
@@ -32,14 +32,14 @@
 extern "C" {
 #endif
 
-void hf_generation(sbr_info *sbr, const qmf_t Xlow[40][32],
-                   qmf_t Xhigh[40][64]
+void hf_generation(sbr_info *sbr, const qmf_t Xlow[MAX_NTSRHFG][32],
+                   qmf_t Xhigh[MAX_NTSRHFG][64]
 #ifdef SBR_LOW_POWER
                    ,real_t *deg
 #endif
                    ,uint8_t ch);
 
-static void calc_prediction_coef(sbr_info *sbr, const qmf_t Xlow[40][32],
+static void calc_prediction_coef(sbr_info *sbr, const qmf_t Xlow[MAX_NTSRHFG][32],
                                  complex_t *alpha_0, complex_t *alpha_1
 #ifdef SBR_LOW_POWER
                                  , real_t *rxx
--- 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.14 2003/10/09 20:04:25 menno Exp $
+** $Id: sbr_qmf.c,v 1.15 2003/10/20 13:57:32 menno Exp $
 **/
 
 #include "common.h"
@@ -60,7 +60,7 @@
 }
 
 void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
-                         qmf_t X[40][32], uint8_t offset, uint8_t kx)
+                         qmf_t X[MAX_NTSRHFG][32], uint8_t offset, uint8_t kx)
 {
     uint8_t l;
     real_t u[64];
@@ -193,7 +193,7 @@
 }
 
 #ifdef SBR_LOW_POWER
-void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t X[32][64],
+void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t X[MAX_NTSRHFG][64],
                           real_t *output)
 {
     uint8_t l;
@@ -257,7 +257,7 @@
     }
 }
 #else
-void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t X[32][64],
+void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t X[MAX_NTSRHFG][64],
                           real_t *output)
 {
     real_t x1[64], x2[64];
--- a/libfaad/sbr_qmf.h
+++ b/libfaad/sbr_qmf.h
@@ -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.h,v 1.8 2003/10/09 20:04:25 menno Exp $
+** $Id: sbr_qmf.h,v 1.11 2003/11/04 21:43:30 menno Exp $
 **/
 
 #ifndef __SBR_QMF_H__
@@ -38,10 +38,10 @@
 void qmfs_end(qmfs_info *qmfs);
 
 void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
-                         qmf_t X[40][32], uint8_t offset, uint8_t kx);
+                         qmf_t X[MAX_NTSRHFG][32], uint8_t offset, uint8_t kx);
 void sbr_qmf_synthesis_32(qmfs_info *qmfs, const qmf_t *X,
                           real_t *output);
-void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t X[32][64],
+void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t X[MAX_NTSRHFG][64],
                           real_t *output);
 
 
--- 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.12 2003/10/09 20:04:25 menno Exp $
+** $Id: sbr_syntax.c,v 1.14 2003/11/02 20:24:05 menno Exp $
 **/
 
 #include "common.h"
--- a/libfaad/sbr_syntax.h
+++ b/libfaad/sbr_syntax.h
@@ -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.h,v 1.8 2003/10/09 20:04:25 menno Exp $
+** $Id: sbr_syntax.h,v 1.12 2003/11/12 20:47:58 menno Exp $
 **/
 
 #ifndef __SBR_SYNTAX_H__
--- a/libfaad/sbr_tf_grid.c
+++ b/libfaad/sbr_tf_grid.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_tf_grid.c,v 1.5 2003/10/09 20:04:25 menno Exp $
+** $Id: sbr_tf_grid.c,v 1.9 2003/12/17 14:43:16 menno Exp $
 **/
 
 /* Time/Frequency grid */