From patchwork Wed Dec 6 08:22:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 44949 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9153:b0:181:818d:5e7f with SMTP id x19csp106631pzc; Wed, 6 Dec 2023 00:23:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IGvh1eZKdweYO4DDEv5SyDdDNQSFMYJq2XtyGxg91jnIBsJLEH+57hIBI+54XdWpP1sYhkP X-Received: by 2002:a17:906:2b55:b0:a19:4f2b:f78a with SMTP id b21-20020a1709062b5500b00a194f2bf78amr222440ejg.5.1701851028478; Wed, 06 Dec 2023 00:23:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701851028; cv=none; d=google.com; s=arc-20160816; b=A4+ck+cQur5KJwIgpEw0W1jEih0dN8nY45VK8YhrOBMHX2v8MLT/sr5PWZmfM9gfzv pXeobtzmA1tmbaTQ1riinCUPI/Hr7ImzgRgTFnecVhnv0pONdBQOD8el0BNuP0/kRLKj DS/PLtR5JuFMfFzjzCreiF5gul7A8yWPgWt77F8IGdFfNZrHsuAlTiBLVM0kseC81FXz 2vZgVAtnUTZbkeA/ULw1mmwmxvrfvWp6dOhnoHBPqJ5X7gukDYP9rK1//BzRyCjXSV7o 34GUJCuu2L2L/Kr6wvsGrw6BiZB7+uqw+jdibqocg2KJgckHA+i+1k99RFFZ1ZwoyxU1 ov1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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:delivered-to; bh=ruk3yrQC+4chWLc4o0xLgcxZ3RvFJVqHLLNEVI+MlLU=; fh=s+G8Ss4JbeMFkWPSp2LmIH/LXFyBlALRiww1j3FPjHY=; b=OavsD1mDpKMnSzCzjwI6uBE/fHEmgz0/kQIgZ5V/Y1aWLJ6xIzp0KSJkBKx+m4ko3V eucZ5MDyPc2nTCIinfPp2qVg13tpZpLdnyIdg8Cne0utCoAYA2eFj7pl5uLNKw0V2T5V p7HxqkSN9MGBa3mwhDPxEkAx24IicWAsTp/rkJUJh2CaLadaVzuoNuvyJ9PIy0FFNhmO 5Azj0dw4V6FW7dSlGK5LQb0fr4jMoeWpIUwRrf6unm0cfZgRvMyZ93fUbVcqPI9c/3QT OW2cWPhvAm1EGOstcp4bKrhxnoFawxI2C12jzKTWrDWgSbc46oxWgHMQBz/N6ffI3Jdj STTw== ARC-Authentication-Results: i=1; mx.google.com; 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 u25-20020a1709060b1900b009fc5429b148si6205088ejg.586.2023.12.06.00.23.48; Wed, 06 Dec 2023 00:23:48 -0800 (PST) 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; 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 2820B68CF75; Wed, 6 Dec 2023 10:22:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AE1E868CF5D for ; Wed, 6 Dec 2023 10:22:37 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 93C4FE9982; Wed, 6 Dec 2023 09:22:37 +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 1kG5NqBYHfds; Wed, 6 Dec 2023 09:22:35 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id D54C4E9A23; Wed, 6 Dec 2023 09:22:31 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Wed, 6 Dec 2023 09:22:20 +0100 Message-Id: <20231206082220.5532-7-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231206082220.5532-1-cus@passwd.hu> References: <20231206082220.5532-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: AlhbbMlF4w4r 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. + 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. + */ +#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); + } + ret = ff_attach_decode_data(frame); if (ret < 0) goto fail; diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index ee243d9894..23ff4cddf8 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -62,6 +62,7 @@ static const AVOption avcodec_options[] = { {"frame_duration", "use frame durations", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_FRAME_DURATION}, .unit = "flags"}, {"pass1", "use internal 2-pass ratecontrol in first pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PASS1 }, INT_MIN, INT_MAX, 0, "flags"}, {"pass2", "use internal 2-pass ratecontrol in second pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PASS2 }, INT_MIN, INT_MAX, 0, "flags"}, +{"clear", "clear frames before decoding", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_CLEAR }, INT_MIN, INT_MAX, V|D, "flags"}, {"gray", "only decode/encode grayscale", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_GRAY }, INT_MIN, INT_MAX, V|E|D, "flags"}, {"psnr", "error[?] variables will be set during encoding", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PSNR }, INT_MIN, INT_MAX, V|E, "flags"}, {"ildct", "use interlaced DCT", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_INTERLACED_DCT }, INT_MIN, INT_MAX, V|E, "flags"}, diff --git a/libavcodec/version.h b/libavcodec/version.h index 1008fead27..34b059a8a9 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 35 +#define LIBAVCODEC_VERSION_MINOR 36 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \