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

libavcodec/svq3.c:1514:23: Call
1512.             }
1513. 
1514.             mb_type = get_interleaved_ue_golomb(&s->bc_slice);
                            ^
1515. 
1516.             if (s->pict_type == AV_PICTURE_TYPE_I)

libavcodec/golomb.h:112:9: Call
  110.     if (buf & 0xAA800000) {
  111.         buf >>= 32 - 8;
  112.         bitstream_skip(bc, ff_interleaved_golomb_vlc_len[buf]);
               ^
  113. 
  114.         return ff_interleaved_ue_golomb_vlc_code[buf];

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/svq3.c:1520:33: Call
1518.             else if (s->pict_type == AV_PICTURE_TYPE_B && mb_type >= 4)
1519.                 mb_type += 4;
1520.             if (mb_type > 33 || svq3_decode_mb(s, mb_type)) {
                                      ^
1521.                 av_log(s->avctx, AV_LOG_ERROR,
1522.                        "error while decoding MB %d %d\n", s->mb_x, s->mb_y);

libavcodec/svq3.c:714:1: Parameter `s->bc_slice.bits_left`
  712. }
  713. 
  714. static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
       ^
  715. {
  716.     int i, j, k, m, dir, mode;

libavcodec/svq3.c:748:53: Call
  746.         }
  747.     } else if (mb_type < 8) {     /* INTER */
  748.         if (s->thirdpel_flag && s->halfpel_flag == !bitstream_read_bit(&s->bc_slice))
                                                           ^
  749.             mode = THIRDPEL_MODE;
  750.         else if (s->halfpel_flag &&

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 `svq3_decode_mb` 
      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 svq3_decode_frame(AVCodecContext *avctx, void *data,\n                             int *got_frame, AVPacket *avpkt)\n{\n    const uint8_t *buf = avpkt->data;\n    SVQ3Context *s     = avctx->priv_data;\n    int buf_size       = avpkt->size;\n    int ret, m, i;\n    if (buf_size == 0) {\n        if (s->next_pic->f->data[0] && !s->low_delay && !s->last_frame_output) {\n            ret = av_frame_ref(data, s->next_pic->f);\n            if (ret < 0)\n                return ret;\n            s->last_frame_output = 1;\n            *got_frame          = 1;\n        }\n        return 0;\n    }\n    ret = bitstream_init8(&s->bc, buf, buf_size);\n    if (ret < 0)\n        return ret;\n    s->mb_x = s->mb_y = s->mb_xy = 0;\n    if (svq3_decode_slice_header(avctx))\n        return -1;\n    if (s->pict_type != AV_PICTURE_TYPE_B)\n        FFSWAP(SVQ3Frame*, s->next_pic, s->last_pic);\n    av_frame_unref(s->cur_pic->f);\n    s->cur_pic->f->pict_type = s->pict_type;\n    s->cur_pic->f->key_frame = (s->pict_type == AV_PICTURE_TYPE_I);\n    ret = get_buffer(avctx, s->cur_pic);\n    if (ret < 0)\n        return ret;\n    for (i = 0; i < 16; i++) {\n        s->block_offset[i]           = (4 * ((scan8[i] - scan8[0]) & 7)) + 4 * s->cur_pic->f->linesize[0] * ((scan8[i] - scan8[0]) >> 3);\n        s->block_offset[48 + i]      = (4 * ((scan8[i] - scan8[0]) & 7)) + 8 * s->cur_pic->f->linesize[0] * ((scan8[i] - scan8[0]) >> 3);\n    }\n    for (i = 0; i < 16; i++) {\n        s->block_offset[16 + i]      =\n        s->block_offset[32 + i]      = (4 * ((scan8[i] - scan8[0]) & 7)) + 4 * s->cur_pic->f->linesize[1] * ((scan8[i] - scan8[0]) >> 3);\n        s->block_offset[48 + 16 + i] =\n        s->block_offset[48 + 32 + i] = (4 * ((scan8[i] - scan8[0]) & 7)) + 8 * s->cur_pic->f->linesize[1] * ((scan8[i] - scan8[0]) >> 3);\n    }\n    if (s->pict_type != AV_PICTURE_TYPE_I) {\n        if (!s->last_pic->f->data[0]) {\n            av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\\n");\n            ret = get_buffer(avctx, s->last_pic);\n            if (ret < 0)\n                return ret;\n            memset(s->last_pic->f->data[0], 0, avctx->height * s->last_pic->f->linesize[0]);\n            memset(s->last_pic->f->data[1], 0x80, (avctx->height / 2) *\n                   s->last_pic->f->linesize[1]);\n            memset(s->last_pic->f->data[2], 0x80, (avctx->height / 2) *\n                   s->last_pic->f->linesize[2]);\n        }\n        if (s->pict_type == AV_PICTURE_TYPE_B && !s->next_pic->f->data[0]) {\n            av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\\n");\n            ret = get_buffer(avctx, s->next_pic);\n            if (ret < 0)\n                return ret;\n            memset(s->next_pic->f->data[0], 0, avctx->height * s->next_pic->f->linesize[0]);\n            memset(s->next_pic->f->data[1], 0x80, (avctx->height / 2) *\n                   s->next_pic->f->linesize[1]);\n            memset(s->next_pic->f->data[2], 0x80, (avctx->height / 2) *\n                   s->next_pic->f->linesize[2]);\n        }\n    }\n    if (avctx->debug & FF_DEBUG_PICT_INFO)\n        av_log(s->avctx, AV_LOG_DEBUG,\n               "%c hpel:%d, tpel:%d aqp:%d qp:%d, slice_num:%02X\\n",\n               av_get_picture_type_char(s->pict_type),\n               s->halfpel_flag, s->thirdpel_flag,\n               s->adaptive_quant, s->qscale, s->slice_num);\n    if (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B ||\n        avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I ||\n        avctx->skip_frame >= AVDISCARD_ALL)\n        return 0;\n    if (s->next_p_frame_damaged) {\n        if (s->pict_type == AV_PICTURE_TYPE_B)\n            return 0;\n        else\n            s->next_p_frame_damaged = 0;\n    }\n    if (s->pict_type == AV_PICTURE_TYPE_B) {\n        s->frame_num_offset = s->slice_num - s->prev_frame_num;\n        if (s->frame_num_offset < 0)\n            s->frame_num_offset += 256;\n        if (s->frame_num_offset == 0 ||\n            s->frame_num_offset >= s->prev_frame_num_offset) {\n            av_log(s->avctx, AV_LOG_ERROR, "error in B-frame picture id\\n");\n            return -1;\n        }\n    } else {\n        s->prev_frame_num        = s->frame_num;\n        s->frame_num             = s->slice_num;\n        s->prev_frame_num_offset = s->frame_num - s->prev_frame_num;\n        if (s->prev_frame_num_offset < 0)\n            s->prev_frame_num_offset += 256;\n    }\n    for (m = 0; m < 2; m++) {\n        int i;\n        for (i = 0; i < 4; i++) {\n            int j;\n            for (j = -1; j < 4; j++)\n                s->ref_cache[m][scan8[0] + 8 * i + j] = 1;\n            if (i < 3)\n                s->ref_cache[m][scan8[0] + 8 * i + j] = PART_NOT_AVAILABLE;\n        }\n    }\n    for (s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) {\n        for (s->mb_x = 0; s->mb_x < s->mb_width; s->mb_x++) {\n            unsigned mb_type;\n            s->mb_xy = s->mb_x + s->mb_y * s->mb_stride;\n            if ((bitstream_bits_left(&s->bc_slice)) <= 7) {\n                if (((bitstream_tell(&s->bc_slice) & 7) == 0 ||\n                    bitstream_peek(&s->bc_slice, bitstream_bits_left(&s->bc_slice) & 7) == 0)) {\n                    if (svq3_decode_slice_header(avctx))\n                        return -1;\n                }\n            }\n            mb_type = get_interleaved_ue_golomb(&s->bc_slice);\n            if (s->pict_type == AV_PICTURE_TYPE_I)\n                mb_type += 8;\n            else if (s->pict_type == AV_PICTURE_TYPE_B && mb_type >= 4)\n                mb_type += 4;\n            if (mb_type > 33 || svq3_decode_mb(s, mb_type)) {\n                av_log(s->avctx, AV_LOG_ERROR,\n                       "error while decoding MB %d %d\\n", s->mb_x, s->mb_y);\n                return -1;\n            }\n            if (mb_type != 0)\n                hl_decode_mb(s);\n            if (s->pict_type != AV_PICTURE_TYPE_B && !s->low_delay)\n                s->cur_pic->mb_type[s->mb_x + s->mb_y * s->mb_stride] =\n                    (s->pict_type == AV_PICTURE_TYPE_P && mb_type < 8) ? (mb_type - 1) : -1;\n        }\n        ff_draw_horiz_band(avctx, s->cur_pic->f,\n                           s->last_pic->f->data[0] ? s->last_pic->f : NULL,\n                           16 * s->mb_y, 16, PICT_FRAME, 0,\n                           s->low_delay);\n    }\n    if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay)\n        ret = av_frame_ref(data, s->cur_pic->f);\n    else if (s->last_pic->f->data[0])\n        ret = av_frame_ref(data, s->last_pic->f);\n    if (ret < 0)\n        return ret;\n    if (s->last_pic->f->data[0] || s->low_delay)\n        *got_frame = 1;\n    if (s->pict_type != AV_PICTURE_TYPE_B) {\n        FFSWAP(SVQ3Frame*, s->cur_pic, s->next_pic);\n    } else {\n        av_frame_unref(s->cur_pic->f);\n    }\n    return buf_size;\n}', 'static inline unsigned get_interleaved_ue_golomb(BitstreamContext *bc)\n{\n    uint32_t buf;\n    buf = bitstream_peek(bc, 32);\n    if (buf & 0xAA800000) {\n        buf >>= 32 - 8;\n        bitstream_skip(bc, ff_interleaved_golomb_vlc_len[buf]);\n        return ff_interleaved_ue_golomb_vlc_code[buf];\n    } else {\n        unsigned ret = 1;\n        do {\n            buf >>= 32 - 8;\n            bitstream_skip(bc, FFMIN(ff_interleaved_golomb_vlc_len[buf], 8));\n            if (ff_interleaved_golomb_vlc_len[buf] != 9) {\n                ret <<= (ff_interleaved_golomb_vlc_len[buf] - 1) >> 1;\n                ret  |= ff_interleaved_dirac_golomb_vlc_code[buf];\n                break;\n            }\n            ret = (ret << 4) | ff_interleaved_dirac_golomb_vlc_code[buf];\n            buf = bitstream_peek(bc, 32);\n        } while (bitstream_bits_left(bc) > 0);\n        return ret - 1;\n    }\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 int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)\n{\n    int i, j, k, m, dir, mode;\n    int cbp = 0;\n    uint32_t vlc;\n    int8_t *top, *left;\n    const int mb_xy = s->mb_xy;\n    const int b_xy  = 4 * s->mb_x + 4 * s->mb_y * s->b_stride;\n    s->top_samples_available      = (s->mb_y == 0) ? 0x33FF : 0xFFFF;\n    s->left_samples_available     = (s->mb_x == 0) ? 0x5F5F : 0xFFFF;\n    s->topright_samples_available = 0xFFFF;\n    if (mb_type == 0) {\n        if (s->pict_type == AV_PICTURE_TYPE_P ||\n            s->next_pic->mb_type[mb_xy] == -1) {\n            svq3_mc_dir_part(s, 16 * s->mb_x, 16 * s->mb_y, 16, 16,\n                             0, 0, 0, 0, 0, 0);\n            if (s->pict_type == AV_PICTURE_TYPE_B)\n                svq3_mc_dir_part(s, 16 * s->mb_x, 16 * s->mb_y, 16, 16,\n                                 0, 0, 0, 0, 1, 1);\n            mb_type = MB_TYPE_SKIP;\n        } else {\n            mb_type = FFMIN(s->next_pic->mb_type[mb_xy], 6);\n            if (svq3_mc_dir(s, mb_type, PREDICT_MODE, 0, 0) < 0)\n                return -1;\n            if (svq3_mc_dir(s, mb_type, PREDICT_MODE, 1, 1) < 0)\n                return -1;\n            mb_type = MB_TYPE_16x16;\n        }\n    } else if (mb_type < 8) {\n        if (s->thirdpel_flag && s->halfpel_flag == !bitstream_read_bit(&s->bc_slice))\n            mode = THIRDPEL_MODE;\n        else if (s->halfpel_flag &&\n                 s->thirdpel_flag == !bitstream_read_bit(&s->bc_slice))\n            mode = HALFPEL_MODE;\n        else\n            mode = FULLPEL_MODE;\n        for (m = 0; m < 2; m++) {\n            if (s->mb_x > 0 && s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - 1] + 6] != -1) {\n                for (i = 0; i < 4; i++)\n                    AV_COPY32(s->mv_cache[m][scan8[0] - 1 + i * 8],\n                              s->cur_pic->motion_val[m][b_xy - 1 + i * s->b_stride]);\n            } else {\n                for (i = 0; i < 4; i++)\n                    AV_ZERO32(s->mv_cache[m][scan8[0] - 1 + i * 8]);\n            }\n            if (s->mb_y > 0) {\n                memcpy(s->mv_cache[m][scan8[0] - 1 * 8],\n                       s->cur_pic->motion_val[m][b_xy - s->b_stride],\n                       4 * 2 * sizeof(int16_t));\n                memset(&s->ref_cache[m][scan8[0] - 1 * 8],\n                       (s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - s->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1, 4);\n                if (s->mb_x < s->mb_width - 1) {\n                    AV_COPY32(s->mv_cache[m][scan8[0] + 4 - 1 * 8],\n                              s->cur_pic->motion_val[m][b_xy - s->b_stride + 4]);\n                    s->ref_cache[m][scan8[0] + 4 - 1 * 8] =\n                        (s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - s->mb_stride + 1] + 6] == -1 ||\n                         s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - s->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1;\n                } else\n                    s->ref_cache[m][scan8[0] + 4 - 1 * 8] = PART_NOT_AVAILABLE;\n                if (s->mb_x > 0) {\n                    AV_COPY32(s->mv_cache[m][scan8[0] - 1 - 1 * 8],\n                              s->cur_pic->motion_val[m][b_xy - s->b_stride - 1]);\n                    s->ref_cache[m][scan8[0] - 1 - 1 * 8] =\n                        (s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - s->mb_stride - 1] + 3] == -1) ? PART_NOT_AVAILABLE : 1;\n                } else\n                    s->ref_cache[m][scan8[0] - 1 - 1 * 8] = PART_NOT_AVAILABLE;\n            } else\n                memset(&s->ref_cache[m][scan8[0] - 1 * 8 - 1],\n                       PART_NOT_AVAILABLE, 8);\n            if (s->pict_type != AV_PICTURE_TYPE_B)\n                break;\n        }\n        if (s->pict_type == AV_PICTURE_TYPE_P) {\n            if (svq3_mc_dir(s, mb_type - 1, mode, 0, 0) < 0)\n                return -1;\n        } else {\n            if (mb_type != 2) {\n                if (svq3_mc_dir(s, 0, mode, 0, 0) < 0)\n                    return -1;\n            } else {\n                for (i = 0; i < 4; i++)\n                    memset(s->cur_pic->motion_val[0][b_xy + i * s->b_stride],\n                           0, 4 * 2 * sizeof(int16_t));\n            }\n            if (mb_type != 1) {\n                if (svq3_mc_dir(s, 0, mode, 1, mb_type == 3) < 0)\n                    return -1;\n            } else {\n                for (i = 0; i < 4; i++)\n                    memset(s->cur_pic->motion_val[1][b_xy + i * s->b_stride],\n                           0, 4 * 2 * sizeof(int16_t));\n            }\n        }\n        mb_type = MB_TYPE_16x16;\n    } else if (mb_type == 8 || mb_type == 33) {\n        int8_t *i4x4       = s->intra4x4_pred_mode + s->mb2br_xy[s->mb_xy];\n        int8_t *i4x4_cache = s->intra4x4_pred_mode_cache;\n        memset(s->intra4x4_pred_mode_cache, -1, 8 * 5 * sizeof(int8_t));\n        if (mb_type == 8) {\n            if (s->mb_x > 0) {\n                for (i = 0; i < 4; i++)\n                    s->intra4x4_pred_mode_cache[scan8[0] - 1 + i * 8] = s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - 1] + 6 - i];\n                if (s->intra4x4_pred_mode_cache[scan8[0] - 1] == -1)\n                    s->left_samples_available = 0x5F5F;\n            }\n            if (s->mb_y > 0) {\n                s->intra4x4_pred_mode_cache[4 + 8 * 0] = s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - s->mb_stride] + 0];\n                s->intra4x4_pred_mode_cache[5 + 8 * 0] = s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - s->mb_stride] + 1];\n                s->intra4x4_pred_mode_cache[6 + 8 * 0] = s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - s->mb_stride] + 2];\n                s->intra4x4_pred_mode_cache[7 + 8 * 0] = s->intra4x4_pred_mode[s->mb2br_xy[mb_xy - s->mb_stride] + 3];\n                if (s->intra4x4_pred_mode_cache[4 + 8 * 0] == -1)\n                    s->top_samples_available = 0x33FF;\n            }\n            for (i = 0; i < 16; i += 2) {\n                vlc = get_interleaved_ue_golomb(&s->bc_slice);\n                if (vlc >= 25) {\n                    av_log(s->avctx, AV_LOG_ERROR,\n                           "luma prediction:%"PRIu32"\\n", vlc);\n                    return -1;\n                }\n                left = &s->intra4x4_pred_mode_cache[scan8[i] - 1];\n                top  = &s->intra4x4_pred_mode_cache[scan8[i] - 8];\n                left[1] = svq3_pred_1[top[0] + 1][left[0] + 1][svq3_pred_0[vlc][0]];\n                left[2] = svq3_pred_1[top[1] + 1][left[1] + 1][svq3_pred_0[vlc][1]];\n                if (left[1] == -1 || left[2] == -1) {\n                    av_log(s->avctx, AV_LOG_ERROR, "weird prediction\\n");\n                    return -1;\n                }\n            }\n        } else {\n            for (i = 0; i < 4; i++)\n                memset(&s->intra4x4_pred_mode_cache[scan8[0] + 8 * i], DC_PRED, 4);\n        }\n        AV_COPY32(i4x4, i4x4_cache + 4 + 8 * 4);\n        i4x4[4] = i4x4_cache[7 + 8 * 3];\n        i4x4[5] = i4x4_cache[7 + 8 * 2];\n        i4x4[6] = i4x4_cache[7 + 8 * 1];\n        if (mb_type == 8) {\n            ff_h264_check_intra4x4_pred_mode(s->intra4x4_pred_mode_cache,\n                                             s->avctx, s->top_samples_available,\n                                             s->left_samples_available);\n            s->top_samples_available  = (s->mb_y == 0) ? 0x33FF : 0xFFFF;\n            s->left_samples_available = (s->mb_x == 0) ? 0x5F5F : 0xFFFF;\n        } else {\n            for (i = 0; i < 4; i++)\n                memset(&s->intra4x4_pred_mode_cache[scan8[0] + 8 * i], DC_128_PRED, 4);\n            s->top_samples_available  = 0x33FF;\n            s->left_samples_available = 0x5F5F;\n        }\n        mb_type = MB_TYPE_INTRA4x4;\n    } else {\n        dir = ff_h264_i_mb_type_info[mb_type - 8].pred_mode;\n        dir = (dir >> 1) ^ 3 * (dir & 1) ^ 1;\n        if ((s->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(s->avctx, s->top_samples_available,\n                                                                     s->left_samples_available, dir, 0)) < 0) {\n            av_log(s->avctx, AV_LOG_ERROR, "ff_h264_check_intra_pred_mode < 0\\n");\n            return s->intra16x16_pred_mode;\n        }\n        cbp     = ff_h264_i_mb_type_info[mb_type - 8].cbp;\n        mb_type = MB_TYPE_INTRA16x16;\n    }\n    if (!IS_INTER(mb_type) && s->pict_type != AV_PICTURE_TYPE_I) {\n        for (i = 0; i < 4; i++)\n            memset(s->cur_pic->motion_val[0][b_xy + i * s->b_stride],\n                   0, 4 * 2 * sizeof(int16_t));\n        if (s->pict_type == AV_PICTURE_TYPE_B) {\n            for (i = 0; i < 4; i++)\n                memset(s->cur_pic->motion_val[1][b_xy + i * s->b_stride],\n                       0, 4 * 2 * sizeof(int16_t));\n        }\n    }\n    if (!IS_INTRA4x4(mb_type)) {\n        memset(s->intra4x4_pred_mode + s->mb2br_xy[mb_xy], DC_PRED, 8);\n    }\n    if (!IS_SKIP(mb_type) || s->pict_type == AV_PICTURE_TYPE_B) {\n        memset(s->non_zero_count_cache + 8, 0, 14 * 8 * sizeof(uint8_t));\n    }\n    if (!IS_INTRA16x16(mb_type) &&\n        (!IS_SKIP(mb_type) || s->pict_type == AV_PICTURE_TYPE_B)) {\n        if ((vlc = get_interleaved_ue_golomb(&s->bc_slice)) >= 48) {\n            av_log(s->avctx, AV_LOG_ERROR, "cbp_vlc=%"PRIu32"\\n", vlc);\n            return -1;\n        }\n        cbp = IS_INTRA(mb_type) ? ff_h264_golomb_to_intra4x4_cbp[vlc]\n                                : ff_h264_golomb_to_inter_cbp[vlc];\n    }\n    if (IS_INTRA16x16(mb_type) ||\n        (s->pict_type != AV_PICTURE_TYPE_I && s->adaptive_quant && cbp)) {\n        s->qscale += get_interleaved_se_golomb(&s->bc_slice);\n        if (s->qscale > 31u) {\n            av_log(s->avctx, AV_LOG_ERROR, "qscale:%d\\n", s->qscale);\n            return -1;\n        }\n    }\n    if (IS_INTRA16x16(mb_type)) {\n        AV_ZERO128(s->mb_luma_dc[0] + 0);\n        AV_ZERO128(s->mb_luma_dc[0] + 8);\n        if (svq3_decode_block(&s->bc_slice, s->mb_luma_dc[0], 0, 1)) {\n            av_log(s->avctx, AV_LOG_ERROR,\n                   "error while decoding intra luma dc\\n");\n            return -1;\n        }\n    }\n    if (cbp) {\n        const int index = IS_INTRA16x16(mb_type) ? 1 : 0;\n        const int type  = ((s->qscale < 24 && IS_INTRA4x4(mb_type)) ? 2 : 1);\n        for (i = 0; i < 4; i++)\n            if ((cbp & (1 << i))) {\n                for (j = 0; j < 4; j++) {\n                    k = index ? (1 * (j & 1) + 2 * (i & 1) +\n                                 2 * (j & 2) + 4 * (i & 2))\n                              : (4 * i + j);\n                    s->non_zero_count_cache[scan8[k]] = 1;\n                    if (svq3_decode_block(&s->bc_slice, &s->mb[16 * k], index, type)) {\n                        av_log(s->avctx, AV_LOG_ERROR,\n                               "error while decoding block\\n");\n                        return -1;\n                    }\n                }\n            }\n        if ((cbp & 0x30)) {\n            for (i = 1; i < 3; ++i)\n                if (svq3_decode_block(&s->bc_slice, &s->mb[16 * 16 * i], 0, 3)) {\n                    av_log(s->avctx, AV_LOG_ERROR,\n                           "error while decoding chroma dc block\\n");\n                    return -1;\n                }\n            if ((cbp & 0x20)) {\n                for (i = 1; i < 3; i++) {\n                    for (j = 0; j < 4; j++) {\n                        k                                 = 16 * i + j;\n                        s->non_zero_count_cache[scan8[k]] = 1;\n                        if (svq3_decode_block(&s->bc_slice, &s->mb[16 * k], 1, 1)) {\n                            av_log(s->avctx, AV_LOG_ERROR,\n                                   "error while decoding chroma ac block\\n");\n                            return -1;\n                        }\n                    }\n                }\n            }\n        }\n    }\n    s->cbp                     = cbp;\n    s->cur_pic->mb_type[mb_xy] = mb_type;\n    if (IS_INTRA(mb_type))\n        s->chroma_pred_mode = ff_h264_check_intra_pred_mode(s->avctx, s->top_samples_available,\n                                                            s->left_samples_available, DC_PRED8x8, 1);\n    return 0;\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}']