Commit ea624d1e8d for ffmpeg

commit ea624d1e8d4712995f5652bfc12579f9f7b294d1
Author: Uraza Aru <271304759+urzaru@users.noreply.github.com>
Date:   Wed Oct 14 02:14:02 2026 +0500

    avcodec/vulkan_encode_av1: zero constantQIndex when rate control is on

    VUID-vkCmdEncodeVideoKHR-constantQIndex-10320 requires constantQIndex
    to be 0 unless the rate control mode is DISABLED; the H.264 encoder
    already does the same for constantQp. The AV1 encoder always passed
    base_q_idx. On NVIDIA the frame headers then signal
    delta_q_present = 0 while blocks are evidently quantised differently,
    so every frame decodes with an error: 2560x1440 at 60 fps and
    50 Mbit/s reached only 37.3 dB PSNR, and quality fell as the bitrate
    rose (165 fps: 40.2, 38.4 and 37.7 dB at 60, 100 and 137 Mbit/s).

    With this change those become 57.1 dB and 46.8, 53.9 and 59.5 dB, on
    par with NVIDIA's own encoder sample on the same input. Constant QP is
    unchanged.

    Fixes #25046.

    Assisted-by: Claude Opus 5.5
    Signed-off-by: Uraza Aru <271304759+urzaru@users.noreply.github.com>

diff --git a/libavcodec/vulkan_encode_av1.c b/libavcodec/vulkan_encode_av1.c
index 9f864732df..e5d88803a4 100644
--- a/libavcodec/vulkan_encode_av1.c
+++ b/libavcodec/vulkan_encode_av1.c
@@ -453,6 +453,10 @@ static int init_pic_params(AVCodecContext *avctx, FFHWBaseEncodePicture *pic,
         .primaryReferenceCdfOnly = 0,
         .generateObuExtensionHeader = 0,
     };
+    /* With rate control on, the driver picks the quantiser; constantQIndex must be 0
+     * (VUID-vkCmdEncodeVideoKHR-constantQIndex-10320). */
+    if (ctx->opts.rc_mode != VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR)
+        ap->vkav1pic_info.constantQIndex = 0;
     encode_info->pNext = &ap->vkav1pic_info;

     for (int i = 0; i < FF_ARRAY_ELEMS(ap->vkav1pic_info.referenceNameSlotIndices); i++)