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

libavcodec/escape124.c:305:24: Call
303.                 unsigned mask;
304.                 mb = decode_macroblock(s, &bc, &cb_index, superblock_index);
305.                 mask = bitstream_read(&bc, 16);
                            ^
306.                 multi_mask |= mask;
307.                 for (i = 0; i < 16; i++) {

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] - 16):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 escape124_decode_frame(AVCodecContext *avctx,\n                                  void *data, int *got_frame,\n                                  AVPacket *avpkt)\n{\n    const uint8_t *buf = avpkt->data;\n    int buf_size = avpkt->size;\n    Escape124Context *s = avctx->priv_data;\n    AVFrame *frame = data;\n    BitstreamContext bc;\n    unsigned frame_flags, frame_size;\n    unsigned i;\n    unsigned superblock_index, cb_index = 1,\n             superblock_col_index = 0,\n             superblocks_per_row = avctx->width / 8, skip = -1;\n    uint16_t* old_frame_data, *new_frame_data;\n    unsigned old_stride, new_stride;\n    int ret;\n    bitstream_init(&bc, buf, buf_size * 8);\n    if (!can_safely_read(&bc, 64))\n        return -1;\n    frame_flags = bitstream_read(&bc, 32);\n    frame_size  = bitstream_read(&bc, 32);\n    if (!(frame_flags & 0x114) || !(frame_flags & 0x7800000)) {\n        if (!s->frame->data[0])\n            return AVERROR_INVALIDDATA;\n        av_log(NULL, AV_LOG_DEBUG, "Skipping frame\\n");\n        *got_frame = 1;\n        if ((ret = av_frame_ref(frame, s->frame)) < 0)\n            return ret;\n        return frame_size;\n    }\n    for (i = 0; i < 3; i++) {\n        if (frame_flags & (1 << (17 + i))) {\n            unsigned cb_depth, cb_size;\n            if (i == 2) {\n                cb_size = bitstream_read(&bc, 20);\n                cb_depth = av_log2(cb_size - 1) + 1;\n            } else {\n                cb_depth = bitstream_read(&bc, 4);\n                if (i == 0) {\n                    cb_size = 1 << cb_depth;\n                } else {\n                    cb_size = s->num_superblocks << cb_depth;\n                }\n            }\n            av_free(s->codebooks[i].blocks);\n            s->codebooks[i] = unpack_codebook(&bc, cb_depth, cb_size);\n            if (!s->codebooks[i].blocks)\n                return -1;\n        }\n    }\n    if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0) {\n        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\\n");\n        return ret;\n    }\n    new_frame_data = (uint16_t*)frame->data[0];\n    new_stride = frame->linesize[0] / 2;\n    old_frame_data = (uint16_t*)s->frame->data[0];\n    old_stride = s->frame->linesize[0] / 2;\n    for (superblock_index = 0; superblock_index < s->num_superblocks;\n         superblock_index++) {\n        MacroBlock mb;\n        SuperBlock sb;\n        unsigned multi_mask = 0;\n        if (skip == -1) {\n            skip = decode_skip_count(&bc);\n        }\n        if (skip) {\n            copy_superblock(new_frame_data, new_stride,\n                            old_frame_data, old_stride);\n        } else {\n            copy_superblock(sb.pixels, 8,\n                            old_frame_data, old_stride);\n            while (can_safely_read(&bc, 1) && !bitstream_read_bit(&bc)) {\n                unsigned mask;\n                mb = decode_macroblock(s, &bc, &cb_index, superblock_index);\n                mask = bitstream_read(&bc, 16);\n                multi_mask |= mask;\n                for (i = 0; i < 16; i++) {\n                    if (mask & mask_matrix[i]) {\n                        insert_mb_into_sb(&sb, mb, i);\n                    }\n                }\n            }\n            if (can_safely_read(&bc, 1) && !bitstream_read_bit(&bc)) {\n                unsigned inv_mask = bitstream_read(&bc, 4);\n                for (i = 0; i < 4; i++) {\n                    if (inv_mask & (1 << i)) {\n                        multi_mask ^= 0xF << i*4;\n                    } else {\n                        multi_mask ^= bitstream_read(&bc, 4) << i * 4;\n                    }\n                }\n                for (i = 0; i < 16; i++) {\n                    if (multi_mask & mask_matrix[i]) {\n                        if (!can_safely_read(&bc, 1))\n                            break;\n                        mb = decode_macroblock(s, &bc, &cb_index,\n                                               superblock_index);\n                        insert_mb_into_sb(&sb, mb, i);\n                    }\n                }\n            } else if (frame_flags & (1 << 16)) {\n                while (can_safely_read(&bc, 1) && !bitstream_read_bit(&bc)) {\n                    mb = decode_macroblock(s, &bc, &cb_index, superblock_index);\n                    insert_mb_into_sb(&sb, mb, bitstream_read(&bc, 4));\n                }\n            }\n            copy_superblock(new_frame_data, new_stride, sb.pixels, 8);\n        }\n        superblock_col_index++;\n        new_frame_data += 8;\n        if (old_frame_data)\n            old_frame_data += 8;\n        if (superblock_col_index == superblocks_per_row) {\n            new_frame_data += new_stride * 8 - superblocks_per_row * 8;\n            if (old_frame_data)\n                old_frame_data += old_stride * 8 - superblocks_per_row * 8;\n            superblock_col_index = 0;\n        }\n        skip--;\n    }\n    av_log(NULL, AV_LOG_DEBUG,\n           "Escape sizes: %i, %i, %i\\n",\n           frame_size, buf_size, bitstream_tell(&bc) / 8);\n    av_frame_unref(s->frame);\n    if ((ret = av_frame_ref(s->frame, frame)) < 0)\n        return ret;\n    *got_frame = 1;\n    return frame_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}']