Commit 181907dd26 for ffmpeg

commit 181907dd2668dafb5133d23f6431b0f05b4f12e3
Author: Michael Niedermayer <michael@niedermayer.cc>
Date:   Wed Nov 18 17:23:59 2026 +0000

    avfilter/scale_vulkan: normalize sampling by the actual texture size

    DRM imports can create a 1920x1080 image in a hardware frames context
    whose height is 1088. Using the context dimensions for normalized
    sampling stretches the luma plane and loses the bottom picture rows.

    Query the luma texture size once in the shader and reuse it when
    converting normalized coordinates back to luma pixels for chroma
    sampling. Remove the unused input dimensions from the shared push
    constant declarations. This preserves sampling for Vulkan-decoded
    frames whose images really include padding.

    Verified the dimension mismatch with Vulkan images on NVIDIA, including
    the introducing commit and its parent. Tested nearest/bilinear sampling,
    width/height padding, cropping, chroma locations, RGB conversion, and
    Vulkan H.264 decoding. The original Intel VAAPI path needs a hardware
    retest.

    Fixes: a344f0976c5d0fc736715b3a63b0128f90c56377
    Fixes: #26111
    Assisted-by: Fairy

diff --git a/libavfilter/vf_scale_vulkan.c b/libavfilter/vf_scale_vulkan.c
index 1681ad1b50..c71af65b88 100644
--- a/libavfilter/vf_scale_vulkan.c
+++ b/libavfilter/vf_scale_vulkan.c
@@ -72,7 +72,6 @@ typedef struct ScaleVulkanContext {
         int crop_y;
         int crop_w;
         int crop_h;
-        float in_dims[2];
         float in_chroma_loc[2];
         float out_chroma_loc[2];
     } opts;
@@ -99,7 +98,6 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)

     int in_planes = av_pix_fmt_count_planes(s->vkctx.input_format);
     int out_planes = av_pix_fmt_count_planes(s->vkctx.output_format);
-    const AVHWFramesContext *frames = (AVHWFramesContext *)in->hw_frames_ctx->data;

     switch (s->scaler) {
     case F_NEAREST:
@@ -178,10 +176,6 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
         s->opts.yuv_matrix[3][3] = 1.0;
     }

-    /* Normalized texture coordinates include hardware frame padding. */
-    s->opts.in_dims[0] = frames->width;
-    s->opts.in_dims[1] = frames->height;
-
     RET(ff_vk_shader_link(vkctx, shd,
                           ff_scale_comp_spv_data,
                           ff_scale_comp_spv_len, "main"));
diff --git a/libavfilter/vulkan/debayer.comp.glsl b/libavfilter/vulkan/debayer.comp.glsl
index 90a1516717..0a4e22de99 100644
--- a/libavfilter/vulkan/debayer.comp.glsl
+++ b/libavfilter/vulkan/debayer.comp.glsl
@@ -36,7 +36,6 @@ layout(push_constant, std430) uniform pushConstants {
    int crop_y;
    int crop_w;
    int crop_h;
-   vec2 in_dims;
 };

 #define LD(xo, yo) \
diff --git a/libavfilter/vulkan/scale.comp.glsl b/libavfilter/vulkan/scale.comp.glsl
index 62b11448ec..7ba95bfea7 100644
--- a/libavfilter/vulkan/scale.comp.glsl
+++ b/libavfilter/vulkan/scale.comp.glsl
@@ -48,7 +48,6 @@ layout (push_constant, std430) uniform pushConstants {
     int crop_y;
     int crop_w;
     int crop_h;
-    vec2 in_dims;
     vec2 in_chroma_loc;
     vec2 out_chroma_loc;
 };
@@ -61,7 +60,8 @@ vec4 scale_bilinear(int idx, vec2 pos, vec2 crop_range, vec2 crop_off)
     return texture(input_img[idx], npos);
 }

-vec4 scale_chroma(int idx, ivec2 pos, vec2 crop_range, vec2 crop_off)
+vec4 scale_chroma(int idx, ivec2 pos, vec2 crop_range, vec2 crop_off,
+                  vec2 in_dims)
 {
     vec2 sub = vec2(1 << log2_chroma_w, 1 << log2_chroma_h);
     vec2 npos = (vec2(pos) * sub + 0.5f + out_chroma_loc) / imageSize(output_img[0]);
@@ -103,6 +103,8 @@ void write_444(vec4 src, ivec2 pos)
 void main()
 {
     ivec2 pos = ivec2(gl_GlobalInvocationID.xy);
+    /* Imported images can be smaller than their hardware frames context. */
+    vec2 in_dims = textureSize(input_img[0], 0);
     vec2 c_r = vec2(crop_w, crop_h) / in_dims;
     vec2 c_o = vec2(crop_x, crop_y) / in_dims;

@@ -114,7 +116,7 @@ void main()

             vec4 res;
             if ((chroma_planes & (1 << i)) != 0)
-                res = scale_chroma(i, pos, c_r, c_o);
+                res = scale_chroma(i, pos, c_r, c_o, in_dims);
             else
                 res = scale_bilinear(i, vec2(pos) + 0.5f, c_r, c_o);
             imageStore(output_img[i], pos, res);