From 08ee0f9e783cbaa8ca84c1a17c666f7f29def12a Mon Sep 17 00:00:00 2001 From: Hyunjun Ko Date: Wed, 8 Jun 2016 10:14:16 +0900 Subject: vaapipostproc: Add colorimetry attributes to src caps https://bugzilla.gnome.org/show_bug.cgi?id=766596 --- gst/vaapi/gstvaapipostprocutil.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/gst/vaapi/gstvaapipostprocutil.c b/gst/vaapi/gstvaapipostprocutil.c index 139f5fc9..956bd84d 100644 --- a/gst/vaapi/gstvaapipostprocutil.c +++ b/gst/vaapi/gstvaapipostprocutil.c @@ -548,6 +548,43 @@ overflow_error: } } +static gboolean +_set_colorimetry (GstVaapiPostproc * postproc, GstVideoFormat format, + GstStructure * outs) +{ + GstVideoInfo vinfo; + GstVideoColorimetry colorimetry; + gchar *color; + gint width, height; + + if (!gst_structure_get_int (outs, "width", &width) + || !gst_structure_get_int (outs, "height", &height)) + return FALSE; + + gst_video_info_set_format (&vinfo, format, width, height); + + if (GST_VIDEO_INFO_CHROMA_SITE (&vinfo) != GST_VIDEO_CHROMA_SITE_UNKNOWN) { + gst_structure_set (outs, "chroma-site", G_TYPE_STRING, + gst_video_chroma_to_string (GST_VIDEO_INFO_CHROMA_SITE (&vinfo)), NULL); + } + + /* make sure we set the RGB matrix for RGB formats */ + colorimetry = GST_VIDEO_INFO_COLORIMETRY (&vinfo); + if (GST_VIDEO_FORMAT_INFO_IS_RGB (vinfo.finfo) && + colorimetry.matrix != GST_VIDEO_COLOR_MATRIX_RGB) { + GST_WARNING ("invalid matrix %d for RGB format, using RGB", + colorimetry.matrix); + colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_RGB; + } + + if ((color = gst_video_colorimetry_to_string (&colorimetry))) { + gst_structure_set (outs, "colorimetry", G_TYPE_STRING, color, NULL); + g_free (color); + } + + return TRUE; +} + static gboolean _set_preferred_format (GstStructure * outs, GstVideoFormat format) { @@ -609,6 +646,9 @@ _get_preferred_caps (GstVaapiPostproc * postproc, GstVideoInfo * vinfo, if (!_fixate_frame_rate (postproc, vinfo, structure)) goto fixate_failed; + if (f == GST_VAAPI_CAPS_FEATURE_SYSTEM_MEMORY) + _set_colorimetry (postproc, format, structure); + outcaps = gst_caps_new_empty (); gst_caps_append_structure_full (outcaps, structure, gst_caps_features_copy (features)); -- cgit v1.2.3