summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunjun Ko <zzoon@igalia.com>2016-06-08 10:14:16 +0900
committerVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>2016-06-08 10:17:02 +0200
commit08ee0f9e783cbaa8ca84c1a17c666f7f29def12a (patch)
tree3d5e89dd9df7e4b1695c105222d6cd3483592fd0
parent1e52269b893b1bd02d88fe70309d692afa823718 (diff)
vaapipostproc: Add colorimetry attributes to src caps
https://bugzilla.gnome.org/show_bug.cgi?id=766596
-rw-r--r--gst/vaapi/gstvaapipostprocutil.c40
1 files changed, 40 insertions, 0 deletions
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
@@ -549,6 +549,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)
{
GValue value = G_VALUE_INIT;
@@ -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));