From patchwork Sun Mar 3 11:37:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46722 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2264555pzb; Sun, 3 Mar 2024 03:35:45 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXL3VwDfARnEvzbYEaHo9cWsGYN1cv2sX0OK5yWnN6KmL7KbMbl8wbGVKsA0OYY2q8QaBUBt2liIzHD1MMOpGKyC5FG0BGbOXeZ4Q== X-Google-Smtp-Source: AGHT+IEKmbnFIwmWCYQ6qae00Eb8QH596Z3463uA93ZdGjIYzKgIORkwNnWTAsRQ7FhS2GtAtiiZ X-Received: by 2002:a05:6402:31af:b0:566:f603:75d2 with SMTP id dj15-20020a05640231af00b00566f60375d2mr2999901edb.16.1709465744749; Sun, 03 Mar 2024 03:35:44 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f18-20020a056402355200b005653f265584si3145035edd.241.2024.03.03.03.35.44; Sun, 03 Mar 2024 03:35:44 -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; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=Gk7juGe3; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3288D68D389; Sun, 3 Mar 2024 13:35:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04olkn2107.outbound.protection.outlook.com [40.92.75.107]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 92FA368D2D1 for ; Sun, 3 Mar 2024 13:35:31 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YIkG2DrH7/a3A4wzGZYTCsj2oqaDpqCpXGqcv9xB2TyK3QiexieiiyDciyrxGjy0s0fO+of+e83K9WSfFqRHiI2Y1o7h0Nw4hBeFcmS+hSMWygmaUaNMT+3KnqX9JlDHKkOKVMbvfEce+tI9xvi7qUrsp7MTYx+Y/Kuq80N1lRKCcWo5VSoHExI86j/k86UWRa+gHnU0vfyQY8/WifwaivAJZjY23P/CuFKKn0GtDTYbtc7vTe9HGGCKzBlJZ6/0B5lpqG8joKiCqGwwAl4AK/8v2Ant2llgibhZStOO0YSnDwrKr+WJ9/626lHekytV/hCo/k44S3Xx7Ca5fg4X3Q== 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=XkJAgf2BAERab4yARr9CuCEUwX84gmPLPbxsUNsEBFM=; b=OZ1qH4LMwvMnQYXQjeQE191VHuull5nTqadlvoEpp3dXadYA06CbYLvNptknMx9LXYXMQs1BJd6w948qV1+clm14UzMGNoTfDluXWsMq9eKrA5DZCE/IaiRJD2uymRHsCX5kwJkON6HhHMNkaC06Tb9hoahrZ6PUgQ2SLW3SgHXj79EtM8lgyku+wdUrHDjtSfZsPhHoZnViPJaTmkEtC7W07ymdqw2JJLMLqXcs2m5wat4lM91+MT7ltM5/ZZnwS1J+clhMgFSuPfoTjG8mEzM0h4hEnKWSV5YFEoht1GlCxGEk8caMwqMVFGCXh6zSJCS6UiWqip5KAmQpYcGkGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XkJAgf2BAERab4yARr9CuCEUwX84gmPLPbxsUNsEBFM=; b=Gk7juGe3RrBpZw25jNK5/QF9KwHRzLS7t7UBRES62lmvbxCwnixpbON2mkj0UpoHYxzo35DpZgMKZ9Jfk8f9gqgWTS52Po72o/WcpPE8KNJ1JlCgwGZlxhwyN1WOiB1fE8HjKddFmElX55pj3LxSEWeXa0xq2yQyfUQO7XC0NKyLD9Mun/6IZlxlomHX9jFjNIXB42Z4UeJulLEASixQrES43+gMGmOeaud/fux6/9CCkA1G7sDC7ovrZWyQkeP11yvrG9H1HevHjFngoF+faN7GnKrJfZKYfwM4nC2RKScMxYEKngB+bldopgHawzKsndrJx5hJO49TmIg7cT+3MA== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by AS1P250MB0429.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:4aa::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.39; Sun, 3 Mar 2024 11:35:26 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d%5]) with mapi id 15.20.7316.023; Sun, 3 Mar 2024 11:35:26 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 3 Mar 2024 12:37:18 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [9Wje/W362riAG3C/O1a9TaAK0KNy0CMk] X-ClientProxiedBy: FR5P281CA0052.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f0::11) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240303113718.313583-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|AS1P250MB0429:EE_ X-MS-Office365-Filtering-Correlation-Id: 1df617c2-440a-4107-3716-08dc3b760577 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PHbrn4HvkEahwFpLjxd5cNSORAKnaAg78IbCSDbLp4x8l+LSnoHkbpcC8uP5Pnyy1GMYztqt9asdc5VMwMjKc/IclNfZb4no1BBsmCyDD+IPp6F8aYeG+8yjf5x1POTnFvE0BpxnsCEcxQFUr+z2MMEyHNvE6JGEUpsU73/si6fIsMKxQPVdb1ZeoG8n4IQbig8jiWqD8xStkrhZKQqnMQeSdymbgj/L/OewMCLR61qqd82p5YPHd0imdU3WCYBN6XFz2OoSy0zAh7F4UL2d994scK3KsDs+7g0rQdbGrhRLpDRsrKVfkbTuEImfbHLqzjJJUgj3P7RUwqzPtXdWxrnRTzGgJesV9eWTGLjmIsalFYcScBy4unVyREM00EW3M0uEaas81ZzWimDLv82KPOJNOkVIVCpc/BQzv+WkXOEC4cJl5+n50abaBYqmIr6uDSXCuZk8/WgfNundUiRizD+dH5QaWqDl11IjuAq41L5DW1tX/uS2YzAYs4VxZRHsg9yNxbPSk+9ONY+rUhvq54YkcU93R0rnUHlgLTkIj9/OmIjxRI8wWFY4OA5QVViwMvXGyR8Yocv12nMZiRp1WOGlhts2KBNbgX2c5wJpNecvRlksVRUmnr0sFQwMKBxZ X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VjhW7Pstw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ENj0MdDeXKxLRGA+Kvxm1tFKc6Ai6CT+H0btMuPrd2Tt+Vr4fiX2Md4DkTMY/Guelm//lhYl8+yPNSk4+KiZXUBiTb4uXl+oJymiOuE6v+OKPdHKs9w089nB+LI0El9PoAgH3Jm5bts+CJdaOShvPNe3ABfyExkv4Mo1eueuJMSjyxAGZzEFhUIWb1pLhpuQd3d6yTqtpdBnGo9vYbEpi20vA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1df617c2-440a-4107-3716-08dc3b760577 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2024 11:35:26.5242 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1P250MB0429 Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/vulkan_decode: Un-sparse extensions table 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: xdwmF8L3BD0+ Only three of the 226 (== AV_CODEC_ID_AV1) entries have been used. Unsparsing this table is especially important given that this array lives in .data.rel.ro. Signed-off-by: Andreas Rheinhardt --- Instead of parallel tables, one could also merge VkCodecMap and VkExtensionProperties (i.e. putting one of the latter inside the former) if preferred. libavcodec/vulkan_decode.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c index b80415a019..121ed40f40 100644 --- a/libavcodec/vulkan_decode.c +++ b/libavcodec/vulkan_decode.c @@ -28,22 +28,29 @@ typedef struct VkCodecMap { VkVideoCodecOperationFlagBitsKHR decode_op; } VkCodecMap; +/* The following table and dec_ext below are supposed to be parallel. */ static const VkCodecMap vk_codec_map[] = { +#if CONFIG_H264_VULKAN_HWACCEL { .codec_id = AV_CODEC_ID_H264, .decode_extension = FF_VK_EXT_VIDEO_DECODE_H264, .decode_op = VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR, }, +#endif +#if CONFIG_HEVC_VULKAN_HWACCEL { .codec_id = AV_CODEC_ID_HEVC, .decode_extension = FF_VK_EXT_VIDEO_DECODE_H265, .decode_op = VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR, }, +#endif +#if CONFIG_AV1_VULKAN_HWACCEL { .codec_id = AV_CODEC_ID_AV1, .decode_extension = FF_VK_EXT_VIDEO_DECODE_AV1, .decode_op = 0x01000000, /* TODO fix this */ }, +#endif }; #if CONFIG_H264_VULKAN_HWACCEL @@ -58,16 +65,19 @@ extern const VkExtensionProperties ff_vk_dec_av1_ext; static const VkExtensionProperties *dec_ext[] = { #if CONFIG_H264_VULKAN_HWACCEL - [AV_CODEC_ID_H264] = &ff_vk_dec_h264_ext, + &ff_vk_dec_h264_ext, #endif #if CONFIG_HEVC_VULKAN_HWACCEL - [AV_CODEC_ID_HEVC] = &ff_vk_dec_hevc_ext, + &ff_vk_dec_hevc_ext, #endif #if CONFIG_AV1_VULKAN_HWACCEL - [AV_CODEC_ID_AV1] = &ff_vk_dec_av1_ext, + &ff_vk_dec_av1_ext, #endif }; +_Static_assert(FF_ARRAY_ELEMS(dec_ext) == FF_ARRAY_ELEMS(vk_codec_map), + "dec_ext and vk_codec_map out-of-sync"); + static const VkCodecMap *get_codecmap(enum AVCodecID codec_id) { for (size_t i = 0; i < FF_ARRAY_ELEMS(vk_codec_map); i++) @@ -77,6 +87,11 @@ static const VkCodecMap *get_codecmap(enum AVCodecID codec_id) return NULL; } +static const VkExtensionProperties *get_extension(const VkCodecMap *vk_codec) +{ + return dec_ext[vk_codec - vk_codec_map]; +} + static const VkVideoProfileInfoKHR *get_video_profile(FFVulkanDecodeShared *ctx, enum AVCodecID codec_id) { const VkVideoProfileListInfoKHR *profile_list; @@ -772,6 +787,7 @@ static int vulkan_decode_get_profile(AVCodecContext *avctx, AVBufferRef *frames_ VkResult ret; int max_level, base_profile, cur_profile; const VkCodecMap *vk_codec = get_codecmap(avctx->codec_id); + const VkExtensionProperties *extension = get_extension(vk_codec); AVHWFramesContext *frames = (AVHWFramesContext *)frames_ref->data; AVHWDeviceContext *device = (AVHWDeviceContext *)frames->device_ref->data; AVVulkanDeviceContext *hwctx = device->hwctx; @@ -890,10 +906,10 @@ static int vulkan_decode_get_profile(AVCodecContext *avctx, AVBufferRef *frames_ caps->maxActiveReferencePictures); av_log(avctx, AV_LOG_VERBOSE, " Codec header name: '%s' (driver), '%s' (compiled)\n", caps->stdHeaderVersion.extensionName, - dec_ext[avctx->codec_id]->extensionName); + extension->extensionName); av_log(avctx, AV_LOG_VERBOSE, " Codec header version: %i.%i.%i (driver), %i.%i.%i (compiled)\n", CODEC_VER(caps->stdHeaderVersion.specVersion), - CODEC_VER(dec_ext[avctx->codec_id]->specVersion)); + CODEC_VER(extension->specVersion)); av_log(avctx, AV_LOG_VERBOSE, " Decode modes:%s%s%s\n", dec_caps->flags ? "" : " invalid", @@ -1221,7 +1237,7 @@ int ff_vk_decode_init(AVCodecContext *avctx) session_create.maxActiveReferencePictures = ctx->caps.maxActiveReferencePictures; session_create.pictureFormat = s->hwfc->format[0]; session_create.referencePictureFormat = session_create.pictureFormat; - session_create.pStdHeaderVersion = dec_ext[avctx->codec_id]; + session_create.pStdHeaderVersion = get_extension(vk_codec); session_create.pVideoProfile = profile; /* Create decode exec context for this specific main thread.