From patchwork Fri Sep 20 11:33:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?V=C3=ADctor_Manuel_J=C3=A1quez_Leal?= X-Patchwork-Id: 51678 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d154:0:b0:48e:c0f8:d0de with SMTP id bt20csp898509vqb; Fri, 20 Sep 2024 04:33:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW1m4d41YgXi6WDoNxyolDr/p3oXgNY1goVEF0L5jzRy/4kYJu4CSzoouSghbXa721yKjgUIqTPcuw+oFGh5YFn@gmail.com X-Google-Smtp-Source: AGHT+IEoCEf4cYfK3HJ20nbyNLp0cRtsnFN6/fY219z62omBZY7rZ7Mwi8PAg06xb+TViwUzGcOg X-Received: by 2002:a05:6512:a8e:b0:536:545c:bbfa with SMTP id 2adb3069b0e04-536ad164314mr1050291e87.20.1726832014286; Fri, 20 Sep 2024 04:33:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726832014; cv=none; d=google.com; s=arc-20240605; b=MrypFq6dTW6cOdtih5mQ951z8VphhUXUGtGmZuhC/OV4R01eCVOwXmS6aBYDGuoNEx ozr+RDQpUm8opjaZTfKXhVDzZ4clsS2Dscz48VCZ30wKY2FBusuIP0XJnNPqc7fq+nKY KYGrIo5CX8KO0BOoZiFvqX3qXqGwVqqyzRZyLaDpGjqsiDwxMOe4caB+QA1YBMpvfH1U Pl5kzKsav0PBXUxTLp7Woa1JPVw3Rju47YIZn0dHAbZVLWCN/U2n2hppC+Kmnlrd2rGD c91eaa3aTuivAHMyAXdZ/Jmaa5yTBDazZ0qf2TmhG825/eJFz5Lrm2gmk3eDVVKcKkfj pIQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=PzNh7abVtXna8awXO4CM8XnHy43NDLHcQmUZuGYNYk4=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=BG6bClhtvhStRGMAX84j0wd5oggiMLhbdqFsLRNl1JE4xIAGUY7zH3uCrwMvMKCYVY ns8Xq5Cpm870YgG0h/srF35VYtFGywmCKTKX5g9DK5bUOi9veGp2DGU5uPtxaPyawrSa tny7Oid4f1cPJQ71bg8alSvcWKz9lTIj4CytV52wlHI36G4Yr8hpKLPbPxz7AmAH06qe M5t5ZfDTKifleBBXnTLDmMmlBPF5Fj/4dEA0FZyZ32notyq9zgINBNMuy9WmVOmIwi1N dNgboMf7/RNm/nQ1d94J0jSWrXuyEUhQWtE9vxnupORxWqQU3r3cFW7oJhf30MNrwtJm 4fPQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@igalia.com header.s=20170329 header.b=nIWFoXGN; 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=NONE dis=NONE) header.from=igalia.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 2adb3069b0e04-5368708dff9si4876200e87.279.2024.09.20.04.33.33; Fri, 20 Sep 2024 04:33:34 -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; dkim=neutral (body hash did not verify) header.i=@igalia.com header.s=20170329 header.b=nIWFoXGN; 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=NONE dis=NONE) header.from=igalia.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9CA3368DCCA; Fri, 20 Sep 2024 14:33:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B530368D57A for ; Fri, 20 Sep 2024 14:33:21 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject: To:From:Sender:Reply-To:Cc:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=PzkT6V7gO85pKAMld9uVVHfg6ixRoc/+Mq3zjK7qYt8=; b=nIWFoXGNb75AZzWpXUK4WGZZXs MpPlOKJ/p8EaWuITYAN76JFeE2dhgPm/tY344hVvDZ/trVu6mcSgXB4Zi+fMApoM1bqOAEb6MIgQX pkoWUfjZFj4wT6O3OWIDF1uzboaUBbQ+vz9aTjyG8XRy5ZJguYH+Y6trx2VSTwyi6dBcFOoHH68Fs uTddro0KG3YhjQbg0/trNtIPhhLu1NPGFtF9lO6Z2Oy0zoG11oF/hbz82sHewBo2FPP37SWzQ3FSA vSleq87MRN33/Po0abygUxWo2JAU5UOsRKhFUwqWhWTqssJMPSx+3sbjoprH3qhTUSS3Vun0tVWrt cUxR39kw==; Received: from static-149-87-62-95.ipcom.comunitel.net ([95.62.87.149] helo=octavia) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1srbt1-00G3kD-C5 for ; Fri, 20 Sep 2024 13:33:19 +0200 Received: from vjaquez by octavia with local (Exim 4.98) (envelope-from ) id 1srbsz-00000003BiM-2lFE for ffmpeg-devel@ffmpeg.org; Fri, 20 Sep 2024 13:33:17 +0200 From: =?utf-8?q?V=C3=ADctor_Manuel_J=C3=A1quez_Leal?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Sep 2024 13:33:17 +0200 Message-ID: <20240920113317.760007-1-vjaquez@igalia.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] vulkan_encode: set the quality level in session parameters 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 0G3ue5rKvDj9 While running this command ./ffmpeg_g -loglevel debug -hwaccel vulkan -init_hw_device vulkan=vk:0,debug=1 -hwaccel_output_format vulkan -i input.y4m -vf 'format=nv12,hwupload' -c:v h264_vulkan -quality 2 output.mp4 -y It hit this validation error: Validation Error: [ VUID-vkCmdEncodeVideoKHR-None-08318 ] Object 0: handle = 0x8f000000008f, type = VK_OBJECT_TYPE_VIDEO_SESSION_KHR; Object 1: handle = 0xfd00000000fd, type = VK_OBJECT_TYPE_VIDEO_SESSION_PARAMETERS_KHR; | MessageID = 0x5dc3dd39 | vkCmdEncodeVideoKHR(): The currently configured encode quality level (2) for VkVideoSessionKHR 0x8f000000008f[] does not match the encode quality level (0) VkVideoSessionParametersKHR 0xfd00000000fd[] was created with. The Vulkan spec states: The bound video session parameters object must have been created with the currently set video encode quality level for the bound video session at the time the command is executed on the device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdEncodeVideoKHR-None-08318) This patch sets the quality level at session parameter creation for both H.264 and H.265 Vulkan encoders. --- libavcodec/vulkan_encode_h264.c | 8 +++++++- libavcodec/vulkan_encode_h265.c | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libavcodec/vulkan_encode_h264.c b/libavcodec/vulkan_encode_h264.c index af229afe52..4b78e6f43d 100644 --- a/libavcodec/vulkan_encode_h264.c +++ b/libavcodec/vulkan_encode_h264.c @@ -1016,6 +1016,7 @@ static int create_session_params(AVCodecContext *avctx) VkVideoEncodeH264SessionParametersAddInfoKHR h264_params_info; VkVideoEncodeH264SessionParametersCreateInfoKHR h264_params; VkVideoSessionParametersCreateInfoKHR session_params_create; + VkVideoEncodeQualityLevelInfoKHR q_info; /* Convert it to Vulkan */ err = base_unit_to_vk(avctx, &vk_units); @@ -1044,9 +1045,14 @@ static int create_session_params(AVCodecContext *avctx) .maxStdPPSCount = 1, .pParametersAddInfo = &h264_params_info, }; + q_info = (VkVideoEncodeQualityLevelInfoKHR) { + .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_QUALITY_LEVEL_INFO_KHR, + .pNext = &h264_params, + .qualityLevel = ctx->opts.quality, + }; session_params_create = (VkVideoSessionParametersCreateInfoKHR) { .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR, - .pNext = &h264_params, + .pNext = &q_info, .videoSession = ctx->common.session, .videoSessionParametersTemplate = NULL, }; diff --git a/libavcodec/vulkan_encode_h265.c b/libavcodec/vulkan_encode_h265.c index 3cb7a3b7df..f1e61ab894 100644 --- a/libavcodec/vulkan_encode_h265.c +++ b/libavcodec/vulkan_encode_h265.c @@ -1166,6 +1166,7 @@ static int create_session_params(AVCodecContext *avctx) VkVideoEncodeH265SessionParametersAddInfoKHR h265_params_info; VkVideoEncodeH265SessionParametersCreateInfoKHR h265_params; VkVideoSessionParametersCreateInfoKHR session_params_create; + VkVideoEncodeQualityLevelInfoKHR q_info; /* Convert it to Vulkan */ err = base_unit_to_vk(avctx, &vk_units); @@ -1197,9 +1198,14 @@ static int create_session_params(AVCodecContext *avctx) .maxStdVPSCount = 1, .pParametersAddInfo = &h265_params_info, }; + q_info = (VkVideoEncodeQualityLevelInfoKHR) { + .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_QUALITY_LEVEL_INFO_KHR, + .pNext = &h265_params, + .qualityLevel = ctx->opts.quality, + }; session_params_create = (VkVideoSessionParametersCreateInfoKHR) { .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR, - .pNext = &h265_params, + .pNext = &q_info, .videoSession = ctx->common.session, .videoSessionParametersTemplate = NULL, };