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 B03074858D for ; Thu, 7 Dec 2023 16:30:58 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5374868CF80; Thu, 7 Dec 2023 18:30:55 +0200 (EET) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3F09568C11C for ; Thu, 7 Dec 2023 18:30:48 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 036702405ED; Thu, 7 Dec 2023 17:30:48 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id LNvJgOtzM6r8; Thu, 7 Dec 2023 17:30:47 +0100 (CET) Received: from lain.khirnov.net (lain.khirnov.net [IPv6:2001:67c:1138:4306::3]) (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 "lain.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 465EF2400AC; Thu, 7 Dec 2023 17:30:47 +0100 (CET) Received: by lain.khirnov.net (Postfix, from userid 1000) id 23E981601B9; Thu, 7 Dec 2023 17:30:47 +0100 (CET) From: Anton Khirnov To: FFmpeg development discussions and patches In-Reply-To: <20231206082220.5532-7-cus@passwd.hu> References: <20231206082220.5532-1-cus@passwd.hu> <20231206082220.5532-7-cus@passwd.hu> Mail-Followup-To: FFmpeg development discussions and patches , Marton Balint Date: Thu, 07 Dec 2023 17:30:47 +0100 Message-ID: <170196664712.8914.15749136255711961223@lain.khirnov.net> User-Agent: alot/0.8.1 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 Cc: Marton Balint 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: 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'. > + > 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. > + */ > +#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? -- Anton Khirnov _______________________________________________ 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".