From patchwork Fri Sep 20 00:44:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: wzq via ffmpeg-devel X-Patchwork-Id: 51665 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d154:0:b0:48e:c0f8:d0de with SMTP id bt20csp661418vqb; Thu, 19 Sep 2024 17:44:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXoPmY/9Ql3WtIcOCMvz6QWF1iDBZoeJo66JwewicT/1vCo14/K3QJUs4iNxaDkJJeaNyw825kF7lW5VkoFEWVK@gmail.com X-Google-Smtp-Source: AGHT+IFRHuFdi9yAYpaPd/CgN9ahbUykjHbS282NiliyrF45BFhRxdz/Ie/q6uEkOWqJZm/PCLXQ X-Received: by 2002:a2e:70a:0:b0:2f7:6869:3b55 with SMTP id 38308e7fff4ca-2f7cb31c9e4mr7926151fa.21.1726793063253; Thu, 19 Sep 2024 17:44:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726793063; cv=none; d=google.com; s=arc-20240605; b=IDnJveMoujbi0pFotAr66io7k80yZisol9jDuCdgZyP89SucP3K0aySJSHeUkbOVjR ceEfz0tLzTNXi7wlSvEcWmbV0hNr0JAcG8bC+bMWl0Ugu7xyJPi9TN+zNkgK/gxpwx/5 HgL7VIQreGKocXXfdtppzx/W7evwOwjou+h0Q9Aj/SbWlegKLq3LupoIq+EEF53vDpYH 3ESjG3t83S5hzA7SiYYIsjZXP5JEuXdFo+/V5MltIk4oHrlpxvYaDg2GmIK8EP14ncP+ sxRIHUEE901Y8xafIophe2WTco5TnDGUmu7KQZsLegtih//zGI4kl9SFkA1FRYiWMdBT kdOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:cc:reply-to:from :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:content-id:content-language :accept-language:message-id:date:thread-index:thread-topic:to :delivered-to; bh=Z8BY2E70/DIM9m2Rxdsax8V6zfWvX2ERw/4LVe/NAqA=; fh=95aBa8D1rLPK8RMCJmEpewcRxmtn52v1CfXNTjgpso4=; b=doPNQnypZnN4XbG/VJBjAhWr+1cxt0hgJvf2GsCwvmgFVLJBeEgMLsMlWqWEUWiJw7 8EbEdzRp/xuUyjS6hZBNA6kZT2gU3DmIPbOdMFCoiTRgkv8bf0/1olf/1xaFQPgz0qJT zt7p70pvxNv51g2495ADpGS+p0hDceqdfHSEBx4rnczHMel6T62OKzPWWNKS1VdkK9ey OY4ILF3WtPZw7M8uQJr4AKFSmbmLJ3aZGvR9Udg/4kR+Kmjir8qi1ftxu3jp8rUYq7Rg /xpnSu+xq9EiRnWqVecsFHR8tzLFxpjiaA24MVyAGe6PW8iqBbJap5SHVlSpxeL71JuU H6oQ==; dara=google.com 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 38308e7fff4ca-2f79d47bffdsi40034981fa.563.2024.09.19.17.44.22; Thu, 19 Sep 2024 17:44:23 -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; 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 0BEC668DC68; Fri, 20 Sep 2024 03:44:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtp-fw-33001.amazon.com (smtp-fw-33001.amazon.com [207.171.190.10]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F0AD168D905 for ; Fri, 20 Sep 2024 03:44:12 +0300 (EEST) X-IronPort-AV: E=Sophos;i="6.10,243,1719878400"; d="scan'208";a="369236921" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.43.8.6]) by smtp-border-fw-33001.sea14.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2024 00:44:11 +0000 Received: from EX19MTAUWA002.ant.amazon.com [10.0.21.151:50763] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.39.219:2525] with esmtp (Farcaster) id ec81ca06-7de1-439b-b48f-ba1e06a1ff2f; Fri, 20 Sep 2024 00:44:08 +0000 (UTC) X-Farcaster-Flow-ID: ec81ca06-7de1-439b-b48f-ba1e06a1ff2f Received: from EX19D022UWC004.ant.amazon.com (10.13.139.244) by EX19MTAUWA002.ant.amazon.com (10.250.64.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34; Fri, 20 Sep 2024 00:44:04 +0000 Received: from EX19D022UWC002.ant.amazon.com (10.13.139.216) by EX19D022UWC004.ant.amazon.com (10.13.139.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34; Fri, 20 Sep 2024 00:44:04 +0000 Received: from EX19D022UWC002.ant.amazon.com ([fe80::e13f:1459:3a4b:7b06]) by EX19D022UWC002.ant.amazon.com ([fe80::e13f:1459:3a4b:7b06%5]) with mapi id 15.02.1258.034; Fri, 20 Sep 2024 00:44:04 +0000 To: FFmpeg development discussions and patches Thread-Topic: [PATCH 2/3] - libavcodec/aom_film_grain: Add apply_grain flag Thread-Index: AQHbCvYxuXE2oF2BOUaJdaIuMnhGvA== Date: Fri, 20 Sep 2024 00:44:03 +0000 Message-ID: <5674DDE0-D4B3-4F88-B889-28A02ED9FCA4@amazon.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.13.138.181] Content-ID: <463B4510F4CFC14481FB60AF5C50ECCF@amazon.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] - libavcodec/aom_film_grain: Add apply_grain 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: , X-Patchwork-Original-From: "Segall, Andrew via ffmpeg-devel" From: wzq via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: "Segall, Andrew" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: AG/2FZAC5A6n Details: Add support for the apply_grain_flag. This allows the film grain process to be enabled/disabled for different display properties. On 9/8/24, 12:06 AM, "Andrew Segall" > wrote: Signed-off-by: Andrew Segall > --- libavcodec/aom_film_grain.c | 6 ++++-- libavcodec/hevc/hevcdec.c | 5 ++++- libavfilter/vf_showinfo.c | 1 + libavutil/film_grain_params.h | 5 +++++ 4 files changed, 14 insertions(+), 3 deletions(-) * -- 2.46.0 diff --git a/libavcodec/aom_film_grain.c b/libavcodec/aom_film_grain.c index fdfa3dbf77..251a2793ac 100644 --- a/libavcodec/aom_film_grain.c +++ b/libavcodec/aom_film_grain.c @@ -149,8 +149,10 @@ int ff_aom_parse_film_grain_sets(AVFilmGrainAFGS1Params *s, fgp = &s->sets[set_idx]; aom = &fgp->codec.aom; - fgp->type = get_bits1(gb) ? AV_FILM_GRAIN_PARAMS_AV1 : AV_FILM_GRAIN_PARAMS_NONE; - if (!fgp->type) + fgp->type = AV_FILM_GRAIN_PARAMS_AV1; + + fgp->apply_grain = get_bits1(gb); + if ( !fgp->apply_grain) { payload_bits = get_bits_count(gb) - start_position; if (payload_bits > payload_size * 8) diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c index d915d74d22..8dd4fb10c5 100644 --- a/libavcodec/hevc/hevcdec.c +++ b/libavcodec/hevc/hevcdec.c @@ -3155,7 +3155,10 @@ static int hevc_frame_end(HEVCContext *s) &s->h274db, fgp); break; case AV_FILM_GRAIN_PARAMS_AV1: - ret = ff_aom_apply_film_grain(out->frame_grain, out->f, fgp); + if(fgp->apply_grain) + ret = ff_aom_apply_film_grain(out->frame_grain, out->f, fgp); + else + out->needs_fg = 0; break; } av_assert1(ret >= 0); diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c index f81df9d1bf..08e144ca46 100644 --- a/libavfilter/vf_showinfo.c +++ b/libavfilter/vf_showinfo.c @@ -455,6 +455,7 @@ static void dump_sei_film_grain_params_metadata(AVFilterContext *ctx, const AVFr } av_log(ctx, AV_LOG_INFO, "type %s; ", film_grain_type_names[fgp->type]); + av_log(ctx, AV_LOG_INFO, "apply_grain=%d; ", fgp->apply_grain); av_log(ctx, AV_LOG_INFO, "seed=%"PRIu64"; ", fgp->seed); av_log(ctx, AV_LOG_INFO, "width=%d; ", fgp->width); av_log(ctx, AV_LOG_INFO, "height=%d; ", fgp->height); diff --git a/libavutil/film_grain_params.h b/libavutil/film_grain_params.h index ccacab88fe..f3275923e1 100644 --- a/libavutil/film_grain_params.h +++ b/libavutil/film_grain_params.h @@ -241,6 +241,11 @@ typedef struct AVFilmGrainParams { */ enum AVFilmGrainParamsType type; + /** + * Specifies if film grain parameters are enabled. + */ + int apply_grain; + /** * Seed to use for the synthesis process, if the codec allows for it.