shithub: aacdec

Download patch

ref: d7fd5cfc180d6f110527f5ccebeb7d6463570dd8
parent: 3655d4b9ff799a6765205fa8a6a308354fe0af9f
author: menno <menno>
date: Fri Aug 30 15:03:48 EDT 2002

Fixes to PNS and more dynamic memory allocation

--- a/libfaad/decoder.c
+++ b/libfaad/decoder.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: decoder.c,v 1.27 2002/08/30 18:14:25 menno Exp $
+** $Id: decoder.c,v 1.28 2002/08/30 19:03:48 menno Exp $
 **/
 
 #include <stdlib.h>
@@ -85,8 +85,11 @@
 
     hDecoder->drc = drc_init(REAL_CONST(1.0), REAL_CONST(1.0));
 
+    hDecoder->iq_table = (real_t*)malloc(IQ_TABLE_SIZE*sizeof(real_t));
+
     /* build table for inverse quantization */
 #if IQ_TABLE_SIZE && POW_TABLE_SIZE
+    hDecoder->pow2_table = (real_t*)malloc(POW_TABLE_SIZE*sizeof(real_t));
     build_tables(hDecoder->iq_table, hDecoder->pow2_table);
 #elif !POW_TABLE_SIZE
     build_tables(hDecoder->iq_table, NULL);
@@ -325,6 +328,11 @@
 
     drc_end(hDecoder->drc);
 
+    if (hDecoder->iq_table) free(hDecoder->iq_table);
+#if POW_TABLE_SIZE
+    if (hDecoder->pow2_table) free(hDecoder->pow2_table);
+#endif
+
     if (hDecoder->sample_buffer) free(hDecoder->sample_buffer);
 
     if (hDecoder) free(hDecoder);
@@ -682,18 +690,16 @@
             }
         }
 
-        /* pns decoding */
-        if ((!right_channel) && (pch != -1) && (ics->ms_mask_present))
-            pns_decode(ics, icsr, spec_coef[ch], spec_coef[pch], frame_len, 1);
-        else if (pch == -1)
-            pns_decode(ics, NULL, spec_coef[ch], NULL, frame_len, 0);
-
-        printf("\n\n%d\n\n",pch);
-
         if (!right_channel)
         {
             /* mid/side decoding */
             ms_decode(ics, icsr, spec_coef[ch], spec_coef[pch], frame_len);
+
+            /* pns decoding */
+            if ((pch != -1) && (ics->ms_mask_present))
+                pns_decode(ics, icsr, spec_coef[ch], spec_coef[pch], frame_len, 1);
+            else if (pch == -1)
+                pns_decode(ics, NULL, spec_coef[ch], NULL, frame_len, 0);
 
             /* intensity stereo decoding */
             is_decode(ics, icsr, spec_coef[ch], spec_coef[pch], frame_len);
--- a/libfaad/decoder.h
+++ b/libfaad/decoder.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: decoder.h,v 1.13 2002/08/30 12:10:57 menno Exp $
+** $Id: decoder.h,v 1.14 2002/08/30 19:03:48 menno Exp $
 **/
 
 #ifndef __DECODER_H__
@@ -103,9 +103,9 @@
     real_t exp_table[256];
     real_t mnt_table[128];
 
-    real_t iq_table[IQ_TABLE_SIZE];
-#if POW_TABLE_SIZE   
-    real_t pow2_table[POW_TABLE_SIZE];
+    real_t *iq_table;
+#if POW_TABLE_SIZE
+    real_t *pow2_table;
 #endif 
 
     /* Configuration data */