diff options
author | Vivia Nikolaidou <vivia@ahiru.eu> | 2020-06-26 12:22:08 +0300 |
---|---|---|
committer | Vivia Nikolaidou <vivia@ahiru.eu> | 2020-07-03 11:57:49 +0300 |
commit | ad55d3ce9d80e5c254d97ae21c340bb249b7f7c3 (patch) | |
tree | 56f13e9ea5449b73bfc4121bb4faa1508041ece2 /gst/videoconvert | |
parent | 1d0ccf8baaf460e378cf2ea7083ad387c2c566ff (diff) | |
download | gstreamer-plugins-base-ad55d3ce9d80e5c254d97ae21c340bb249b7f7c3.tar.gz |
video-converter: Make fast path work for equivalent transfer functions
For example, BT709, BT601, and BT2020_10 all have theoretically
different transfer functions, but the same function in practice. In
these cases, we should use the fast path for negotiating. Also,
BT2020_12 is essentially the same as the other three, just with one more
decimal point, so it gives the same result for fewer bits. This is now
also aliased to the former three.
Also make videoconvert do passthrough if the caps have equivalent
transfer functions but are otherwise matching.
As of the previous commit, we write the correct transfer function for
BT601, instead of the (functionally identical but different ISO code)
transfer function for BT709. Files created using GStreamer prior to that
commit write the wrong transfer function for BT601 and are, strictly
speaking, 2:4:5:4 instead. However, this commit takes care of
negotiation, so that conversions from/to the same transfer function are
done using the fast path.
Fixes #783
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/724>
Diffstat (limited to 'gst/videoconvert')
-rw-r--r-- | gst/videoconvert/gstvideoconvert.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gst/videoconvert/gstvideoconvert.c b/gst/videoconvert/gstvideoconvert.c index 66783c524..b190c3422 100644 --- a/gst/videoconvert/gstvideoconvert.c +++ b/gst/videoconvert/gstvideoconvert.c @@ -430,6 +430,9 @@ gst_video_convert_set_info (GstVideoFilter * filter, GstVideoInfo * out_info) { GstVideoConvert *space; + GstBaseTransformClass *gstbasetransform_class = + GST_BASE_TRANSFORM_GET_CLASS (filter); + GstVideoInfo tmp_info; space = GST_VIDEO_CONVERT_CAST (filter); @@ -451,6 +454,21 @@ gst_video_convert_set_info (GstVideoFilter * filter, if (in_info->interlace_mode != out_info->interlace_mode) goto format_mismatch; + /* if the only thing different in the caps is the transfer function, and + * we're converting between equivalent transfer functions, do passthrough */ + tmp_info = *in_info; + tmp_info.colorimetry.transfer = out_info->colorimetry.transfer; + if (gst_video_info_is_equal (&tmp_info, out_info)) { + if (gst_video_color_transfer_is_equivalent (in_info->colorimetry.transfer, + in_info->finfo->bits, out_info->colorimetry.transfer, + out_info->finfo->bits)) { + gstbasetransform_class->passthrough_on_same_caps = FALSE; + gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (filter), TRUE); + return TRUE; + } + } + gstbasetransform_class->passthrough_on_same_caps = TRUE; + gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (filter), FALSE); space->convert = gst_video_converter_new (in_info, out_info, gst_structure_new ("GstVideoConvertConfig", |