From patchwork Thu Mar 28 12:13:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Decai Lin X-Patchwork-Id: 12516 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id DB739447800 for ; Thu, 28 Mar 2019 14:15:24 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C4A8C68A924; Thu, 28 Mar 2019 14:15:24 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 51FED68A5F3 for ; Thu, 28 Mar 2019 14:15:18 +0200 (EET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2019 05:15:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,280,1549958400"; d="scan'208";a="311133929" Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([172.16.181.59]) by orsmga005.jf.intel.com with ESMTP; 28 Mar 2019 05:15:15 -0700 From: Decai Lin To: ffmpeg-devel@ffmpeg.org Date: Thu, 28 Mar 2019 20:13:28 +0800 Message-Id: <1553775208-25791-1-git-send-email-decai.lin@intel.com> X-Mailer: git-send-email 1.8.3.1 Subject: [FFmpeg-devel] [PATCH v1 1/1] avcodec/h264: workaround if the IDR frame_num is non-zero for some error clips. 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 Cc: Decai Lin MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Decai Lin --- libavcodec/h264_slice.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 1c9a270..1bc9bdb 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1477,6 +1477,11 @@ static int h264_field_start(H264Context *h, const H264SliceContext *sl, /* Shorten frame num gaps so we don't have to allocate reference * frames just to throw them away */ if (h->poc.frame_num != h->poc.prev_frame_num) { + /* In case for some error clips the IDR frame_num is not-zero, set the + * prev_frame_num = frame_num -1; otherwise will generate frame num gap. */ + if (nal->type == H264_NAL_IDR_SLICE && h->poc.frame_num != 0) + h->poc.prev_frame_num = h->poc.frame_num - 1; + int unwrap_prev_frame_num = h->poc.prev_frame_num; int max_frame_num = 1 << sps->log2_max_frame_num;