]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/cook.c
vc1_parser.o does not depend on h263dec.o and intrax8.o.
[ffmpeg] / libavcodec / cook.c
index edc1a22d17e38388682496b3f596dea8039240c8..6dec2566a73ec8c356d7148c5c303d6694a423a3 100644 (file)
@@ -136,7 +136,7 @@ typedef struct cook {
     AVLFG               random_state;
 
     /* transform data */
-    MDCTContext         mdct_ctx;
+    FFTContext          mdct_ctx;
     float*              mlt_window;
 
     /* VLC data */
@@ -259,7 +259,7 @@ static av_cold int init_cook_mlt(COOKContext *q) {
         q->mlt_window[j] *= sqrt(2.0 / q->samples_per_channel);
 
     /* Initialize the MDCT. */
-    if (ff_mdct_init(&q->mdct_ctx, av_log2(mlt_size)+1, 1)) {
+    if (ff_mdct_init(&q->mdct_ctx, av_log2(mlt_size)+1, 1, 1.0)) {
       av_free(q->mlt_window);
       return -1;
     }
@@ -1008,10 +1008,14 @@ static int cook_decode_frame(AVCodecContext *avctx,
     /* estimate subpacket sizes */
     q->subpacket[0].size = avctx->block_align;
 
-        for(i=1;i<q->num_subpackets;i++){
-            q->subpacket[i].size = 2 * buf[avctx->block_align - q->num_subpackets + i];
-            q->subpacket[0].size -= (q->subpacket[i].size + 1);
+    for(i=1;i<q->num_subpackets;i++){
+        q->subpacket[i].size = 2 * buf[avctx->block_align - q->num_subpackets + i];
+        q->subpacket[0].size -= q->subpacket[i].size + 1;
+        if (q->subpacket[0].size < 0) {
+            av_log(avctx,AV_LOG_DEBUG,"frame subpacket size total > avctx->block_align!\n");
+            return -1;
         }
+    }
 
     /* decode supbackets */
     *data_size = 0;
@@ -1097,7 +1101,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
     q->bit_rate = avctx->bit_rate;
 
     /* Initialize RNG. */
-    av_lfg_init(&q->random_state, ff_random_get_seed());
+    av_lfg_init(&q->random_state, 0);
 
     while(edata_ptr < edata_ptr_end){
         /* 8 for mono, 16 for stereo, ? for multichannel
@@ -1137,9 +1141,10 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
                 av_log(avctx,AV_LOG_DEBUG,"MONO\n");
                 break;
             case STEREO:
-                if (q->nb_channels != 1)
+                if (q->nb_channels != 1) {
                     q->subpacket[s].bits_per_subpdiv = 1;
-                q->subpacket[s].num_channels = 2;
+                    q->subpacket[s].num_channels = 2;
+                }
                 av_log(avctx,AV_LOG_DEBUG,"STEREO\n");
                 break;
             case JOINT_STEREO:
@@ -1219,6 +1224,10 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
 
         q->num_subpackets++;
         s++;
+        if (s > MAX_SUBPACKETS) {
+            av_log(avctx,AV_LOG_ERROR,"Too many subpackets > 5, report file!\n");
+            return -1;
+        }
     }
     /* Generate tables */
     init_pow2table();