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

libavcodec/cook.c:956:5: Assignment
954.     int i, ret;
955.     int offset = 0;
956.     int chidx = 0;
         ^
957. 
958.     if (buf_size < avctx->block_align)

libavcodec/cook.c:988:9: Assignment
986.         q->subpacket[i].bits_per_subpacket = (q->subpacket[i].size * 8) >>
987.                                               q->subpacket[i].bits_per_subpdiv;
988.         q->subpacket[i].ch_idx = chidx;
             ^
989.         av_log(avctx, AV_LOG_DEBUG,
990.                "subpacket[%i] size %i js %i %i block_align %i\n",

libavcodec/cook.c:994:20: Call
992.                avctx->block_align);
993. 
994.         if ((ret = decode_subpacket(q, &q->subpacket[i], buf + offset, samples)) < 0)
                        ^
995.             return ret;
996.         offset += q->subpacket[i].size;

libavcodec/cook.c:906:1: Parameter `p->subbands`
  904.  * @param outbuffer         pointer to the outbuffer
  905.  */
  906. static int decode_subpacket(COOKContext *q, COOKSubpacket *p,
       ^
  907.                             const uint8_t *inbuffer, float **outbuffer)
  908. {

libavcodec/cook.c:916:20: Call
  914. 
  915.     if (p->joint_stereo) {
  916.         if ((res = joint_decode(q, p, q->decode_buffer_1, q->decode_buffer_2)) < 0)
                          ^
  917.             return res;
  918.     } else {

libavcodec/cook.c:796:1: Parameter `p->subbands`
    794.  * @param mlt_buffer2       pointer to right channel mlt coefficients
    795.  */
    796. static int joint_decode(COOKContext *q, COOKSubpacket *p,
         ^
    797.                         float *mlt_buffer_left, float *mlt_buffer_right)
    798. {

libavcodec/cook.c:811:5: Call
    809.     memset(mlt_buffer_left,  0, 1024 * sizeof(*mlt_buffer_left));
    810.     memset(mlt_buffer_right, 0, 1024 * sizeof(*mlt_buffer_right));
    811.     decouple_info(q, p, decouple_tab);
             ^
    812.     if ((res = mono_decode(q, p, decode_buffer)) < 0)
    813.         return res;

libavcodec/cook.c:742:1: <Offset trace>
740.  * @param decouple_tab      decoupling array
741.  */
742. static void decouple_info(COOKContext *q, COOKSubpacket *p, int *decouple_tab)
     ^
743. {
744.     int i;

libavcodec/cook.c:742:1: Parameter `p->subbands`
      740.  * @param decouple_tab      decoupling array
      741.  */
      742. static void decouple_info(COOKContext *q, COOKSubpacket *p, int *decouple_tab)
           ^
      743. {
      744.     int i;

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:747:18: Array access: Offset: -1 Size: 51 by call to `decode_subpacket` 
      745.     int vlc    = get_bits1(&q->gb);
      746.     int start  = cplband[p->js_subband_start];
      747.     int end    = cplband[p->subbands - 1];
                            ^
      748.     int length = end - start + 1;
      749. 

static void decouple_info(COOKContext *q, COOKSubpacket *p, int *decouple_tab)
{
    int i;
    int vlc    = get_bits1(&q->gb);
    int start  = cplband[p->js_subband_start];
    int end    = cplband[p->subbands - 1];
    int length = end - start + 1;
    if (start > end)
        return;
    if (vlc)
        for (i = 0; i < length; i++)
            decouple_tab[start + i] = get_vlc2(&q->gb,
                                               p->channel_coupling.table,
                                               p->channel_coupling.bits, 2);
    else
        for (i = 0; i < length; i++)
            decouple_tab[start + i] = get_bits(&q->gb, p->js_vlc_bits);
}
['static int cook_decode_frame(AVCodecContext *avctx, void *data,\n                             int *got_frame_ptr, AVPacket *avpkt)\n{\n    const uint8_t *buf = avpkt->data;\n    int buf_size = avpkt->size;\n    COOKContext *q = avctx->priv_data;\n    float **samples = NULL;\n    int i, ret;\n    int offset = 0;\n    int chidx = 0;\n    if (buf_size < avctx->block_align)\n        return buf_size;\n    if (q->discarded_packets >= 2) {\n        q->frame.nb_samples = q->samples_per_channel;\n        if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) {\n            av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\\n");\n            return ret;\n        }\n        samples = (float **)q->frame.extended_data;\n    }\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,\n                   "frame subpacket size total > avctx->block_align!\\n");\n            return AVERROR_INVALIDDATA;\n        }\n    }\n    for (i = 0; i < q->num_subpackets; i++) {\n        q->subpacket[i].bits_per_subpacket = (q->subpacket[i].size * 8) >>\n                                              q->subpacket[i].bits_per_subpdiv;\n        q->subpacket[i].ch_idx = chidx;\n        av_log(avctx, AV_LOG_DEBUG,\n               "subpacket[%i] size %i js %i %i block_align %i\\n",\n               i, q->subpacket[i].size, q->subpacket[i].joint_stereo, offset,\n               avctx->block_align);\n        if ((ret = decode_subpacket(q, &q->subpacket[i], buf + offset, samples)) < 0)\n            return ret;\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",\n               i, q->subpacket[i].size * 8, get_bits_count(&q->gb));\n    }\n    if (q->discarded_packets < 2) {\n        q->discarded_packets++;\n        *got_frame_ptr = 0;\n        return avctx->block_align;\n    }\n    *got_frame_ptr    = 1;\n    *(AVFrame *) data = q->frame;\n    return avctx->block_align;\n}', 'static int decode_subpacket(COOKContext *q, COOKSubpacket *p,\n                            const uint8_t *inbuffer, float **outbuffer)\n{\n    int sub_packet_size = p->size;\n    int res;\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        if ((res = joint_decode(q, p, q->decode_buffer_1, q->decode_buffer_2)) < 0)\n            return res;\n    } else {\n        if ((res = mono_decode(q, p, q->decode_buffer_1)) < 0)\n            return res;\n        if (p->num_channels == 2) {\n            decode_bytes_and_gain(q, p, inbuffer + sub_packet_size / 2, &p->gains2);\n            if ((res = mono_decode(q, p, q->decode_buffer_2)) < 0)\n                return res;\n        }\n    }\n    mlt_compensate_output(q, q->decode_buffer_1, &p->gains1,\n                          p->mono_previous_buffer1,\n                          outbuffer ? outbuffer[p->ch_idx] : NULL);\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,\n                                  outbuffer ? outbuffer[p->ch_idx + 1] : NULL);\n        else\n            mlt_compensate_output(q, q->decode_buffer_2, &p->gains2,\n                                  p->mono_previous_buffer2,\n                                  outbuffer ? outbuffer[p->ch_idx + 1] : NULL);\n    return 0;\n}', 'static int joint_decode(COOKContext *q, COOKSubpacket *p,\n                        float *mlt_buffer_left, float *mlt_buffer_right)\n{\n    int i, j, res;\n    int decouple_tab[SUBBAND_SIZE] = { 0 };\n    float *decode_buffer = q->decode_buffer_0;\n    int idx, cpl_tmp;\n    float f1, f2;\n    const float *cplscale;\n    memset(decode_buffer, 0, sizeof(q->decode_buffer_0));\n    memset(mlt_buffer_left,  0, 1024 * sizeof(*mlt_buffer_left));\n    memset(mlt_buffer_right, 0, 1024 * sizeof(*mlt_buffer_right));\n    decouple_info(q, p, decouple_tab);\n    if ((res = mono_decode(q, p, decode_buffer)) < 0)\n        return res;\n    for (i = 0; i < p->js_subband_start; i++) {\n        for (j = 0; j < SUBBAND_SIZE; j++) {\n            mlt_buffer_left[i  * 20 + j] = decode_buffer[i * 40 + j];\n            mlt_buffer_right[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] + 1];\n        f2 = cplscale[idx];\n        q->decouple(q, p, i, f1, f2, decode_buffer,\n                    mlt_buffer_left, mlt_buffer_right);\n        idx = (1 << p->js_vlc_bits) - 1;\n    }\n    return 0;\n}', 'static void decouple_info(COOKContext *q, COOKSubpacket *p, int *decouple_tab)\n{\n    int i;\n    int vlc    = get_bits1(&q->gb);\n    int start  = cplband[p->js_subband_start];\n    int end    = cplband[p->subbands - 1];\n    int length = end - start + 1;\n    if (start > end)\n        return;\n    if (vlc)\n        for (i = 0; i < length; i++)\n            decouple_tab[start + i] = get_vlc2(&q->gb,\n                                               p->channel_coupling.table,\n                                               p->channel_coupling.bits, 2);\n    else\n        for (i = 0; i < length; i++)\n            decouple_tab[start + i] = get_bits(&q->gb, p->js_vlc_bits);\n}']