From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 343E848226 for ; Tue, 14 Nov 2023 17:21:37 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B065068CD83; Tue, 14 Nov 2023 19:21:05 +0200 (EET) Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C95CA68CD69 for ; Tue, 14 Nov 2023 19:20:56 +0200 (EET) Received: by mail.gandi.net (Postfix) with ESMTPSA id 03C5F40003 for ; Tue, 14 Nov 2023 17:20:55 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 14 Nov 2023 18:20:50 +0100 Message-Id: <20231114172051.13872-5-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231114172051.13872-1-michael@niedermayer.cc> References: <20231114172051.13872-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 5/6] avcodec/h264: Avoid using gray gap frames as references X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Signed-off-by: Michael Niedermayer --- libavcodec/h264_refs.c | 11 +++++++++++ libavcodec/h264dec.c | 1 + libavcodec/h264dec.h | 1 + 3 files changed, 13 insertions(+) diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c index 92778e737a5..9bc7b20988f 100644 --- a/libavcodec/h264_refs.c +++ b/libavcodec/h264_refs.c @@ -410,6 +410,17 @@ int ff_h264_build_ref_list(H264Context *h, H264SliceContext *sl) else return -1; } + if (h->noref_gray>0 && sl->ref_list[list][index].parent->gray && h->non_gray) { + for (int j=0; jlist_count; j++) { + int list2 = (list+j)&1; + if (h->default_ref[list2].parent && !h->default_ref[list2].parent->gray + && !(!FIELD_PICTURE(h) && (h->default_ref[list2].reference&3) != 3)) { + sl->ref_list[list][index] = h->default_ref[list2]; + av_log(h, AV_LOG_DEBUG, "replacement of gray gap frame\n"); + break; + } + } + } av_assert0(av_buffer_get_ref_count(sl->ref_list[list][index].parent->f->buf[0]) > 0); } } diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 7ea55db75dd..b48821db244 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -1091,6 +1091,7 @@ static const AVOption h264_options[] = { { "nal_length_size", "nal_length_size", OFFSET(nal_length_size), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, VDX }, { "enable_er", "Enable error resilience on damaged frames (unsafe)", OFFSET(enable_er), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VD }, { "x264_build", "Assume this x264 version if no x264 version found in any SEI", OFFSET(x264_build), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VD }, + { "noref_gray", "Avoid using gray gap frames as references", OFFSET(noref_gray), AV_OPT_TYPE_INT, {.i64 = 1}, -1, 1, VD }, { NULL }, }; diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h index 366626c056c..591769ab258 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -571,6 +571,7 @@ typedef struct H264Context { int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1 int non_gray; ///< Did we encounter a intra frame after a gray gap frame + int noref_gray; } H264Context; extern const uint16_t ff_h264_mb_sizes[4]; -- 2.17.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".