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 A732746D4B for ; Thu, 7 Dec 2023 23:11:31 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3E4CE68CFCE; Fri, 8 Dec 2023 01:11:29 +0200 (EET) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D222468C7DA for ; Fri, 8 Dec 2023 01:11:23 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 1059CE9358 for ; Fri, 8 Dec 2023 00:11:23 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YEgu_8q46Sw8 for ; Fri, 8 Dec 2023 00:11:21 +0100 (CET) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id 332EFE79BC for ; Fri, 8 Dec 2023 00:11:21 +0100 (CET) Date: Fri, 8 Dec 2023 00:11:21 +0100 (CET) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: <170196664712.8914.15749136255711961223@lain.khirnov.net> Message-ID: <85f4ba43-ab24-2598-6346-28dfef2ee88e@passwd.hu> References: <20231206082220.5532-1-cus@passwd.hu> <20231206082220.5532-7-cus@passwd.hu> <170196664712.8914.15749136255711961223@lain.khirnov.net> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH v2 7/7] avcodec: add AV_CODEC_FLAG_CLEAR 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Thu, 7 Dec 2023, Anton Khirnov wrote: > Quoting Marton Balint (2023-12-06 09:22:20) >> Signed-off-by: Marton Balint >> --- >> doc/APIchanges | 3 +++ >> doc/codecs.texi | 14 ++++++++++++++ >> libavcodec/avcodec.h | 4 ++++ >> libavcodec/decode.c | 6 ++++++ >> libavcodec/options_table.h | 1 + >> libavcodec/version.h | 2 +- >> 6 files changed, 29 insertions(+), 1 deletion(-) >> >> diff --git a/doc/APIchanges b/doc/APIchanges >> index 416e2bec5e..f839504a64 100644 >> --- a/doc/APIchanges >> +++ b/doc/APIchanges >> @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09 >> >> API changes, most recent first: >> >> +2023-12-xx - xxxxxxxxxxx - lavc 60.36.100 - avcodec.h >> + Add AV_CODEC_FLAG_CLEAR. > > I'm not a huge fan of calling it just 'clear'. How about something more > descriptive like 'wipe_frames'. Wipe reminds me of the wipe effect. How about 'predecode_clear'? >> + >> 2023-12-xx - xxxxxxxxxxx - lavu 58.33.100 - imgutils.h >> Add av_image_fill_color() >> >> diff --git a/doc/codecs.texi b/doc/codecs.texi >> index 5b950b4560..0504a535f2 100644 >> --- a/doc/codecs.texi >> +++ b/doc/codecs.texi >> @@ -76,6 +76,20 @@ Apply interlaced motion estimation. >> Use closed gop. >> @item output_corrupt >> Output even potentially corrupted frames. >> +@item clear >> +Clear the contents of the video buffer before decoding the next picture to it. >> + >> +Usually if only a part of a picture is affected by a decode error then the >> +decoder (if it implements error concealment) tries to hide it by interpolating >> +pixels from neighbouring areas or in some cases from the previous frame. Even >> +without error concealment it is quite likely that the affected area will >> +contain pixels from an earlier frame, due to frame pooling. >> + >> +For quality checking this might not be desirable, because it makes the errors >> +less noticable. By using this flag, and combining it with disabled error >> +concealment (@code{-ec 0}) it is possible to ensure that no leftover data from >> +an earlier frame is presented in areas affected by decode errors. >> + >> @end table >> >> @item time_base @var{rational number} >> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h >> index 7fb44e28f4..97848e942f 100644 >> --- a/libavcodec/avcodec.h >> +++ b/libavcodec/avcodec.h >> @@ -312,6 +312,10 @@ typedef struct RcOverride{ >> * loop filter. >> */ >> #define AV_CODEC_FLAG_LOOP_FILTER (1 << 11) >> +/** >> + * Clear frame buffer contents before decoding. > > Clear the contents of each frame buffer after it is allocated with > AVCodecContext.get_buffer2() and before anything is decoded into it. > > Note that this may have a significant performance cost. ok. > >> + */ >> +#define AV_CODEC_FLAG_CLEAR (1 << 12) >> /** >> * Only decode/encode grayscale. >> */ >> diff --git a/libavcodec/decode.c b/libavcodec/decode.c >> index 2cfb3fcf97..f9b18a2c35 100644 >> --- a/libavcodec/decode.c >> +++ b/libavcodec/decode.c >> @@ -1675,6 +1675,12 @@ FF_ENABLE_DEPRECATION_WARNINGS >> >> validate_avframe_allocation(avctx, frame); >> >> + if (avctx->flags & AV_CODEC_FLAG_CLEAR && avctx->codec_type == AVMEDIA_TYPE_VIDEO) { >> + uint32_t color[4] = {0}; >> + ptrdiff_t linesize[4] = {frame->linesize[0], frame->linesize[1], frame->linesize[2], frame->linesize[3]}; >> + av_image_fill_color(frame->data, linesize, frame->format, color, frame->width, frame->height); > > Should this check for errors? Lack of error checking is intentional. av_image_fill_color might not support all pixel formats, definitely not support hwaccel formats. It might make sense to warn the user once, but I don't think propagating the error back is needed here. I primarily thought of this as a QC feature (even thought about making the color fill green by default to make it more noticeable (YUV green happens to be 0,0,0), but for that I'd need similar checks for colorspaces to what I have for fill_black())... Regards, Marton _______________________________________________ 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".