[FFmpeg-devel] [PATCH] vulkan_encode_av1: Fix setting QP (PR #20174)

nowrep code at ffmpeg.org
Fri Aug 8 14:28:10 EEST 2025


PR #20174 opened by nowrep
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20174
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20174.patch

Use the "qp" param instead of "global_quality" to match H264/5.

Note: Currently all codecs use the min QP as default value when no `qp` param has been set. It should instead pick some sane value, and maybe also print warning as VAAPI does.


From eb826726b8b971573f805365b22487b35089f9a0 Mon Sep 17 00:00:00 2001
From: David Rosca <nowrep at gmail.com>
Date: Fri, 8 Aug 2025 13:19:29 +0200
Subject: [PATCH] vulkan_encode_av1: Fix setting QP

Use the "qp" param instead of "global_quality" to match H264/5.
---
 libavcodec/vulkan_encode_av1.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/vulkan_encode_av1.c b/libavcodec/vulkan_encode_av1.c
index 83a8734c93..db70b2dc29 100644
--- a/libavcodec/vulkan_encode_av1.c
+++ b/libavcodec/vulkan_encode_av1.c
@@ -675,9 +675,9 @@ static int init_enc_options(AVCodecContext *avctx)
         enc->initial_buffer_fullness = enc->hrd_buffer_size * 3 / 4;
     }
 
-    if (enc->common.opts.rc_mode == VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR &&
-        avctx->global_quality) {
-        enc->q_idx_p = av_clip_intp2(avctx->global_quality / FF_QP2LAMBDA, 8);
+    if (enc->common.opts.rc_mode == VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR) {
+        enc->q_idx_p = av_clip(enc->common.opts.qp,
+                               enc->caps.minQIndex, enc->caps.maxQIndex);
         if (fabs(avctx->i_quant_factor) > 0.0)
             enc->q_idx_idr =
                 av_clip((fabs(avctx->i_quant_factor) * enc->q_idx_p  +
-- 
2.49.1



More information about the ffmpeg-devel mailing list