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

libavcodec/cavsdec.c:941:5: Call
939.     av_frame_unref(h->cur.f);
940. 
941.     bitstream_skip(&h->bc, 16); // bbv_dwlay
         ^
942.     if (h->stc == PIC_PB_START_CODE) {
943.         h->cur.f->pict_type = bitstream_read(&h->bc, 2) + AV_PICTURE_TYPE_I;

libavcodec/bitstream.h:241:1: Parameter `n`
  239. 
  240. /* Skip n bits in the buffer. */
  241. static inline void bitstream_skip(BitstreamContext *bc, unsigned n)
       ^
  242. {
  243.     if (n <= bc->bits_left)

libavcodec/bitstream.h:244:9: Call
  242. {
  243.     if (n <= bc->bits_left)
  244.         skip_remaining(bc, n);
               ^
  245.     else {
  246.         n -= bc->bits_left;

libavcodec/bitstream.h:230:1: Parameter `n`
    228. }
    229. 
    230. static inline void skip_remaining(BitstreamContext *bc, unsigned n)
         ^
    231. {
    232. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:237:5: Assignment
    235.     bc->bits <<= n;
    236. #endif
    237.     bc->bits_left -= n;
             ^
    238. }
    239. 

libavcodec/cavsdec.c:954:13: Call
952.     } else {
953.         h->cur.f->pict_type = AV_PICTURE_TYPE_I;
954.         if (bitstream_read_bit(&h->bc))
                 ^
955.             bitstream_skip(&h->bc, 24); // time_code
956.         /* old sample clips were all progressive and no low_delay,

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 `bitstream_read_bit` 
    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 decode_pic(AVSContext *h)\n{\n    int ret;\n    int skip_count    = -1;\n    enum cavs_mb mb_type;\n    if (!h->top_qp) {\n        av_log(h->avctx, AV_LOG_ERROR, "No sequence header decoded yet\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    av_frame_unref(h->cur.f);\n    bitstream_skip(&h->bc, 16);\n    if (h->stc == PIC_PB_START_CODE) {\n        h->cur.f->pict_type = bitstream_read(&h->bc, 2) + AV_PICTURE_TYPE_I;\n        if (h->cur.f->pict_type > AV_PICTURE_TYPE_B) {\n            av_log(h->avctx, AV_LOG_ERROR, "illegal picture type\\n");\n            return AVERROR_INVALIDDATA;\n        }\n        if (!h->DPB[0].f->data[0] ||\n           (!h->DPB[1].f->data[0] && h->cur.f->pict_type == AV_PICTURE_TYPE_B))\n            return AVERROR_INVALIDDATA;\n    } else {\n        h->cur.f->pict_type = AV_PICTURE_TYPE_I;\n        if (bitstream_read_bit(&h->bc))\n            bitstream_skip(&h->bc, 24);\n        if (h->low_delay || !(bitstream_peek(&h->bc, 9) & 1))\n            h->stream_revision = 1;\n        else if (bitstream_peek(&h->bc, 11) & 3)\n            h->stream_revision = 1;\n        if (h->stream_revision > 0)\n            bitstream_skip(&h->bc, 1);\n    }\n    ret = ff_get_buffer(h->avctx, h->cur.f, h->cur.f->pict_type == AV_PICTURE_TYPE_B ?\n                        0 : AV_GET_BUFFER_FLAG_REF);\n    if (ret < 0)\n        return ret;\n    if (!h->edge_emu_buffer) {\n        int alloc_size = FFALIGN(FFABS(h->cur.f->linesize[0]) + 32, 32);\n        h->edge_emu_buffer = av_mallocz(alloc_size * 2 * 24);\n        if (!h->edge_emu_buffer)\n            return AVERROR(ENOMEM);\n    }\n    ff_cavs_init_pic(h);\n    h->cur.poc = bitstream_read(&h->bc, 8) * 2;\n    if (h->cur.f->pict_type != AV_PICTURE_TYPE_B) {\n        h->dist[0] = (h->cur.poc - h->DPB[0].poc  + 512) % 512;\n    } else {\n        h->dist[0] = (h->DPB[0].poc  - h->cur.poc + 512) % 512;\n    }\n    h->dist[1] = (h->cur.poc - h->DPB[1].poc  + 512) % 512;\n    h->scale_den[0] = h->dist[0] ? 512/h->dist[0] : 0;\n    h->scale_den[1] = h->dist[1] ? 512/h->dist[1] : 0;\n    if (h->cur.f->pict_type == AV_PICTURE_TYPE_B) {\n        h->sym_factor = h->dist[0] * h->scale_den[1];\n    } else {\n        h->direct_den[0] = h->dist[0] ? 16384 / h->dist[0] : 0;\n        h->direct_den[1] = h->dist[1] ? 16384 / h->dist[1] : 0;\n    }\n    if (h->low_delay)\n        get_ue_golomb(&h->bc);\n    h->progressive   = bitstream_read_bit(&h->bc);\n    h->pic_structure = 1;\n    if (!h->progressive)\n        h->pic_structure = bitstream_read_bit(&h->bc);\n    if (!h->pic_structure && h->stc == PIC_PB_START_CODE)\n        bitstream_skip(&h->bc, 1);\n    bitstream_skip(&h->bc, 1);\n    bitstream_skip(&h->bc, 1);\n    h->qp_fixed = bitstream_read_bit(&h->bc);\n    h->qp       = bitstream_read(&h->bc, 6);\n    if (h->cur.f->pict_type == AV_PICTURE_TYPE_I) {\n        if (!h->progressive && !h->pic_structure)\n            bitstream_skip(&h->bc, 1);\n        bitstream_skip(&h->bc, 4);\n    } else {\n        if (!(h->cur.f->pict_type == AV_PICTURE_TYPE_B && h->pic_structure == 1))\n            h->ref_flag        = bitstream_read_bit(&h->bc);\n        bitstream_skip(&h->bc, 4);\n        h->skip_mode_flag      = bitstream_read_bit(&h->bc);\n    }\n    h->loop_filter_disable     = bitstream_read_bit(&h->bc);\n    if (!h->loop_filter_disable && bitstream_read_bit(&h->bc)) {\n        h->alpha_offset        = get_se_golomb(&h->bc);\n        h->beta_offset         = get_se_golomb(&h->bc);\n    } else {\n        h->alpha_offset = h->beta_offset  = 0;\n    }\n    if (h->cur.f->pict_type == AV_PICTURE_TYPE_I) {\n        do {\n            check_for_slice(h);\n            decode_mb_i(h, 0);\n        } while (ff_cavs_next_mb(h));\n    } else if (h->cur.f->pict_type == AV_PICTURE_TYPE_P) {\n        do {\n            if (check_for_slice(h))\n                skip_count = -1;\n            if (h->skip_mode_flag && (skip_count < 0))\n                skip_count = get_ue_golomb(&h->bc);\n            if (h->skip_mode_flag && skip_count--) {\n                decode_mb_p(h, P_SKIP);\n            } else {\n                mb_type = get_ue_golomb(&h->bc) + P_SKIP + h->skip_mode_flag;\n                if (mb_type > P_8X8)\n                    decode_mb_i(h, mb_type - P_8X8 - 1);\n                else\n                    decode_mb_p(h, mb_type);\n            }\n        } while (ff_cavs_next_mb(h));\n    } else {\n        do {\n            if (check_for_slice(h))\n                skip_count = -1;\n            if (h->skip_mode_flag && (skip_count < 0))\n                skip_count = get_ue_golomb(&h->bc);\n            if (h->skip_mode_flag && skip_count--) {\n                decode_mb_b(h, B_SKIP);\n            } else {\n                mb_type = get_ue_golomb(&h->bc) + B_SKIP + h->skip_mode_flag;\n                if (mb_type > B_8X8)\n                    decode_mb_i(h, mb_type - B_8X8 - 1);\n                else\n                    decode_mb_b(h, mb_type);\n            }\n        } while (ff_cavs_next_mb(h));\n    }\n    if (h->cur.f->pict_type != AV_PICTURE_TYPE_B) {\n        av_frame_unref(h->DPB[1].f);\n        FFSWAP(AVSFrame, h->cur, h->DPB[1]);\n        FFSWAP(AVSFrame, h->DPB[0], h->DPB[1]);\n    }\n    return 0;\n}', 'static inline void bitstream_skip(BitstreamContext *bc, unsigned n)\n{\n    if (n <= bc->bits_left)\n        skip_remaining(bc, n);\n    else {\n        n -= bc->bits_left;\n        skip_remaining(bc, bc->bits_left);\n        if (n >= 64) {\n            unsigned skip = n / 8;\n            n -= skip * 8;\n            bc->ptr += skip;\n        }\n        refill_64(bc);\n        if (n)\n            skip_remaining(bc, n);\n    }\n}', 'static inline void skip_remaining(BitstreamContext *bc, unsigned n)\n{\n#ifdef BITSTREAM_READER_LE\n    bc->bits >>= n;\n#else\n    bc->bits <<= n;\n#endif\n    bc->bits_left -= n;\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}']