From patchwork Fri Apr 12 20:08:13 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: 48032 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:670b:b0:1a9:af23:56c1 with SMTP id wh11csp495574pzb; Fri, 12 Apr 2024 13:09:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV/5oNTOeBCO7HEjzoZoVPnWWahcmE7ri/aELTDdQjYihzx65+iw2WlsqDFP4oKP9GOLM49yzUg/2O1QXLDu6sCfIs3/ora2heqNg== X-Google-Smtp-Source: AGHT+IHFl3nDQ424xWbejaTQYs9Cc66FyvxpV2b2A+ABWcDrA4swlWpDcO7bhv3Do5Bs+74d/pD7 X-Received: by 2002:a50:ab50:0:b0:568:1248:9f49 with SMTP id t16-20020a50ab50000000b0056812489f49mr2096417edc.18.1712952560761; Fri, 12 Apr 2024 13:09:20 -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 s18-20020a50ab12000000b0056c4f2a7346si2004100edc.23.2024.04.12.13.09.20; Fri, 12 Apr 2024 13:09:20 -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 2265968D2E2; Fri, 12 Apr 2024 23:09:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2061.outbound.protection.outlook.com [40.107.92.61]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CAD0668D2BE for ; Fri, 12 Apr 2024 23:09:04 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QUS1w+obAy8085UbZu8rv9PBc1/2kEMMjKUAK8AiBb4ogUxlrc2uUlCS3xg4HBtP+5GH0Uhxl4tV3WF40Mru6W+0sRwbbargMK0d5WNqZQdqw5xX+rLAT5Q5kFKZmD7ftAqltoX4N2BEeugfj/BEAIvhyhxwXIFi2Q2BM8j14BtH9zrTFmFpo9YnKeiOamsNJIzxm5N3NYMm78uexmPfIEHbAf77s3TzriGfHYPyetDYQ3zx9qEOYvyh+NuMKO4pEqJJMgyGBMOLb2iGEK/cGD2jMX6M7I49AWKjzms5P6iPplIr25WhnU+B8OX811igrLIqJ4liROmgmmBVxa2d9w== 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=uns21e6cbLVzbiIh7upoJ9N2h2d1MwgUQQe6Q0YLHHU=; b=oMTh/ny7KiHaSX6TgLBgdlquFBEp2ZbdOBA3HiA0gnMBVyuNRhLR6lVgHIg0mK6tciP3t6Z5xKO0pWcoVzJPCw5cnvhMECsnAYaMxXe/RKUfMACbd4Nwjs6WYzK+0flF1HyefJyVNYeWa2mvYk3ZgIceuZZpiL/FGBn4SvNl5rQkLEjSiLy5/Oj9Q5ZFvTJYTJ6RwKbF2VTG5xHEmpv6PPIJqdzdBhFp65CJ2EoK4GDRZMYvJAr3/UKi/lAUfDNHJsjG2eGJRI0U7N159eZtMAW20vlSR9oMajAER5CAZg6xuMq2lj1Zzyq+apiDdfj7ky/vk8vyLIIt0S0VcAjPcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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 MW4PR03CA0240.namprd03.prod.outlook.com (2603:10b6:303:b9::35) by DS0PR12MB7897.namprd12.prod.outlook.com (2603:10b6:8:146::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.55; Fri, 12 Apr 2024 20:08:54 +0000 Received: from MWH0EPF000A6730.namprd04.prod.outlook.com (2603:10b6:303:b9:cafe::b9) by MW4PR03CA0240.outlook.office365.com (2603:10b6:303:b9::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.26 via Frontend Transport; Fri, 12 Apr 2024 20:08:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by MWH0EPF000A6730.mail.protection.outlook.com (10.167.249.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 20:08:53 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 12 Apr 2024 13:08:37 -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; Fri, 12 Apr 2024 13:08:36 -0700 To: Date: Fri, 12 Apr 2024 20:08:13 +0000 Message-ID: <20240412200813.611054-2-ddesouza@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412200813.611054-1-ddesouza@nvidia.com> References: <20240411115844.290887-1-ddesouza@nvidia.com> <20240412200813.611054-1-ddesouza@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6730:EE_|DS0PR12MB7897:EE_ X-MS-Office365-Filtering-Correlation-Id: 42749ca2-93bf-43ed-7d1c-08dc5b2c609b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EPV4sdAH5bGAGunjDzbIiBTja8KZSs4BMcjr0ebb8Nj1cs1iBZMliVHOIDkQyfcmKtO7BCYAS729g3+vrteuuEMrPQ6e5IHFB/89PVBwHRUAzSchhWZojTo9OKrp3iWK3CpqcdJ1bgcbS/npWYzlOTgz0uaPrKiQnzubGXdtf7sgTLXjDELbeoVaFvmFZrBu7WfrZWv3/lllp5JHA7cY3M2/P8Jc6EYHYPyVBpkzEesTSPpIAS4b3im1n9xNQhcKsUni5YP0XlLBWbro+wE+z+c9ZR2H0U2VJ7DExJ7VDb+ob2NjH/LtO8Ks138zsUVHGsqvEyTr4U5Oisxdn7Jud12bbZ/ADoz0bjxSGkn4MvpE+ugt2eKWqghL7q77xt82hn4StZzyjo1/RuoY0gLX6ypLzMwXl8QSnBacLkgD+xnQYflPpW5aTmZL2CYk0iJP5B6V7tjrbyhbJIzrwx8dRhtmWDe2k6l3A0iPtF7iCZEUyODi+TjOtwZr4Ls8aqyp6rAWucrXi6YK6XaRksdofFTpaYkKYU0fHZ6bwcK4IGNKH4sp+mTB4Twsikt6qsEY81izkuyVSXyVLQuckEXWZECYx5MWes4lEZaST56RCpaJngbyVJeulv8vM7+XVb5XeJBPqwZJz18b04LfHg7L4J/GsSZ7VoDZTgkxOewE23eWp8wD6yTRgLW2HAIWYADRd2iWUaD0o/JByUSc1rl04HDlpIURkbbPMQ3tSQJtiQOKkZub04KWp+NFXG0bEOcj2f4ENBn+h4l/AWIW73f/se+rQPqv6VaqK006otttMd28SDmdNTa0B0oUKbCFdzVx40genz6DMcwuF1/NNQ2btKDsr8VnSt+nB6pjAVe0GsjLKZARA04Hd3GM9YaNCOpVh6Tpl4smDjIfFFBjVN0gEg/A5JOy1D1gw0uBnbQuyB4AvyTb8PmRmbHGJ0+NLn4PdkaN3AuOzo8TkL5eVzreLDH7gZdZvD0miXbZmuwEk30sCiq9Mvpli9BcEhzFcxqIXnWRoG1JAqv9ttd5l1g2uifWCjbILWSpJtl1imf0xhrpTBY1PEdUAZXBh1rMWJLS7RDRZJTsJ42d8lnr0uPDE+PAGktyoBVAvuEsat7cuL0nb6khBtbi2DwFK5E0pzvg7RD8JzIOrApWluFi9EQqCq0lUGjBN/S/5VyiES2EGZJXR3TYkyHSO8Fhi34OqE8ClMzxRWbr6cGQ/pWnAGEdyxnBBBlvdZJkQujXv1Oj54TNfP8WlSbhfiTrRc9EzPN8jHnWeEhpFA/omM7mWl6Oi0wCFPLd+UPkx5ElV/HpaYveKTK1LQ2NUAMv3NihGh4OnU6BRpRPgCWGs2ifaer+i8p7gMA1CxltZZxaxrXPLA0o788F3jtyKZv+IoQOq+rT X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230031)(1800799015)(36860700004)(82310400014)(376005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 20:08:53.5852 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 42749ca2-93bf-43ed-7d1c-08dc5b2c609b 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.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6730.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7897 Subject: [FFmpeg-devel] [PATCH v2 2/2] avcodec/nvenc: Multi NVENC Split Frame Encoding in HEVC and AV1 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: 84dz6HOpNUlW From: Diego Felix de Souza When Split frame encoding is enabled, each input frame is partitioned into horizontal strips which are encoded independently and simultaneously by separate NVENCs, usually resulting in increased encoding speed compared to single NVENC encoding. Signed-off-by: Diego Felix de Souza --- libavcodec/nvenc.c | 14 ++++---------- libavcodec/nvenc_av1.c | 2 +- libavcodec/nvenc_hevc.c | 2 +- 3 files changed, 6 insertions(+), 12 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 f4d0d21715..469ef3bebd 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -1697,18 +1697,12 @@ FF_ENABLE_DEPRECATION_WARNINGS ctx->init_encode_params.enableWeightedPrediction = 1; #ifdef NVENC_HAVE_SPLIT_FRAME_ENCODING - if (avctx->codec->id != AV_CODEC_ID_H264 ) - ctx->init_encode_params.splitEncodeMode = ctx->split_encode_mode; + ctx->init_encode_params.splitEncodeMode = ctx->split_encode_mode; if ((ctx->split_encode_mode != NV_ENC_SPLIT_DISABLE_MODE) && - ((ctx->weighted_pred == 1) && (avctx->codec->id == AV_CODEC_ID_HEVC ))) { - av_log(avctx, AV_LOG_WARNING, "Split encoding is not " - "supported if any of the following features: weighted prediction, " - "alpha layer encoding, subframe mode, output into video memory " - "buffer, picture timing/buffering period SEI message insertion " - "with DX12 interface are enabled in case of HEVC. For AV1, split " - "encoding is not supported when output into video memory buffer " - "is enabled.\n"); + ((ctx->weighted_pred == 1) && (avctx->codec->id == AV_CODEC_ID_HEVC))) + { + av_log(avctx, AV_LOG_WARNING, "Split encoding not supported with weighted prediction enabled.\n"); } #endif diff --git a/libavcodec/nvenc_av1.c b/libavcodec/nvenc_av1.c index 45dc3c26e0..a9e065e3b9 100644 --- a/libavcodec/nvenc_av1.c +++ b/libavcodec/nvenc_av1.c @@ -159,7 +159,7 @@ static const AVOption options[] = { { "3", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LOOKAHEAD_LEVEL_3 }, 0, 0, VE, .unit = "lookahead_level" }, #endif #ifdef NVENC_HAVE_SPLIT_FRAME_ENCODING - { "split_encode_mode", "Specifies the split encoding mode", OFFSET(split_encode_mode), AV_OPT_TYPE_INT, { .i64 = NV_ENC_SPLIT_DISABLE_MODE }, 0, NV_ENC_SPLIT_DISABLE_MODE, VE, .unit = "split_encode_mode" }, + { "split_encode_mode", "Specifies the split encoding mode", OFFSET(split_encode_mode), AV_OPT_TYPE_INT, { .i64 = NV_ENC_SPLIT_AUTO_MODE }, 0, NV_ENC_SPLIT_DISABLE_MODE, VE, .unit = "split_encode_mode" }, { "disabled", "Disabled for all configurations", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_SPLIT_DISABLE_MODE }, 0, 0, VE, .unit = "split_encode_mode" }, { "auto", "Enabled or disabled depending on the preset and tuning info", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_SPLIT_AUTO_MODE }, 0, 0, VE, .unit = "split_encode_mode" }, { "forced", "Enabled with number of horizontal strips selected by the driver", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_SPLIT_AUTO_FORCED_MODE }, 0, 0, VE, .unit = "split_encode_mode" }, diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c index 1f5e56ecd0..b949cb1bd7 100644 --- a/libavcodec/nvenc_hevc.c +++ b/libavcodec/nvenc_hevc.c @@ -218,7 +218,7 @@ static const AVOption options[] = { { "unidir_b", "Enable use of unidirectional B-Frames.", OFFSET(unidir_b), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, #endif #ifdef NVENC_HAVE_SPLIT_FRAME_ENCODING - { "split_encode_mode", "Specifies the split encoding mode", OFFSET(split_encode_mode), AV_OPT_TYPE_INT, { .i64 = NV_ENC_SPLIT_DISABLE_MODE }, 0, NV_ENC_SPLIT_DISABLE_MODE, VE, .unit = "split_encode_mode" }, + { "split_encode_mode", "Specifies the split encoding mode", OFFSET(split_encode_mode), AV_OPT_TYPE_INT, { .i64 = NV_ENC_SPLIT_AUTO_MODE }, 0, NV_ENC_SPLIT_DISABLE_MODE, VE, .unit = "split_encode_mode" }, { "disabled", "Disabled for all configurations", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_SPLIT_DISABLE_MODE }, 0, 0, VE, .unit = "split_encode_mode" }, { "auto", "Enabled or disabled depending on the preset and tuning info", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_SPLIT_AUTO_MODE }, 0, 0, VE, .unit = "split_encode_mode" }, { "forced", "Enabled with number of horizontal strips selected by the driver", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_SPLIT_AUTO_FORCED_MODE }, 0, 0, VE, .unit = "split_encode_mode" },