changeset 3009:f5898b9b8a8a libavcodec

Fix an out of array access and some minor cleanup of the code. All available cook samples decode correctly now. patch by Benjamin Larsson < banan ** at ** student ** dot ** ltu ** dot ** se >
author diego
date Wed, 04 Jan 2006 12:48:10 +0000
parents e23d2bddf122
children 533c6386eca9
files cook.c
diffstat 1 files changed, 15 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/cook.c	Wed Jan 04 09:42:37 2006 +0000
+++ b/cook.c	Wed Jan 04 12:48:10 2006 +0000
@@ -131,11 +131,6 @@
     float               rootpow2tab[127];
 
     /* data buffers */
-    uint8_t*            frame_reorder_buffer;
-    int*                frame_reorder_index;
-    int                 frame_reorder_counter;
-    int                 frame_reorder_complete;
-    int                 frame_reorder_index_size;
 
     uint8_t*            decoded_bytes_buffer;
     float               mono_mdct_output[2048] __attribute__((aligned(16)));
@@ -325,8 +320,6 @@
     av_free(q->mlt_precos);
     av_free(q->mlt_presin);
     av_free(q->mlt_postcos);
-    av_free(q->frame_reorder_index);
-    av_free(q->frame_reorder_buffer);
     av_free(q->decoded_bytes_buffer);
 
     /* Free the transform. */
@@ -915,7 +908,7 @@
                          float* mlt_buffer2) {
     int i,j;
     int decouple_tab[SUBBAND_SIZE];
-    float decode_buffer[2048];  //Only 1060 might be needed.
+    float decode_buffer[1060];
     int idx, cpl_tmp,tmp_idx;
     float f1,f2;
     float* cplscale;
@@ -940,20 +933,18 @@
     /* When we reach js_subband_start (the higher frequencies)
        the coefficients are stored in a coupling scheme. */
     idx = (1 << q->js_vlc_bits) - 1;
-    if (q->js_subband_start < q->subbands) {
-        for (i=0 ; i<q->subbands ; i++) {
-            cpl_tmp = cplband[i + q->js_subband_start];
-            idx -=decouple_tab[cpl_tmp];
-            cplscale = (float*)cplscales[q->js_vlc_bits-2];  //choose decoupler table
-            f1 = cplscale[decouple_tab[cpl_tmp]];
-            f2 = cplscale[idx-1];
-            for (j=0 ; j<SUBBAND_SIZE ; j++) {
-                tmp_idx = ((2*q->js_subband_start + i)*20)+j;
-                mlt_buffer1[20*(i+q->js_subband_start) + j] = f1 * decode_buffer[tmp_idx];
-                mlt_buffer2[20*(i+q->js_subband_start) + j] = f2 * decode_buffer[tmp_idx];
-            }
-            idx = (1 << q->js_vlc_bits) - 1;
+    for (i=q->js_subband_start ; i<q->subbands ; i++) {
+        cpl_tmp = cplband[i];
+        idx -=decouple_tab[cpl_tmp];
+        cplscale = (float*)cplscales[q->js_vlc_bits-2];  //choose decoupler table
+        f1 = cplscale[decouple_tab[cpl_tmp]];
+        f2 = cplscale[idx-1];
+        for (j=0 ; j<SUBBAND_SIZE ; j++) {
+            tmp_idx = ((q->js_subband_start + i)*20)+j;
+            mlt_buffer1[20*i + j] = f1 * decode_buffer[tmp_idx];
+            mlt_buffer2[20*i + j] = f2 * decode_buffer[tmp_idx];
         }
+        idx = (1 << q->js_vlc_bits) - 1;
     }
 }
 
@@ -1159,8 +1150,6 @@
     PRINT("numvector_bits",q->numvector_bits);
     PRINT("numvector_size",q->numvector_size);
     PRINT("total_subbands",q->total_subbands);
-    PRINT("frame_reorder_counter",q->frame_reorder_counter);
-    PRINT("frame_reorder_index_size",q->frame_reorder_index_size);
 }
 #endif
 /**
@@ -1293,8 +1282,9 @@
     /* Initialize transform. */
     if ( init_cook_mlt(q) == 0 )
         return -1;
-
-    //dump_cook_context(q,e);
+#ifdef COOKDEBUG
+    dump_cook_context(q,e);
+#endif
     return 0;
 }