shithub: aacdec

Download patch

ref: d4dba8d18950596d3bbd6bdc45ffce94ea42341c
parent: 2e8547789313ae2b0a99a724177805b51c642b55
author: menno <menno>
date: Wed Apr 2 13:31:08 EST 2003

More bitstream error protection

--- a/common/mp4v2/libmp4v2_cb.dsp
+++ b/common/mp4v2/libmp4v2_cb.dsp
@@ -42,7 +42,7 @@
 # PROP Target_Dir ""
 MTL=midl.exe
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I ".\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_FILE_CALLBACKS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I ".\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_FILE_CALLBACKS" /YX /FD /c
 # ADD BASE RSC /l 0x413 /d "NDEBUG"
 # ADD RSC /l 0x413 /d "NDEBUG"
 BSC32=bscmake.exe
--- a/libfaad/pulse.c
+++ b/libfaad/pulse.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: pulse.c,v 1.3 2002/11/28 18:48:30 menno Exp $
+** $Id: pulse.c,v 1.4 2003/04/02 18:31:07 menno Exp $
 **/
 
 #include "common.h"
@@ -25,7 +25,7 @@
 #include "syntax.h"
 #include "pulse.h"
 
-void pulse_decode(ic_stream *ics, int16_t *spec_data)
+void pulse_decode(ic_stream *ics, int16_t *spec_data, uint16_t framelen)
 {
     uint8_t i;
     uint16_t k;
@@ -35,6 +35,10 @@
 
     for(i = 0; i <= pul->number_pulse; i++) {
         k += pul->pulse_offset[i];
+
+        if (k >= framelen)
+            return; /* should not be possible */
+
         if (spec_data[k] > 0)
             spec_data[k] += pul->pulse_amp[i];
         else
--- a/libfaad/pulse.h
+++ b/libfaad/pulse.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: pulse.h,v 1.2 2002/02/18 10:01:05 menno Exp $
+** $Id: pulse.h,v 1.3 2003/04/02 18:31:07 menno Exp $
 **/
 
 #ifndef __PULSE_H__
@@ -26,7 +26,7 @@
 extern "C" {
 #endif
 
-void pulse_decode(ic_stream *ics, int16_t *spec_coef);
+void pulse_decode(ic_stream *ics, int16_t *spec_coef, uint16_t framelen);
 
 #ifdef __cplusplus
 }
--- a/libfaad/rvlc.c
+++ b/libfaad/rvlc.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: rvlc.c,v 1.3 2002/12/22 20:19:24 menno Exp $
+** $Id: rvlc.c,v 1.4 2003/04/02 18:31:08 menno Exp $
 **/
 
 /* RVLC scalefactor decoding
@@ -489,9 +489,9 @@
 
     i = h->len;
     if (direction > 0)
-        cw = faad_getbits(ld, i);
+        cw = faad_getbits(ld, i DEBUGVAR(1,0,""));
     else
-        cw = faad_getbits_rev(ld, i);
+        cw = faad_getbits_rev(ld, i DEBUGVAR(1,0,""));
 
     while ((cw != h->cw)
         && (i < 21))
--- a/libfaad/syntax.c
+++ b/libfaad/syntax.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: syntax.c,v 1.40 2003/04/01 16:34:34 menno Exp $
+** $Id: syntax.c,v 1.41 2003/04/02 18:31:08 menno Exp $
 **/
 
 /*
@@ -505,7 +505,7 @@
         if (ics->pulse_data_present)
         {
             if (ics->window_sequence != EIGHT_SHORT_SEQUENCE)
-                pulse_decode(ics, spec_data);
+                pulse_decode(ics, spec_data, hDecoder->frameLength);
             else
                 return 2; /* pulse coding not allowed for short blocks */
         }
@@ -615,7 +615,7 @@
         if (ics1->pulse_data_present)
         {
             if (ics1->window_sequence != EIGHT_SHORT_SEQUENCE)
-                pulse_decode(ics1, spec_data1);
+                pulse_decode(ics1, spec_data1, hDecoder->frameLength);
             else
                 return 2; /* pulse coding not allowed for short blocks */
         }
@@ -622,7 +622,7 @@
         if (ics2->pulse_data_present)
         {
             if (ics2->window_sequence != EIGHT_SHORT_SEQUENCE)
-                pulse_decode(ics2, spec_data2);
+                pulse_decode(ics2, spec_data2, hDecoder->frameLength);
             else
                 return 2; /* pulse coding not allowed for short blocks */
         }
@@ -955,7 +955,6 @@
 #ifdef ERROR_RESILIENCE
     if (hDecoder->aacSpectralDataResilienceFlag)
     {
-#if 0
         if (hDecoder->channelConfiguration == 2)
         {
             if (ics->length_of_reordered_spectral_data > 6144)
@@ -964,7 +963,7 @@
             if (ics->length_of_reordered_spectral_data > 12288)
                 ics->length_of_reordered_spectral_data = 12288;
         }
-#endif
+
         ics->length_of_reordered_spectral_data = (uint16_t)faad_getbits(ld, 14
             DEBUGVAR(1,147,"individual_channel_stream(): length_of_reordered_spectral_data"));
         /* TODO: test for >6144/12288, see page 143 */
@@ -1014,7 +1013,7 @@
     if (ics->pulse_data_present)
     {
         if (ics->window_sequence != EIGHT_SHORT_SEQUENCE)
-            pulse_decode(ics, spec_data);
+            pulse_decode(ics, spec_data, hDecoder->frameLength);
         else
             return 2; /* pulse coding not allowed for short blocks */
     }