shithub: aacdec

Download patch

ref: bb4d5f6e30689298bab8060996cc20e4ec689588
parent: e1d13b171c77ab0f1b9fc4ae2d43b263094b7fcf
author: menno <menno>
date: Mon Jan 26 17:32:31 EST 2009

DAB+ support

--- a/libfaad/ps_dec.c
+++ b/libfaad/ps_dec.c
@@ -25,7 +25,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: ps_dec.c,v 1.15 2008/09/22 17:55:09 menno Exp $
+** $Id: ps_dec.c,v 1.16 2009/01/26 22:32:31 menno Exp $
 **/
 
 #include "common.h"
@@ -162,7 +162,7 @@
 
 /* static function declarations */
 static void ps_data_decode(ps_info *ps);
-static hyb_info *hybrid_init();
+static hyb_info *hybrid_init(uint8_t numTimeSlotsRate);
 static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter,
                             qmf_t *buffer, qmf_t **X_hybrid);
 static void INLINE DCT3_4_unscaled(real_t *y, real_t *x);
@@ -169,9 +169,9 @@
 static void channel_filter8(hyb_info *hyb, uint8_t frame_len, const real_t *filter,
                             qmf_t *buffer, qmf_t **X_hybrid);
 static void hybrid_analysis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32],
-                            uint8_t use34);
+                            uint8_t use34, uint8_t numTimeSlotsRate);
 static void hybrid_synthesis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32],
-                             uint8_t use34);
+                             uint8_t use34, uint8_t numTimeSlotsRate);
 static int8_t delta_clip(int8_t i, int8_t min, int8_t max);
 static void delta_decode(uint8_t enable, int8_t *index, int8_t *index_prev,
                          uint8_t dt_flag, uint8_t nr_par, uint8_t stride,
@@ -192,7 +192,7 @@
 /*  */
 
 
-static hyb_info *hybrid_init()
+static hyb_info *hybrid_init(uint8_t numTimeSlotsRate)
 {
     uint8_t i;
 
@@ -208,7 +208,7 @@
     hyb->resolution20[1] = 2;
     hyb->resolution20[2] = 2;
 
-    hyb->frame_len = 32;
+    hyb->frame_len = numTimeSlotsRate;
 
     hyb->work = (qmf_t*)faad_malloc((hyb->frame_len+12) * sizeof(qmf_t));
     memset(hyb->work, 0, (hyb->frame_len+12) * sizeof(qmf_t));
@@ -505,7 +505,7 @@
  * to improve frequency resolution
  */
 static void hybrid_analysis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32],
-                            uint8_t use34)
+                            uint8_t use34, uint8_t numTimeSlotsRate)
 {
     uint8_t k, n, band;
     uint8_t offset = 0;
@@ -563,7 +563,7 @@
     /* group hybrid channels */
     if (!use34)
     {
-        for (n = 0; n < 32 /*30?*/; n++)
+        for (n = 0; n < numTimeSlotsRate; n++)
         {
             QMF_RE(X_hybrid[n][3]) += QMF_RE(X_hybrid[n][4]);
             QMF_IM(X_hybrid[n][3]) += QMF_IM(X_hybrid[n][4]);
@@ -579,7 +579,7 @@
 }
 
 static void hybrid_synthesis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32],
-                             uint8_t use34)
+                             uint8_t use34, uint8_t numTimeSlotsRate)
 {
     uint8_t k, n, band;
     uint8_t offset = 0;
@@ -913,13 +913,13 @@
         ps->border_position[0] = 0;
         for (env = 1; env < ps->num_env; env++)
         {
-            ps->border_position[env] = (env * 32 /* 30 for 960? */) / ps->num_env;
+            ps->border_position[env] = (env * ps->numTimeSlotsRate) / ps->num_env;
         }
-        ps->border_position[ps->num_env] = 32 /* 30 for 960? */;
+        ps->border_position[ps->num_env] = ps->numTimeSlotsRate;
     } else {
         ps->border_position[0] = 0;
 
-        if (ps->border_position[ps->num_env] < 32 /* 30 for 960? */)
+        if (ps->border_position[ps->num_env] < ps->numTimeSlotsRate)
         {
             for (bin = 0; bin < 34; bin++)
             {
@@ -932,12 +932,12 @@
                 ps->opd_index[ps->num_env][bin] = ps->opd_index[ps->num_env-1][bin];
             }
             ps->num_env++;
-            ps->border_position[ps->num_env] = 32 /* 30 for 960? */;
+            ps->border_position[ps->num_env] = ps->numTimeSlotsRate;
         }
 
         for (env = 1; env < ps->num_env; env++)
         {
-            int8_t thr = 32 /* 30 for 960? */ - (ps->num_env - env);
+            int8_t thr = ps->numTimeSlotsRate - (ps->num_env - env);
 
             if (ps->border_position[env] > thr)
             {
@@ -1866,7 +1866,7 @@
     faad_free(ps);
 }
 
-ps_info *ps_init(uint8_t sr_index)
+ps_info *ps_init(uint8_t sr_index, uint8_t numTimeSlotsRate)
 {
     uint8_t i;
     uint8_t short_delay_band;
@@ -1874,7 +1874,8 @@
     ps_info *ps = (ps_info*)faad_malloc(sizeof(ps_info));
     memset(ps, 0, sizeof(ps_info));
 
-    ps->hyb = hybrid_init();
+    ps->hyb = hybrid_init(numTimeSlotsRate);
+    ps->numTimeSlotsRate = numTimeSlotsRate;
 
     ps->ps_data_available = 0;
 
@@ -1990,7 +1991,7 @@
      * frequency resolution
      */
     hybrid_analysis((hyb_info*)ps->hyb, X_left, X_hybrid_left,
-        ps->use34hybrid_bands);
+        ps->use34hybrid_bands, ps->numTimeSlotsRate);
 
     /* decorrelate mono signal */
     ps_decorrelate(ps, X_left, X_right, X_hybrid_left, X_hybrid_right);
@@ -2000,10 +2001,10 @@
 
     /* hybrid synthesis, to rebuild the SBR QMF matrices */
     hybrid_synthesis((hyb_info*)ps->hyb, X_left, X_hybrid_left,
-        ps->use34hybrid_bands);
+        ps->use34hybrid_bands, ps->numTimeSlotsRate);
 
     hybrid_synthesis((hyb_info*)ps->hyb, X_right, X_hybrid_right,
-        ps->use34hybrid_bands);
+        ps->use34hybrid_bands, ps->numTimeSlotsRate);
 
     return 0;
 }
--- a/libfaad/ps_dec.h
+++ b/libfaad/ps_dec.h
@@ -25,7 +25,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: ps_dec.h,v 1.12 2007/11/01 12:33:33 menno Exp $
+** $Id: ps_dec.h,v 1.13 2009/01/26 22:32:31 menno Exp $
 **/
 
 #ifndef __PS_DEC_H__
@@ -92,6 +92,7 @@
     /* hybrid filterbank parameters */
     void *hyb;
     uint8_t use34hybrid_bands;
+    uint8_t numTimeSlotsRate;
 
     /**/
     uint8_t num_groups;
@@ -138,7 +139,7 @@
 uint16_t ps_data(ps_info *ps, bitfile *ld, uint8_t *header);
 
 /* ps_dec.c */
-ps_info *ps_init(uint8_t sr_index);
+ps_info *ps_init(uint8_t sr_index, uint8_t numTimeSlotsRate);
 void ps_free(ps_info *ps);
 
 uint8_t ps_decode(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64]);
--- a/libfaad/sbr_dec.c
+++ b/libfaad/sbr_dec.c
@@ -25,7 +25,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_dec.c,v 1.43 2007/11/01 12:33:34 menno Exp $
+** $Id: sbr_dec.c,v 1.44 2009/01/26 22:32:31 menno Exp $
 **/
 
 
@@ -637,7 +637,7 @@
     sbr->ret += sbr_process_channel(sbr, left_channel, X_left, 0, dont_process, downSampledSBR);
 
     /* copy some extra data for PS */
-    for (l = 32; l < 38; l++)
+    for (l = sbr->numTimeSlotsRate; l < sbr->numTimeSlotsRate + 6; l++)
     {
         for (k = 0; k < 5; k++)
         {
--- a/libfaad/sbr_syntax.c
+++ b/libfaad/sbr_syntax.c
@@ -25,7 +25,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_syntax.c,v 1.38 2007/11/01 12:33:36 menno Exp $
+** $Id: sbr_syntax.c,v 1.39 2009/01/26 22:32:31 menno Exp $
 **/
 
 #include "common.h"
@@ -857,7 +857,7 @@
     case EXTENSION_ID_PS:
         if (!sbr->ps)
         {
-            sbr->ps = ps_init(get_sr_index(sbr->sample_rate));
+            sbr->ps = ps_init(get_sr_index(sbr->sample_rate), sbr->numTimeSlotsRate);
         }
         if (sbr->psResetFlag)
         {