Commit 9ea1b5dd21 for ffmpeg
commit 9ea1b5dd219731027176f888114dc33cec3e1f51
Author: Lynne <dev@lynne.ee>
Date: Sat Dec 5 15:48:57 2026 +0800
avfilter/scale_vulkan: fix swapped red and blue converting BGRA/BGR0
BGRA and BGR0 are stored in RGBA images, so the shader read blue as red
when converting them to YUV. Swap the matrix columns for them.
diff --git a/libavfilter/vf_scale_vulkan.c b/libavfilter/vf_scale_vulkan.c
index 716d41f573..3487e328b1 100644
--- a/libavfilter/vf_scale_vulkan.c
+++ b/libavfilter/vf_scale_vulkan.c
@@ -173,6 +173,11 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
for (int y = 0; y < 3; y++)
for (int x = 0; x < 3; x++)
s->opts.yuv_matrix[x][y] = tmp_mat[x][y];
+ /* BGRA and BGR0 are stored in RGBA images */
+ if (s->vkctx.input_format == AV_PIX_FMT_BGRA ||
+ s->vkctx.input_format == AV_PIX_FMT_BGR0)
+ for (int x = 0; x < 3; x++)
+ FFSWAP(float, s->opts.yuv_matrix[x][0], s->opts.yuv_matrix[x][2]);
s->opts.yuv_matrix[3][3] = 1.0;
}