X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fh264_slice.c;h=ac3c50ce515ec716db7f3f5b7df0d0a4e9bd9ae6;hb=68f48406069e9aff0c01c96671f7c58de166e1f8;hp=c10568a4ed16b21bbdcf47358787ad3a113cd75c;hpb=53bf6b155cee8cdf0fd12fe49e4ccfb9cf6714a2;p=ffmpeg diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index c10568a4ed1..ac3c50ce515 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -583,6 +583,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst, return ret; } + h->enable_er = h1->enable_er; h->workaround_bugs = h1->workaround_bugs; h->low_delay = h1->low_delay; h->droppable = h1->droppable; @@ -711,7 +712,7 @@ static int h264_frame_start(H264Context *h) h->slice_ctx[i].uvlinesize = h->cur_pic_ptr->f.linesize[1]; } - if (CONFIG_ERROR_RESILIENCE) { + if (CONFIG_ERROR_RESILIENCE && h->enable_er) { ff_er_frame_start(&h->slice_ctx[0].er); ff_h264_set_erpic(&h->slice_ctx[0].er.last_pic, NULL); ff_h264_set_erpic(&h->slice_ctx[0].er.next_pic, NULL); @@ -1205,11 +1206,21 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl) first_mb_in_slice = get_ue_golomb_long(&sl->gb); if (first_mb_in_slice == 0) { // FIXME better field boundary detection - if (h->current_slice && h->cur_pic_ptr && FIELD_PICTURE(h)) { - ff_h264_field_end(h, sl, 1); + if (h->current_slice) { + if (h->cur_pic_ptr && FIELD_PICTURE(h) && h->first_field) { + ff_h264_field_end(h, sl, 1); + h->current_slice = 0; + } else if (h->cur_pic_ptr && !FIELD_PICTURE(h) && !h->first_field && h->nal_unit_type == NAL_IDR_SLICE) { + av_log(h, AV_LOG_WARNING, "Broken frame packetizing\n"); + ff_h264_field_end(h, sl, 1); + h->current_slice = 0; + ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 0); + ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 1); + h->cur_pic_ptr = NULL; + } else + return AVERROR_INVALIDDATA; } - h->current_slice = 0; if (!h->first_field) { if (h->cur_pic_ptr && !h->droppable) { ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, @@ -2283,6 +2294,9 @@ static void er_add_slice(H264SliceContext *sl, int startx, int starty, int endx, int endy, int status) { + if (!sl->h264->enable_er) + return; + if (CONFIG_ERROR_RESILIENCE) { ERContext *er = &sl->er;