libavcodec/imc.c:1023: error: Integer Overflow L2
  (32 - [0, 64]):unsigned32 by call to `imc_decode_block`.

libavcodec/imc.c:1019:9: Call
1017.         q->bdsp.bswap16_buf(buf16, (const uint16_t *) buf, IMC_BLOCK_SIZE / 2);
1018. 
1019.         bitstream_init(&q->bc, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8);
              ^
1020. 
1021.         buf += IMC_BLOCK_SIZE;

libavcodec/bitstream.h:85:9: Assignment
  83.         bc->buffer    =
  84.         bc->ptr       = NULL;
  85.         bc->bits_left = 0;
              ^
  86.         return AVERROR_INVALIDDATA;
  87.     }

libavcodec/imc.c:1023:20: Call
1021.         buf += IMC_BLOCK_SIZE;
1022. 
1023.         if ((ret = imc_decode_block(avctx, q, i)) < 0)
                         ^
1024.             return ret;
1025.     }

libavcodec/imc.c:844:1: Parameter `q->bc.bits_left`
  842. }
  843. 
  844. static int imc_decode_block(AVCodecContext *avctx, IMCContext *q, int ch)
       ^
  845. {
  846.     int stream_format_code;

libavcodec/imc.c:855:15: Call
  853. 
  854.     /* Check the frame header */
  855.     imc_hdr = bitstream_read(&q->bc, 9);
                     ^
  856.     if (imc_hdr & 0x18) {
  857.         av_log(avctx, AV_LOG_ERROR, "frame header check failed!\n");

libavcodec/bitstream.h:183:1: Parameter `n`
    181. 
    182. /* Return n bits from the buffer. n has to be in the 0-32 range. */
    183. static inline uint32_t bitstream_read(BitstreamContext *bc, unsigned n)
         ^
    184. {
    185.     if (!n)

libavcodec/bitstream.h:189:9: Call
    187. 
    188.     if (n > bc->bits_left) {
    189.         refill_32(bc);
                 ^
    190.         if (bc->bits_left < 32)
    191.             bc->bits_left = n;

libavcodec/bitstream.h:60:1: <RHS trace>
58. }
59. 
60. static inline void refill_32(BitstreamContext *bc)
    ^
61. {
62.     if (bc->ptr >= bc->buffer_end)

libavcodec/bitstream.h:60:1: Parameter `bc->bits_left`
      58. }
      59. 
      60. static inline void refill_32(BitstreamContext *bc)
          ^
      61. {
      62.     if (bc->ptr >= bc->buffer_end)

libavcodec/bitstream.h:68:5: Binary operation: (32 - [0, 64]):unsigned32 by call to `imc_decode_block` 
      66.     bc->bits       = (uint64_t)AV_RL32(bc->ptr) << bc->bits_left | bc->bits;
      67. #else
      68.     bc->bits       = bc->bits | (uint64_t)AV_RB32(bc->ptr) << (32 - bc->bits_left);
              ^
      69. #endif
      70.     bc->ptr       += 4;

static inline void refill_32(BitstreamContext *bc)
{
    if (bc->ptr >= bc->buffer_end)
        return;
#ifdef BITSTREAM_READER_LE
    bc->bits       = (uint64_t)AV_RL32(bc->ptr) << bc->bits_left | bc->bits;
#else
    bc->bits       = bc->bits | (uint64_t)AV_RB32(bc->ptr) << (32 - bc->bits_left);
#endif
    bc->ptr       += 4;
    bc->bits_left += 32;
}
['static int imc_decode_frame(AVCodecContext *avctx, void *data,\n                            int *got_frame_ptr, AVPacket *avpkt)\n{\n    AVFrame *frame     = data;\n    const uint8_t *buf = avpkt->data;\n    int buf_size = avpkt->size;\n    int ret, i;\n    IMCContext *q = avctx->priv_data;\n    LOCAL_ALIGNED_16(uint16_t, buf16, [(IMC_BLOCK_SIZE + AV_INPUT_BUFFER_PADDING_SIZE) / 2]);\n    if (buf_size < IMC_BLOCK_SIZE * avctx->channels) {\n        av_log(avctx, AV_LOG_ERROR, "frame too small!\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    frame->nb_samples = COEFFS;\n    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {\n        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\\n");\n        return ret;\n    }\n    for (i = 0; i < avctx->channels; i++) {\n        q->out_samples = (float *)frame->extended_data[i];\n        q->bdsp.bswap16_buf(buf16, (const uint16_t *) buf, IMC_BLOCK_SIZE / 2);\n        bitstream_init(&q->bc, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8);\n        buf += IMC_BLOCK_SIZE;\n        if ((ret = imc_decode_block(avctx, q, i)) < 0)\n            return ret;\n    }\n    if (avctx->channels == 2) {\n        q->fdsp.butterflies_float((float *)frame->extended_data[0],\n                                  (float *)frame->extended_data[1], COEFFS);\n    }\n    *got_frame_ptr = 1;\n    return IMC_BLOCK_SIZE * avctx->channels;\n}', 'static inline int bitstream_init(BitstreamContext *bc, const uint8_t *buffer,\n                                 unsigned bit_size)\n{\n    unsigned buffer_size;\n    if (bit_size > INT_MAX - 7 || !buffer) {\n        buffer        =\n        bc->buffer    =\n        bc->ptr       = NULL;\n        bc->bits_left = 0;\n        return AVERROR_INVALIDDATA;\n    }\n    buffer_size = (bit_size + 7) >> 3;\n    bc->buffer       = buffer;\n    bc->buffer_end   = buffer + buffer_size;\n    bc->ptr          = bc->buffer;\n    bc->size_in_bits = bit_size;\n    bc->bits_left    = 0;\n    bc->bits         = 0;\n    refill_64(bc);\n    return 0;\n}', 'static int imc_decode_block(AVCodecContext *avctx, IMCContext *q, int ch)\n{\n    int stream_format_code;\n    int imc_hdr, i, j, ret;\n    int flag;\n    int bits;\n    int counter, bitscount;\n    IMCChannel *chctx = q->chctx + ch;\n    imc_hdr = bitstream_read(&q->bc, 9);\n    if (imc_hdr & 0x18) {\n        av_log(avctx, AV_LOG_ERROR, "frame header check failed!\\n");\n        av_log(avctx, AV_LOG_ERROR, "got %X.\\n", imc_hdr);\n        return AVERROR_INVALIDDATA;\n    }\n    stream_format_code = bitstream_read(&q->bc, 3);\n    if (stream_format_code & 0x04)\n        chctx->decoder_reset = 1;\n    if (chctx->decoder_reset) {\n        for (i = 0; i < BANDS; i++)\n            chctx->old_floor[i] = 1.0;\n        for (i = 0; i < COEFFS; i++)\n            chctx->CWdecoded[i] = 0;\n        chctx->decoder_reset = 0;\n    }\n    flag = bitstream_read_bit(&q->bc);\n    if (stream_format_code & 0x1)\n        imc_read_level_coeffs_raw(q, stream_format_code, chctx->levlCoeffBuf);\n    else\n        imc_read_level_coeffs(q, stream_format_code, chctx->levlCoeffBuf);\n    if (stream_format_code & 0x1)\n        imc_decode_level_coefficients_raw(q, chctx->levlCoeffBuf,\n                                          chctx->flcoeffs1, chctx->flcoeffs2);\n    else if (stream_format_code & 0x4)\n        imc_decode_level_coefficients(q, chctx->levlCoeffBuf,\n                                      chctx->flcoeffs1, chctx->flcoeffs2);\n    else\n        imc_decode_level_coefficients2(q, chctx->levlCoeffBuf, chctx->old_floor,\n                                       chctx->flcoeffs1, chctx->flcoeffs2);\n    memcpy(chctx->old_floor, chctx->flcoeffs1, 32 * sizeof(float));\n    counter = 0;\n    if (stream_format_code & 0x1) {\n        for (i = 0; i < BANDS; i++) {\n            chctx->bandWidthT[i]   = band_tab[i + 1] - band_tab[i];\n            chctx->bandFlagsBuf[i] = 0;\n            chctx->flcoeffs3[i]    = chctx->flcoeffs2[i] * 2;\n            chctx->flcoeffs5[i]    = 1.0;\n        }\n    } else {\n        for (i = 0; i < BANDS; i++) {\n            if (chctx->levlCoeffBuf[i] == 16) {\n                chctx->bandWidthT[i] = 0;\n                counter++;\n            } else\n                chctx->bandWidthT[i] = band_tab[i + 1] - band_tab[i];\n        }\n        memset(chctx->bandFlagsBuf, 0, BANDS * sizeof(int));\n        for (i = 0; i < BANDS - 1; i++)\n            if (chctx->bandWidthT[i])\n                chctx->bandFlagsBuf[i] = bitstream_read_bit(&q->bc);\n        imc_calculate_coeffs(q, chctx->flcoeffs1, chctx->flcoeffs2,\n                             chctx->bandWidthT, chctx->flcoeffs3,\n                             chctx->flcoeffs5);\n    }\n    bitscount = 0;\n    if (stream_format_code & 0x2) {\n        bitscount += 15;\n        chctx->bitsBandT[0] = 5;\n        chctx->CWlengthT[0] = 5;\n        chctx->CWlengthT[1] = 5;\n        chctx->CWlengthT[2] = 5;\n        for (i = 1; i < 4; i++) {\n            if (stream_format_code & 0x1)\n                bits = 5;\n            else\n                bits = (chctx->levlCoeffBuf[i] == 16) ? 0 : 5;\n            chctx->bitsBandT[i] = bits;\n            for (j = band_tab[i]; j < band_tab[i + 1]; j++) {\n                chctx->CWlengthT[j] = bits;\n                bitscount      += bits;\n            }\n        }\n    }\n    if (avctx->codec_id == AV_CODEC_ID_IAC) {\n        bitscount += !!chctx->bandWidthT[BANDS - 1];\n        if (!(stream_format_code & 0x2))\n            bitscount += 16;\n    }\n    if ((ret = bit_allocation(q, chctx, stream_format_code,\n                              512 - bitscount - bitstream_tell(&q->bc),\n                              flag)) < 0) {\n        av_log(avctx, AV_LOG_ERROR, "Bit allocations failed\\n");\n        chctx->decoder_reset = 1;\n        return ret;\n    }\n    if (stream_format_code & 0x1) {\n        for (i = 0; i < BANDS; i++)\n            chctx->skipFlags[i] = 0;\n    } else {\n        imc_refine_bit_allocation(q, chctx);\n    }\n    for (i = 0; i < BANDS; i++) {\n        chctx->sumLenArr[i] = 0;\n        for (j = band_tab[i]; j < band_tab[i + 1]; j++)\n            if (!chctx->skipFlags[j])\n                chctx->sumLenArr[i] += chctx->CWlengthT[j];\n    }\n    memset(chctx->codewords, 0, sizeof(chctx->codewords));\n    if (imc_get_coeffs(q, chctx) < 0) {\n        av_log(avctx, AV_LOG_ERROR, "Read coefficients failed\\n");\n        chctx->decoder_reset = 1;\n        return AVERROR_INVALIDDATA;\n    }\n    if (inverse_quant_coeff(q, chctx, stream_format_code) < 0) {\n        av_log(avctx, AV_LOG_ERROR, "Inverse quantization of coefficients failed\\n");\n        chctx->decoder_reset = 1;\n        return AVERROR_INVALIDDATA;\n    }\n    memset(chctx->skipFlags, 0, sizeof(chctx->skipFlags));\n    imc_imdct256(q, chctx, avctx->channels);\n    return 0;\n}', 'static inline uint32_t bitstream_read(BitstreamContext *bc, unsigned n)\n{\n    if (!n)\n        return 0;\n    if (n > bc->bits_left) {\n        refill_32(bc);\n        if (bc->bits_left < 32)\n            bc->bits_left = n;\n    }\n    return get_val(bc, n);\n}', 'static inline void refill_32(BitstreamContext *bc)\n{\n    if (bc->ptr >= bc->buffer_end)\n        return;\n#ifdef BITSTREAM_READER_LE\n    bc->bits       = (uint64_t)AV_RL32(bc->ptr) << bc->bits_left | bc->bits;\n#else\n    bc->bits       = bc->bits | (uint64_t)AV_RB32(bc->ptr) << (32 - bc->bits_left);\n#endif\n    bc->ptr       += 4;\n    bc->bits_left += 32;\n}']