libavcodec/mpc8.c:352: error: Integer Overflow L2
  ([0, 1020] - 510):unsigned32.

libavcodec/mpc8.c:268:38: <LHS trace>
266.         maxband = mpc8_get_mod_golomb(bc, c->maxbands + 1);
267.     else{
268.         maxband = c->last_max_band + bitstream_read_vlc(bc, band_vlc.table, MPC8_BANDS_BITS, 2);
                                          ^
269.         if(maxband > 32) maxband -= 33;
270.     }

libavcodec/mpc8.c:268:38: Call
266.         maxband = mpc8_get_mod_golomb(bc, c->maxbands + 1);
267.     else{
268.         maxband = c->last_max_band + bitstream_read_vlc(bc, band_vlc.table, MPC8_BANDS_BITS, 2);
                                          ^
269.         if(maxband > 32) maxband -= 33;
270.     }

libavcodec/bitstream.h:313:1: Parameter `(*table)[*]`
  311.  * If the VLC code is invalid and max_depth > 1, then the number of bits removed
  312.  * is undefined. */
  313. static inline int bitstream_read_vlc(BitstreamContext *bc, VLC_TYPE (*table)[2],
       ^
  314.                                      int bits, int max_depth)
  315. {

libavcodec/mpc8.c:352:42: Call
350.             case -1:
351.                 for(j = 0; j < SAMPLES_PER_BAND; j++)
352.                     c->Q[ch][off + j] = (av_lfg_get(&c->rnd) & 0x3FC) - 510;
                                              ^
353.                 break;
354.             case 0:

libavutil/lfg.h:38:1: Parameter `c->state[*]`
  36.  * it may be good enough and faster for your specific use case.
  37.  */
  38. static inline unsigned int av_lfg_get(AVLFG *c){
      ^
  39.     c->state[c->index & 63] = c->state[(c->index-24) & 63] + c->state[(c->index-55) & 63];
  40.     return c->state[c->index++ & 63];

libavutil/lfg.h:40:5: Assignment
  38. static inline unsigned int av_lfg_get(AVLFG *c){
  39.     c->state[c->index & 63] = c->state[(c->index-24) & 63] + c->state[(c->index-55) & 63];
  40.     return c->state[c->index++ & 63];
          ^
  41. }
  42. 

libavcodec/mpc8.c:352:21: Binary operation: ([0, 1020] - 510):unsigned32
350.             case -1:
351.                 for(j = 0; j < SAMPLES_PER_BAND; j++)
352.                     c->Q[ch][off + j] = (av_lfg_get(&c->rnd) & 0x3FC) - 510;
                         ^
353.                 break;
354.             case 0:

static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
                             int *got_frame_ptr, AVPacket *avpkt)
{
    AVFrame *frame     = data;
    const uint8_t *buf = avpkt->data;
    int buf_size = avpkt->size;
    MPCContext *c = avctx->priv_data;
    BitstreamContext bc2, *bc = &bc2;
    int i, j, k, ch, cnt, res, t;
    Band *bands = c->bands;
    int off;
    int maxband, keyframe;
    int last[2];
    frame->nb_samples = MPC_FRAME_SIZE;
    if ((res = ff_get_buffer(avctx, frame, 0)) < 0) {
        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
        return res;
    }
    keyframe = c->cur_frame == 0;
    if(keyframe){
        memset(c->Q, 0, sizeof(c->Q));
        c->last_bits_used = 0;
    }
    bitstream_init(bc, buf, buf_size * 8);
    bitstream_skip(bc, c->last_bits_used & 7);
    if(keyframe)
        maxband = mpc8_get_mod_golomb(bc, c->maxbands + 1);
    else{
        maxband = c->last_max_band + bitstream_read_vlc(bc, band_vlc.table, MPC8_BANDS_BITS, 2);
        if(maxband > 32) maxband -= 33;
    }
    if(maxband > c->maxbands + 1)
        return AVERROR_INVALIDDATA;
    c->last_max_band = maxband;
    if(maxband){
        last[0] = last[1] = 0;
        for(i = maxband - 1; i >= 0; i--){
            for(ch = 0; ch < 2; ch++){
                last[ch] = bitstream_read_vlc(bc, res_vlc[last[ch] > 2].table, MPC8_RES_BITS, 2) + last[ch];
                if(last[ch] > 15) last[ch] -= 17;
                bands[i].res[ch] = last[ch];
            }
        }
        if(c->MSS){
            int mask;
            cnt = 0;
            for(i = 0; i < maxband; i++)
                if(bands[i].res[0] || bands[i].res[1])
                    cnt++;
            t = mpc8_get_mod_golomb(bc, cnt);
            mask = mpc8_get_mask(bc, cnt, t);
            for(i = maxband - 1; i >= 0; i--)
                if(bands[i].res[0] || bands[i].res[1]){
                    bands[i].msf = mask & 1;
                    mask >>= 1;
                }
        }
    }
    for(i = maxband; i < c->maxbands; i++)
        bands[i].res[0] = bands[i].res[1] = 0;
    if(keyframe){
        for(i = 0; i < 32; i++)
            c->oldDSCF[0][i] = c->oldDSCF[1][i] = 1;
    }
    for(i = 0; i < maxband; i++){
        if(bands[i].res[0] || bands[i].res[1]){
            cnt = !!bands[i].res[0] + !!bands[i].res[1] - 1;
            if(cnt >= 0){
                t = bitstream_read_vlc(bc, scfi_vlc[cnt].table, scfi_vlc[cnt].bits, 1);
                if(bands[i].res[0]) bands[i].scfi[0] = t >> (2 * cnt);
                if(bands[i].res[1]) bands[i].scfi[1] = t & 3;
            }
        }
    }
    for(i = 0; i < maxband; i++){
        for(ch = 0; ch < 2; ch++){
            if(!bands[i].res[ch]) continue;
            if(c->oldDSCF[ch][i]){
                bands[i].scf_idx[ch][0] = bitstream_read(bc, 7) - 6;
                c->oldDSCF[ch][i] = 0;
            }else{
                t = bitstream_read_vlc(bc, dscf_vlc[1].table, MPC8_DSCF1_BITS, 2);
                if(t == 64)
                    t += bitstream_read(bc, 6);
                bands[i].scf_idx[ch][0] = ((bands[i].scf_idx[ch][2] + t - 25) & 0x7F) - 6;
            }
            for(j = 0; j < 2; j++){
                if((bands[i].scfi[ch] << j) & 2)
                    bands[i].scf_idx[ch][j + 1] = bands[i].scf_idx[ch][j];
                else{
                    t = bitstream_read_vlc(bc, dscf_vlc[0].table, MPC8_DSCF0_BITS, 2);
                    if(t == 31)
                        t = 64 + bitstream_read(bc, 6);
                    bands[i].scf_idx[ch][j + 1] = ((bands[i].scf_idx[ch][j] + t - 25) & 0x7F) - 6;
                }
            }
        }
    }
    for(i = 0, off = 0; i < maxband; i++, off += SAMPLES_PER_BAND){
        for(ch = 0; ch < 2; ch++){
            res = bands[i].res[ch];
            switch(res){
            case -1:
                for(j = 0; j < SAMPLES_PER_BAND; j++)
                    c->Q[ch][off + j] = (av_lfg_get(&c->rnd) & 0x3FC) - 510;
                break;
            case 0:
                break;
            case 1:
                for(j = 0; j < SAMPLES_PER_BAND; j += SAMPLES_PER_BAND / 2){
                    cnt = bitstream_read_vlc(bc, q1_vlc.table, MPC8_Q1_BITS, 2);
                    t = mpc8_get_mask(bc, 18, cnt);
                    for(k = 0; k < SAMPLES_PER_BAND / 2; k++, t <<= 1)
                        c->Q[ch][off + j + k] = (t & 0x20000) ? (bitstream_read_bit(bc) << 1) - 1 : 0;
                }
                break;
            case 2:
                cnt = 6;
                for(j = 0; j < SAMPLES_PER_BAND; j += 3){
                    t = bitstream_read_vlc(bc, q2_vlc[cnt > 3].table, MPC8_Q2_BITS, 2);
                    c->Q[ch][off + j + 0] = mpc8_idx50[t];
                    c->Q[ch][off + j + 1] = mpc8_idx51[t];
                    c->Q[ch][off + j + 2] = mpc8_idx52[t];
                    cnt = (cnt >> 1) + mpc8_huffq2[t];
                }
                break;
            case 3:
            case 4:
                for(j = 0; j < SAMPLES_PER_BAND; j += 2){
                    t = bitstream_read_vlc(bc, q3_vlc[res - 3].table, MPC8_Q3_BITS, 2) + q3_offsets[res - 3];
                    c->Q[ch][off + j + 1] = t >> 4;
                    c->Q[ch][off + j + 0] = (t & 8) ? (t & 0xF) - 16 : (t & 0xF);
                }
                break;
            case 5:
            case 6:
            case 7:
            case 8:
                cnt = 2 * mpc8_thres[res];
                for(j = 0; j < SAMPLES_PER_BAND; j++){
                    t = bitstream_read_vlc(bc, quant_vlc[res - 5][cnt > mpc8_thres[res]].table, quant_vlc[res - 5][cnt > mpc8_thres[res]].bits, 2) + quant_offsets[res - 5];
                    c->Q[ch][off + j] = t;
                    cnt = (cnt >> 1) + FFABS(c->Q[ch][off + j]);
                }
                break;
            default:
                for(j = 0; j < SAMPLES_PER_BAND; j++){
                    c->Q[ch][off + j] = bitstream_read_vlc(bc, q9up_vlc.table, MPC8_Q9UP_BITS, 2);
                    if(res != 9){
                        c->Q[ch][off + j] <<= res - 9;
                        c->Q[ch][off + j] |= bitstream_read(bc, res - 9);
                    }
                    c->Q[ch][off + j] -= (1 << (res - 2)) - 1;
                }
            }
        }
    }
    ff_mpc_dequantize_and_synth(c, maxband - 1,
                                (int16_t **)frame->extended_data,
                                avctx->channels);
    c->cur_frame++;
    c->last_bits_used = bitstream_tell(bc);
    if (bitstream_bits_left(bc) < 8)
        c->last_bits_used = buf_size << 3;
    if(c->cur_frame >= c->frames)
        c->cur_frame = 0;
    *got_frame_ptr = 1;
    return c->cur_frame ? c->last_bits_used >> 3 : buf_size;
}
['static int mpc8_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    MPCContext *c = avctx->priv_data;\n    BitstreamContext bc2, *bc = &bc2;\n    int i, j, k, ch, cnt, res, t;\n    Band *bands = c->bands;\n    int off;\n    int maxband, keyframe;\n    int last[2];\n    frame->nb_samples = MPC_FRAME_SIZE;\n    if ((res = ff_get_buffer(avctx, frame, 0)) < 0) {\n        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\\n");\n        return res;\n    }\n    keyframe = c->cur_frame == 0;\n    if(keyframe){\n        memset(c->Q, 0, sizeof(c->Q));\n        c->last_bits_used = 0;\n    }\n    bitstream_init(bc, buf, buf_size * 8);\n    bitstream_skip(bc, c->last_bits_used & 7);\n    if(keyframe)\n        maxband = mpc8_get_mod_golomb(bc, c->maxbands + 1);\n    else{\n        maxband = c->last_max_band + bitstream_read_vlc(bc, band_vlc.table, MPC8_BANDS_BITS, 2);\n        if(maxband > 32) maxband -= 33;\n    }\n    if(maxband > c->maxbands + 1)\n        return AVERROR_INVALIDDATA;\n    c->last_max_band = maxband;\n    if(maxband){\n        last[0] = last[1] = 0;\n        for(i = maxband - 1; i >= 0; i--){\n            for(ch = 0; ch < 2; ch++){\n                last[ch] = bitstream_read_vlc(bc, res_vlc[last[ch] > 2].table, MPC8_RES_BITS, 2) + last[ch];\n                if(last[ch] > 15) last[ch] -= 17;\n                bands[i].res[ch] = last[ch];\n            }\n        }\n        if(c->MSS){\n            int mask;\n            cnt = 0;\n            for(i = 0; i < maxband; i++)\n                if(bands[i].res[0] || bands[i].res[1])\n                    cnt++;\n            t = mpc8_get_mod_golomb(bc, cnt);\n            mask = mpc8_get_mask(bc, cnt, t);\n            for(i = maxband - 1; i >= 0; i--)\n                if(bands[i].res[0] || bands[i].res[1]){\n                    bands[i].msf = mask & 1;\n                    mask >>= 1;\n                }\n        }\n    }\n    for(i = maxband; i < c->maxbands; i++)\n        bands[i].res[0] = bands[i].res[1] = 0;\n    if(keyframe){\n        for(i = 0; i < 32; i++)\n            c->oldDSCF[0][i] = c->oldDSCF[1][i] = 1;\n    }\n    for(i = 0; i < maxband; i++){\n        if(bands[i].res[0] || bands[i].res[1]){\n            cnt = !!bands[i].res[0] + !!bands[i].res[1] - 1;\n            if(cnt >= 0){\n                t = bitstream_read_vlc(bc, scfi_vlc[cnt].table, scfi_vlc[cnt].bits, 1);\n                if(bands[i].res[0]) bands[i].scfi[0] = t >> (2 * cnt);\n                if(bands[i].res[1]) bands[i].scfi[1] = t & 3;\n            }\n        }\n    }\n    for(i = 0; i < maxband; i++){\n        for(ch = 0; ch < 2; ch++){\n            if(!bands[i].res[ch]) continue;\n            if(c->oldDSCF[ch][i]){\n                bands[i].scf_idx[ch][0] = bitstream_read(bc, 7) - 6;\n                c->oldDSCF[ch][i] = 0;\n            }else{\n                t = bitstream_read_vlc(bc, dscf_vlc[1].table, MPC8_DSCF1_BITS, 2);\n                if(t == 64)\n                    t += bitstream_read(bc, 6);\n                bands[i].scf_idx[ch][0] = ((bands[i].scf_idx[ch][2] + t - 25) & 0x7F) - 6;\n            }\n            for(j = 0; j < 2; j++){\n                if((bands[i].scfi[ch] << j) & 2)\n                    bands[i].scf_idx[ch][j + 1] = bands[i].scf_idx[ch][j];\n                else{\n                    t = bitstream_read_vlc(bc, dscf_vlc[0].table, MPC8_DSCF0_BITS, 2);\n                    if(t == 31)\n                        t = 64 + bitstream_read(bc, 6);\n                    bands[i].scf_idx[ch][j + 1] = ((bands[i].scf_idx[ch][j] + t - 25) & 0x7F) - 6;\n                }\n            }\n        }\n    }\n    for(i = 0, off = 0; i < maxband; i++, off += SAMPLES_PER_BAND){\n        for(ch = 0; ch < 2; ch++){\n            res = bands[i].res[ch];\n            switch(res){\n            case -1:\n                for(j = 0; j < SAMPLES_PER_BAND; j++)\n                    c->Q[ch][off + j] = (av_lfg_get(&c->rnd) & 0x3FC) - 510;\n                break;\n            case 0:\n                break;\n            case 1:\n                for(j = 0; j < SAMPLES_PER_BAND; j += SAMPLES_PER_BAND / 2){\n                    cnt = bitstream_read_vlc(bc, q1_vlc.table, MPC8_Q1_BITS, 2);\n                    t = mpc8_get_mask(bc, 18, cnt);\n                    for(k = 0; k < SAMPLES_PER_BAND / 2; k++, t <<= 1)\n                        c->Q[ch][off + j + k] = (t & 0x20000) ? (bitstream_read_bit(bc) << 1) - 1 : 0;\n                }\n                break;\n            case 2:\n                cnt = 6;\n                for(j = 0; j < SAMPLES_PER_BAND; j += 3){\n                    t = bitstream_read_vlc(bc, q2_vlc[cnt > 3].table, MPC8_Q2_BITS, 2);\n                    c->Q[ch][off + j + 0] = mpc8_idx50[t];\n                    c->Q[ch][off + j + 1] = mpc8_idx51[t];\n                    c->Q[ch][off + j + 2] = mpc8_idx52[t];\n                    cnt = (cnt >> 1) + mpc8_huffq2[t];\n                }\n                break;\n            case 3:\n            case 4:\n                for(j = 0; j < SAMPLES_PER_BAND; j += 2){\n                    t = bitstream_read_vlc(bc, q3_vlc[res - 3].table, MPC8_Q3_BITS, 2) + q3_offsets[res - 3];\n                    c->Q[ch][off + j + 1] = t >> 4;\n                    c->Q[ch][off + j + 0] = (t & 8) ? (t & 0xF) - 16 : (t & 0xF);\n                }\n                break;\n            case 5:\n            case 6:\n            case 7:\n            case 8:\n                cnt = 2 * mpc8_thres[res];\n                for(j = 0; j < SAMPLES_PER_BAND; j++){\n                    t = bitstream_read_vlc(bc, quant_vlc[res - 5][cnt > mpc8_thres[res]].table, quant_vlc[res - 5][cnt > mpc8_thres[res]].bits, 2) + quant_offsets[res - 5];\n                    c->Q[ch][off + j] = t;\n                    cnt = (cnt >> 1) + FFABS(c->Q[ch][off + j]);\n                }\n                break;\n            default:\n                for(j = 0; j < SAMPLES_PER_BAND; j++){\n                    c->Q[ch][off + j] = bitstream_read_vlc(bc, q9up_vlc.table, MPC8_Q9UP_BITS, 2);\n                    if(res != 9){\n                        c->Q[ch][off + j] <<= res - 9;\n                        c->Q[ch][off + j] |= bitstream_read(bc, res - 9);\n                    }\n                    c->Q[ch][off + j] -= (1 << (res - 2)) - 1;\n                }\n            }\n        }\n    }\n    ff_mpc_dequantize_and_synth(c, maxband - 1,\n                                (int16_t **)frame->extended_data,\n                                avctx->channels);\n    c->cur_frame++;\n    c->last_bits_used = bitstream_tell(bc);\n    if (bitstream_bits_left(bc) < 8)\n        c->last_bits_used = buf_size << 3;\n    if(c->cur_frame >= c->frames)\n        c->cur_frame = 0;\n    *got_frame_ptr = 1;\n    return c->cur_frame ? c->last_bits_used >> 3 : buf_size;\n}', 'static inline int bitstream_read_vlc(BitstreamContext *bc, VLC_TYPE (*table)[2],\n                                     int bits, int max_depth)\n{\n    int nb_bits;\n    unsigned idx = bitstream_peek(bc, bits);\n    int code = table[idx][0];\n    int n    = table[idx][1];\n    if (max_depth > 1 && n < 0) {\n        skip_remaining(bc, bits);\n        code = set_idx(bc, code, &n, &nb_bits, table);\n        if (max_depth > 2 && n < 0) {\n            skip_remaining(bc, nb_bits);\n            code = set_idx(bc, code, &n, &nb_bits, table);\n        }\n    }\n    skip_remaining(bc, n);\n    return code;\n}', 'static inline unsigned int av_lfg_get(AVLFG *c){\n    c->state[c->index & 63] = c->state[(c->index-24) & 63] + c->state[(c->index-55) & 63];\n    return c->state[c->index++ & 63];\n}']