From patchwork Mon Apr 15 14:39:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wzq via ffmpeg-devel X-Patchwork-Id: 48068 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:670b:b0:1a9:af23:56c1 with SMTP id wh11csp1884982pzb; Mon, 15 Apr 2024 07:40:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWZaMRVscB+SbmZrbJHkVs3oLEsQ8H3OxhG1SoA0p/s33STbUBbLl3CuYvHUOHzCRYpp/zuJK7xYHxfC0yVLT61VzWuCGJdbMRp5w== X-Google-Smtp-Source: AGHT+IGsUD5Gzpp1obibkszIGq/y+9rb8vPYe3F9orbQapfuPaoFSBOsVAcEBOj0YdtkpgLjwV8k X-Received: by 2002:a17:906:2997:b0:a52:22f4:21a6 with SMTP id x23-20020a170906299700b00a5222f421a6mr8080583eje.72.1713192035684; Mon, 15 Apr 2024 07:40:35 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id x18-20020a170906135200b00a526dbdb22asi837278ejb.321.2024.04.15.07.40.34; Mon, 15 Apr 2024 07:40:35 -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; arc=fail (body hash mismatch); 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 91D7B68C7C2; Mon, 15 Apr 2024 17:40:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2089.outbound.protection.outlook.com [40.107.100.89]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 745DF68A906 for ; Mon, 15 Apr 2024 17:40:23 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JSeR65cXsr997wVBzJl9UKo4sD+vFX+ZudgMwsEO1BL9BEm/PusTYsN36eapVqMh3ibyYLBrV7gD6yrI1PiQK1LJ6A2hW4ERc9bqmjRC/sqotLxUhUEYlZK1gSXQcQToF76+D/yd4kwet4RZohMO+lzyuKEdWWXMOs/2/cgtLy01eTktu+7QHDZJ6tKjZsjTAIxrLsOo25VG54BLDy4MfoSveY9v3ibTl3M3Jd+/YOnqIlnJ8NitEQ4LAXfxN37nD5AcUNtZG4jVf0rUmb8s8mt+H8Zo8gsIPdRYIKmBqNXKOYSIZ4vkjvhIiw3VuPLQTGz0t/BTOvYj1uoAo6Iz/A== 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=1NXBD+SL1v0/fHZiM5bfrugJRnJX9OpGdPeu5UECD4c=; b=ekeQ3GQCMgiiCz2bsgcU5AG/+RoIe4VTyzpR0jV10V/RcVFHyzVyRDCiGdyQVK9buMslFqlYUHopWi2eJIbVCIfHUADWvMyVt6wwkoxibUawCFV+CDWx88xHswYb4bbfEuPhukDIjd3jqY8KG+OCYCW8KxDdyVWI9wiqLEzXdFpIh5jTrN+2UigEfdciAcMMAtSo8rfVNaIw2HryMFCaaT3SVkicAeDOw3R83kuH3YEppZ+LFvyNOe3mBnU2g6sIbadoKmjujaM9/dBiV07rjkZkBL3kEvQuk0bm05a4VWZSWZ0ciFoHLDZ/p9pZk2zNeIALvygsCpbf9xpCQk33uA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=ffmpeg.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) Received: from MW4P220CA0013.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::18) by SN7PR12MB7934.namprd12.prod.outlook.com (2603:10b6:806:346::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Mon, 15 Apr 2024 14:40:18 +0000 Received: from MWH0EPF000971E4.namprd02.prod.outlook.com (2603:10b6:303:115:cafe::ab) by MW4P220CA0013.outlook.office365.com (2603:10b6:303:115::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.33 via Frontend Transport; Mon, 15 Apr 2024 14:40:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by MWH0EPF000971E4.mail.protection.outlook.com (10.167.243.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Mon, 15 Apr 2024 14:40:17 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 15 Apr 2024 07:40:03 -0700 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Mon, 15 Apr 2024 07:40:02 -0700 To: Date: Mon, 15 Apr 2024 14:39:32 +0000 Message-ID: <20240415143932.338380-1-ddesouza@nvidia.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E4:EE_|SN7PR12MB7934:EE_ X-MS-Office365-Filtering-Correlation-Id: 20ad8fad-5f99-48bf-29e7-08dc5d59f85b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +E9yAwVMbdkpKy6JJAWikqpzoa3lDMDUcNrF5Ryv9r3h4NL9l7+tlbDpkIuOFoU2rpkp7rv3msIF7/40B5AZUoI3B4eNu92TJoHUfwYqf8ZuU0TOWSta2th7IzXGfv38G/9t6zvOv5sU532ONnp7im6+L0at4qXlEmphcmW4EG1fUx1tv2sSry0i933LOjcgxsJVH4qOlygUDbTpLPINqLZUeKZYAymP4VUHcmoRhAN0uyK9jQEW4N7W4QqDATE3gB50H46PkygoILvVEABeixhRzIVeR9MhhMsLYNgCl5ma2KatWHOkF65kGK0JFbjaXQeTmNRfH8IxL3YyLsfAv/E/Pgl5UjGL6LsmF/Bpi41NL0O0JZdDJJFvKJBbJFAqHVndl0En5+nBHNsDSONKr2zVVwIjVgQPc8wWVuvkrbNowLkublnoHBxSxzlAxv81MrGjMNnkxjrK6BX1V/AN/y9nhyEgr7FurGky60oQwyxVMc3kDoa0A8fD6GBntxBzH6ZwwoePAktOW06WqQ4Qwz36PfGKwSCmHIkr+S1wIAj/OEUJe4MLddN4Vsl0N8r4nOnWhaqoXM3edzW2o9KiLvD6y6jRm88BZR52nVwWHEP9Fr8cmg5YnQ285JMU2ZDelHTnstxmcZ84a0hs35OvgJkU5WvNPOwqSjje2xnH144loN5+PDWJ70g0Ruxh9L+zt7n+yITyLeakxCYTcBuZDhE76ta2gJAwPMG55lIUk7kiA3Zq0YcCNAHHuwCauW4P X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(376005)(1800799015)(36860700004)(82310400014); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2024 14:40:17.9026 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 20ad8fad-5f99-48bf-29e7-08dc5d59f85b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000971E4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7934 Subject: [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: , X-Patchwork-Original-From: Diego Felix de Souza via ffmpeg-devel From: wzq via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: ddesouza@nvidia.com Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 6mg+874yDlsi 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. Signed-off-by: Diego Felix de Souza --- libavcodec/nvenc.c | 8 ++++---- libavcodec/nvenc_hevc.c | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) -- 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. ----------------------------------------------------------------------------------- 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) { 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 }, #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 },