libavcodec/h264dec.c:735: error: Integer Overflow L2
  ([0, 4294967295] × 8):signed32 by call to `ff_h264_field_end`.

libavcodec/h264dec.c:717:17: Call
715.     }
716. 
717.     buf_index = decode_nal_units(h, buf, buf_size);
                     ^
718.     if (buf_index < 0)
719.         return AVERROR_INVALIDDATA;

libavcodec/h264dec.c:521:11: Call
  519.     }
  520. 
  521.     ret = ff_h2645_packet_split(&h->pkt, buf, buf_size, avctx, h->is_avc,
                 ^
  522.                                 h->nal_length_size, avctx->codec_id);
  523.     if (ret < 0) {

libavcodec/h2645_parse.c:301:15: Call
    299.         nal->size_bits = get_bit_length(nal, skip_trailing_zeros);
    300. 
    301.         ret = init_get_bits(&nal->gb, nal->data, nal->size_bits);
                       ^
    302.         if (ret < 0)
    303.             return ret;

libavcodec/get_bits.h:362:1: Parameter `bit_size`
      360.  * @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.
      361.  */
      362. static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,
           ^
      363.                                 int bit_size)
      364. {

libavcodec/get_bits.h:379:5: Assignment
      377.     s->size_in_bits       = bit_size;
      378. #if !UNCHECKED_BITSTREAM_READER
      379.     s->size_in_bits_plus8 = bit_size + 8;
               ^
      380. #endif
      381.     s->buffer_end         = buffer + buffer_size;

libavcodec/h264dec.c:735:9: Call
733.     if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) ||
734.         (h->mb_y >= h->mb_height && h->mb_height)) {
735.         ff_h264_field_end(h, &h->slice_ctx[0], 0);
             ^
736. 
737.         *got_frame = 0;

libavcodec/h264_picture.c:145:1: Parameter `sl->er.mb_width`
  143. #endif /* CONFIG_ERROR_RESILIENCE */
  144. 
  145. int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup)
       ^
  146. {
  147.     AVCodecContext *const avctx = h->avctx;

libavcodec/h264_picture.c:190:9: Call
  188.         h264_set_erpic(&sl->er.next_pic,
  189.                        sl->ref_count[1] ? sl->ref_list[1][0].parent : NULL);
  190.         ff_er_frame_end(&sl->er);
               ^
  191.     }
  192. #endif /* CONFIG_ERROR_RESILIENCE */

libavcodec/error_resilience.c:1020:14: Assignment
    1018.     /* handle inter blocks with damaged AC */
    1019.     for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
    1020.         for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
                       ^
    1021.             const int mb_xy   = mb_x + mb_y * s->mb_stride;
    1022.             const int mb_type = s->cur_pic.mb_type[mb_xy];

libavcodec/error_resilience.c:1194:9: Call
    1192. 
    1193.         /* filter vertical block boundaries */
    1194.         v_block_filter(s, s->cur_pic.f->data[0], s->mb_width * 2,
                  ^
    1195.                        s->mb_height * 2, linesize[0], 1);
    1196.         v_block_filter(s, s->cur_pic.f->data[1], s->mb_width,

libavcodec/error_resilience.c:290:1: <LHS trace>
288.  * @param h     height in 8 pixel blocks
289.  */
290. static void v_block_filter(ERContext *s, uint8_t *dst, int w, int h,
     ^
291.                            int stride, int is_luma)
292. {

libavcodec/error_resilience.c:290:1: Parameter `w`
      288.  * @param h     height in 8 pixel blocks
      289.  */
      290. static void v_block_filter(ERContext *s, uint8_t *dst, int w, int h,
           ^
      291.                            int stride, int is_luma)
      292. {

libavcodec/error_resilience.c:308:13: Binary operation: ([0, 4294967295] × 8):signed32 by call to `ff_h264_field_end` 
      306.             int top_damage    = top_status & ER_MB_ERROR;
      307.             int bottom_damage = bottom_status & ER_MB_ERROR;
      308.             int offset        = b_x * 8 + b_y * stride * 8;
                       ^
      309. 
      310.             int16_t *top_mv    = s->cur_pic.motion_val[0][mvy_stride *  b_y      + mvx_stride * b_x];

static void v_block_filter(ERContext *s, uint8_t *dst, int w, int h,
                           int stride, int is_luma)
{
    int b_x, b_y, mvx_stride, mvy_stride;
    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
    set_mv_strides(s, &mvx_stride, &mvy_stride);
    mvx_stride >>= is_luma;
    mvy_stride *= mvx_stride;
    for (b_y = 0; b_y < h - 1; b_y++) {
        for (b_x = 0; b_x < w; b_x++) {
            int x;
            int top_status    = s->error_status_table[(b_x >> is_luma) +  (b_y      >> is_luma) * s->mb_stride];
            int bottom_status = s->error_status_table[(b_x >> is_luma) + ((b_y + 1) >> is_luma) * s->mb_stride];
            int top_intra     = IS_INTRA(s->cur_pic.mb_type[(b_x >> is_luma) + ( b_y      >> is_luma) * s->mb_stride]);
            int bottom_intra  = IS_INTRA(s->cur_pic.mb_type[(b_x >> is_luma) + ((b_y + 1) >> is_luma) * s->mb_stride]);
            int top_damage    = top_status & ER_MB_ERROR;
            int bottom_damage = bottom_status & ER_MB_ERROR;
            int offset        = b_x * 8 + b_y * stride * 8;
            int16_t *top_mv    = s->cur_pic.motion_val[0][mvy_stride *  b_y      + mvx_stride * b_x];
            int16_t *bottom_mv = s->cur_pic.motion_val[0][mvy_stride * (b_y + 1) + mvx_stride * b_x];
            if (!(top_damage || bottom_damage))
                continue;
            if ((!top_intra) && (!bottom_intra) &&
                FFABS(top_mv[0] - bottom_mv[0]) +
                FFABS(top_mv[1] + bottom_mv[1]) < 2)
                continue;
            for (x = 0; x < 8; x++) {
                int a, b, c, d;
                a = dst[offset + x + 7 * stride] - dst[offset + x + 6 * stride];
                b = dst[offset + x + 8 * stride] - dst[offset + x + 7 * stride];
                c = dst[offset + x + 9 * stride] - dst[offset + x + 8 * stride];
                d = FFABS(b) - ((FFABS(a) + FFABS(c) + 1) >> 1);
                d = FFMAX(d, 0);
                if (b < 0)
                    d = -d;
                if (d == 0)
                    continue;
                if (!(top_damage && bottom_damage))
                    d = d * 16 / 9;
                if (top_damage) {
                    dst[offset + x +  7 * stride] = cm[dst[offset + x +  7 * stride] + ((d * 7) >> 4)];
                    dst[offset + x +  6 * stride] = cm[dst[offset + x +  6 * stride] + ((d * 5) >> 4)];
                    dst[offset + x +  5 * stride] = cm[dst[offset + x +  5 * stride] + ((d * 3) >> 4)];
                    dst[offset + x +  4 * stride] = cm[dst[offset + x +  4 * stride] + ((d * 1) >> 4)];
                }
                if (bottom_damage) {
                    dst[offset + x +  8 * stride] = cm[dst[offset + x +  8 * stride] - ((d * 7) >> 4)];
                    dst[offset + x +  9 * stride] = cm[dst[offset + x +  9 * stride] - ((d * 5) >> 4)];
                    dst[offset + x + 10 * stride] = cm[dst[offset + x + 10 * stride] - ((d * 3) >> 4)];
                    dst[offset + x + 11 * stride] = cm[dst[offset + x + 11 * stride] - ((d * 1) >> 4)];
                }
            }
        }
    }
}
['static int h264_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    H264Context *h     = avctx->priv_data;\n    AVFrame *pict      = data;\n    int buf_index      = 0;\n    int ret;\n    const uint8_t *new_extradata;\n    int new_extradata_size;\n    h->flags = avctx->flags;\n    h->setup_finished = 0;\n    h->nb_slice_ctx_queued = 0;\nout:\n    if (buf_size == 0) {\n        H264Picture *out;\n        int i, out_idx;\n        h->cur_pic_ptr = NULL;\n        out     = h->delayed_pic[0];\n        out_idx = 0;\n        for (i = 1;\n             h->delayed_pic[i] &&\n             !h->delayed_pic[i]->f->key_frame &&\n             !h->delayed_pic[i]->mmco_reset;\n             i++)\n            if (h->delayed_pic[i]->poc < out->poc) {\n                out     = h->delayed_pic[i];\n                out_idx = i;\n            }\n        for (i = out_idx; h->delayed_pic[i]; i++)\n            h->delayed_pic[i] = h->delayed_pic[i + 1];\n        if (out) {\n            ret = output_frame(h, pict, out->f);\n            if (ret < 0)\n                return ret;\n            *got_frame = 1;\n        }\n        return buf_index;\n    }\n    new_extradata_size = 0;\n    new_extradata = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA,\n                                            &new_extradata_size);\n    if (new_extradata_size > 0 && new_extradata) {\n        ret = ff_h264_decode_extradata(new_extradata, new_extradata_size,\n                                       &h->ps, &h->is_avc, &h->nal_length_size,\n                                       avctx->err_recognition, avctx);\n        if (ret < 0)\n            return ret;\n    }\n    buf_index = decode_nal_units(h, buf, buf_size);\n    if (buf_index < 0)\n        return AVERROR_INVALIDDATA;\n    if (!h->cur_pic_ptr && h->nal_unit_type == H264_NAL_END_SEQUENCE) {\n        buf_size = 0;\n        goto out;\n    }\n    if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) && !h->cur_pic_ptr) {\n        if (avctx->skip_frame >= AVDISCARD_NONREF)\n            return 0;\n        av_log(avctx, AV_LOG_ERROR, "no frame!\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) ||\n        (h->mb_y >= h->mb_height && h->mb_height)) {\n        ff_h264_field_end(h, &h->slice_ctx[0], 0);\n        *got_frame = 0;\n        if (h->output_frame->buf[0]) {\n            ret = output_frame(h, pict, h->output_frame) ;\n            av_frame_unref(h->output_frame);\n            if (ret < 0)\n                return ret;\n            *got_frame = 1;\n        }\n    }\n    assert(pict->buf[0] || !*got_frame);\n    return get_consumed_bytes(buf_index, buf_size);\n}', 'static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)\n{\n    AVCodecContext *const avctx = h->avctx;\n    int nals_needed = 0;\n    int i, ret = 0;\n    if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)) {\n        h->current_slice = 0;\n        if (!h->first_field)\n            h->cur_pic_ptr = NULL;\n        ff_h264_sei_uninit(&h->sei);\n    }\n    ret = ff_h2645_packet_split(&h->pkt, buf, buf_size, avctx, h->is_avc,\n                                h->nal_length_size, avctx->codec_id);\n    if (ret < 0) {\n        av_log(avctx, AV_LOG_ERROR,\n               "Error splitting the input into NAL units.\\n");\n        return ret;\n    }\n    if (avctx->active_thread_type & FF_THREAD_FRAME)\n        nals_needed = get_last_needed_nal(h);\n    for (i = 0; i < h->pkt.nb_nals; i++) {\n        H2645NAL *nal = &h->pkt.nals[i];\n        int max_slice_ctx, err;\n        if (avctx->skip_frame >= AVDISCARD_NONREF &&\n            nal->ref_idc == 0 && nal->type != H264_NAL_SEI)\n            continue;\n        h->nal_ref_idc   = nal->ref_idc;\n        h->nal_unit_type = nal->type;\n        err = 0;\n        switch (nal->type) {\n        case H264_NAL_IDR_SLICE:\n            idr(h);\n        case H264_NAL_SLICE:\n            if ((err = ff_h264_queue_decode_slice(h, nal)))\n                break;\n            if (avctx->active_thread_type & FF_THREAD_FRAME && !h->avctx->hwaccel &&\n                i >= nals_needed) {\n                ff_thread_finish_setup(avctx);\n                h->setup_finished = 1;\n            }\n            max_slice_ctx = avctx->hwaccel ? 1 : h->nb_slice_ctx;\n            if (h->nb_slice_ctx_queued == max_slice_ctx) {\n                if (avctx->hwaccel)\n                    ret = avctx->hwaccel->decode_slice(avctx, nal->raw_data, nal->raw_size);\n                else\n                    ret = ff_h264_execute_decode_slices(h);\n                if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))\n                    goto end;\n            }\n            break;\n        case H264_NAL_DPA:\n        case H264_NAL_DPB:\n        case H264_NAL_DPC:\n            avpriv_request_sample(avctx, "data partitioning");\n            ret = AVERROR(ENOSYS);\n            goto end;\n            break;\n        case H264_NAL_SEI:\n            ret = ff_h264_sei_decode(&h->sei, &nal->gb, &h->ps, avctx);\n            if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))\n                goto end;\n            break;\n        case H264_NAL_SPS:\n            ret = ff_h264_decode_seq_parameter_set(&nal->gb, avctx, &h->ps);\n            if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))\n                goto end;\n            break;\n        case H264_NAL_PPS:\n            ret = ff_h264_decode_picture_parameter_set(&nal->gb, avctx, &h->ps,\n                                                       nal->size_bits);\n            if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))\n                goto end;\n            break;\n        case H264_NAL_AUD:\n        case H264_NAL_END_SEQUENCE:\n        case H264_NAL_END_STREAM:\n        case H264_NAL_FILLER_DATA:\n        case H264_NAL_SPS_EXT:\n        case H264_NAL_AUXILIARY_SLICE:\n            break;\n        default:\n            av_log(avctx, AV_LOG_DEBUG, "Unknown NAL code: %d (%d bits)\\n",\n                   nal->type, nal->size_bits);\n        }\n        if (err < 0) {\n            av_log(h->avctx, AV_LOG_ERROR, "decode_slice_header error\\n");\n        }\n    }\n    ret = ff_h264_execute_decode_slices(h);\n    if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))\n        goto end;\n    ret = 0;\nend:\n    if (h->cur_pic_ptr && !h->droppable) {\n        ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,\n                                  h->picture_structure == PICT_BOTTOM_FIELD);\n    }\n    return (ret < 0) ? ret : buf_size;\n}', 'int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,\n                          void *logctx, int is_nalff, int nal_length_size,\n                          enum AVCodecID codec_id)\n{\n    int consumed, ret = 0;\n    const uint8_t *next_avc = buf + (is_nalff ? 0 : length);\n    pkt->nb_nals = 0;\n    while (length >= 4) {\n        H2645NAL *nal;\n        int extract_length = 0;\n        int skip_trailing_zeros = 1;\n        if (buf == next_avc) {\n            int i;\n            for (i = 0; i < nal_length_size; i++)\n                extract_length = (extract_length << 8) | buf[i];\n            if (extract_length > length) {\n                av_log(logctx, AV_LOG_ERROR,\n                       "Invalid NAL unit size (%d > %d).\\n",\n                       extract_length, length);\n                return AVERROR_INVALIDDATA;\n            }\n            buf     += nal_length_size;\n            length  -= nal_length_size;\n            next_avc = buf + extract_length;\n        } else {\n            int buf_index = find_next_start_code(buf, next_avc);\n            buf    += buf_index;\n            length -= buf_index;\n            if (buf == next_avc)\n                continue;\n            if (length > 0) {\n                extract_length = length;\n            } else if (pkt->nb_nals == 0) {\n                av_log(logctx, AV_LOG_ERROR, "No NAL unit found\\n");\n                return AVERROR_INVALIDDATA;\n            } else {\n                break;\n            }\n        }\n        if (pkt->nals_allocated < pkt->nb_nals + 1) {\n            int new_size = pkt->nals_allocated + 1;\n            H2645NAL *tmp = av_realloc_array(pkt->nals, new_size, sizeof(*tmp));\n            if (!tmp)\n                return AVERROR(ENOMEM);\n            pkt->nals = tmp;\n            memset(pkt->nals + pkt->nals_allocated, 0,\n                   (new_size - pkt->nals_allocated) * sizeof(*tmp));\n            pkt->nals_allocated = new_size;\n        }\n        nal = &pkt->nals[pkt->nb_nals++];\n        consumed = ff_h2645_extract_rbsp(buf, extract_length, nal);\n        if (consumed < 0)\n            return consumed;\n        if (consumed < length - 3 &&\n            buf[consumed]     == 0x00 && buf[consumed + 1] == 0x00 &&\n            buf[consumed + 2] == 0x01 && buf[consumed + 3] == 0xE0)\n            skip_trailing_zeros = 0;\n        nal->size_bits = get_bit_length(nal, skip_trailing_zeros);\n        ret = init_get_bits(&nal->gb, nal->data, nal->size_bits);\n        if (ret < 0)\n            return ret;\n        if (codec_id == AV_CODEC_ID_HEVC)\n            ret = hevc_parse_nal_header(nal, logctx);\n        else\n            ret = h264_parse_nal_header(nal, logctx);\n        if (ret <= 0) {\n            if (ret < 0) {\n                av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit %d, skipping.\\n",\n                       nal->type);\n            }\n            pkt->nb_nals--;\n        }\n        buf    += consumed;\n        length -= consumed;\n    }\n    return 0;\n}', 'static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,\n                                int bit_size)\n{\n    int buffer_size;\n    int ret = 0;\n    if (bit_size > INT_MAX - 7 || bit_size < 0 || !buffer) {\n        bit_size    = 0;\n        buffer      = NULL;\n        ret         = AVERROR_INVALIDDATA;\n    }\n    buffer_size = (bit_size + 7) >> 3;\n    s->buffer             = buffer;\n    s->size_in_bits       = bit_size;\n#if !UNCHECKED_BITSTREAM_READER\n    s->size_in_bits_plus8 = bit_size + 8;\n#endif\n    s->buffer_end         = buffer + buffer_size;\n    s->index              = 0;\n    return ret;\n}', 'int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup)\n{\n    AVCodecContext *const avctx = h->avctx;\n    int err = 0;\n    h->mb_y = 0;\n    if (!in_setup && !h->droppable)\n        ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,\n                                  h->picture_structure == PICT_BOTTOM_FIELD);\n    if (in_setup || !(avctx->active_thread_type & FF_THREAD_FRAME)) {\n        if (!h->droppable) {\n            err = ff_h264_execute_ref_pic_marking(h);\n            h->poc.prev_poc_msb = h->poc.poc_msb;\n            h->poc.prev_poc_lsb = h->poc.poc_lsb;\n        }\n        h->poc.prev_frame_num_offset = h->poc.frame_num_offset;\n        h->poc.prev_frame_num        = h->poc.frame_num;\n    }\n    if (avctx->hwaccel) {\n        if (avctx->hwaccel->end_frame(avctx) < 0)\n            av_log(avctx, AV_LOG_ERROR,\n                   "hardware accelerator failed to decode picture\\n");\n    }\n#if CONFIG_ERROR_RESILIENCE\n    if (!FIELD_PICTURE(h) && h->enable_er) {\n        h264_set_erpic(&sl->er.cur_pic, h->cur_pic_ptr);\n        h264_set_erpic(&sl->er.last_pic,\n                       sl->ref_count[0] ? sl->ref_list[0][0].parent : NULL);\n        h264_set_erpic(&sl->er.next_pic,\n                       sl->ref_count[1] ? sl->ref_list[1][0].parent : NULL);\n        ff_er_frame_end(&sl->er);\n    }\n#endif\n    emms_c();\n    h->current_slice = 0;\n    return err;\n}', 'void ff_er_frame_end(ERContext *s)\n{\n    int *linesize = s->cur_pic.f->linesize;\n    int i, mb_x, mb_y, error, error_type, dc_error, mv_error, ac_error;\n    int distance;\n    int threshold_part[4] = { 100, 100, 100 };\n    int threshold = 50;\n    int is_intra_likely;\n    if (!s->avctx->error_concealment || s->error_count == 0            ||\n        s->avctx->hwaccel                                              ||\n        !s->cur_pic.f                                                  ||\n        s->cur_pic.field_picture                                       ||\n        s->error_count == 3 * s->mb_width *\n                          (s->avctx->skip_top + s->avctx->skip_bottom)) {\n        return;\n    };\n    if (!s->cur_pic.motion_val[0] || !s->cur_pic.ref_index[0]) {\n        av_log(s->avctx, AV_LOG_ERROR, "MVs not available, ER not possible.\\n");\n        return;\n    }\n    if (s->avctx->debug & FF_DEBUG_ER) {\n        for (mb_y = 0; mb_y < s->mb_height; mb_y++) {\n            for (mb_x = 0; mb_x < s->mb_width; mb_x++) {\n                int status = s->error_status_table[mb_x + mb_y * s->mb_stride];\n                av_log(s->avctx, AV_LOG_DEBUG, "%2X ", status);\n            }\n            av_log(s->avctx, AV_LOG_DEBUG, "\\n");\n        }\n    }\n    for (error_type = 1; error_type <= 3; error_type++) {\n        int end_ok = 0;\n        for (i = s->mb_num - 1; i >= 0; i--) {\n            const int mb_xy = s->mb_index2xy[i];\n            int error       = s->error_status_table[mb_xy];\n            if (error & (1 << error_type))\n                end_ok = 1;\n            if (error & (8 << error_type))\n                end_ok = 1;\n            if (!end_ok)\n                s->error_status_table[mb_xy] |= 1 << error_type;\n            if (error & VP_START)\n                end_ok = 0;\n        }\n    }\n    if (s->partitioned_frame) {\n        int end_ok = 0;\n        for (i = s->mb_num - 1; i >= 0; i--) {\n            const int mb_xy = s->mb_index2xy[i];\n            int error       = s->error_status_table[mb_xy];\n            if (error & ER_AC_END)\n                end_ok = 0;\n            if ((error & ER_MV_END) ||\n                (error & ER_DC_END) ||\n                (error & ER_AC_ERROR))\n                end_ok = 1;\n            if (!end_ok)\n                s->error_status_table[mb_xy]|= ER_AC_ERROR;\n            if (error & VP_START)\n                end_ok = 0;\n        }\n    }\n    if (s->avctx->err_recognition & AV_EF_EXPLODE) {\n        int end_ok = 1;\n        for (i = s->mb_num - 2; i >= s->mb_width + 100; i--) {\n            const int mb_xy = s->mb_index2xy[i];\n            int error1 = s->error_status_table[mb_xy];\n            int error2 = s->error_status_table[s->mb_index2xy[i + 1]];\n            if (error1 & VP_START)\n                end_ok = 1;\n            if (error2 == (VP_START | ER_MB_ERROR | ER_MB_END) &&\n                error1 != (VP_START | ER_MB_ERROR | ER_MB_END) &&\n                ((error1 & ER_AC_END) || (error1 & ER_DC_END) ||\n                (error1 & ER_MV_END))) {\n                end_ok = 0;\n            }\n            if (!end_ok)\n                s->error_status_table[mb_xy] |= ER_MB_ERROR;\n        }\n    }\n    distance = 9999999;\n    for (error_type = 1; error_type <= 3; error_type++) {\n        for (i = s->mb_num - 1; i >= 0; i--) {\n            const int mb_xy = s->mb_index2xy[i];\n            int       error = s->error_status_table[mb_xy];\n            if (s->mbskip_table && !s->mbskip_table[mb_xy])\n                distance++;\n            if (error & (1 << error_type))\n                distance = 0;\n            if (s->partitioned_frame) {\n                if (distance < threshold_part[error_type - 1])\n                    s->error_status_table[mb_xy] |= 1 << error_type;\n            } else {\n                if (distance < threshold)\n                    s->error_status_table[mb_xy] |= 1 << error_type;\n            }\n            if (error & VP_START)\n                distance = 9999999;\n        }\n    }\n    error = 0;\n    for (i = 0; i < s->mb_num; i++) {\n        const int mb_xy = s->mb_index2xy[i];\n        int old_error   = s->error_status_table[mb_xy];\n        if (old_error & VP_START) {\n            error = old_error & ER_MB_ERROR;\n        } else {\n            error |= old_error & ER_MB_ERROR;\n            s->error_status_table[mb_xy] |= error;\n        }\n    }\n    if (!s->partitioned_frame) {\n        for (i = 0; i < s->mb_num; i++) {\n            const int mb_xy = s->mb_index2xy[i];\n            error = s->error_status_table[mb_xy];\n            if (error & ER_MB_ERROR)\n                error |= ER_MB_ERROR;\n            s->error_status_table[mb_xy] = error;\n        }\n    }\n    dc_error = ac_error = mv_error = 0;\n    for (i = 0; i < s->mb_num; i++) {\n        const int mb_xy = s->mb_index2xy[i];\n        error = s->error_status_table[mb_xy];\n        if (error & ER_DC_ERROR)\n            dc_error++;\n        if (error & ER_AC_ERROR)\n            ac_error++;\n        if (error & ER_MV_ERROR)\n            mv_error++;\n    }\n    av_log(s->avctx, AV_LOG_INFO, "concealing %d DC, %d AC, %d MV errors\\n",\n           dc_error, ac_error, mv_error);\n    is_intra_likely = is_intra_more_likely(s);\n    for (i = 0; i < s->mb_num; i++) {\n        const int mb_xy = s->mb_index2xy[i];\n        error = s->error_status_table[mb_xy];\n        if (!((error & ER_DC_ERROR) && (error & ER_MV_ERROR)))\n            continue;\n        if (is_intra_likely)\n            s->cur_pic.mb_type[mb_xy] = MB_TYPE_INTRA4x4;\n        else\n            s->cur_pic.mb_type[mb_xy] = MB_TYPE_16x16 | MB_TYPE_L0;\n    }\n    if (!(s->last_pic.f && s->last_pic.f->data[0]) &&\n        !(s->next_pic.f && s->next_pic.f->data[0]))\n        for (i = 0; i < s->mb_num; i++) {\n            const int mb_xy = s->mb_index2xy[i];\n            if (!IS_INTRA(s->cur_pic.mb_type[mb_xy]))\n                s->cur_pic.mb_type[mb_xy] = MB_TYPE_INTRA4x4;\n        }\n    for (mb_y = 0; mb_y < s->mb_height; mb_y++) {\n        for (mb_x = 0; mb_x < s->mb_width; mb_x++) {\n            const int mb_xy   = mb_x + mb_y * s->mb_stride;\n            const int mb_type = s->cur_pic.mb_type[mb_xy];\n            const int dir     = !(s->last_pic.f && s->last_pic.f->data[0]);\n            const int mv_dir  = dir ? MV_DIR_BACKWARD : MV_DIR_FORWARD;\n            int mv_type;\n            error = s->error_status_table[mb_xy];\n            if (IS_INTRA(mb_type))\n                continue;\n            if (error & ER_MV_ERROR)\n                continue;\n            if (!(error & ER_AC_ERROR))\n                continue;\n            if (IS_8X8(mb_type)) {\n                int mb_index = mb_x * 2 + mb_y * 2 * s->b8_stride;\n                int j;\n                mv_type = MV_TYPE_8X8;\n                for (j = 0; j < 4; j++) {\n                    s->mv[0][j][0] = s->cur_pic.motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][0];\n                    s->mv[0][j][1] = s->cur_pic.motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][1];\n                }\n            } else {\n                mv_type     = MV_TYPE_16X16;\n                s->mv[0][0][0] = s->cur_pic.motion_val[dir][mb_x * 2 + mb_y * 2 * s->b8_stride][0];\n                s->mv[0][0][1] = s->cur_pic.motion_val[dir][mb_x * 2 + mb_y * 2 * s->b8_stride][1];\n            }\n            s->decode_mb(s->opaque, 0  ,\n                         mv_dir, mv_type, &s->mv, mb_x, mb_y, 0, 0);\n        }\n    }\n    if (s->cur_pic.f->pict_type == AV_PICTURE_TYPE_B) {\n        for (mb_y = 0; mb_y < s->mb_height; mb_y++) {\n            for (mb_x = 0; mb_x < s->mb_width; mb_x++) {\n                int       xy      = mb_x * 2 + mb_y * 2 * s->b8_stride;\n                const int mb_xy   = mb_x + mb_y * s->mb_stride;\n                const int mb_type = s->cur_pic.mb_type[mb_xy];\n                int mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;\n                error = s->error_status_table[mb_xy];\n                if (IS_INTRA(mb_type))\n                    continue;\n                if (!(error & ER_MV_ERROR))\n                    continue;\n                if (!(error & ER_AC_ERROR))\n                    continue;\n                if (!(s->last_pic.f && s->last_pic.f->data[0]))\n                    mv_dir &= ~MV_DIR_FORWARD;\n                if (!(s->next_pic.f && s->next_pic.f->data[0]))\n                    mv_dir &= ~MV_DIR_BACKWARD;\n                if (s->pp_time) {\n                    int time_pp = s->pp_time;\n                    int time_pb = s->pb_time;\n                    ff_thread_await_progress(s->next_pic.tf, mb_y, 0);\n                    s->mv[0][0][0] = s->next_pic.motion_val[0][xy][0] *  time_pb            / time_pp;\n                    s->mv[0][0][1] = s->next_pic.motion_val[0][xy][1] *  time_pb            / time_pp;\n                    s->mv[1][0][0] = s->next_pic.motion_val[0][xy][0] * (time_pb - time_pp) / time_pp;\n                    s->mv[1][0][1] = s->next_pic.motion_val[0][xy][1] * (time_pb - time_pp) / time_pp;\n                } else {\n                    s->mv[0][0][0] = 0;\n                    s->mv[0][0][1] = 0;\n                    s->mv[1][0][0] = 0;\n                    s->mv[1][0][1] = 0;\n                }\n                s->decode_mb(s->opaque, 0, mv_dir, MV_TYPE_16X16, &s->mv,\n                             mb_x, mb_y, 0, 0);\n            }\n        }\n    } else\n        guess_mv(s);\n#if FF_API_XVMC\nFF_DISABLE_DEPRECATION_WARNINGS\n    if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)\n        goto ec_clean;\nFF_ENABLE_DEPRECATION_WARNINGS\n#endif\n    for (mb_y = 0; mb_y < s->mb_height; mb_y++) {\n        for (mb_x = 0; mb_x < s->mb_width; mb_x++) {\n            int dc, dcu, dcv, y, n;\n            int16_t *dc_ptr;\n            uint8_t *dest_y, *dest_cb, *dest_cr;\n            const int mb_xy   = mb_x + mb_y * s->mb_stride;\n            const int mb_type = s->cur_pic.mb_type[mb_xy];\n            error = s->error_status_table[mb_xy];\n            if (IS_INTRA(mb_type) && s->partitioned_frame)\n                continue;\n            dest_y  = s->cur_pic.f->data[0] + mb_x * 16 + mb_y * 16 * linesize[0];\n            dest_cb = s->cur_pic.f->data[1] + mb_x *  8 + mb_y *  8 * linesize[1];\n            dest_cr = s->cur_pic.f->data[2] + mb_x *  8 + mb_y *  8 * linesize[2];\n            dc_ptr = &s->dc_val[0][mb_x * 2 + mb_y * 2 * s->b8_stride];\n            for (n = 0; n < 4; n++) {\n                dc = 0;\n                for (y = 0; y < 8; y++) {\n                    int x;\n                    for (x = 0; x < 8; x++)\n                       dc += dest_y[x + (n & 1) * 8 +\n                             (y + (n >> 1) * 8) * linesize[0]];\n                }\n                dc_ptr[(n & 1) + (n >> 1) * s->b8_stride] = (dc + 4) >> 3;\n            }\n            dcu = dcv = 0;\n            for (y = 0; y < 8; y++) {\n                int x;\n                for (x = 0; x < 8; x++) {\n                    dcu += dest_cb[x + y * linesize[1]];\n                    dcv += dest_cr[x + y * linesize[2]];\n                }\n            }\n            s->dc_val[1][mb_x + mb_y * s->mb_stride] = (dcu + 4) >> 3;\n            s->dc_val[2][mb_x + mb_y * s->mb_stride] = (dcv + 4) >> 3;\n        }\n    }\n    guess_dc(s, s->dc_val[0], s->mb_width * 2, s->mb_height * 2, s->b8_stride, 1);\n    guess_dc(s, s->dc_val[1], s->mb_width, s->mb_height, s->mb_stride, 0);\n    guess_dc(s, s->dc_val[2], s->mb_width, s->mb_height, s->mb_stride, 0);\n    filter181(s->dc_val[0], s->mb_width * 2, s->mb_height * 2, s->b8_stride);\n    for (mb_y = 0; mb_y < s->mb_height; mb_y++) {\n        for (mb_x = 0; mb_x < s->mb_width; mb_x++) {\n            uint8_t *dest_y, *dest_cb, *dest_cr;\n            const int mb_xy   = mb_x + mb_y * s->mb_stride;\n            const int mb_type = s->cur_pic.mb_type[mb_xy];\n            error = s->error_status_table[mb_xy];\n            if (IS_INTER(mb_type))\n                continue;\n            if (!(error & ER_AC_ERROR))\n                continue;\n            dest_y  = s->cur_pic.f->data[0] + mb_x * 16 + mb_y * 16 * linesize[0];\n            dest_cb = s->cur_pic.f->data[1] + mb_x *  8 + mb_y *  8 * linesize[1];\n            dest_cr = s->cur_pic.f->data[2] + mb_x *  8 + mb_y *  8 * linesize[2];\n            put_dc(s, dest_y, dest_cb, dest_cr, mb_x, mb_y);\n        }\n    }\n    if (s->avctx->error_concealment & FF_EC_DEBLOCK) {\n        h_block_filter(s, s->cur_pic.f->data[0], s->mb_width * 2,\n                       s->mb_height * 2, linesize[0], 1);\n        h_block_filter(s, s->cur_pic.f->data[1], s->mb_width,\n                       s->mb_height, linesize[1], 0);\n        h_block_filter(s, s->cur_pic.f->data[2], s->mb_width,\n                       s->mb_height, linesize[2], 0);\n        v_block_filter(s, s->cur_pic.f->data[0], s->mb_width * 2,\n                       s->mb_height * 2, linesize[0], 1);\n        v_block_filter(s, s->cur_pic.f->data[1], s->mb_width,\n                       s->mb_height, linesize[1], 0);\n        v_block_filter(s, s->cur_pic.f->data[2], s->mb_width,\n                       s->mb_height, linesize[2], 0);\n    }\n#if FF_API_XVMC\nec_clean:\n#endif\n    for (i = 0; i < s->mb_num; i++) {\n        const int mb_xy = s->mb_index2xy[i];\n        int       error = s->error_status_table[mb_xy];\n        if (s->mbskip_table && s->cur_pic.f->pict_type != AV_PICTURE_TYPE_B &&\n            (error & (ER_DC_ERROR | ER_MV_ERROR | ER_AC_ERROR))) {\n            s->mbskip_table[mb_xy] = 0;\n        }\n        if (s->mbintra_table)\n            s->mbintra_table[mb_xy] = 1;\n    }\n    memset(&s->cur_pic, 0, sizeof(ERPicture));\n    memset(&s->last_pic, 0, sizeof(ERPicture));\n    memset(&s->next_pic, 0, sizeof(ERPicture));\n}', 'static void v_block_filter(ERContext *s, uint8_t *dst, int w, int h,\n                           int stride, int is_luma)\n{\n    int b_x, b_y, mvx_stride, mvy_stride;\n    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\n    set_mv_strides(s, &mvx_stride, &mvy_stride);\n    mvx_stride >>= is_luma;\n    mvy_stride *= mvx_stride;\n    for (b_y = 0; b_y < h - 1; b_y++) {\n        for (b_x = 0; b_x < w; b_x++) {\n            int x;\n            int top_status    = s->error_status_table[(b_x >> is_luma) +  (b_y      >> is_luma) * s->mb_stride];\n            int bottom_status = s->error_status_table[(b_x >> is_luma) + ((b_y + 1) >> is_luma) * s->mb_stride];\n            int top_intra     = IS_INTRA(s->cur_pic.mb_type[(b_x >> is_luma) + ( b_y      >> is_luma) * s->mb_stride]);\n            int bottom_intra  = IS_INTRA(s->cur_pic.mb_type[(b_x >> is_luma) + ((b_y + 1) >> is_luma) * s->mb_stride]);\n            int top_damage    = top_status & ER_MB_ERROR;\n            int bottom_damage = bottom_status & ER_MB_ERROR;\n            int offset        = b_x * 8 + b_y * stride * 8;\n            int16_t *top_mv    = s->cur_pic.motion_val[0][mvy_stride *  b_y      + mvx_stride * b_x];\n            int16_t *bottom_mv = s->cur_pic.motion_val[0][mvy_stride * (b_y + 1) + mvx_stride * b_x];\n            if (!(top_damage || bottom_damage))\n                continue;\n            if ((!top_intra) && (!bottom_intra) &&\n                FFABS(top_mv[0] - bottom_mv[0]) +\n                FFABS(top_mv[1] + bottom_mv[1]) < 2)\n                continue;\n            for (x = 0; x < 8; x++) {\n                int a, b, c, d;\n                a = dst[offset + x + 7 * stride] - dst[offset + x + 6 * stride];\n                b = dst[offset + x + 8 * stride] - dst[offset + x + 7 * stride];\n                c = dst[offset + x + 9 * stride] - dst[offset + x + 8 * stride];\n                d = FFABS(b) - ((FFABS(a) + FFABS(c) + 1) >> 1);\n                d = FFMAX(d, 0);\n                if (b < 0)\n                    d = -d;\n                if (d == 0)\n                    continue;\n                if (!(top_damage && bottom_damage))\n                    d = d * 16 / 9;\n                if (top_damage) {\n                    dst[offset + x +  7 * stride] = cm[dst[offset + x +  7 * stride] + ((d * 7) >> 4)];\n                    dst[offset + x +  6 * stride] = cm[dst[offset + x +  6 * stride] + ((d * 5) >> 4)];\n                    dst[offset + x +  5 * stride] = cm[dst[offset + x +  5 * stride] + ((d * 3) >> 4)];\n                    dst[offset + x +  4 * stride] = cm[dst[offset + x +  4 * stride] + ((d * 1) >> 4)];\n                }\n                if (bottom_damage) {\n                    dst[offset + x +  8 * stride] = cm[dst[offset + x +  8 * stride] - ((d * 7) >> 4)];\n                    dst[offset + x +  9 * stride] = cm[dst[offset + x +  9 * stride] - ((d * 5) >> 4)];\n                    dst[offset + x + 10 * stride] = cm[dst[offset + x + 10 * stride] - ((d * 3) >> 4)];\n                    dst[offset + x + 11 * stride] = cm[dst[offset + x + 11 * stride] - ((d * 1) >> 4)];\n                }\n            }\n        }\n    }\n}']