From 94f2d110a1e0db374b14824fa9412dd4dbc65e85 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Wed, 10 Dec 2025 17:28:15 +0100 Subject: [PATCH] frontends/va: Fix RGB/YUV conversion in Get/PutImage This needs to set some matrix, otherwise identity would be used for RGB/YUV conversion. For YUV/YUV or RGB/RGB conversion vlVaPostProcCompositor will ignore the matrices, so it's okay to always set bt709. Also set color range. Fixes: 9393a0510b5 ("frontends/va: Use new RGB YUV conversion matrix") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14456 Reviewed-by: Ruijing Dong Part-of: --- src/gallium/frontends/va/image.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gallium/frontends/va/image.c b/src/gallium/frontends/va/image.c index 48691f072eb..fd21e2a3859 100644 --- a/src/gallium/frontends/va/image.c +++ b/src/gallium/frontends/va/image.c @@ -504,6 +504,12 @@ vlVaGetImage(VADriverContextP ctx, VASurfaceID surface, int x, int y, .x1 = vaimage->width, .y1 = vaimage->height, }, + .in_color_range = util_format_is_yuv(surf->buffer->buffer_format) ? + PIPE_VIDEO_VPP_CHROMA_COLOR_RANGE_REDUCED : PIPE_VIDEO_VPP_CHROMA_COLOR_RANGE_FULL, + .out_color_range = util_format_is_yuv(tmp_surf.buffer->buffer_format) ? + PIPE_VIDEO_VPP_CHROMA_COLOR_RANGE_REDUCED : PIPE_VIDEO_VPP_CHROMA_COLOR_RANGE_FULL, + .in_matrix_coefficients = PIPE_VIDEO_VPP_MCF_BT709, + .out_matrix_coefficients = PIPE_VIDEO_VPP_MCF_BT709, }; ret = vlVaPostProcCompositor(drv, surf->buffer, tmp_surf.buffer, VL_COMPOSITOR_NONE, ¶m); @@ -674,6 +680,12 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image, .x1 = dest_x + dest_width, .y1 = dest_y + dest_height, }, + .in_color_range = util_format_is_yuv(tmp_surf.buffer->buffer_format) ? + PIPE_VIDEO_VPP_CHROMA_COLOR_RANGE_REDUCED : PIPE_VIDEO_VPP_CHROMA_COLOR_RANGE_FULL, + .out_color_range = util_format_is_yuv(surf->buffer->buffer_format) ? + PIPE_VIDEO_VPP_CHROMA_COLOR_RANGE_REDUCED : PIPE_VIDEO_VPP_CHROMA_COLOR_RANGE_FULL, + .in_matrix_coefficients = PIPE_VIDEO_VPP_MCF_BT709, + .out_matrix_coefficients = PIPE_VIDEO_VPP_MCF_BT709, }; ret = vlVaPostProcCompositor(drv, tmp_surf.buffer, surf->buffer, VL_COMPOSITOR_NONE, ¶m);