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: 9393a0510b ("frontends/va: Use new RGB YUV conversion matrix")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14456
Reviewed-by: Ruijing Dong <ruijing.dong@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38892>
This commit is contained in:
David Rosca 2025-12-10 17:28:15 +01:00 committed by Marge Bot
parent 1395d806ba
commit 94f2d110a1

View file

@ -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, &param);
@ -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, &param);