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.
This commit is contained in:
U. Artie Eoff 2020-02-04 14:17:43 -08:00
parent c6d8ee737f
commit 2b6fa19665

View file

@ -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))