Commit a344f0976c for ffmpeg
commit a344f0976c5d0fc736715b3a63b0128f90c56377
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Tue Sep 29 21:52:33 2026 +0000
avfilter/scale_vulkan: normalize sampling by the hardware image size
Vulkan decode can return a visible 1920x1080 frame backed by a
1920x1088 image. Dividing the crop extent by the visible frame dimensions
makes scale_vulkan sample the padding along with the picture.
Use the hardware frames context dimensions for normalized texture
coordinates. Keep the visible frame dimensions for the crop extent.
With a generated H.264 testsrc2 clip, this removes the scaling difference
between Vulkan decoding and software decoding followed by hwupload.
Tested padded widths and heights, aligned controls, up/downscaling,
and both bilinear and nearest sampling on an RTX 5090.
Related to issue #24051; confirmation with the reporter's input is still
needed because the observed padding error affects both luma and chroma.
Assisted-by: Fairy
diff --git a/libavfilter/vf_scale_vulkan.c b/libavfilter/vf_scale_vulkan.c
index 770f831050..c7a2aa7495 100644
--- a/libavfilter/vf_scale_vulkan.c
+++ b/libavfilter/vf_scale_vulkan.c
@@ -94,6 +94,7 @@ 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:
@@ -167,8 +168,9 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
s->opts.yuv_matrix[3][3] = 1.0;
}
- s->opts.in_dims[0] = in->width;
- s->opts.in_dims[1] = in->height;
+ /* 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,