libavcodec/escape130.c:265: error: Integer Overflow L2
  ([1, +oo] - 3):unsigned32 by call to `bitstream_read`.

libavcodec/escape130.c:265:45: Call
263.                     y_avg = bitstream_read(&bc, 6);
264.                 } else {
265.                     unsigned adjust_index = bitstream_read(&bc, 3);
                                                 ^
266.                     y_avg = (y_avg + luma_adjust[adjust_index]) & 63;
267.                 }

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:194:12: Call
  192.     }
  193. 
  194.     return get_val(bc, n);
                  ^
  195. }
  196. 

libavcodec/bitstream.h:130:1: <LHS trace>
128. }
129. 
130. static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
     ^
131. {
132. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:130:1: Parameter `bc->bits_left`
    128. }
    129. 
    130. static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
         ^
    131. {
    132. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:130:1: <RHS trace>
128. }
129. 
130. static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
     ^
131. {
132. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:130:1: Parameter `n`
    128. }
    129. 
    130. static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
         ^
    131. {
    132. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:139:5: Binary operation: ([1, +oo] - 3):unsigned32 by call to `bitstream_read` 
    137.     bc->bits <<= n;
    138. #endif
    139.     bc->bits_left -= n;
             ^
    140. 
    141.     return ret;

static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
{
#ifdef BITSTREAM_READER_LE
    uint64_t ret = bc->bits & ((UINT64_C(1) << n) - 1);
    bc->bits >>= n;
#else
    uint64_t ret = bc->bits >> (64 - n);
    bc->bits <<= n;
#endif
    bc->bits_left -= n;
    return ret;
}
['static int escape130_decode_frame(AVCodecContext *avctx, void *data,\n                                  int *got_frame, AVPacket *avpkt)\n{\n    const uint8_t *buf  = avpkt->data;\n    int buf_size        = avpkt->size;\n    Escape130Context *s = avctx->priv_data;\n    AVFrame *pic        = data;\n    BitstreamContext bc;\n    int ret;\n    uint8_t *old_y, *old_cb, *old_cr,\n            *new_y, *new_cb, *new_cr;\n    uint8_t *dstY, *dstU, *dstV;\n    unsigned old_y_stride, old_cb_stride, old_cr_stride,\n             new_y_stride, new_cb_stride, new_cr_stride;\n    unsigned total_blocks = avctx->width * avctx->height / 4,\n             block_index, block_x = 0;\n    unsigned y[4] = { 0 }, cb = 0x10, cr = 0x10;\n    int skip = -1, y_avg = 0, i, j;\n    uint8_t *ya = s->old_y_avg;\n    if (buf_size <= 16) {\n        av_log(avctx, AV_LOG_ERROR, "Insufficient frame data\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)\n        return ret;\n    bitstream_init(&bc, buf + 16, (buf_size - 16) * 8);\n    new_y  = s->new_y;\n    new_cb = s->new_u;\n    new_cr = s->new_v;\n    new_y_stride  = s->linesize[0];\n    new_cb_stride = s->linesize[1];\n    new_cr_stride = s->linesize[2];\n    old_y  = s->old_y;\n    old_cb = s->old_u;\n    old_cr = s->old_v;\n    old_y_stride  = s->linesize[0];\n    old_cb_stride = s->linesize[1];\n    old_cr_stride = s->linesize[2];\n    for (block_index = 0; block_index < total_blocks; block_index++) {\n        if (skip == -1)\n            skip = decode_skip_count(&bc);\n        if (skip == -1) {\n            av_log(avctx, AV_LOG_ERROR, "Error decoding skip value\\n");\n            return AVERROR_INVALIDDATA;\n        }\n        if (skip) {\n            y[0] = old_y[0];\n            y[1] = old_y[1];\n            y[2] = old_y[old_y_stride];\n            y[3] = old_y[old_y_stride + 1];\n            y_avg = ya[0];\n            cb = old_cb[0];\n            cr = old_cr[0];\n        } else {\n            if (bitstream_read_bit(&bc)) {\n                unsigned sign_selector       = bitstream_read(&bc, 6);\n                unsigned difference_selector = bitstream_read(&bc, 2);\n                y_avg = 2 * bitstream_read(&bc, 5);\n                for (i = 0; i < 4; i++) {\n                    y[i] = av_clip(y_avg + offset_table[difference_selector] *\n                                   sign_table[sign_selector][i], 0, 63);\n                }\n            } else if (bitstream_read_bit(&bc)) {\n                if (bitstream_read_bit(&bc)) {\n                    y_avg = bitstream_read(&bc, 6);\n                } else {\n                    unsigned adjust_index = bitstream_read(&bc, 3);\n                    y_avg = (y_avg + luma_adjust[adjust_index]) & 63;\n                }\n                for (i = 0; i < 4; i++)\n                    y[i] = y_avg;\n            }\n            if (bitstream_read_bit(&bc)) {\n                if (bitstream_read_bit(&bc)) {\n                    cb = bitstream_read(&bc, 5);\n                    cr = bitstream_read(&bc, 5);\n                } else {\n                    unsigned adjust_index = bitstream_read(&bc, 3);\n                    cb = (cb + chroma_adjust[0][adjust_index]) & 31;\n                    cr = (cr + chroma_adjust[1][adjust_index]) & 31;\n                }\n            }\n        }\n        *ya++ = y_avg;\n        new_y[0]                = y[0];\n        new_y[1]                = y[1];\n        new_y[new_y_stride]     = y[2];\n        new_y[new_y_stride + 1] = y[3];\n        *new_cb = cb;\n        *new_cr = cr;\n        old_y += 2;\n        old_cb++;\n        old_cr++;\n        new_y += 2;\n        new_cb++;\n        new_cr++;\n        block_x++;\n        if (block_x * 2 == avctx->width) {\n            block_x = 0;\n            old_y  += old_y_stride * 2  - avctx->width;\n            old_cb += old_cb_stride     - avctx->width / 2;\n            old_cr += old_cr_stride     - avctx->width / 2;\n            new_y  += new_y_stride * 2  - avctx->width;\n            new_cb += new_cb_stride     - avctx->width / 2;\n            new_cr += new_cr_stride     - avctx->width / 2;\n        }\n        skip--;\n    }\n    new_y  = s->new_y;\n    new_cb = s->new_u;\n    new_cr = s->new_v;\n    dstY   = pic->data[0];\n    dstU   = pic->data[1];\n    dstV   = pic->data[2];\n    for (j = 0; j < avctx->height; j++) {\n        for (i = 0; i < avctx->width; i++)\n            dstY[i] = new_y[i] << 2;\n        dstY  += pic->linesize[0];\n        new_y += new_y_stride;\n    }\n    for (j = 0; j < avctx->height / 2; j++) {\n        for (i = 0; i < avctx->width / 2; i++) {\n            dstU[i] = chroma_vals[new_cb[i]];\n            dstV[i] = chroma_vals[new_cr[i]];\n        }\n        dstU   += pic->linesize[1];\n        dstV   += pic->linesize[2];\n        new_cb += new_cb_stride;\n        new_cr += new_cr_stride;\n    }\n    ff_dlog(avctx, "Frame data: provided %d bytes, used %d bytes\\n",\n            buf_size, bitstream_tell(&bc) >> 3);\n    FFSWAP(uint8_t*, s->old_y, s->new_y);\n    FFSWAP(uint8_t*, s->old_u, s->new_u);\n    FFSWAP(uint8_t*, s->old_v, s->new_v);\n    *got_frame = 1;\n    return buf_size;\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 uint64_t get_val(BitstreamContext *bc, unsigned n)\n{\n#ifdef BITSTREAM_READER_LE\n    uint64_t ret = bc->bits & ((UINT64_C(1) << n) - 1);\n    bc->bits >>= n;\n#else\n    uint64_t ret = bc->bits >> (64 - n);\n    bc->bits <<= n;\n#endif\n    bc->bits_left -= n;\n    return ret;\n}']