libavcodec/h264dec.c:761: error: Integer Overflow L2
  (3 × [8, 2147483648]):signed32 by call to `ff_h264_field_end`.

libavcodec/h264dec.c:742:17: Call
740.     }
741. 
742.     buf_index = decode_nal_units(h, buf, buf_size);
                     ^
743.     if (buf_index < 0)
744.         return AVERROR_INVALIDDATA;

libavcodec/h264dec.c:528:11: Call
  526.     }
  527. 
  528.     ret = ff_h2645_packet_split(&h->pkt, buf, buf_size, avctx, h->is_avc,
                 ^
  529.                                 h->nal_length_size, avctx->codec_id);
  530.     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:761:13: Call
759.         (h->mb_y >= h->mb_height && h->mb_height)) {
760.         if (h->field_started)
761.             ff_h264_field_end(h, &h->slice_ctx[0], 0);
                 ^
762. 
763.         *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:827:1: <RHS trace>
825. }
826. 
827. void ff_er_frame_end(ERContext *s)
     ^
828. {
829.     int *linesize = s->cur_pic.f->linesize;

libavcodec/error_resilience.c:827:1: Parameter `s->mb_width`
    825. }
    826. 
    827. void ff_er_frame_end(ERContext *s)
         ^
    828. {
    829.     int *linesize = s->cur_pic.f->linesize;

libavcodec/error_resilience.c:842:9: Binary operation: (3 × [8, 2147483648]):signed32 by call to `ff_h264_field_end` 
    840.         !s->cur_pic.f                                                  ||
    841.         s->cur_pic.field_picture                                       ||
    842.         s->error_count == 3 * s->mb_width *
                 ^
    843.                           (s->avctx->skip_top + s->avctx->skip_bottom)) {
    844.         return;

void ff_er_frame_end(ERContext *s)
{
    int *linesize = s->cur_pic.f->linesize;
    int i, mb_x, mb_y, error, error_type, dc_error, mv_error, ac_error;
    int distance;
    int threshold_part[4] = { 100, 100, 100 };
    int threshold = 50;
    int is_intra_likely;
    if (!s->avctx->error_concealment || s->error_count == 0            ||
        s->avctx->hwaccel                                              ||
        !s->cur_pic.f                                                  ||
        s->cur_pic.field_picture                                       ||
        s->error_count == 3 * s->mb_width *
                          (s->avctx->skip_top + s->avctx->skip_bottom)) {
        return;
    };
    if (!s->cur_pic.motion_val[0] || !s->cur_pic.ref_index[0]) {
        av_log(s->avctx, AV_LOG_ERROR, "MVs not available, ER not possible.\n");
        return;
    }
    if (s->avctx->debug & FF_DEBUG_ER) {
        for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
            for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
                int status = s->error_status_table[mb_x + mb_y * s->mb_stride];
                av_log(s->avctx, AV_LOG_DEBUG, "%2X ", status);
            }
            av_log(s->avctx, AV_LOG_DEBUG, "\n");
        }
    }
    for (error_type = 1; error_type <= 3; error_type++) {
        int end_ok = 0;
        for (i = s->mb_num - 1; i >= 0; i--) {
            const int mb_xy = s->mb_index2xy[i];
            int error       = s->error_status_table[mb_xy];
            if (error & (1 << error_type))
                end_ok = 1;
            if (error & (8 << error_type))
                end_ok = 1;
            if (!end_ok)
                s->error_status_table[mb_xy] |= 1 << error_type;
            if (error & VP_START)
                end_ok = 0;
        }
    }
    if (s->partitioned_frame) {
        int end_ok = 0;
        for (i = s->mb_num - 1; i >= 0; i--) {
            const int mb_xy = s->mb_index2xy[i];
            int error       = s->error_status_table[mb_xy];
            if (error & ER_AC_END)
                end_ok = 0;
            if ((error & ER_MV_END) ||
                (error & ER_DC_END) ||
                (error & ER_AC_ERROR))
                end_ok = 1;
            if (!end_ok)
                s->error_status_table[mb_xy]|= ER_AC_ERROR;
            if (error & VP_START)
                end_ok = 0;
        }
    }
    if (s->avctx->err_recognition & AV_EF_EXPLODE) {
        int end_ok = 1;
        for (i = s->mb_num - 2; i >= s->mb_width + 100; i--) {
            const int mb_xy = s->mb_index2xy[i];
            int error1 = s->error_status_table[mb_xy];
            int error2 = s->error_status_table[s->mb_index2xy[i + 1]];
            if (error1 & VP_START)
                end_ok = 1;
            if (error2 == (VP_START | ER_MB_ERROR | ER_MB_END) &&
                error1 != (VP_START | ER_MB_ERROR | ER_MB_END) &&
                ((error1 & ER_AC_END) || (error1 & ER_DC_END) ||
                (error1 & ER_MV_END))) {
                end_ok = 0;
            }
            if (!end_ok)
                s->error_status_table[mb_xy] |= ER_MB_ERROR;
        }
    }
    distance = 9999999;
    for (error_type = 1; error_type <= 3; error_type++) {
        for (i = s->mb_num - 1; i >= 0; i--) {
            const int mb_xy = s->mb_index2xy[i];
            int       error = s->error_status_table[mb_xy];
            if (s->mbskip_table && !s->mbskip_table[mb_xy])
                distance++;
            if (error & (1 << error_type))
                distance = 0;
            if (s->partitioned_frame) {
                if (distance < threshold_part[error_type - 1])
                    s->error_status_table[mb_xy] |= 1 << error_type;
            } else {
                if (distance < threshold)
                    s->error_status_table[mb_xy] |= 1 << error_type;
            }
            if (error & VP_START)
                distance = 9999999;
        }
    }
    error = 0;
    for (i = 0; i < s->mb_num; i++) {
        const int mb_xy = s->mb_index2xy[i];
        int old_error   = s->error_status_table[mb_xy];
        if (old_error & VP_START) {
            error = old_error & ER_MB_ERROR;
        } else {
            error |= old_error & ER_MB_ERROR;
            s->error_status_table[mb_xy] |= error;
        }
    }
    if (!s->partitioned_frame) {
        for (i = 0; i < s->mb_num; i++) {
            const int mb_xy = s->mb_index2xy[i];
            error = s->error_status_table[mb_xy];
            if (error & ER_MB_ERROR)
                error |= ER_MB_ERROR;
            s->error_status_table[mb_xy] = error;
        }
    }
    dc_error = ac_error = mv_error = 0;
    for (i = 0; i < s->mb_num; i++) {
        const int mb_xy = s->mb_index2xy[i];
        error = s->error_status_table[mb_xy];
        if (error & ER_DC_ERROR)
            dc_error++;
        if (error & ER_AC_ERROR)
            ac_error++;
        if (error & ER_MV_ERROR)
            mv_error++;
    }
    av_log(s->avctx, AV_LOG_INFO, "concealing %d DC, %d AC, %d MV errors\n",
           dc_error, ac_error, mv_error);
    is_intra_likely = is_intra_more_likely(s);
    for (i = 0; i < s->mb_num; i++) {
        const int mb_xy = s->mb_index2xy[i];
        error = s->error_status_table[mb_xy];
        if (!((error & ER_DC_ERROR) && (error & ER_MV_ERROR)))
            continue;
        if (is_intra_likely)
            s->cur_pic.mb_type[mb_xy] = MB_TYPE_INTRA4x4;
        else
            s->cur_pic.mb_type[mb_xy] = MB_TYPE_16x16 | MB_TYPE_L0;
    }
    if (!(s->last_pic.f && s->last_pic.f->data[0]) &&
        !(s->next_pic.f && s->next_pic.f->data[0]))
        for (i = 0; i < s->mb_num; i++) {
            const int mb_xy = s->mb_index2xy[i];
            if (!IS_INTRA(s->cur_pic.mb_type[mb_xy]))
                s->cur_pic.mb_type[mb_xy] = MB_TYPE_INTRA4x4;
        }
    for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
        for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
            const int mb_xy   = mb_x + mb_y * s->mb_stride;
            const int mb_type = s->cur_pic.mb_type[mb_xy];
            const int dir     = !(s->last_pic.f && s->last_pic.f->data[0]);
            const int mv_dir  = dir ? MV_DIR_BACKWARD : MV_DIR_FORWARD;
            int mv_type;
            error = s->error_status_table[mb_xy];
            if (IS_INTRA(mb_type))
                continue;
            if (error & ER_MV_ERROR)
                continue;
            if (!(error & ER_AC_ERROR))
                continue;
            if (IS_8X8(mb_type)) {
                int mb_index = mb_x * 2 + mb_y * 2 * s->b8_stride;
                int j;
                mv_type = MV_TYPE_8X8;
                for (j = 0; j < 4; j++) {
                    s->mv[0][j][0] = s->cur_pic.motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][0];
                    s->mv[0][j][1] = s->cur_pic.motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][1];
                }
            } else {
                mv_type     = MV_TYPE_16X16;
                s->mv[0][0][0] = s->cur_pic.motion_val[dir][mb_x * 2 + mb_y * 2 * s->b8_stride][0];
                s->mv[0][0][1] = s->cur_pic.motion_val[dir][mb_x * 2 + mb_y * 2 * s->b8_stride][1];
            }
            s->decode_mb(s->opaque, 0  ,
                         mv_dir, mv_type, &s->mv, mb_x, mb_y, 0, 0);
        }
    }
    if (s->cur_pic.f->pict_type == AV_PICTURE_TYPE_B) {
        for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
            for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
                int       xy      = mb_x * 2 + mb_y * 2 * s->b8_stride;
                const int mb_xy   = mb_x + mb_y * s->mb_stride;
                const int mb_type = s->cur_pic.mb_type[mb_xy];
                int mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
                error = s->error_status_table[mb_xy];
                if (IS_INTRA(mb_type))
                    continue;
                if (!(error & ER_MV_ERROR))
                    continue;
                if (!(error & ER_AC_ERROR))
                    continue;
                if (!(s->last_pic.f && s->last_pic.f->data[0]))
                    mv_dir &= ~MV_DIR_FORWARD;
                if (!(s->next_pic.f && s->next_pic.f->data[0]))
                    mv_dir &= ~MV_DIR_BACKWARD;
                if (s->pp_time) {
                    int time_pp = s->pp_time;
                    int time_pb = s->pb_time;
                    ff_thread_await_progress(s->next_pic.tf, mb_y, 0);
                    s->mv[0][0][0] = s->next_pic.motion_val[0][xy][0] *  time_pb            / time_pp;
                    s->mv[0][0][1] = s->next_pic.motion_val[0][xy][1] *  time_pb            / time_pp;
                    s->mv[1][0][0] = s->next_pic.motion_val[0][xy][0] * (time_pb - time_pp) / time_pp;
                    s->mv[1][0][1] = s->next_pic.motion_val[0][xy][1] * (time_pb - time_pp) / time_pp;
                } else {
                    s->mv[0][0][0] = 0;
                    s->mv[0][0][1] = 0;
                    s->mv[1][0][0] = 0;
                    s->mv[1][0][1] = 0;
                }
                s->decode_mb(s->opaque, 0, mv_dir, MV_TYPE_16X16, &s->mv,
                             mb_x, mb_y, 0, 0);
            }
        }
    } else
        guess_mv(s);
#if FF_API_XVMC
FF_DISABLE_DEPRECATION_WARNINGS
    if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
        goto ec_clean;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
    for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
        for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
            int dc, dcu, dcv, y, n;
            int16_t *dc_ptr;
            uint8_t *dest_y, *dest_cb, *dest_cr;
            const int mb_xy   = mb_x + mb_y * s->mb_stride;
            const int mb_type = s->cur_pic.mb_type[mb_xy];
            error = s->error_status_table[mb_xy];
            if (IS_INTRA(mb_type) && s->partitioned_frame)
                continue;
            dest_y  = s->cur_pic.f->data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
            dest_cb = s->cur_pic.f->data[1] + mb_x *  8 + mb_y *  8 * linesize[1];
            dest_cr = s->cur_pic.f->data[2] + mb_x *  8 + mb_y *  8 * linesize[2];
            dc_ptr = &s->dc_val[0][mb_x * 2 + mb_y * 2 * s->b8_stride];
            for (n = 0; n < 4; n++) {
                dc = 0;
                for (y = 0; y < 8; y++) {
                    int x;
                    for (x = 0; x < 8; x++)
                       dc += dest_y[x + (n & 1) * 8 +
                             (y + (n >> 1) * 8) * linesize[0]];
                }
                dc_ptr[(n & 1) + (n >> 1) * s->b8_stride] = (dc + 4) >> 3;
            }
            dcu = dcv = 0;
            for (y = 0; y < 8; y++) {
                int x;
                for (x = 0; x < 8; x++) {
                    dcu += dest_cb[x + y * linesize[1]];
                    dcv += dest_cr[x + y * linesize[2]];
                }
            }
            s->dc_val[1][mb_x + mb_y * s->mb_stride] = (dcu + 4) >> 3;
            s->dc_val[2][mb_x + mb_y * s->mb_stride] = (dcv + 4) >> 3;
        }
    }
    guess_dc(s, s->dc_val[0], s->mb_width * 2, s->mb_height * 2, s->b8_stride, 1);
    guess_dc(s, s->dc_val[1], s->mb_width, s->mb_height, s->mb_stride, 0);
    guess_dc(s, s->dc_val[2], s->mb_width, s->mb_height, s->mb_stride, 0);
    filter181(s->dc_val[0], s->mb_width * 2, s->mb_height * 2, s->b8_stride);
    for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
        for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
            uint8_t *dest_y, *dest_cb, *dest_cr;
            const int mb_xy   = mb_x + mb_y * s->mb_stride;
            const int mb_type = s->cur_pic.mb_type[mb_xy];
            error = s->error_status_table[mb_xy];
            if (IS_INTER(mb_type))
                continue;
            if (!(error & ER_AC_ERROR))
                continue;
            dest_y  = s->cur_pic.f->data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
            dest_cb = s->cur_pic.f->data[1] + mb_x *  8 + mb_y *  8 * linesize[1];
            dest_cr = s->cur_pic.f->data[2] + mb_x *  8 + mb_y *  8 * linesize[2];
            put_dc(s, dest_y, dest_cb, dest_cr, mb_x, mb_y);
        }
    }
    if (s->avctx->error_concealment & FF_EC_DEBLOCK) {
        h_block_filter(s, s->cur_pic.f->data[0], s->mb_width * 2,
                       s->mb_height * 2, linesize[0], 1);
        h_block_filter(s, s->cur_pic.f->data[1], s->mb_width,
                       s->mb_height, linesize[1], 0);
        h_block_filter(s, s->cur_pic.f->data[2], s->mb_width,
                       s->mb_height, linesize[2], 0);
        v_block_filter(s, s->cur_pic.f->data[0], s->mb_width * 2,
                       s->mb_height * 2, linesize[0], 1);
        v_block_filter(s, s->cur_pic.f->data[1], s->mb_width,
                       s->mb_height, linesize[1], 0);
        v_block_filter(s, s->cur_pic.f->data[2], s->mb_width,
                       s->mb_height, linesize[2], 0);
    }
#if FF_API_XVMC
ec_clean:
#endif
    for (i = 0; i < s->mb_num; i++) {
        const int mb_xy = s->mb_index2xy[i];
        int       error = s->error_status_table[mb_xy];
        if (s->mbskip_table && s->cur_pic.f->pict_type != AV_PICTURE_TYPE_B &&
            (error & (ER_DC_ERROR | ER_MV_ERROR | ER_AC_ERROR))) {
            s->mbskip_table[mb_xy] = 0;
        }
        if (s->mbintra_table)
            s->mbintra_table[mb_xy] = 1;
    }
    memset(&s->cur_pic, 0, sizeof(ERPicture));
    memset(&s->last_pic, 0, sizeof(ERPicture));
    memset(&s->next_pic, 0, sizeof(ERPicture));
}
['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        if (h->field_started)\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        if (h->is_avc && !(avctx->err_recognition & AV_EF_EXPLODE)) {\n            int err = ff_h2645_packet_split(&h->pkt, buf, buf_size, avctx, 0, 0,\n                                            avctx->codec_id);\n            if (err >= 0) {\n                av_log(avctx, AV_LOG_WARNING,\n                       "The stream seems to contain AVCC extradata with Annex B "\n                       "formatted data, which is invalid.");\n                h->is_avc = 0;\n                ret       = 0;\n            }\n        }\n        if (ret < 0)\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 &&\n                i >= nals_needed && !h->setup_finished && h->cur_pic_ptr) {\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                    h->nb_slice_ctx_queued = 0;\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    h->field_started = 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}']