Commit 4c08bc10 authored by Seungha Yang's avatar Seungha Yang

videoconvert: Preserve and forward upstream colorimetry

When upstream provides colorimetry explicitly, preserve it as mush as
possible and set the converted colorimetry to output caps.

Closes gstreamer/gst-plugins-base#614
parent 779704b8
Pipeline #38657 passed with stages
in 75 minutes and 10 seconds
......@@ -361,9 +361,45 @@ gst_video_convert_fixate_caps (GstBaseTransform * trans,
if (direction == GST_PAD_SINK) {
if (gst_caps_is_subset (caps, result)) {
gst_caps_replace (&result, caps);
} else {
GstVideoInfo vinfo;
GstVideoColorimetry cinfo;
GstStructure *structure;
const gchar *s;
gchar *other_s;
structure = gst_caps_get_structure (result, 0);
/* 1. respect downstream requested colorimetry */
if ((s = gst_structure_get_string (structure, "colorimetry")))
goto done;
structure = gst_caps_get_structure (caps, 0);
/* 2. when upstream provides colorimetry explicitly,
* perserve it as much as possible */
if ((s = gst_structure_get_string (structure, "colorimetry")) == NULL ||
!gst_video_colorimetry_from_string (&cinfo, s))
goto done;
/* 3. fill colorimetry with default values */
if (!gst_video_info_from_caps (&vinfo, result))
goto done;
/* 4. Forward primaries and transfer function.
* the primaries is used for conversion between RGB and XYZ (CIE 1931 coordinate).
* the transfer function could be another reference (e.g., HDR)
*/
vinfo.colorimetry.primaries = cinfo.primaries;
vinfo.colorimetry.transfer = cinfo.transfer;
other_s = gst_video_colorimetry_to_string (&vinfo.colorimetry);
gst_caps_set_simple (result, "colorimetry", G_TYPE_STRING, other_s, NULL);
g_free (other_s);
}
}
done:
return result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment