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 ED6DD48226 for ; Tue, 14 Nov 2023 17:21:01 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BBF3968CD33; Tue, 14 Nov 2023 19:20:59 +0200 (EET) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0D5E068CBCB for ; Tue, 14 Nov 2023 19:20:53 +0200 (EET) Received: by mail.gandi.net (Postfix) with ESMTPSA id 2A3CDFF80A for ; Tue, 14 Nov 2023 17:20:51 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 14 Nov 2023 18:20:46 +0100 Message-Id: <20231114172051.13872-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 1/6] avcodec/h264: Seperate SEI and IDR recovery handling 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: This avoids SEI and IDR recovery flags affecting each other Also eliminate litteral numbers from recovery handling This should make the code clearer Improves: tickets/4738/tickets_cut.ts Signed-off-by: Michael Niedermayer --- libavcodec/h264_refs.c | 2 +- libavcodec/h264_slice.c | 30 ++++++++++++++++-------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c index a11597745c8..25e521dafc0 100644 --- a/libavcodec/h264_refs.c +++ b/libavcodec/h264_refs.c @@ -822,7 +822,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h) || pps_ref_count[0] <= 1 + (h->picture_structure != PICT_FRAME) && pps_ref_count[1] <= 1) && pps_ref_count[0]<=2 + (h->picture_structure != PICT_FRAME) + (2*!h->has_recovery_point) && h->cur_pic_ptr->f->pict_type == AV_PICTURE_TYPE_I){ - h->cur_pic_ptr->recovered |= 1; + h->cur_pic_ptr->recovered |= FRAME_RECOVERED_IDR; if(!h->avctx->has_b_frames) h->frame_recovered |= FRAME_RECOVERED_SEI; } diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 07cc1b094f9..4861a2cabba 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1356,12 +1356,11 @@ static int h264_select_output_frame(H264Context *h) } else h->next_outputed_poc = out->poc; - if (out->recovered) { - // We have reached an recovery point and all frames after it in - // display order are "recovered". - h->frame_recovered |= FRAME_RECOVERED_SEI; - } - out->recovered |= !!(h->frame_recovered & FRAME_RECOVERED_SEI); + // We have reached an recovery point and all frames after it in + // display order are "recovered". + h->frame_recovered |= out->recovered; + + out->recovered |= h->frame_recovered & FRAME_RECOVERED_SEI; if (!out->recovered) { if (!(h->avctx->flags & AV_CODEC_FLAG_OUTPUT_CORRUPT) && @@ -1643,15 +1642,18 @@ static int h264_field_start(H264Context *h, const H264SliceContext *sl, h->cur_pic_ptr->f->flags |= AV_FRAME_FLAG_KEY * !!(nal->type == H264_NAL_IDR_SLICE); - if (nal->type == H264_NAL_IDR_SLICE || - (h->recovery_frame == h->poc.frame_num && nal->ref_idc)) { - h->recovery_frame = -1; - h->cur_pic_ptr->recovered = 1; - } - // If we have an IDR, all frames after it in decoded order are - // "recovered". - if (nal->type == H264_NAL_IDR_SLICE) + if (nal->type == H264_NAL_IDR_SLICE) { + h->cur_pic_ptr->recovered |= FRAME_RECOVERED_IDR; + // If we have an IDR, all frames after it in decoded order are + // "recovered". h->frame_recovered |= FRAME_RECOVERED_IDR; + } + + if (h->recovery_frame == h->poc.frame_num && nal->ref_idc) { + h->recovery_frame = -1; + h->cur_pic_ptr->recovered |= FRAME_RECOVERED_SEI; + } + #if 1 h->cur_pic_ptr->recovered |= h->frame_recovered; #else -- 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".