From patchwork Mon Jan 23 23:38:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 2299 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp1472206vsb; Mon, 23 Jan 2017 15:38:28 -0800 (PST) X-Received: by 10.28.173.74 with SMTP id w71mr14597765wme.14.1485214708465; Mon, 23 Jan 2017 15:38:28 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g93si20481555wrd.216.2017.01.23.15.38.27; Mon, 23 Jan 2017 15:38:28 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8FE9D68A246; Tue, 24 Jan 2017 01:38:24 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe01-1.mx.upcmail.net (vie01a-dmta-pe01-1.mx.upcmail.net [62.179.121.154]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2B26468A211 for ; Tue, 24 Jan 2017 01:38:18 +0200 (EET) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe01.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1cVoBl-00074p-BH for ffmpeg-devel@ffmpeg.org; Tue, 24 Jan 2017 00:38:17 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id bzeG1u00B0S5wYM01zeHSG; Tue, 24 Jan 2017 00:38:17 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 24 Jan 2017 00:38:15 +0100 Message-Id: <20170123233815.14644-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.11.0 Subject: [FFmpeg-devel] [PATCH] avcodec/h264dec: Fix regression with "make fate-h264-attachment-631 THREADS=8" X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This treats the case of no slices like no frames which it basically is. The field is added to the context as other nal related fields are also there and passing the has_slices field per *arguments is ugly and not consistent Found-by: ubitux Signed-off-by: Michael Niedermayer --- libavcodec/h264dec.c | 6 ++++-- libavcodec/h264dec.h | 2 ++ tests/fate/h264.mak | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 4ecaec267c..41e6ce458c 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -607,6 +607,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size) int idr_cleared=0; int i, ret = 0; + h->has_slice = 0; h->nal_unit_type= 0; h->max_contexts = h->nb_slice_ctx; @@ -672,6 +673,7 @@ again: h->has_recovery_point = 1; case H264_NAL_SLICE: sl->gb = nal->gb; + h->has_slice = 1; if ((err = ff_h264_decode_slice_header(h, sl, nal))) break; @@ -839,7 +841,7 @@ end: } #endif /* CONFIG_ERROR_RESILIENCE */ /* clean up */ - if (h->cur_pic_ptr && !h->droppable) { + if (h->cur_pic_ptr && !h->droppable && h->has_slice) { ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, h->picture_structure == PICT_BOTTOM_FIELD); } @@ -1055,7 +1057,7 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data, return send_next_delayed_frame(h, pict, got_frame, buf_index); } - if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) && !h->cur_pic_ptr) { + if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) && (!h->cur_pic_ptr || !h->has_slice)) { if (avctx->skip_frame >= AVDISCARD_NONREF || buf_size >= 4 && !memcmp("Q264", buf, 4)) return buf_size; diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h index c8b7e663b3..fa5c98ee90 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -446,6 +446,8 @@ typedef struct H264Context { int nal_ref_idc; int nal_unit_type; + int has_slice; ///< slice NAL is found in the packet, set by decode_nal_units, its state does not need to be preserved outside h264_decode_frame() + /** * Used to parse AVC variant of H.264 */ diff --git a/tests/fate/h264.mak b/tests/fate/h264.mak index d40681f9c9..1f6e5f3947 100644 --- a/tests/fate/h264.mak +++ b/tests/fate/h264.mak @@ -424,7 +424,7 @@ fate-h264-extreme-plane-pred: CMD = framemd5 -i $(TARGET_SAM fate-h264-interlace-crop: CMD = framecrc -i $(TARGET_SAMPLES)/h264/interlaced_crop.mp4 -vframes 3 fate-h264-brokensps-2580: CMD = framecrc -i $(TARGET_SAMPLES)/h264/brokensps.flv -vf format=yuv420p,scale=w=192:h=144 -sws_flags bitexact+bilinear fate-h264-xavc-4389: CMD = framecrc -i $(TARGET_SAMPLES)/h264/SonyXAVC_LongGOP_green_pixelation_early_Frames.MXF -pix_fmt yuv422p10le -fate-h264-attachment-631: CMD = framecrc -i $(TARGET_SAMPLES)/h264/attachment631-small.mp4 -an -max_error_rate 0.95 +fate-h264-attachment-631: CMD = framecrc -i $(TARGET_SAMPLES)/h264/attachment631-small.mp4 -an -max_error_rate 0.96 fate-h264-skip-nokey: CMD = framecrc -skip_frame nokey -i $(TARGET_SAMPLES)/h264/h264_intra_first-small.ts fate-h264-skip-nointra: CMD = framecrc -skip_frame nointra -i $(TARGET_SAMPLES)/h264/h264_intra_first-small.ts fate-h264-intra-refresh-recovery: CMD = framecrc -i $(TARGET_SAMPLES)/h264/intra_refresh.h264 -frames:v 10