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

libavcodec/escape130.c:219:5: Call
217.         return ret;
218. 
219.     bitstream_init8(&bc, buf + 16, buf_size - 16);
         ^
220. 
221.     new_y  = s->new_y;

libavcodec/bitstream.h:104:1: Parameter `bc->bits_left`
  102. 
  103. /* Initialize BitstreamContext with buffer size in bytes instead of bits. */
  104. static inline int bitstream_init8(BitstreamContext *bc, const uint8_t *buffer,
       ^
  105.                                   unsigned byte_size)
  106. {

libavcodec/escape130.c:238:20: Call
236.         // if the frame ends prematurely.
237.         if (skip == -1)
238.             skip = decode_skip_count(&bc);
                        ^
239.         if (skip == -1) {
240.             av_log(avctx, AV_LOG_ERROR, "Error decoding skip value\n");

libavcodec/escape130.c:166:1: Parameter `bc->bits_left`
  164. }
  165. 
  166. static int decode_skip_count(BitstreamContext *bc)
       ^
  167. {
  168.     int value;

libavcodec/escape130.c:170:13: Call
  168.     int value;
  169. 
  170.     value = bitstream_read_bit(bc);
                   ^
  171.     if (value)
  172.         return 0;

libavcodec/bitstream.h:145:1: Parameter `bc->bits_left`
    143. 
    144. /* Return one bit from the buffer. */
    145. static inline unsigned bitstream_read_bit(BitstreamContext *bc)
         ^
    146. {
    147.     if (!bc->bits_left)

libavcodec/bitstream.h:150:12: Call
    148.         refill_64(bc);
    149. 
    150.     return get_val(bc, 1);
                    ^
    151. }
    152. 

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: ([0, +oo] - 1):unsigned32 by call to `decode_skip_count` 
      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_init8(&bc, buf + 16, buf_size - 16);\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 int bitstream_init8(BitstreamContext *bc, const uint8_t *buffer,\n                                  unsigned byte_size)\n{\n    if (byte_size > INT_MAX / 8)\n        return AVERROR_INVALIDDATA;\n    return bitstream_init(bc, buffer, byte_size * 8);\n}', 'static int decode_skip_count(BitstreamContext *bc)\n{\n    int value;\n    value = bitstream_read_bit(bc);\n    if (value)\n        return 0;\n    value = bitstream_read(bc, 3);\n    if (value)\n        return value;\n    value = bitstream_read(bc, 8);\n    if (value)\n        return value + 7;\n    value = bitstream_read(bc, 15);\n    if (value)\n        return value + 262;\n    return -1;\n}', 'static inline unsigned bitstream_read_bit(BitstreamContext *bc)\n{\n    if (!bc->bits_left)\n        refill_64(bc);\n    return get_val(bc, 1);\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}']