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

libavcodec/svq3.c:1285:33: Call
1283.             else if (h->pict_type == AV_PICTURE_TYPE_B && mb_type >= 4)
1284.                 mb_type += 4;
1285.             if (mb_type > 33 || svq3_decode_mb(s, mb_type)) {
                                      ^
1286.                 av_log(h->avctx, AV_LOG_ERROR,
1287.                        "error while decoding MB %d %d\n", sl->mb_x, sl->mb_y);

libavcodec/svq3.c:511:17: Call
  509.         } else {
  510.             mb_type = FFMIN(s->next_pic->mb_type[mb_xy], 6);
  511.             if (svq3_mc_dir(s, mb_type, PREDICT_MODE, 0, 0) < 0)
                       ^
  512.                 return -1;
  513.             if (svq3_mc_dir(s, mb_type, PREDICT_MODE, 1, 1) < 0)

libavcodec/svq3.c:391:17: Call
    389. 
    390.             if (mode != PREDICT_MODE) {
    391.                 pred_motion(h, sl, k, part_width >> 2, dir, 1, &mx, &my);
                         ^
    392.             } else {
    393.                 mx = s->next_pic->motion_val[0][b_xy][0] << 1;

libavcodec/h264_mvpred.h:95:1: Parameter `sl->mb_field_decoding_flag`
      93.  * @param my the y component of the predicted motion vector
      94.  */
      95. static av_always_inline void pred_motion(const H264Context *const h,
          ^
      96.                                          H264SliceContext *sl,
      97.                                          int n,

libavcodec/h264_mvpred.h:119:20: Call
      117.  */
      118. 
      119.     diagonal_ref = fetch_diagonal_mv(h, sl, &C, index8, list, part_width);
                              ^
      120.     match_count  = (diagonal_ref == ref) + (top_ref == ref) + (left_ref == ref);
      121.     ff_tlog(h->avctx, "pred_motion match_count=%d\n", match_count);

libavcodec/h264_mvpred.h:38:1: Parameter `sl->mb_field_decoding_flag`
        36. #include <assert.h>
        37. 
        38. static av_always_inline int fetch_diagonal_mv(const H264Context *h, H264SliceContext *sl,
            ^
        39.                                               const int16_t **C,
        40.                                               int i, int list, int part_width)

libavcodec/svq3.c:1292:17: Call
1290. 
1291.             if (mb_type != 0)
1292.                 ff_h264_hl_decode_mb(h, &h->slice_ctx[0]);
                      ^
1293. 
1294.             if (h->pict_type != AV_PICTURE_TYPE_B && !h->low_delay)

libavcodec/h264_mb.c:812:1: Parameter `sl->list_count`
  810. #include "h264_mb_template.c"
  811. 
  812. void ff_h264_hl_decode_mb(const H264Context *h, H264SliceContext *sl)
       ^
  813. {
  814.     const int mb_xy   = sl->mb_xy;

libavcodec/h264_mb.c:821:13: Call
  819.     if (CHROMA444(h)) {
  820.         if (is_complex || h->pixel_shift)
  821.             hl_decode_mb_444_complex(h, sl);
                   ^
  822.         else
  823.             hl_decode_mb_444_simple_8(h, sl);

libavcodec/h264_mb_template.c:275:1: Parameter `sl->list_count`
    273. #include "h264_mc_template.c"
    274. 
    275. static av_noinline void FUNC(hl_decode_mb_444)(const H264Context *h, H264SliceContext *sl)
         ^
    276. {
    277.     const int mb_x    = sl->mb_x;

libavcodec/h264_mb_template.c:358:13: Call
    356.                                linesize, 0, 1, SIMPLE, PIXEL_SHIFT);
    357.         } else {
    358.             FUNC(hl_motion_444)(h, sl, dest[0], dest[1], dest[2],
                     ^
    359.                       h->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
    360.                       h->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,

libavcodec/h264_mc_template.c:64:1: Parameter `sl->list_count`
      62. }
      63. 
      64. static void MCFUNC(hl_motion)(const H264Context *h, H264SliceContext *sl,
          ^
      65.                               uint8_t *dest_y,
      66.                               uint8_t *dest_cb, uint8_t *dest_cr,

libavcodec/h264_mc_template.c:80:9: Call
      78. 
      79.     if (HAVE_THREADS && (h->avctx->active_thread_type & FF_THREAD_FRAME))
      80.         await_references(h, sl);
                  ^
      81.     prefetch_motion(h, sl, 0, PIXEL_SHIFT, CHROMA_IDC);
      82. 

libavcodec/h264_mb.c:96:1: <LHS trace>
94.  * @param h the H264 context
95.  */
96. static void await_references(const H264Context *h, H264SliceContext *sl)
    ^
97. {
98.     const int mb_xy   = sl->mb_xy;

libavcodec/h264_mb.c:96:1: Parameter `sl->list_count`
        94.  * @param h the H264 context
        95.  */
        96. static void await_references(const H264Context *h, H264SliceContext *sl)
            ^
        97. {
        98.     const int mb_xy   = sl->mb_xy;

libavcodec/h264_mb.c:166:10: Binary operation: ([0, +oo] - 1):unsigned32 by call to `ff_h264_hl_decode_mb` 
        164.     }
        165. 
        166.     for (list = sl->list_count - 1; list >= 0; list--)
                      ^
        167.         for (ref = 0; ref < 48 && nrefs[list]; ref++) {
        168.             int row = refs[list][ref];

static void await_references(const H264Context *h, H264SliceContext *sl)
{
    const int mb_xy   = sl->mb_xy;
    const int mb_type = h->cur_pic.mb_type[mb_xy];
    int refs[2][48];
    int nrefs[2] = { 0 };
    int ref, list;
    memset(refs, -1, sizeof(refs));
    if (IS_16X16(mb_type)) {
        get_lowest_part_y(h, sl, refs, 0, 16, 0,
                          IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs);
    } else if (IS_16X8(mb_type)) {
        get_lowest_part_y(h, sl, refs, 0, 8, 0,
                          IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs);
        get_lowest_part_y(h, sl, refs, 8, 8, 8,
                          IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1), nrefs);
    } else if (IS_8X16(mb_type)) {
        get_lowest_part_y(h, sl, refs, 0, 16, 0,
                          IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs);
        get_lowest_part_y(h, sl, refs, 4, 16, 0,
                          IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1), nrefs);
    } else {
        int i;
        assert(IS_8X8(mb_type));
        for (i = 0; i < 4; i++) {
            const int sub_mb_type = sl->sub_mb_type[i];
            const int n           = 4 * i;
            int y_offset          = (i & 2) << 2;
            if (IS_SUB_8X8(sub_mb_type)) {
                get_lowest_part_y(h, sl, refs, n, 8, y_offset,
                                  IS_DIR(sub_mb_type, 0, 0),
                                  IS_DIR(sub_mb_type, 0, 1),
                                  nrefs);
            } else if (IS_SUB_8X4(sub_mb_type)) {
                get_lowest_part_y(h, sl, refs, n, 4, y_offset,
                                  IS_DIR(sub_mb_type, 0, 0),
                                  IS_DIR(sub_mb_type, 0, 1),
                                  nrefs);
                get_lowest_part_y(h, sl, refs, n + 2, 4, y_offset + 4,
                                  IS_DIR(sub_mb_type, 0, 0),
                                  IS_DIR(sub_mb_type, 0, 1),
                                  nrefs);
            } else if (IS_SUB_4X8(sub_mb_type)) {
                get_lowest_part_y(h, sl, refs, n, 8, y_offset,
                                  IS_DIR(sub_mb_type, 0, 0),
                                  IS_DIR(sub_mb_type, 0, 1),
                                  nrefs);
                get_lowest_part_y(h, sl, refs, n + 1, 8, y_offset,
                                  IS_DIR(sub_mb_type, 0, 0),
                                  IS_DIR(sub_mb_type, 0, 1),
                                  nrefs);
            } else {
                int j;
                assert(IS_SUB_4X4(sub_mb_type));
                for (j = 0; j < 4; j++) {
                    int sub_y_offset = y_offset + 2 * (j & 2);
                    get_lowest_part_y(h, sl, refs, n + j, 4, sub_y_offset,
                                      IS_DIR(sub_mb_type, 0, 0),
                                      IS_DIR(sub_mb_type, 0, 1),
                                      nrefs);
                }
            }
        }
    }
    for (list = sl->list_count - 1; list >= 0; list--)
        for (ref = 0; ref < 48 && nrefs[list]; ref++) {
            int row = refs[list][ref];
            if (row >= 0) {
                H264Ref *ref_pic  = &sl->ref_list[list][ref];
                int ref_field         = ref_pic->reference - 1;
                int ref_field_picture = ref_pic->parent->field_picture;
                int pic_height        = 16 * h->mb_height >> ref_field_picture;
                row <<= MB_MBAFF(sl);
                nrefs[list]--;
                if (!FIELD_PICTURE(h) && ref_field_picture) {
                    ff_thread_await_progress(&ref_pic->parent->tf,
                                             FFMIN((row >> 1) - !(row & 1),
                                                   pic_height - 1),
                                             1);
                    ff_thread_await_progress(&ref_pic->parent->tf,
                                             FFMIN((row >> 1), pic_height - 1),
                                             0);
                } else if (FIELD_PICTURE(h) && !ref_field_picture) {
                    ff_thread_await_progress(&ref_pic->parent->tf,
                                             FFMIN(row * 2 + ref_field,
                                                   pic_height - 1),
                                             0);
                } else if (FIELD_PICTURE(h)) {
                    ff_thread_await_progress(&ref_pic->parent->tf,
                                             FFMIN(row, pic_height - 1),
                                             ref_field);
                } else {
                    ff_thread_await_progress(&ref_pic->parent->tf,
                                             FFMIN(row, pic_height - 1),
                                             0);
                }
            }
        }
}
['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    H264Context *h     = &s->h;\n    H264SliceContext *sl = &h->slice_ctx[0];\n    int buf_size       = avpkt->size;\n    int ret, m, i;\n    if (buf_size == 0) {\n        if (s->next_pic->f.data[0] && !h->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    init_get_bits(&h->gb, buf, 8 * buf_size);\n    sl->mb_x = sl->mb_y = sl->mb_xy = 0;\n    if (svq3_decode_slice_header(avctx))\n        return -1;\n    h->pict_type = sl->slice_type;\n    if (h->pict_type != AV_PICTURE_TYPE_B)\n        FFSWAP(H264Picture*, s->next_pic, s->last_pic);\n    av_frame_unref(&s->cur_pic->f);\n    s->cur_pic->f.pict_type = h->pict_type;\n    s->cur_pic->f.key_frame = (h->pict_type == AV_PICTURE_TYPE_I);\n    ret = get_buffer(avctx, s->cur_pic);\n    if (ret < 0)\n        return ret;\n    h->cur_pic_ptr = s->cur_pic;\n    av_frame_unref(&h->cur_pic.f);\n    h->cur_pic     = *s->cur_pic;\n    ret = av_frame_ref(&h->cur_pic.f, &s->cur_pic->f);\n    if (ret < 0)\n        return ret;\n    for (i = 0; i < 16; i++) {\n        h->block_offset[i]           = (4 * ((scan8[i] - scan8[0]) & 7)) + 4 * sl->linesize * ((scan8[i] - scan8[0]) >> 3);\n        h->block_offset[48 + i]      = (4 * ((scan8[i] - scan8[0]) & 7)) + 8 * sl->linesize * ((scan8[i] - scan8[0]) >> 3);\n    }\n    for (i = 0; i < 16; i++) {\n        h->block_offset[16 + i]      =\n        h->block_offset[32 + i]      = (4 * ((scan8[i] - scan8[0]) & 7)) + 4 * sl->uvlinesize * ((scan8[i] - scan8[0]) >> 3);\n        h->block_offset[48 + 16 + i] =\n        h->block_offset[48 + 32 + i] = (4 * ((scan8[i] - scan8[0]) & 7)) + 8 * sl->uvlinesize * ((scan8[i] - scan8[0]) >> 3);\n    }\n    if (h->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 (h->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(h->avctx, AV_LOG_DEBUG,\n               "%c hpel:%d, tpel:%d aqp:%d qp:%d, slice_num:%02X\\n",\n               av_get_picture_type_char(h->pict_type),\n               s->halfpel_flag, s->thirdpel_flag,\n               s->adaptive_quant, h->slice_ctx[0].qscale, sl->slice_num);\n    if (avctx->skip_frame >= AVDISCARD_NONREF && h->pict_type == AV_PICTURE_TYPE_B ||\n        avctx->skip_frame >= AVDISCARD_NONKEY && h->pict_type != AV_PICTURE_TYPE_I ||\n        avctx->skip_frame >= AVDISCARD_ALL)\n        return 0;\n    if (s->next_p_frame_damaged) {\n        if (h->pict_type == AV_PICTURE_TYPE_B)\n            return 0;\n        else\n            s->next_p_frame_damaged = 0;\n    }\n    if (h->pict_type == AV_PICTURE_TYPE_B) {\n        h->frame_num_offset = sl->slice_num - h->prev_frame_num;\n        if (h->frame_num_offset < 0)\n            h->frame_num_offset += 256;\n        if (h->frame_num_offset == 0 ||\n            h->frame_num_offset >= h->prev_frame_num_offset) {\n            av_log(h->avctx, AV_LOG_ERROR, "error in B-frame picture id\\n");\n            return -1;\n        }\n    } else {\n        h->prev_frame_num        = h->frame_num;\n        h->frame_num             = sl->slice_num;\n        h->prev_frame_num_offset = h->frame_num - h->prev_frame_num;\n        if (h->prev_frame_num_offset < 0)\n            h->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                sl->ref_cache[m][scan8[0] + 8 * i + j] = 1;\n            if (i < 3)\n                sl->ref_cache[m][scan8[0] + 8 * i + j] = PART_NOT_AVAILABLE;\n        }\n    }\n    for (sl->mb_y = 0; sl->mb_y < h->mb_height; sl->mb_y++) {\n        for (sl->mb_x = 0; sl->mb_x < h->mb_width; sl->mb_x++) {\n            unsigned mb_type;\n            sl->mb_xy = sl->mb_x + sl->mb_y * h->mb_stride;\n            if ((get_bits_count(&h->gb) + 7) >= h->gb.size_in_bits &&\n                ((get_bits_count(&h->gb) & 7) == 0 ||\n                 show_bits(&h->gb, -get_bits_count(&h->gb) & 7) == 0)) {\n                skip_bits(&h->gb, s->next_slice_index - get_bits_count(&h->gb));\n                h->gb.size_in_bits = 8 * buf_size;\n                if (svq3_decode_slice_header(avctx))\n                    return -1;\n            }\n            mb_type = svq3_get_ue_golomb(&h->gb);\n            if (h->pict_type == AV_PICTURE_TYPE_I)\n                mb_type += 8;\n            else if (h->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(h->avctx, AV_LOG_ERROR,\n                       "error while decoding MB %d %d\\n", sl->mb_x, sl->mb_y);\n                return -1;\n            }\n            if (mb_type != 0)\n                ff_h264_hl_decode_mb(h, &h->slice_ctx[0]);\n            if (h->pict_type != AV_PICTURE_TYPE_B && !h->low_delay)\n                h->cur_pic.mb_type[sl->mb_x + sl->mb_y * h->mb_stride] =\n                    (h->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 * sl->mb_y, 16, h->picture_structure, 0,\n                           h->low_delay);\n    }\n    if (h->pict_type == AV_PICTURE_TYPE_B || h->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] || h->low_delay)\n        *got_frame = 1;\n    if (h->pict_type != AV_PICTURE_TYPE_B) {\n        FFSWAP(H264Picture*, s->cur_pic, s->next_pic);\n    } else {\n        av_frame_unref(&s->cur_pic->f);\n    }\n    return buf_size;\n}', 'static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)\n{\n    H264Context *h = &s->h;\n    H264SliceContext *sl = &h->slice_ctx[0];\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         = sl->mb_xy;\n    const int b_xy          = 4 * sl->mb_x + 4 * sl->mb_y * h->b_stride;\n    sl->top_samples_available      = (sl->mb_y == 0) ? 0x33FF : 0xFFFF;\n    sl->left_samples_available     = (sl->mb_x == 0) ? 0x5F5F : 0xFFFF;\n    sl->topright_samples_available = 0xFFFF;\n    if (mb_type == 0) {\n        if (h->pict_type == AV_PICTURE_TYPE_P ||\n            s->next_pic->mb_type[mb_xy] == -1) {\n            svq3_mc_dir_part(s, 16 * sl->mb_x, 16 * sl->mb_y, 16, 16,\n                             0, 0, 0, 0, 0, 0);\n            if (h->pict_type == AV_PICTURE_TYPE_B)\n                svq3_mc_dir_part(s, 16 * sl->mb_x, 16 * sl->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 == !get_bits1(&h->gb))\n            mode = THIRDPEL_MODE;\n        else if (s->halfpel_flag &&\n                 s->thirdpel_flag == !get_bits1(&h->gb))\n            mode = HALFPEL_MODE;\n        else\n            mode = FULLPEL_MODE;\n        for (m = 0; m < 2; m++) {\n            if (sl->mb_x > 0 && sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1] + 6] != -1) {\n                for (i = 0; i < 4; i++)\n                    AV_COPY32(sl->mv_cache[m][scan8[0] - 1 + i * 8],\n                              h->cur_pic.motion_val[m][b_xy - 1 + i * h->b_stride]);\n            } else {\n                for (i = 0; i < 4; i++)\n                    AV_ZERO32(sl->mv_cache[m][scan8[0] - 1 + i * 8]);\n            }\n            if (sl->mb_y > 0) {\n                memcpy(sl->mv_cache[m][scan8[0] - 1 * 8],\n                       h->cur_pic.motion_val[m][b_xy - h->b_stride],\n                       4 * 2 * sizeof(int16_t));\n                memset(&sl->ref_cache[m][scan8[0] - 1 * 8],\n                       (sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1, 4);\n                if (sl->mb_x < h->mb_width - 1) {\n                    AV_COPY32(sl->mv_cache[m][scan8[0] + 4 - 1 * 8],\n                              h->cur_pic.motion_val[m][b_xy - h->b_stride + 4]);\n                    sl->ref_cache[m][scan8[0] + 4 - 1 * 8] =\n                        (sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride + 1] + 6] == -1 ||\n                         sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1;\n                } else\n                    sl->ref_cache[m][scan8[0] + 4 - 1 * 8] = PART_NOT_AVAILABLE;\n                if (sl->mb_x > 0) {\n                    AV_COPY32(sl->mv_cache[m][scan8[0] - 1 - 1 * 8],\n                              h->cur_pic.motion_val[m][b_xy - h->b_stride - 1]);\n                    sl->ref_cache[m][scan8[0] - 1 - 1 * 8] =\n                        (sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride - 1] + 3] == -1) ? PART_NOT_AVAILABLE : 1;\n                } else\n                    sl->ref_cache[m][scan8[0] - 1 - 1 * 8] = PART_NOT_AVAILABLE;\n            } else\n                memset(&sl->ref_cache[m][scan8[0] - 1 * 8 - 1],\n                       PART_NOT_AVAILABLE, 8);\n            if (h->pict_type != AV_PICTURE_TYPE_B)\n                break;\n        }\n        if (h->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(h->cur_pic.motion_val[0][b_xy + i * h->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(h->cur_pic.motion_val[1][b_xy + i * h->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        memset(sl->intra4x4_pred_mode_cache, -1, 8 * 5 * sizeof(int8_t));\n        if (mb_type == 8) {\n            if (sl->mb_x > 0) {\n                for (i = 0; i < 4; i++)\n                    sl->intra4x4_pred_mode_cache[scan8[0] - 1 + i * 8] = sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1] + 6 - i];\n                if (sl->intra4x4_pred_mode_cache[scan8[0] - 1] == -1)\n                    sl->left_samples_available = 0x5F5F;\n            }\n            if (sl->mb_y > 0) {\n                sl->intra4x4_pred_mode_cache[4 + 8 * 0] = sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride] + 0];\n                sl->intra4x4_pred_mode_cache[5 + 8 * 0] = sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride] + 1];\n                sl->intra4x4_pred_mode_cache[6 + 8 * 0] = sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride] + 2];\n                sl->intra4x4_pred_mode_cache[7 + 8 * 0] = sl->intra4x4_pred_mode[h->mb2br_xy[mb_xy - h->mb_stride] + 3];\n                if (sl->intra4x4_pred_mode_cache[4 + 8 * 0] == -1)\n                    sl->top_samples_available = 0x33FF;\n            }\n            for (i = 0; i < 16; i += 2) {\n                vlc = svq3_get_ue_golomb(&h->gb);\n                if (vlc >= 25) {\n                    av_log(h->avctx, AV_LOG_ERROR,\n                           "luma prediction:%"PRIu32"\\n", vlc);\n                    return -1;\n                }\n                left = &sl->intra4x4_pred_mode_cache[scan8[i] - 1];\n                top  = &sl->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(h->avctx, AV_LOG_ERROR, "weird prediction\\n");\n                    return -1;\n                }\n            }\n        } else {\n            for (i = 0; i < 4; i++)\n                memset(&sl->intra4x4_pred_mode_cache[scan8[0] + 8 * i], DC_PRED, 4);\n        }\n        write_back_intra_pred_mode(h, sl);\n        if (mb_type == 8) {\n            ff_h264_check_intra4x4_pred_mode(h, sl);\n            sl->top_samples_available  = (sl->mb_y == 0) ? 0x33FF : 0xFFFF;\n            sl->left_samples_available = (sl->mb_x == 0) ? 0x5F5F : 0xFFFF;\n        } else {\n            for (i = 0; i < 4; i++)\n                memset(&sl->intra4x4_pred_mode_cache[scan8[0] + 8 * i], DC_128_PRED, 4);\n            sl->top_samples_available  = 0x33FF;\n            sl->left_samples_available = 0x5F5F;\n        }\n        mb_type = MB_TYPE_INTRA4x4;\n    } else {\n        dir = i_mb_type_info[mb_type - 8].pred_mode;\n        dir = (dir >> 1) ^ 3 * (dir & 1) ^ 1;\n        if ((sl->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h, sl, dir, 0)) < 0) {\n            av_log(h->avctx, AV_LOG_ERROR, "ff_h264_check_intra_pred_mode < 0\\n");\n            return sl->intra16x16_pred_mode;\n        }\n        cbp     = i_mb_type_info[mb_type - 8].cbp;\n        mb_type = MB_TYPE_INTRA16x16;\n    }\n    if (!IS_INTER(mb_type) && h->pict_type != AV_PICTURE_TYPE_I) {\n        for (i = 0; i < 4; i++)\n            memset(h->cur_pic.motion_val[0][b_xy + i * h->b_stride],\n                   0, 4 * 2 * sizeof(int16_t));\n        if (h->pict_type == AV_PICTURE_TYPE_B) {\n            for (i = 0; i < 4; i++)\n                memset(h->cur_pic.motion_val[1][b_xy + i * h->b_stride],\n                       0, 4 * 2 * sizeof(int16_t));\n        }\n    }\n    if (!IS_INTRA4x4(mb_type)) {\n        memset(sl->intra4x4_pred_mode + h->mb2br_xy[mb_xy], DC_PRED, 8);\n    }\n    if (!IS_SKIP(mb_type) || h->pict_type == AV_PICTURE_TYPE_B) {\n        memset(sl->non_zero_count_cache + 8, 0, 14 * 8 * sizeof(uint8_t));\n    }\n    if (!IS_INTRA16x16(mb_type) &&\n        (!IS_SKIP(mb_type) || h->pict_type == AV_PICTURE_TYPE_B)) {\n        if ((vlc = svq3_get_ue_golomb(&h->gb)) >= 48) {\n            av_log(h->avctx, AV_LOG_ERROR, "cbp_vlc=%"PRIu32"\\n", vlc);\n            return -1;\n        }\n        cbp = IS_INTRA(mb_type) ? golomb_to_intra4x4_cbp[vlc]\n                                : golomb_to_inter_cbp[vlc];\n    }\n    if (IS_INTRA16x16(mb_type) ||\n        (h->pict_type != AV_PICTURE_TYPE_I && s->adaptive_quant && cbp)) {\n        sl->qscale += svq3_get_se_golomb(&h->gb);\n        if (sl->qscale > 31u) {\n            av_log(h->avctx, AV_LOG_ERROR, "qscale:%d\\n", sl->qscale);\n            return -1;\n        }\n    }\n    if (IS_INTRA16x16(mb_type)) {\n        AV_ZERO128(sl->mb_luma_dc[0] + 0);\n        AV_ZERO128(sl->mb_luma_dc[0] + 8);\n        if (svq3_decode_block(&h->gb, sl->mb_luma_dc[0], 0, 1)) {\n            av_log(h->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  = ((sl->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                    sl->non_zero_count_cache[scan8[k]] = 1;\n                    if (svq3_decode_block(&h->gb, &sl->mb[16 * k], index, type)) {\n                        av_log(h->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(&h->gb, &sl->mb[16 * 16 * i], 0, 3)) {\n                    av_log(h->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                        sl->non_zero_count_cache[scan8[k]] = 1;\n                        if (svq3_decode_block(&h->gb, &sl->mb[16 * k], 1, 1)) {\n                            av_log(h->avctx, AV_LOG_ERROR,\n                                   "error while decoding chroma ac block\\n");\n                            return -1;\n                        }\n                    }\n                }\n            }\n        }\n    }\n    sl->cbp                   = cbp;\n    h->cur_pic.mb_type[mb_xy] = mb_type;\n    if (IS_INTRA(mb_type))\n        sl->chroma_pred_mode = ff_h264_check_intra_pred_mode(h, sl, DC_PRED8x8, 1);\n    return 0;\n}', 'static inline int svq3_mc_dir(SVQ3Context *s, int size, int mode,\n                              int dir, int avg)\n{\n    int i, j, k, mx, my, dx, dy, x, y;\n    H264Context *h          = &s->h;\n    H264SliceContext *sl    = &h->slice_ctx[0];\n    const int part_width    = ((size & 5) == 4) ? 4 : 16 >> (size & 1);\n    const int part_height   = 16 >> ((unsigned)(size + 1) / 3);\n    const int extra_width   = (mode == PREDICT_MODE) ? -16 * 6 : 0;\n    const int h_edge_pos    = 6 * (s->h_edge_pos - part_width)  - extra_width;\n    const int v_edge_pos    = 6 * (s->v_edge_pos - part_height) - extra_width;\n    for (i = 0; i < 16; i += part_height)\n        for (j = 0; j < 16; j += part_width) {\n            const int b_xy = (4 * sl->mb_x + (j >> 2)) +\n                             (4 * sl->mb_y + (i >> 2)) * h->b_stride;\n            int dxy;\n            x = 16 * sl->mb_x + j;\n            y = 16 * sl->mb_y + i;\n            k = (j >> 2 & 1) + (i >> 1 & 2) +\n                (j >> 1 & 4) + (i      & 8);\n            if (mode != PREDICT_MODE) {\n                pred_motion(h, sl, k, part_width >> 2, dir, 1, &mx, &my);\n            } else {\n                mx = s->next_pic->motion_val[0][b_xy][0] << 1;\n                my = s->next_pic->motion_val[0][b_xy][1] << 1;\n                if (dir == 0) {\n                    mx = mx * h->frame_num_offset /\n                         h->prev_frame_num_offset + 1 >> 1;\n                    my = my * h->frame_num_offset /\n                         h->prev_frame_num_offset + 1 >> 1;\n                } else {\n                    mx = mx * (h->frame_num_offset - h->prev_frame_num_offset) /\n                         h->prev_frame_num_offset + 1 >> 1;\n                    my = my * (h->frame_num_offset - h->prev_frame_num_offset) /\n                         h->prev_frame_num_offset + 1 >> 1;\n                }\n            }\n            mx = av_clip(mx, extra_width - 6 * x, h_edge_pos - 6 * x);\n            my = av_clip(my, extra_width - 6 * y, v_edge_pos - 6 * y);\n            if (mode == PREDICT_MODE) {\n                dx = dy = 0;\n            } else {\n                dy = svq3_get_se_golomb(&h->gb);\n                dx = svq3_get_se_golomb(&h->gb);\n                if (dx == INVALID_VLC || dy == INVALID_VLC) {\n                    av_log(h->avctx, AV_LOG_ERROR, "invalid MV vlc\\n");\n                    return -1;\n                }\n            }\n            if (mode == THIRDPEL_MODE) {\n                int fx, fy;\n                mx  = (mx + 1 >> 1) + dx;\n                my  = (my + 1 >> 1) + dy;\n                fx  = (unsigned)(mx + 0x3000) / 3 - 0x1000;\n                fy  = (unsigned)(my + 0x3000) / 3 - 0x1000;\n                dxy = (mx - 3 * fx) + 4 * (my - 3 * fy);\n                svq3_mc_dir_part(s, x, y, part_width, part_height,\n                                 fx, fy, dxy, 1, dir, avg);\n                mx += mx;\n                my += my;\n            } else if (mode == HALFPEL_MODE || mode == PREDICT_MODE) {\n                mx  = (unsigned)(mx + 1 + 0x3000) / 3 + dx - 0x1000;\n                my  = (unsigned)(my + 1 + 0x3000) / 3 + dy - 0x1000;\n                dxy = (mx & 1) + 2 * (my & 1);\n                svq3_mc_dir_part(s, x, y, part_width, part_height,\n                                 mx >> 1, my >> 1, dxy, 0, dir, avg);\n                mx *= 3;\n                my *= 3;\n            } else {\n                mx = (unsigned)(mx + 3 + 0x6000) / 6 + dx - 0x1000;\n                my = (unsigned)(my + 3 + 0x6000) / 6 + dy - 0x1000;\n                svq3_mc_dir_part(s, x, y, part_width, part_height,\n                                 mx, my, 0, 0, dir, avg);\n                mx *= 6;\n                my *= 6;\n            }\n            if (mode != PREDICT_MODE) {\n                int32_t mv = pack16to32(mx, my);\n                if (part_height == 8 && i < 8) {\n                    AV_WN32A(sl->mv_cache[dir][scan8[k] + 1 * 8], mv);\n                    if (part_width == 8 && j < 8)\n                        AV_WN32A(sl->mv_cache[dir][scan8[k] + 1 + 1 * 8], mv);\n                }\n                if (part_width == 8 && j < 8)\n                    AV_WN32A(sl->mv_cache[dir][scan8[k] + 1], mv);\n                if (part_width == 4 || part_height == 4)\n                    AV_WN32A(sl->mv_cache[dir][scan8[k]], mv);\n            }\n            fill_rectangle(h->cur_pic.motion_val[dir][b_xy],\n                           part_width >> 2, part_height >> 2, h->b_stride,\n                           pack16to32(mx, my), 4);\n        }\n    return 0;\n}', 'static av_always_inline void pred_motion(const H264Context *const h,\n                                         H264SliceContext *sl,\n                                         int n,\n                                         int part_width, int list, int ref,\n                                         int *const mx, int *const my)\n{\n    const int index8       = scan8[n];\n    const int top_ref      = sl->ref_cache[list][index8 - 8];\n    const int left_ref     = sl->ref_cache[list][index8 - 1];\n    const int16_t *const A = sl->mv_cache[list][index8 - 1];\n    const int16_t *const B = sl->mv_cache[list][index8 - 8];\n    const int16_t *C;\n    int diagonal_ref, match_count;\n    assert(part_width == 1 || part_width == 2 || part_width == 4);\n    diagonal_ref = fetch_diagonal_mv(h, sl, &C, index8, list, part_width);\n    match_count  = (diagonal_ref == ref) + (top_ref == ref) + (left_ref == ref);\n    ff_tlog(h->avctx, "pred_motion match_count=%d\\n", match_count);\n    if (match_count > 1) {\n        *mx = mid_pred(A[0], B[0], C[0]);\n        *my = mid_pred(A[1], B[1], C[1]);\n    } else if (match_count == 1) {\n        if (left_ref == ref) {\n            *mx = A[0];\n            *my = A[1];\n        } else if (top_ref == ref) {\n            *mx = B[0];\n            *my = B[1];\n        } else {\n            *mx = C[0];\n            *my = C[1];\n        }\n    } else {\n        if (top_ref      == PART_NOT_AVAILABLE &&\n            diagonal_ref == PART_NOT_AVAILABLE &&\n            left_ref     != PART_NOT_AVAILABLE) {\n            *mx = A[0];\n            *my = A[1];\n        } else {\n            *mx = mid_pred(A[0], B[0], C[0]);\n            *my = mid_pred(A[1], B[1], C[1]);\n        }\n    }\n    ff_tlog(h->avctx,\n            "pred_motion (%2d %2d %2d) (%2d %2d %2d) (%2d %2d %2d) -> (%2d %2d %2d) at %2d %2d %d list %d\\n",\n            top_ref, B[0], B[1], diagonal_ref, C[0], C[1], left_ref,\n            A[0], A[1], ref, *mx, *my, sl->mb_x, sl->mb_y, n, list);\n}', 'static av_always_inline int fetch_diagonal_mv(const H264Context *h, H264SliceContext *sl,\n                                              const int16_t **C,\n                                              int i, int list, int part_width)\n{\n    const int topright_ref = sl->ref_cache[list][i - 8 + part_width];\n    if (FRAME_MBAFF(h)) {\n#define SET_DIAG_MV(MV_OP, REF_OP, XY, Y4)                              \\\n        const int xy = XY, y4 = Y4;                                     \\\n        const int mb_type = mb_types[xy + (y4 >> 2) * h->mb_stride];    \\\n        if (!USES_LIST(mb_type, list))                                  \\\n            return LIST_NOT_USED;                                       \\\n        mv = h->cur_pic_ptr->motion_val[list][h->mb2b_xy[xy] + 3 + y4 * h->b_stride]; \\\n        sl->mv_cache[list][scan8[0] - 2][0] = mv[0];                     \\\n        sl->mv_cache[list][scan8[0] - 2][1] = mv[1] MV_OP;               \\\n        return h->cur_pic_ptr->ref_index[list][4 * xy + 1 + (y4 & ~1)] REF_OP;\n        if (topright_ref == PART_NOT_AVAILABLE\n            && i >= scan8[0] + 8 && (i & 7) == 4\n            && sl->ref_cache[list][scan8[0] - 1] != PART_NOT_AVAILABLE) {\n            const uint32_t *mb_types = h->cur_pic_ptr->mb_type;\n            const int16_t *mv;\n            AV_ZERO32(sl->mv_cache[list][scan8[0] - 2]);\n            *C = sl->mv_cache[list][scan8[0] - 2];\n            if (!MB_FIELD(sl) && IS_INTERLACED(sl->left_type[0])) {\n                SET_DIAG_MV(* 2, >> 1, sl->left_mb_xy[0] + h->mb_stride,\n                            (sl->mb_y & 1) * 2 + (i >> 5));\n            }\n            if (MB_FIELD(sl) && !IS_INTERLACED(sl->left_type[0])) {\n                SET_DIAG_MV(/ 2, << 1, sl->left_mb_xy[i >= 36], ((i >> 2)) & 3);\n            }\n        }\n#undef SET_DIAG_MV\n    }\n    if (topright_ref != PART_NOT_AVAILABLE) {\n        *C = sl->mv_cache[list][i - 8 + part_width];\n        return topright_ref;\n    } else {\n        ff_tlog(h->avctx, "topright MV not available\\n");\n        *C = sl->mv_cache[list][i - 8 - 1];\n        return sl->ref_cache[list][i - 8 - 1];\n    }\n}', 'void ff_h264_hl_decode_mb(const H264Context *h, H264SliceContext *sl)\n{\n    const int mb_xy   = sl->mb_xy;\n    const int mb_type = h->cur_pic.mb_type[mb_xy];\n    int is_complex    = CONFIG_SMALL || sl->is_complex ||\n                        IS_INTRA_PCM(mb_type) || sl->qscale == 0;\n    if (CHROMA444(h)) {\n        if (is_complex || h->pixel_shift)\n            hl_decode_mb_444_complex(h, sl);\n        else\n            hl_decode_mb_444_simple_8(h, sl);\n    } else if (is_complex) {\n        hl_decode_mb_complex(h, sl);\n    } else if (h->pixel_shift) {\n        hl_decode_mb_simple_16(h, sl);\n    } else\n        hl_decode_mb_simple_8(h, sl);\n}', 'static av_noinline void FUNC(hl_decode_mb_444)(const H264Context *h, H264SliceContext *sl)\n{\n    const int mb_x    = sl->mb_x;\n    const int mb_y    = sl->mb_y;\n    const int mb_xy   = sl->mb_xy;\n    const int mb_type = h->cur_pic.mb_type[mb_xy];\n    uint8_t *dest[3];\n    int linesize;\n    int i, j, p;\n    const int *block_offset = &h->block_offset[0];\n    const int transform_bypass = !SIMPLE && (sl->qscale == 0 && h->sps.transform_bypass);\n    const int plane_count      = (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) ? 3 : 1;\n    for (p = 0; p < plane_count; p++) {\n        dest[p] = h->cur_pic.f.data[p] +\n                  ((mb_x << PIXEL_SHIFT) + mb_y * sl->linesize) * 16;\n        h->vdsp.prefetch(dest[p] + (sl->mb_x & 3) * 4 * sl->linesize + (64 << PIXEL_SHIFT),\n                         sl->linesize, 4);\n    }\n    h->list_counts[mb_xy] = sl->list_count;\n    if (!SIMPLE && MB_FIELD(sl)) {\n        linesize     = sl->mb_linesize = sl->mb_uvlinesize = sl->linesize * 2;\n        block_offset = &h->block_offset[48];\n        if (mb_y & 1)\n            for (p = 0; p < 3; p++)\n                dest[p] -= sl->linesize * 15;\n        if (FRAME_MBAFF(h)) {\n            int list;\n            for (list = 0; list < sl->list_count; list++) {\n                if (!USES_LIST(mb_type, list))\n                    continue;\n                if (IS_16X16(mb_type)) {\n                    int8_t *ref = &sl->ref_cache[list][scan8[0]];\n                    fill_rectangle(ref, 4, 4, 8, (16 + *ref) ^ (sl->mb_y & 1), 1);\n                } else {\n                    for (i = 0; i < 16; i += 4) {\n                        int ref = sl->ref_cache[list][scan8[i]];\n                        if (ref >= 0)\n                            fill_rectangle(&sl->ref_cache[list][scan8[i]], 2, 2,\n                                           8, (16 + ref) ^ (sl->mb_y & 1), 1);\n                    }\n                }\n            }\n        }\n    } else {\n        linesize = sl->mb_linesize = sl->mb_uvlinesize = sl->linesize;\n    }\n    if (!SIMPLE && IS_INTRA_PCM(mb_type)) {\n        if (PIXEL_SHIFT) {\n            const int bit_depth = h->sps.bit_depth_luma;\n            GetBitContext gb;\n            init_get_bits(&gb, sl->intra_pcm_ptr, 768 * bit_depth);\n            for (p = 0; p < plane_count; p++)\n                for (i = 0; i < 16; i++) {\n                    uint16_t *tmp = (uint16_t *)(dest[p] + i * linesize);\n                    for (j = 0; j < 16; j++)\n                        tmp[j] = get_bits(&gb, bit_depth);\n                }\n        } else {\n            for (p = 0; p < plane_count; p++)\n                for (i = 0; i < 16; i++)\n                    memcpy(dest[p] + i * linesize,\n                           sl->intra_pcm_ptr + p * 256 + i * 16, 16);\n        }\n    } else {\n        if (IS_INTRA(mb_type)) {\n            if (sl->deblocking_filter)\n                xchg_mb_border(h, sl, dest[0], dest[1], dest[2], linesize,\n                               linesize, 1, 1, SIMPLE, PIXEL_SHIFT);\n            for (p = 0; p < plane_count; p++)\n                hl_decode_mb_predict_luma(h, sl, mb_type, 1, SIMPLE,\n                                          transform_bypass, PIXEL_SHIFT,\n                                          block_offset, linesize, dest[p], p);\n            if (sl->deblocking_filter)\n                xchg_mb_border(h, sl, dest[0], dest[1], dest[2], linesize,\n                               linesize, 0, 1, SIMPLE, PIXEL_SHIFT);\n        } else {\n            FUNC(hl_motion_444)(h, sl, dest[0], dest[1], dest[2],\n                      h->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,\n                      h->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,\n                      h->h264dsp.weight_h264_pixels_tab,\n                      h->h264dsp.biweight_h264_pixels_tab);\n        }\n        for (p = 0; p < plane_count; p++)\n            hl_decode_mb_idct_luma(h, sl, mb_type, 1, SIMPLE, transform_bypass,\n                                   PIXEL_SHIFT, block_offset, linesize,\n                                   dest[p], p);\n    }\n}', 'static void MCFUNC(hl_motion)(const H264Context *h, H264SliceContext *sl,\n                              uint8_t *dest_y,\n                              uint8_t *dest_cb, uint8_t *dest_cr,\n                              qpel_mc_func(*qpix_put)[16],\n                              const h264_chroma_mc_func(*chroma_put),\n                              qpel_mc_func(*qpix_avg)[16],\n                              const h264_chroma_mc_func(*chroma_avg),\n                              const h264_weight_func *weight_op,\n                              const h264_biweight_func *weight_avg)\n{\n    const int mb_xy   = sl->mb_xy;\n    const int mb_type = h->cur_pic.mb_type[mb_xy];\n    assert(IS_INTER(mb_type));\n    if (HAVE_THREADS && (h->avctx->active_thread_type & FF_THREAD_FRAME))\n        await_references(h, sl);\n    prefetch_motion(h, sl, 0, PIXEL_SHIFT, CHROMA_IDC);\n    if (IS_16X16(mb_type)) {\n        mc_part(h, sl, 0, 1, 16, 0, dest_y, dest_cb, dest_cr, 0, 0,\n                qpix_put[0], chroma_put[0], qpix_avg[0], chroma_avg[0],\n                weight_op, weight_avg,\n                IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1));\n    } else if (IS_16X8(mb_type)) {\n        mc_part(h, sl, 0, 0, 8, 8 << PIXEL_SHIFT, dest_y, dest_cb, dest_cr, 0, 0,\n                qpix_put[1], chroma_put[0], qpix_avg[1], chroma_avg[0],\n                weight_op, weight_avg,\n                IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1));\n        mc_part(h, sl, 8, 0, 8, 8 << PIXEL_SHIFT, dest_y, dest_cb, dest_cr, 0, 4,\n                qpix_put[1], chroma_put[0], qpix_avg[1], chroma_avg[0],\n                weight_op, weight_avg,\n                IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1));\n    } else if (IS_8X16(mb_type)) {\n        mc_part(h, sl, 0, 0, 16, 8 * sl->mb_linesize, dest_y, dest_cb, dest_cr, 0, 0,\n                qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1],\n                &weight_op[1], &weight_avg[1],\n                IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1));\n        mc_part(h, sl, 4, 0, 16, 8 * sl->mb_linesize, dest_y, dest_cb, dest_cr, 4, 0,\n                qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1],\n                &weight_op[1], &weight_avg[1],\n                IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1));\n    } else {\n        int i;\n        assert(IS_8X8(mb_type));\n        for (i = 0; i < 4; i++) {\n            const int sub_mb_type = sl->sub_mb_type[i];\n            const int n  = 4 * i;\n            int x_offset = (i & 1) << 2;\n            int y_offset = (i & 2) << 1;\n            if (IS_SUB_8X8(sub_mb_type)) {\n                mc_part(h, sl, n, 1, 8, 0, dest_y, dest_cb, dest_cr,\n                        x_offset, y_offset,\n                        qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1],\n                        &weight_op[1], &weight_avg[1],\n                        IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));\n            } else if (IS_SUB_8X4(sub_mb_type)) {\n                mc_part(h, sl, n, 0, 4, 4 << PIXEL_SHIFT, dest_y, dest_cb, dest_cr,\n                        x_offset, y_offset,\n                        qpix_put[2], chroma_put[1], qpix_avg[2], chroma_avg[1],\n                        &weight_op[1], &weight_avg[1],\n                        IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));\n                mc_part(h, sl, n + 2, 0, 4, 4 << PIXEL_SHIFT,\n                        dest_y, dest_cb, dest_cr, x_offset, y_offset + 2,\n                        qpix_put[2], chroma_put[1], qpix_avg[2], chroma_avg[1],\n                        &weight_op[1], &weight_avg[1],\n                        IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));\n            } else if (IS_SUB_4X8(sub_mb_type)) {\n                mc_part(h, sl, n, 0, 8, 4 * sl->mb_linesize,\n                        dest_y, dest_cb, dest_cr, x_offset, y_offset,\n                        qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2],\n                        &weight_op[2], &weight_avg[2],\n                        IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));\n                mc_part(h, sl, n + 1, 0, 8, 4 * sl->mb_linesize,\n                        dest_y, dest_cb, dest_cr, x_offset + 2, y_offset,\n                        qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2],\n                        &weight_op[2], &weight_avg[2],\n                        IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));\n            } else {\n                int j;\n                assert(IS_SUB_4X4(sub_mb_type));\n                for (j = 0; j < 4; j++) {\n                    int sub_x_offset = x_offset + 2 * (j & 1);\n                    int sub_y_offset = y_offset + (j & 2);\n                    mc_part(h, sl, n + j, 1, 4, 0,\n                            dest_y, dest_cb, dest_cr, sub_x_offset, sub_y_offset,\n                            qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2],\n                            &weight_op[2], &weight_avg[2],\n                            IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));\n                }\n            }\n        }\n    }\n    prefetch_motion(h, sl, 1, PIXEL_SHIFT, CHROMA_IDC);\n}', 'static void await_references(const H264Context *h, H264SliceContext *sl)\n{\n    const int mb_xy   = sl->mb_xy;\n    const int mb_type = h->cur_pic.mb_type[mb_xy];\n    int refs[2][48];\n    int nrefs[2] = { 0 };\n    int ref, list;\n    memset(refs, -1, sizeof(refs));\n    if (IS_16X16(mb_type)) {\n        get_lowest_part_y(h, sl, refs, 0, 16, 0,\n                          IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs);\n    } else if (IS_16X8(mb_type)) {\n        get_lowest_part_y(h, sl, refs, 0, 8, 0,\n                          IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs);\n        get_lowest_part_y(h, sl, refs, 8, 8, 8,\n                          IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1), nrefs);\n    } else if (IS_8X16(mb_type)) {\n        get_lowest_part_y(h, sl, refs, 0, 16, 0,\n                          IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs);\n        get_lowest_part_y(h, sl, refs, 4, 16, 0,\n                          IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1), nrefs);\n    } else {\n        int i;\n        assert(IS_8X8(mb_type));\n        for (i = 0; i < 4; i++) {\n            const int sub_mb_type = sl->sub_mb_type[i];\n            const int n           = 4 * i;\n            int y_offset          = (i & 2) << 2;\n            if (IS_SUB_8X8(sub_mb_type)) {\n                get_lowest_part_y(h, sl, refs, n, 8, y_offset,\n                                  IS_DIR(sub_mb_type, 0, 0),\n                                  IS_DIR(sub_mb_type, 0, 1),\n                                  nrefs);\n            } else if (IS_SUB_8X4(sub_mb_type)) {\n                get_lowest_part_y(h, sl, refs, n, 4, y_offset,\n                                  IS_DIR(sub_mb_type, 0, 0),\n                                  IS_DIR(sub_mb_type, 0, 1),\n                                  nrefs);\n                get_lowest_part_y(h, sl, refs, n + 2, 4, y_offset + 4,\n                                  IS_DIR(sub_mb_type, 0, 0),\n                                  IS_DIR(sub_mb_type, 0, 1),\n                                  nrefs);\n            } else if (IS_SUB_4X8(sub_mb_type)) {\n                get_lowest_part_y(h, sl, refs, n, 8, y_offset,\n                                  IS_DIR(sub_mb_type, 0, 0),\n                                  IS_DIR(sub_mb_type, 0, 1),\n                                  nrefs);\n                get_lowest_part_y(h, sl, refs, n + 1, 8, y_offset,\n                                  IS_DIR(sub_mb_type, 0, 0),\n                                  IS_DIR(sub_mb_type, 0, 1),\n                                  nrefs);\n            } else {\n                int j;\n                assert(IS_SUB_4X4(sub_mb_type));\n                for (j = 0; j < 4; j++) {\n                    int sub_y_offset = y_offset + 2 * (j & 2);\n                    get_lowest_part_y(h, sl, refs, n + j, 4, sub_y_offset,\n                                      IS_DIR(sub_mb_type, 0, 0),\n                                      IS_DIR(sub_mb_type, 0, 1),\n                                      nrefs);\n                }\n            }\n        }\n    }\n    for (list = sl->list_count - 1; list >= 0; list--)\n        for (ref = 0; ref < 48 && nrefs[list]; ref++) {\n            int row = refs[list][ref];\n            if (row >= 0) {\n                H264Ref *ref_pic  = &sl->ref_list[list][ref];\n                int ref_field         = ref_pic->reference - 1;\n                int ref_field_picture = ref_pic->parent->field_picture;\n                int pic_height        = 16 * h->mb_height >> ref_field_picture;\n                row <<= MB_MBAFF(sl);\n                nrefs[list]--;\n                if (!FIELD_PICTURE(h) && ref_field_picture) {\n                    ff_thread_await_progress(&ref_pic->parent->tf,\n                                             FFMIN((row >> 1) - !(row & 1),\n                                                   pic_height - 1),\n                                             1);\n                    ff_thread_await_progress(&ref_pic->parent->tf,\n                                             FFMIN((row >> 1), pic_height - 1),\n                                             0);\n                } else if (FIELD_PICTURE(h) && !ref_field_picture) {\n                    ff_thread_await_progress(&ref_pic->parent->tf,\n                                             FFMIN(row * 2 + ref_field,\n                                                   pic_height - 1),\n                                             0);\n                } else if (FIELD_PICTURE(h)) {\n                    ff_thread_await_progress(&ref_pic->parent->tf,\n                                             FFMIN(row, pic_height - 1),\n                                             ref_field);\n                } else {\n                    ff_thread_await_progress(&ref_pic->parent->tf,\n                                             FFMIN(row, pic_height - 1),\n                                             0);\n                }\n            }\n        }\n}']