From patchwork Fri Jun 7 13:01:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 49668 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c209:0:b0:460:55fa:d5ed with SMTP id d9csp1012743vqo; Fri, 7 Jun 2024 06:10:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVbOi2S36FGZAmkpRh/M1nYRIR3zfmZMrHdd5zN95cv9EvJNsbyFbtyzg+R3xkOc1Au05QJxvGO03xo2/fvdmZdw1b/svnQ/ANvPg== X-Google-Smtp-Source: AGHT+IHWtmSrsoIQSHViHU0/TL5NBObg3b0CJv37H0JuMc2BjMTfOAbdokTinGDRTlI7wTfp2RvC X-Received: by 2002:a17:906:749:b0:a55:9dec:355f with SMTP id a640c23a62f3a-a6cdc0e203cmr148513766b.70.1717765808084; Fri, 07 Jun 2024 06:10:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717765808; cv=none; d=google.com; s=arc-20160816; b=mQ6Fxyxzo0uShqfE1EG5eFyVG5Zw+wqG5lIBsfHBB1sWWlMoBtWy3KdUylQ40/RRRn C1uhwLaIF0nLHT+XoTqvj9c9bsN1DY1pE4Uv/jXc91/c0SqfkRK2pt6GP7k7MTk6znIN 6++zvqxOZqqExEGTQ5wu8idGh2ILVtufevqzN9L4MjWWSUehnz51iis6HZoSYqWWFBjs QIfsIJw9Wz186xKXyu2onXUCLnJY3OiUDrOVuTKx3MQ6WzytVRMR8ukd83Qj31Zrr6pJ 8QdVGYOaKk46uHM9f6+m4DTFyeVG12VV3ffY1Yh0GEJ3iBHtxKezZtW0wqGp99QAlp3T U4LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=VrA6iHsOGmqat2wafNpqL60/sTOlJApJQs73rAtj+70=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Ao6lfrCI4II7Bc6XX+i6bRQnefORY1XILB+6jVpu50f4fcTThUyykf7NQShqjY3W5j ETOoHk2aUs7LsYyKMIQKYMtGUr5XxTwyDUEtbzGTjuZZWwkbZ4x7MxBAFiKBLzImhEq3 95RQ1w3eG8ZSmU2i5QhQZHbxB2xapFd813dCkKGfB8RCfrL5Zlj8CPvgjV9RYBoMnDnf r9GL+FQ0Dg6HBWzJBR6AIAqriUB++wBG3AU8d1uBa3wws2Bqx6lddT3Pnkq28lsw5OpI hM+Oqa/3GHXHRVz/pVHtj6cd7Ue+MHi9t9Pm5CaxccmzVgMvKDK/1cw/UfzV8sVUgtPf XO6Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=kl6Q9m+d; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a6c806dba44si172836266b.282.2024.06.07.06.10.07; Fri, 07 Jun 2024 06:10:08 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=kl6Q9m+d; 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 5EA7468D870; Fri, 7 Jun 2024 16:04:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 113D068D7E6 for ; Fri, 7 Jun 2024 16:03:50 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=kl6Q9m+d; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id DF9504DBC for ; Fri, 7 Jun 2024 15:03:46 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id Vs8kyNknjOQq for ; Fri, 7 Jun 2024 15:03:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1717765422; bh=s0IW8zJI+GDMHWF/Em71DjO0UCErHeiBWu12dlDVqqI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kl6Q9m+dVrLgGvfZpCY4sGvz6tqrBT82hY7xhEkZyWXCT6wzlxPfmb9Rzg1MWwnvH 5N1oiAbc+Ehe6LCUY4Q5IdpycYSIxh8lfO+f4MTgJe1g7TN2t8XMHHdZJUhfuiHCuG yHCR7KYOHaa0jAqol3rLQZ7UBvOm195wCV9IC35R9Ck4s0/ZtJePBQq59MeOVhu4cr 9AA27fouOtmR+KBb//2o2dvXrZo4Lw7HNNxDoQ8vZDrEOZJZiiC0pSKzcU2fbWK5Dv iTg2Yj9JEleKuMhqR9fV+xP+fIVw2V4nWds+AwWJjYM6JZD9C4GU8hCams5PZTX+hD 2Bu5vusCepRZA== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 064584DF5 for ; Fri, 7 Jun 2024 15:03:41 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 4E82C3A155A for ; Fri, 07 Jun 2024 15:03:35 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 7 Jun 2024 15:01:17 +0200 Message-ID: <20240607130135.9088-21-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240607130135.9088-1-anton@khirnov.net> References: <20240607130135.9088-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 21/39] lavc/hevcdec: output RASL frames based on the value of no_rasl_output_flag 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: xj9s5mCbkK/Z Instead of an ad-hoc scheme. Also, combine skipping RASL frames with skip_frame handling - current code seems flawed as it only executes for the first slice of a RASL frame and unnecessarily unsets is_decoded, which should not be set at this point anyway.. Some RASL frames in fate-hevc-afd-tc-sei that were previously discarded are now output. --- libavcodec/hevc/hevcdec.c | 33 ++++--------------------------- libavcodec/hevc/hevcdec.h | 1 - tests/ref/fate/hevc-afd-tc-sei | 36 ++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c index d444ea93f7..a57fa4e539 100644 --- a/libavcodec/hevc/hevcdec.c +++ b/libavcodec/hevc/hevcdec.c @@ -605,7 +605,6 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) if ((IS_IDR(s) || IS_BLA(s)) && sh->first_slice_in_pic_flag) { s->seq_decode = (s->seq_decode + 1) & HEVC_SEQUENCE_COUNTER_MASK; - s->max_ra = INT_MAX; if (IS_IDR(s)) ff_hevc_clear_refs(s); } @@ -645,7 +644,6 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) s->avctx->pix_fmt = pix_fmt; s->seq_decode = (s->seq_decode + 1) & HEVC_SEQUENCE_COUNTER_MASK; - s->max_ra = INT_MAX; } sh->dependent_slice_segment_flag = 0; @@ -3106,32 +3104,15 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) } - if ( - (s->avctx->skip_frame >= AVDISCARD_BIDIR && s->sh.slice_type == HEVC_SLICE_B) || + if ((s->avctx->skip_frame >= AVDISCARD_BIDIR && s->sh.slice_type == HEVC_SLICE_B) || (s->avctx->skip_frame >= AVDISCARD_NONINTRA && s->sh.slice_type != HEVC_SLICE_I) || - (s->avctx->skip_frame >= AVDISCARD_NONKEY && !IS_IRAP(s))) { + (s->avctx->skip_frame >= AVDISCARD_NONKEY && !IS_IRAP(s)) || + ((s->nal_unit_type == HEVC_NAL_RASL_R || s->nal_unit_type == HEVC_NAL_RASL_N) && + s->no_rasl_output_flag)) { break; } if (s->sh.first_slice_in_pic_flag) { - if (s->max_ra == INT_MAX) { - if (s->nal_unit_type == HEVC_NAL_CRA_NUT || IS_BLA(s)) { - s->max_ra = s->poc; - } else { - if (IS_IDR(s)) - s->max_ra = INT_MIN; - } - } - - if ((s->nal_unit_type == HEVC_NAL_RASL_R || s->nal_unit_type == HEVC_NAL_RASL_N) && - s->poc <= s->max_ra) { - s->is_decoded = 0; - break; - } else { - if (s->nal_unit_type == HEVC_NAL_RASL_R && s->poc > s->max_ra) - s->max_ra = INT_MIN; - } - s->overlap ++; ret = hevc_frame_start(s); if (ret < 0) @@ -3196,7 +3177,6 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) case HEVC_NAL_EOS_NUT: case HEVC_NAL_EOB_NUT: s->seq_decode = (s->seq_decode + 1) & HEVC_SEQUENCE_COUNTER_MASK; - s->max_ra = INT_MAX; break; case HEVC_NAL_AUD: case HEVC_NAL_FD_NUT: @@ -3572,8 +3552,6 @@ static av_cold int hevc_init_context(AVCodecContext *avctx) return AVERROR(ENOMEM); } - s->max_ra = INT_MAX; - s->md5_ctx = av_md5_alloc(); if (!s->md5_ctx) return AVERROR(ENOMEM); @@ -3626,7 +3604,6 @@ static int hevc_update_thread_context(AVCodecContext *dst, s->seq_decode = s0->seq_decode; s->seq_output = s0->seq_output; s->poc_tid0 = s0->poc_tid0; - s->max_ra = s0->max_ra; s->eos = s0->eos; s->no_rasl_output_flag = s0->no_rasl_output_flag; @@ -3640,7 +3617,6 @@ static int hevc_update_thread_context(AVCodecContext *dst, if (s0->eos) { s->seq_decode = (s->seq_decode + 1) & HEVC_SEQUENCE_COUNTER_MASK; - s->max_ra = INT_MAX; } ret = ff_h2645_sei_ctx_replace(&s->sei.common, &s0->sei.common); @@ -3734,7 +3710,6 @@ static void hevc_decode_flush(AVCodecContext *avctx) ff_hevc_reset_sei(&s->sei); ff_dovi_ctx_flush(&s->dovi_ctx); av_buffer_unref(&s->rpu_buf); - s->max_ra = INT_MAX; s->eos = 1; if (FF_HW_HAS_CB(avctx, flush)) diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h index fa7caf9cf7..04eacca76d 100644 --- a/libavcodec/hevc/hevcdec.h +++ b/libavcodec/hevc/hevcdec.h @@ -487,7 +487,6 @@ typedef struct HEVCContext { int slice_idx; ///< number of the slice being currently decoded int eos; ///< current packet contains an EOS/EOB NAL int last_eos; ///< last packet contains an EOS/EOB NAL - int max_ra; int bs_width; int bs_height; int overlap; diff --git a/tests/ref/fate/hevc-afd-tc-sei b/tests/ref/fate/hevc-afd-tc-sei index 27eb3fc8d7..735226745b 100644 --- a/tests/ref/fate/hevc-afd-tc-sei +++ b/tests/ref/fate/hevc-afd-tc-sei @@ -202,3 +202,39 @@ value=00:00:00:00 [/TIMECODE] [/SIDE_DATA] [/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Active format description +active_format=8 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=SMPTE 12-1 timecode +[TIMECODE] +value=00:00:00:00 +[/TIMECODE] +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Active format description +active_format=8 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=SMPTE 12-1 timecode +[TIMECODE] +value=00:00:00:00 +[/TIMECODE] +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Active format description +active_format=8 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=SMPTE 12-1 timecode +[TIMECODE] +value=00:00:00:00 +[/TIMECODE] +[/SIDE_DATA] +[/FRAME]