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 55FCC496EF for ; Thu, 18 Apr 2024 10:44:04 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E35E068D448; Thu, 18 Apr 2024 13:44:01 +0300 (EEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2045.outbound.protection.outlook.com [40.107.94.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0245F68D41F for ; Thu, 18 Apr 2024 13:43:53 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BKlILBPZTlv4ECUNVR9EkJOcv5MHUM+Tf0XF97CSoxVd956g9GlAtYnPApFFM4fR2IDqoVgyZK6665oHRx/Vtu2OYzVLLOsziR0SEpPkQZ7fMuZ4jUFG08ai3JTAs24NtDshfw0ZHZChe6ps3GgxMGf87erWGvClLn9ul+5Alov/4QxVSlhnUwjuTlg/KJsoLd24cK4YRSGzJTJrAQjo+GkocuMkKDcben98l5R+nTC+XT8not7Ng0lp2ttp2ZV6aP/wQzLpNsRSzgSfY4+YA1q6C7mL4/+o0SnG8cr9+NriPYHsQz1LF9aaBhJhwDbtCG4F7M0VnB9ok1Rk98ADfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YkMBqMxy+K+w7WH1q+6NFZIkTlvV5HGbNYHUAVjjdZM=; b=Rbjt/bql+UlnXdKJGzcg1oL77Cyf7GG3ecPnm/VLw7PsNR+7/WwXVbJ7JTeRl7n8GFWuvyzt2uXwUaVI0K9WQ63b/fZiF2VHMdnr5SOi34iLQPOqUMnt38IJTy1db1Y/PvI4ewVEq0s4mgUSNBt0yZfxid26PxX7B9qvaL90N2/Wym3J0DhePmygH9rxig33eMZLi5z7jnIyQIbpouktJXSRPfBYmMajgPyq/yTF3CdEJFbo3Q0x6kvHa7vwUQ4FFvbf1Jo5jIU1pZoWtHHvSAN9oV1W5R/qyfJZjcxtJIdYXkTnfk06K6eMHe3Uf+Kmi6GUlYn5obfRU4Tm0efiRA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none Received: from PH7PR12MB7188.namprd12.prod.outlook.com (2603:10b6:510:204::15) by PH7PR12MB6978.namprd12.prod.outlook.com (2603:10b6:510:1b8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.41; Thu, 18 Apr 2024 10:43:49 +0000 Received: from PH7PR12MB7188.namprd12.prod.outlook.com ([fe80::6324:cf63:797:f848]) by PH7PR12MB7188.namprd12.prod.outlook.com ([fe80::6324:cf63:797:f848%7]) with mapi id 15.20.7472.037; Thu, 18 Apr 2024 10:43:44 +0000 To: Timo Rothenpieler , FFmpeg development discussions and patches Thread-Topic: [FFmpeg-devel] [PATCH] avcodec/nvenc: High bit depth encoding for HEVC Thread-Index: AQHaj0LY7CHs0mqmK0+WBuwTBgctyLFsiDaAgAFL2Hc= Date: Thu, 18 Apr 2024 10:43:21 +0000 Message-ID: References: <20240415143932.338380-1-ddesouza@nvidia.com> <26df08ee-ee02-408a-98ea-ef5fe77c93c7@rothenpieler.org> In-Reply-To: <26df08ee-ee02-408a-98ea-ef5fe77c93c7@rothenpieler.org> Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH7PR12MB7188:EE_|PH7PR12MB6978:EE_ x-ms-office365-filtering-correlation-id: 94f25690-936e-446e-2fc4-08dc5f946bb5 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: r9t0cGo9ZMsNN9K4NR2QFW4CPPriSE6q5fNKG4ijhp+X6tMU0NvqQMny/jFHpznQY/HvPqAWXK4tazsSAjE9Ip4LePuz3DuG9LH0yM5IBifv1aJ8n3Hg6mOU3ymg3hjSzLENN4XcUkSjOIY3kIO9q7GYvGmTGC5wk5SMqi/60pJQ5BU2F2t7a5478O73Gae3PedHnN+409gKKa8YUM7m17AEqXZum1xOFhg9rBD8ysvIECI92vfcVW9oNEmBDof1+THsTXLp+HinJcjkbfqx8NoZJWFXrzXZjM1ADmsNNnocNaEB1By07giMcA3PGPGOqhJkiivkmtSNvzgJyqwOk5YR/XLQ1c6rkIJ2YO3g7C5Y1BBaeq5bhRXKcZuRQuUfoEsiCarXyUKP87EjLY+dKP/pQpjnzsk2Fl0SL3yihTVmmQQCGAnqrzD0WLwD+7gG6OWARvdApNYEWWbjDM1goIkTQ0q9q8fKe0TecEnHdnXQKe4uqbkYIXZe+NsDmO5rc+Wot9FAhMQd7zlRj4xvy/sHFBkhaHt4tZW4Sz2WK1nAy2/98aZNDnF7Rq+wuK8jgCVO5N5Z8yrzBMrfsTyeLwapDFQEmB4miCvutc4JtwKm13jqY2WRBSg6m3KYa6OEEeI4whpJ3P4/jJg03gQbcQmbk0aIT9QLfuAqB/2eNRY= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH7PR12MB7188.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(1800799015)(376005)(366007)(38070700009); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?W6Pbrge2R+YNKXL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L6yGPAe5QtK?= =?us-ascii?Q?h2qgCOtM0WmWcexAJXTg/uqdrTrbGNGAu3KOD/lRRf7NlVf87YUIskb1V14Z?= =?us-ascii?Q?5EAVZNJawzauzkl3CpE1EMfPf4FCSkI9PDSYbMUuoyXq7WMxNzq84vL7HVgN?= =?us-ascii?Q?n8D8Vgyp3O0oqlSo0y84YCmTY3+6zSEadIPbTf3ZcjGpnxsrccAgBEZemmjB?= =?us-ascii?Q?WijwZ6EbibSyghWvpAwFQnSsco0Mb2H5DTPrhA1Io3rr++7CP3LPOj/rOn1B?= =?us-ascii?Q?iEcICHVARBPJwRyNlJPYgNeZBHnM8hcY/xXBi/igxHxtn21llwlVgc0h0W/v?= =?us-ascii?Q?5/ArzV/uwCLycLcgDezdLPJgXypnhEfaTsKNZh8IupT4JfVcchMZbm3PR/r/?= =?us-ascii?Q?ziAdF85M22JDUzSaLS2ggdjjSlCw5pintzYOkhBrJkD+XrBT7ROqjPSCkXuH?= =?us-ascii?Q?BXC9FeHSxijJGSDIuumIuh/mK54sx9JSdw+ZUFYxGwbEysFLqwQTcQ2UstAR?= =?us-ascii?Q?cBkSps9nh2D2eQpBUoQQCCiASJakRuO/kP+VOf5uYjM2040WVoKhh6gId6nG?= =?us-ascii?Q?N2JsgsiDo2hSXT59U/5KRvlePxi4X0VR8Rlv8fao+2Jjx+gRX9MP+5eVVTdb?= =?us-ascii?Q?C9rJhXYUR6ozTNM8OPVuOcoBtw91zO8bfaRKoNTzju19gecPJbK/FKE9AbBY?= =?us-ascii?Q?x+Xqrn3PpWOvsDjRyh1S9d1Pj7QvKXZsCoDRmdzw?= MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH7PR12MB7188.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94f25690-936e-446e-2fc4-08dc5f946bb5 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Apr 2024 10:43:44.5996 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: cHY/g2KHQV+N8Y548/WR5yvIbe8DSsi5bw+xpWHXwpK8vwbVhOSOQw7tuud2Qul3jfFaDLsm33BwNBauxHHNwQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6978 X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [FFmpeg-devel] [PATCH] avcodec/nvenc: High bit depth encoding for HEVC 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: , From: Diego Felix de Souza via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: Diego Felix de Souza 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: Hi Timo, Thank you for your review. Please check my answers below. Best regards, Diego On 17.04.24, 16:27, "Timo Rothenpieler" wrote: External email: Use caution opening links or attachments On 15/04/2024 16:39, Diego Felix de Souza via ffmpeg-devel wrote: > From: Diego Felix de Souza > > Adding 10-bit encoding support for HEVC if the input is 8-bit. In > case of 8-bit input content, NVENC performs an internal CUDA 8 to > 10-bit conversion of the input prior to encoding. Currently, only > AV1 supports encoding 8-bit content as 10-bit. I'm not sure about this one. Since it's just "SW", or rather CUDA based, conversion, this job could also be done by scale_cuda, outside of some niche formats it doesn't support yet. Which would also allow for more consistent command lines across versions. Although it is a software-based solution, the conversion is integrated with other kernels inside the driver. In this way, it will demand fewer memory accesses and better Streaming Multiprocessor (SM) utilization, leading to a improved performance and a lower latency compared to the scale_cuda approach. Moreover, the proposed approach overall consumes less memory since it only requires an 8-bit per channel frame as input and no extra 10-bit frames. > Signed-off-by: Diego Felix de Souza > --- > libavcodec/nvenc.c | 8 ++++---- > libavcodec/nvenc_hevc.c | 1 + > 2 files changed, 5 insertions(+), 4 deletions(-) > > diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c > index 794174a53f..c302cc7dc4 100644 > --- a/libavcodec/nvenc.c > +++ b/libavcodec/nvenc.c > @@ -514,7 +514,7 @@ static int nvenc_check_capabilities(AVCodecContext *avctx) > } > > ret = nvenc_check_cap(avctx, NV_ENC_CAPS_SUPPORT_10BIT_ENCODE); > - if (IS_10BIT(ctx->data_pix_fmt) && ret <= 0) { > + if ((IS_10BIT(ctx->data_pix_fmt) || ctx->highbitdepth) && ret <= 0) { > av_log(avctx, AV_LOG_WARNING, "10 bit encode not supported\n"); > return AVERROR(ENOSYS); > } > @@ -1421,7 +1421,7 @@ static av_cold int nvenc_setup_hevc_config(AVCodecContext *avctx) > } > > // force setting profile as main10 if input is 10 bit > - if (IS_10BIT(ctx->data_pix_fmt)) { > + if (IS_10BIT(ctx->data_pix_fmt) || ctx->highbitdepth) { Won't this need guarded behind the NVENC_HAVE_NEW_BIT_DEPTH_API as well? Or would this also work fine with older headers, by just setting this? For older SDK versions, the HEVC main 10 profile would be selected, but the encoded bitstream would be still 8-bits. For the sake of consistence and clarity, I will put it behind the NVENC_HAVE_NEW_BIT_DEPTH_API as you suggested. > cc->profileGUID = NV_ENC_HEVC_PROFILE_MAIN10_GUID; > avctx->profile = AV_PROFILE_HEVC_MAIN_10; > } > @@ -1435,8 +1435,8 @@ static av_cold int nvenc_setup_hevc_config(AVCodecContext *avctx) > hevc->chromaFormatIDC = IS_YUV444(ctx->data_pix_fmt) ? 3 : 1; > > #ifdef NVENC_HAVE_NEW_BIT_DEPTH_API > - hevc->inputBitDepth = hevc->outputBitDepth = > - IS_10BIT(ctx->data_pix_fmt) ? NV_ENC_BIT_DEPTH_10 : NV_ENC_BIT_DEPTH_8; > + hevc->inputBitDepth = IS_10BIT(ctx->data_pix_fmt) ? NV_ENC_BIT_DEPTH_10 : NV_ENC_BIT_DEPTH_8; > + hevc->outputBitDepth = (IS_10BIT(ctx->data_pix_fmt) || ctx->highbitdepth) ? NV_ENC_BIT_DEPTH_10 : NV_ENC_BIT_DEPTH_8; > #else > hevc->pixelBitDepthMinus8 = IS_10BIT(ctx->data_pix_fmt) ? 2 : 0; > #endif > diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c > index b949cb1bd7..02e9c9c8eb 100644 > --- a/libavcodec/nvenc_hevc.c > +++ b/libavcodec/nvenc_hevc.c > @@ -183,6 +183,7 @@ static const AVOption options[] = { > { "fullres", "Two Pass encoding is enabled where first Pass is full resolution", > 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_TWO_PASS_FULL_RESOLUTION }, 0, 0, VE, .unit = "multipass" }, > #endif > + { "highbitdepth", "Enable 10 bit encode for 8 bit input",OFFSET(highbitdepth),AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, Same question as above, does this always work, even without the new bit depth API? If not, it also needs the #ifdef. Same as above, it would give the wrong impression to the user. I will put it behind the NVENC_HAVE_NEW_BIT_DEPTH_API. > #ifdef NVENC_HAVE_LDKFS > { "ldkfs", "Low delay key frame scale; Specifies the Scene Change frame size increase allowed in case of single frame VBV and CBR", > OFFSET(ldkfs), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, UCHAR_MAX, VE }, > -- > 2.34.1 > > ----------------------------------------------------------------------------------- > NVIDIA GmbH > Wuerselen > Amtsgericht Aachen > HRB 8361 > Managing Directors: Rebecca Peters, Donald Robertson, Janet Hall, Ludwig von Reiche > > ----------------------------------------------------------------------------------- > This email message is for the sole use of the intended recipient(s) and may contain > confidential information. Any unauthorized review, use, disclosure or distribution > is prohibited. If you are not the intended recipient, please contact the sender by > reply email and destroy all copies of the original message. > ----------------------------------------------------------------------------------- > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fffmpeg.org%2Fmailman%2Flistinfo%2Fffmpeg-devel&data=05%7C02%7Cddesouza%40nvidia.com%7Cd750b65e093d40e8dd5508dc5eea7d53%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638489608435687923%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=2F9CxnKyADs6zW1faiZhXQa1FzfcVRKxMJQ8ukoN0nY%3D&reserved=0 > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ----------------------------------------------------------------------------------- NVIDIA GmbH Wuerselen Amtsgericht Aachen HRB 8361 Managing Directors: Rebecca Peters, Donald Robertson, Janet Hall, Ludwig von Reiche ----------------------------------------------------------------------------------- This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. ----------------------------------------------------------------------------------- _______________________________________________ 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".