mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-30 05:00:32 +01:00
frontends/va: Use new RGB YUV conversion matrix
This adds support for SMPTE240M, BT2020 and RGB->YUV conversion for all color standards and color ranges. Acked-by: Ruijing Dong <ruijing.dong@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37058>
This commit is contained in:
parent
a284bff8ad
commit
9393a0510b
3 changed files with 14 additions and 38 deletions
|
|
@ -221,10 +221,6 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
|
|||
goto error_compositor;
|
||||
if (!vl_compositor_init_state(&drv->cstate, drv->pipe))
|
||||
goto error_compositor_state;
|
||||
|
||||
vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, true, &drv->csc);
|
||||
if (!vl_compositor_set_csc_matrix(&drv->cstate, (const vl_csc_matrix *)&drv->csc, 1.0f, 0.0f))
|
||||
goto error_csc_matrix;
|
||||
}
|
||||
|
||||
(void) mtx_init(&drv->mutex, mtx_plain);
|
||||
|
|
@ -252,10 +248,6 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
|
|||
|
||||
return VA_STATUS_SUCCESS;
|
||||
|
||||
error_csc_matrix:
|
||||
if (can_init_compositor)
|
||||
vl_compositor_cleanup_state(&drv->cstate);
|
||||
|
||||
error_compositor_state:
|
||||
if (can_init_compositor)
|
||||
vl_compositor_cleanup(&drv->compositor);
|
||||
|
|
|
|||
|
|
@ -58,14 +58,11 @@ vlVaPostProcCompositor(vlVaDriver *drv,
|
|||
struct pipe_vpp_desc *param)
|
||||
{
|
||||
struct pipe_surface *surfaces;
|
||||
enum VL_CSC_COLOR_STANDARD color_standard;
|
||||
enum pipe_video_vpp_matrix_coefficients coeffs;
|
||||
enum vl_compositor_rotation rotation;
|
||||
enum vl_compositor_mirror mirror;
|
||||
bool src_yuv = util_format_is_yuv(src->buffer_format);
|
||||
bool dst_yuv = util_format_is_yuv(dst->buffer_format);
|
||||
bool dst_full_range =
|
||||
param->out_color_range == PIPE_VIDEO_VPP_CHROMA_COLOR_RANGE_FULL ||
|
||||
(param->out_color_range == PIPE_VIDEO_VPP_CHROMA_COLOR_RANGE_NONE && !dst_yuv);
|
||||
|
||||
if (!drv->cstate.pipe)
|
||||
return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
|
||||
|
|
@ -78,27 +75,13 @@ vlVaPostProcCompositor(vlVaDriver *drv,
|
|||
if (!surfaces[0].texture)
|
||||
return VA_STATUS_ERROR_INVALID_SURFACE;
|
||||
|
||||
if (src_yuv == dst_yuv) {
|
||||
color_standard = VL_CSC_COLOR_STANDARD_IDENTITY;
|
||||
} else if (src_yuv) {
|
||||
switch (param->in_colors_standard) {
|
||||
case PIPE_VIDEO_VPP_COLOR_STANDARD_TYPE_BT601:
|
||||
color_standard = VL_CSC_COLOR_STANDARD_BT_601;
|
||||
break;
|
||||
case PIPE_VIDEO_VPP_COLOR_STANDARD_TYPE_BT709:
|
||||
default:
|
||||
color_standard = param->in_color_range == PIPE_VIDEO_VPP_CHROMA_COLOR_RANGE_FULL ?
|
||||
VL_CSC_COLOR_STANDARD_BT_709_FULL : VL_CSC_COLOR_STANDARD_BT_709;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
color_standard = VL_CSC_COLOR_STANDARD_BT_709_REV;
|
||||
}
|
||||
if (src_yuv == dst_yuv || util_format_get_nr_components(src->buffer_format) == 1)
|
||||
coeffs = PIPE_VIDEO_VPP_MCF_RGB; /* identity */
|
||||
else
|
||||
coeffs = src_yuv ? param->in_matrix_coefficients : param->out_matrix_coefficients;
|
||||
|
||||
if (util_format_get_nr_components(src->buffer_format) == 1)
|
||||
color_standard = VL_CSC_COLOR_STANDARD_IDENTITY;
|
||||
|
||||
vl_csc_get_matrix(color_standard, NULL, dst_full_range, &drv->csc);
|
||||
vl_csc_get_rgbyuv_matrix(coeffs, src->buffer_format, dst->buffer_format,
|
||||
param->in_color_range, param->out_color_range, &drv->csc);
|
||||
vl_compositor_set_csc_matrix(&drv->cstate, &drv->csc, 1.0f, 0.0f);
|
||||
|
||||
if (src_yuv || dst_yuv) {
|
||||
|
|
|
|||
|
|
@ -359,7 +359,7 @@ vlVaPutSurface(VADriverContextP ctx, VASurfaceID surface_id, void* draw, short s
|
|||
struct u_rect dst_rect = {destx, destx + destw, desty, desty + desth};
|
||||
enum pipe_format format;
|
||||
VAStatus status;
|
||||
enum VL_CSC_COLOR_STANDARD color_standard;
|
||||
enum pipe_video_vpp_matrix_coefficients coeffs;
|
||||
|
||||
if (!ctx)
|
||||
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||
|
|
@ -394,14 +394,15 @@ vlVaPutSurface(VADriverContextP ctx, VASurfaceID surface_id, void* draw, short s
|
|||
format = surf->buffer->buffer_format;
|
||||
|
||||
if (flags & VA_SRC_BT601)
|
||||
color_standard = VL_CSC_COLOR_STANDARD_BT_601;
|
||||
coeffs = PIPE_VIDEO_VPP_MCF_SMPTE170M;
|
||||
else if (flags & VA_SRC_SMPTE_240)
|
||||
color_standard = VL_CSC_COLOR_STANDARD_SMPTE_240M;
|
||||
coeffs = PIPE_VIDEO_VPP_MCF_SMPTE240M;
|
||||
else
|
||||
color_standard = VL_CSC_COLOR_STANDARD_BT_709;
|
||||
coeffs = PIPE_VIDEO_VPP_MCF_BT709;
|
||||
|
||||
vl_csc_get_matrix(color_standard, NULL, true, &drv->csc);
|
||||
vl_compositor_set_csc_matrix(&drv->cstate, (const vl_csc_matrix *)&drv->csc, 1.0f, 0.0f);
|
||||
vl_csc_get_rgbyuv_matrix(coeffs, format, surf_templ.format,
|
||||
PIPE_VIDEO_VPP_CHROMA_COLOR_RANGE_REDUCED,
|
||||
PIPE_VIDEO_VPP_CHROMA_COLOR_RANGE_FULL, &drv->cstate.csc_matrix);
|
||||
|
||||
vl_compositor_clear_layers(&drv->cstate);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue