libavcodec/cook.c:1026: error: Buffer Overrun L1
  Offset: -1 Size: 51 by call to `decode_subpacket`.

libavcodec/cook.c:1003:5: Assignment
1001.     int i;
1002.     int offset = 0;
1003.     int chidx = 0;
          ^
1004. 
1005.     if (buf_size < avctx->block_align)

libavcodec/cook.c:1024:9: Assignment
1022.     for(i=0;i<q->num_subpackets;i++){
1023.         q->subpacket[i].bits_per_subpacket = (q->subpacket[i].size*8)>>q->subpacket[i].bits_per_subpdiv;
1024.         q->subpacket[i].ch_idx = chidx;
              ^
1025.         av_log(avctx,AV_LOG_DEBUG,"subpacket[%i] size %i js %i %i block_align %i\n",i,q->subpacket[i].size,q->subpacket[i].joint_stereo,offset,avctx->block_align);
1026.         decode_subpacket(q, &q->subpacket[i], buf + offset, (int16_t*)data);

libavcodec/cook.c:1026:9: Call
1024.         q->subpacket[i].ch_idx = chidx;
1025.         av_log(avctx,AV_LOG_DEBUG,"subpacket[%i] size %i js %i %i block_align %i\n",i,q->subpacket[i].size,q->subpacket[i].joint_stereo,offset,avctx->block_align);
1026.         decode_subpacket(q, &q->subpacket[i], buf + offset, (int16_t*)data);
              ^
1027.         offset += q->subpacket[i].size;
1028.         chidx += q->subpacket[i].num_channels;

libavcodec/cook.c:952:1: Parameter `p->subbands`
  950. 
  951. 
  952. static void decode_subpacket(COOKContext *q, COOKSubpacket* p, const uint8_t *inbuffer, int16_t *outbuffer) {
       ^
  953.     int sub_packet_size = p->size;
  954.     /* packet dump */

libavcodec/cook.c:963:9: Call
  961. 
  962.     if (p->joint_stereo) {
  963.         joint_decode(q, p, q->decode_buffer_1, q->decode_buffer_2);
               ^
  964.     } else {
  965.         mono_decode(q, p, q->decode_buffer_1);

libavcodec/cook.c:833:1: Parameter `p->subbands`
    831.  */
    832. 
    833. static void joint_decode(COOKContext *q, COOKSubpacket *p, float* mlt_buffer1,
         ^
    834.                          float* mlt_buffer2) {
    835.     int i,j;

libavcodec/cook.c:848:5: Call
    846.     memset(mlt_buffer1,0, 1024*sizeof(float));
    847.     memset(mlt_buffer2,0, 1024*sizeof(float));
    848.     decouple_info(q, p, decouple_tab);
             ^
    849.     mono_decode(q, p, decode_buffer);
    850. 

libavcodec/cook.c:777:1: <Offset trace>
775.  */
776. 
777. static void decouple_info(COOKContext *q, COOKSubpacket *p, int* decouple_tab){
     ^
778.     int length, i;
779. 

libavcodec/cook.c:777:1: Parameter `p->subbands`
      775.  */
      776. 
      777. static void decouple_info(COOKContext *q, COOKSubpacket *p, int* decouple_tab){
           ^
      778.     int length, i;
      779. 

libavcodec/cookdata.h:504:1: <Length trace>
502. //Coupling tables
503. 
504. static const int cplband[51] = {
     ^
505.     0,1,2,3,4,5,6,7,8,9,
506.     10,11,11,12,12,13,13,14,14,14,

libavcodec/cookdata.h:504:1: Array declaration
      502. //Coupling tables
      503. 
      504. static const int cplband[51] = {
           ^
      505.     0,1,2,3,4,5,6,7,8,9,
      506.     10,11,11,12,12,13,13,14,14,14,

libavcodec/cook.c:781:43: Array access: Offset: -1 Size: 51 by call to `decode_subpacket` 
      779. 
      780.     if(get_bits1(&q->gb)) {
      781.         if(cplband[p->js_subband_start] > cplband[p->subbands-1]) return;
                                                     ^
      782. 
      783.         length = cplband[p->subbands-1] - cplband[p->js_subband_start] + 1;

static void decouple_info(COOKContext *q, COOKSubpacket *p, int* decouple_tab){
    int length, i;
    if(get_bits1(&q->gb)) {
        if(cplband[p->js_subband_start] > cplband[p->subbands-1]) return;
        length = cplband[p->subbands-1] - cplband[p->js_subband_start] + 1;
        for (i=0 ; i<length ; i++) {
            decouple_tab[cplband[p->js_subband_start] + i] = get_vlc2(&q->gb, p->ccpl.table, p->ccpl.bits, 2);
        }
        return;
    }
    if(cplband[p->js_subband_start] > cplband[p->subbands-1]) return;
    length = cplband[p->subbands-1] - cplband[p->js_subband_start] + 1;
    for (i=0 ; i<length ; i++) {
       decouple_tab[cplband[p->js_subband_start] + i] = get_bits(&q->gb, p->js_vlc_bits);
    }
    return;
}
['static int cook_decode_frame(AVCodecContext *avctx,\n            void *data, int *data_size,\n            AVPacket *avpkt) {\n    const uint8_t *buf = avpkt->data;\n    int buf_size = avpkt->size;\n    COOKContext *q = avctx->priv_data;\n    int i;\n    int offset = 0;\n    int chidx = 0;\n    if (buf_size < avctx->block_align)\n        return buf_size;\n    q->subpacket[0].size = avctx->block_align;\n    for(i=1;i<q->num_subpackets;i++){\n        q->subpacket[i].size = 2 * buf[avctx->block_align - q->num_subpackets + i];\n        q->subpacket[0].size -= q->subpacket[i].size + 1;\n        if (q->subpacket[0].size < 0) {\n            av_log(avctx,AV_LOG_DEBUG,"frame subpacket size total > avctx->block_align!\\n");\n            return -1;\n        }\n    }\n    *data_size = 0;\n    for(i=0;i<q->num_subpackets;i++){\n        q->subpacket[i].bits_per_subpacket = (q->subpacket[i].size*8)>>q->subpacket[i].bits_per_subpdiv;\n        q->subpacket[i].ch_idx = chidx;\n        av_log(avctx,AV_LOG_DEBUG,"subpacket[%i] size %i js %i %i block_align %i\\n",i,q->subpacket[i].size,q->subpacket[i].joint_stereo,offset,avctx->block_align);\n        decode_subpacket(q, &q->subpacket[i], buf + offset, (int16_t*)data);\n        offset += q->subpacket[i].size;\n        chidx += q->subpacket[i].num_channels;\n        av_log(avctx,AV_LOG_DEBUG,"subpacket[%i] %i %i\\n",i,q->subpacket[i].size * 8,get_bits_count(&q->gb));\n    }\n    *data_size = sizeof(int16_t) * q->nb_channels * q->samples_per_channel;\n    if (avctx->frame_number < 2) *data_size = 0;\n    return avctx->block_align;\n}', 'static void decode_subpacket(COOKContext *q, COOKSubpacket* p, const uint8_t *inbuffer, int16_t *outbuffer) {\n    int sub_packet_size = p->size;\n    memset(q->decode_buffer_1,0,sizeof(q->decode_buffer_1));\n    decode_bytes_and_gain(q, p, inbuffer, &p->gains1);\n    if (p->joint_stereo) {\n        joint_decode(q, p, q->decode_buffer_1, q->decode_buffer_2);\n    } else {\n        mono_decode(q, p, q->decode_buffer_1);\n        if (p->num_channels == 2) {\n            decode_bytes_and_gain(q, p, inbuffer + sub_packet_size/2, &p->gains2);\n            mono_decode(q, p, q->decode_buffer_2);\n        }\n    }\n    mlt_compensate_output(q, q->decode_buffer_1, &p->gains1,\n                          p->mono_previous_buffer1, outbuffer, p->ch_idx);\n    if (p->num_channels == 2) {\n        if (p->joint_stereo) {\n            mlt_compensate_output(q, q->decode_buffer_2, &p->gains1,\n                                  p->mono_previous_buffer2, outbuffer, p->ch_idx + 1);\n         } else {\n            mlt_compensate_output(q, q->decode_buffer_2, &p->gains2,\n                                  p->mono_previous_buffer2, outbuffer, p->ch_idx + 1);\n         }\n     }\n}', 'static void joint_decode(COOKContext *q, COOKSubpacket *p, float* mlt_buffer1,\n                         float* mlt_buffer2) {\n    int i,j;\n    int decouple_tab[SUBBAND_SIZE];\n    float *decode_buffer = q->decode_buffer_0;\n    int idx, cpl_tmp;\n    float f1,f2;\n    const float* cplscale;\n    memset(decouple_tab, 0, sizeof(decouple_tab));\n    memset(decode_buffer, 0, sizeof(decode_buffer));\n    memset(mlt_buffer1,0, 1024*sizeof(float));\n    memset(mlt_buffer2,0, 1024*sizeof(float));\n    decouple_info(q, p, decouple_tab);\n    mono_decode(q, p, decode_buffer);\n    for (i=0 ; i<p->js_subband_start ; i++) {\n        for (j=0 ; j<SUBBAND_SIZE ; j++) {\n            mlt_buffer1[i*20+j] = decode_buffer[i*40+j];\n            mlt_buffer2[i*20+j] = decode_buffer[i*40+20+j];\n        }\n    }\n    idx = (1 << p->js_vlc_bits) - 1;\n    for (i=p->js_subband_start ; i<p->subbands ; i++) {\n        cpl_tmp = cplband[i];\n        idx -=decouple_tab[cpl_tmp];\n        cplscale = q->cplscales[p->js_vlc_bits-2];\n        f1 = cplscale[decouple_tab[cpl_tmp]];\n        f2 = cplscale[idx-1];\n        q->decouple (q, p, i, f1, f2, decode_buffer, mlt_buffer1, mlt_buffer2);\n        idx = (1 << p->js_vlc_bits) - 1;\n    }\n}', 'static void decouple_info(COOKContext *q, COOKSubpacket *p, int* decouple_tab){\n    int length, i;\n    if(get_bits1(&q->gb)) {\n        if(cplband[p->js_subband_start] > cplband[p->subbands-1]) return;\n        length = cplband[p->subbands-1] - cplband[p->js_subband_start] + 1;\n        for (i=0 ; i<length ; i++) {\n            decouple_tab[cplband[p->js_subband_start] + i] = get_vlc2(&q->gb, p->ccpl.table, p->ccpl.bits, 2);\n        }\n        return;\n    }\n    if(cplband[p->js_subband_start] > cplband[p->subbands-1]) return;\n    length = cplband[p->subbands-1] - cplband[p->js_subband_start] + 1;\n    for (i=0 ; i<length ; i++) {\n       decouple_tab[cplband[p->js_subband_start] + i] = get_bits(&q->gb, p->js_vlc_bits);\n    }\n    return;\n}']