summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorU. Artie Eoff <ullysses.a.eoff@intel.com>2020-02-04 14:17:43 -0800
committerU. Artie Eoff <ullysses.a.eoff@intel.com>2020-02-05 10:33:23 -0800
commit2b6fa1966570b161008565a294bce863dbbd3ab7 (patch)
tree6d18039f72120d6e77719347a4602d02cb9d156d
parentc6d8ee737f01f897940d79528b0452d117c26e24 (diff)
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.
-rw-r--r--gst/vaapi/gstvaapipostprocutil.c11
1 files changed, 7 insertions, 4 deletions
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))