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

libavcodec/bink.c:834:38: Call
832.                 break;
833.             case 1:
834.                 scan = bink_patterns[bitstream_read(bc, 4)];
                                          ^
835.                 i = 0;
836.                 do {

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] - 4):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 binkb_decode_plane(BinkContext *c, AVFrame *frame, BitstreamContext *bc,\n                              int plane_idx, int is_key, int is_chroma)\n{\n    int blk, ret;\n    int i, j, bx, by;\n    uint8_t *dst, *ref, *ref_start, *ref_end;\n    int v, col[2];\n    const uint8_t *scan;\n    int xoff, yoff;\n    LOCAL_ALIGNED_16(int16_t, block, [64]);\n    LOCAL_ALIGNED_16(int32_t, dctblock, [64]);\n    int coordmap[64];\n    int ybias = is_key ? -15 : 0;\n    int qp;\n    const int stride = frame->linesize[plane_idx];\n    int bw = is_chroma ? (c->avctx->width  + 15) >> 4 : (c->avctx->width  + 7) >> 3;\n    int bh = is_chroma ? (c->avctx->height + 15) >> 4 : (c->avctx->height + 7) >> 3;\n    binkb_init_bundles(c);\n    ref_start = frame->data[plane_idx];\n    ref_end   = frame->data[plane_idx] + (bh * frame->linesize[plane_idx] + bw) * 8;\n    for (i = 0; i < 64; i++)\n        coordmap[i] = (i & 7) + (i >> 3) * stride;\n    for (by = 0; by < bh; by++) {\n        for (i = 0; i < BINKB_NB_SRC; i++) {\n            if ((ret = binkb_read_bundle(c, bc, i)) < 0)\n                return ret;\n        }\n        dst  = frame->data[plane_idx]  + 8*by*stride;\n        for (bx = 0; bx < bw; bx++, dst += 8) {\n            blk = binkb_get_value(c, BINKB_SRC_BLOCK_TYPES);\n            switch (blk) {\n            case 0:\n                break;\n            case 1:\n                scan = bink_patterns[bitstream_read(bc, 4)];\n                i = 0;\n                do {\n                    int mode = bitstream_read_bit(bc);\n                    int run  = bitstream_read(bc, binkb_runbits[i]) + 1;\n                    i += run;\n                    if (i > 64) {\n                        av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\\n");\n                        return AVERROR_INVALIDDATA;\n                    }\n                    if (mode) {\n                        v = binkb_get_value(c, BINKB_SRC_COLORS);\n                        for (j = 0; j < run; j++)\n                            dst[coordmap[*scan++]] = v;\n                    } else {\n                        for (j = 0; j < run; j++)\n                            dst[coordmap[*scan++]] = binkb_get_value(c, BINKB_SRC_COLORS);\n                    }\n                } while (i < 63);\n                if (i == 63)\n                    dst[coordmap[*scan++]] = binkb_get_value(c, BINKB_SRC_COLORS);\n                break;\n            case 2:\n                memset(dctblock, 0, sizeof(*dctblock) * 64);\n                dctblock[0] = binkb_get_value(c, BINKB_SRC_INTRA_DC);\n                qp = binkb_get_value(c, BINKB_SRC_INTRA_Q);\n                read_dct_coeffs(bc, dctblock, bink_scan, binkb_intra_quant, qp);\n                c->binkdsp.idct_put(dst, stride, dctblock);\n                break;\n            case 3:\n                xoff = binkb_get_value(c, BINKB_SRC_X_OFF);\n                yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;\n                ref = dst + xoff + yoff * stride;\n                if (ref < ref_start || ref + 8*stride > ref_end) {\n                    av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\\n");\n                } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {\n                    c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8);\n                } else {\n                    put_pixels8x8_overlapped(dst, ref, stride);\n                }\n                c->bdsp.clear_block(block);\n                v = binkb_get_value(c, BINKB_SRC_INTER_COEFS);\n                read_residue(bc, block, v);\n                c->binkdsp.add_pixels8(dst, block, stride);\n                break;\n            case 4:\n                xoff = binkb_get_value(c, BINKB_SRC_X_OFF);\n                yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;\n                ref = dst + xoff + yoff * stride;\n                if (ref < ref_start || ref + 8 * stride > ref_end) {\n                    av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\\n");\n                } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {\n                    c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8);\n                } else {\n                    put_pixels8x8_overlapped(dst, ref, stride);\n                }\n                memset(dctblock, 0, sizeof(*dctblock) * 64);\n                dctblock[0] = binkb_get_value(c, BINKB_SRC_INTER_DC);\n                qp = binkb_get_value(c, BINKB_SRC_INTER_Q);\n                read_dct_coeffs(bc, dctblock, bink_scan, binkb_inter_quant, qp);\n                c->binkdsp.idct_add(dst, stride, dctblock);\n                break;\n            case 5:\n                v = binkb_get_value(c, BINKB_SRC_COLORS);\n                c->bdsp.fill_block_tab[1](dst, v, stride, 8);\n                break;\n            case 6:\n                for (i = 0; i < 2; i++)\n                    col[i] = binkb_get_value(c, BINKB_SRC_COLORS);\n                for (i = 0; i < 8; i++) {\n                    v = binkb_get_value(c, BINKB_SRC_PATTERN);\n                    for (j = 0; j < 8; j++, v >>= 1)\n                        dst[i*stride + j] = col[v & 1];\n                }\n                break;\n            case 7:\n                xoff = binkb_get_value(c, BINKB_SRC_X_OFF);\n                yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;\n                ref = dst + xoff + yoff * stride;\n                if (ref < ref_start || ref + 8 * stride > ref_end) {\n                    av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\\n");\n                } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {\n                    c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8);\n                } else {\n                    put_pixels8x8_overlapped(dst, ref, stride);\n                }\n                break;\n            case 8:\n                for (i = 0; i < 8; i++)\n                    memcpy(dst + i*stride, c->bundle[BINKB_SRC_COLORS].cur_ptr + i*8, 8);\n                c->bundle[BINKB_SRC_COLORS].cur_ptr += 64;\n                break;\n            default:\n                av_log(c->avctx, AV_LOG_ERROR, "Unknown block type %d\\n", blk);\n                return AVERROR_INVALIDDATA;\n            }\n        }\n    }\n    if (bitstream_tell(bc) & 0x1F)\n        bitstream_skip(bc, 32 - (bitstream_tell(bc) & 0x1F));\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 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}']