From 2b6fa1966570b161008565a294bce863dbbd3ab7 Mon Sep 17 00:00:00 2001 From: "U. Artie Eoff" Date: Tue, 4 Feb 2020 14:17:43 -0800 Subject: vaapipostproc: use sink resolution to calculate src colorimetry The default output colorimetry is persuaded by the output resolution, which is too naive when doing VPP cropping and/or scaling. For example, scaling 4K(sink)->1080P(src) resolution (i.e. both YUV) results in bt2020(sink)->bt709(src) colorimetry selection and some drivers don't support that mode in vpp. Thus, if output (i.e. downstream) does not specify a colorimetry then we use the input resolution instead of the output resolution to create the default colorimetry. Also, note that we still use the output format since it may be a different color space than the input. As in the example above, this will result in bt2020(sink)->bt2020(src) colorimetry selection and all drivers (afaik) should support that in vpp. --- gst/vaapi/gstvaapipostprocutil.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'gst') diff --git a/gst/vaapi/gstvaapipostprocutil.c b/gst/vaapi/gstvaapipostprocutil.c index 51cf7d7b..94ece028 100644 --- a/gst/vaapi/gstvaapipostprocutil.c +++ b/gst/vaapi/gstvaapipostprocutil.c @@ -595,8 +595,8 @@ _set_multiview_mode (GstVaapiPostproc * postproc, GstVideoInfo * vinfo, } static gboolean -_set_colorimetry (GstVaapiPostproc * postproc, GstVideoFormat format, - GstStructure * outs) +_set_colorimetry (GstVaapiPostproc * postproc, GstVideoInfo * sinkinfo, + GstVideoFormat format, GstStructure * outs) { GstVideoInfo vinfo; GstVideoColorimetry colorimetry; @@ -607,7 +607,10 @@ _set_colorimetry (GstVaapiPostproc * postproc, GstVideoFormat format, || !gst_structure_get_int (outs, "height", &height)) return FALSE; - gst_video_info_set_format (&vinfo, format, width, height); + /* Use the sink resolution and the src format to correctly determine the + * default src colorimetry. */ + gst_video_info_set_format (&vinfo, format, GST_VIDEO_INFO_WIDTH (sinkinfo), + GST_VIDEO_INFO_HEIGHT (sinkinfo)); if (GST_VIDEO_INFO_CHROMA_SITE (&vinfo) != GST_VIDEO_CHROMA_SITE_UNKNOWN) { gst_structure_set (outs, "chroma-site", G_TYPE_STRING, @@ -719,7 +722,7 @@ _get_preferred_caps (GstVaapiPostproc * postproc, GstVideoInfo * vinfo, goto fixate_failed; _set_multiview_mode (postproc, vinfo, structure); - if (!_set_colorimetry (postproc, format, structure)) + if (!_set_colorimetry (postproc, vinfo, format, structure)) goto fixate_failed; if (!_set_interlace_mode (postproc, vinfo, structure)) -- cgit v1.2.3