summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Decina <alessandro.d@gmail.com>2016-06-02 11:36:57 +1000
committerAlessandro Decina <alessandro.d@gmail.com>2016-06-02 17:04:39 +1000
commit6dc3b45b719f8d6bcd09c70a109fac0d7912c72e (patch)
tree9bb1d6451e9a05f9e321a249e7b09a243cef60b9
parent54699c5444901b56e03a1d2a3ac8980a4df11d87 (diff)
downloadgstreamer-plugins-bad-6dc3b45b719f8d6bcd09c70a109fac0d7912c72e.tar.gz
vtdec: optimize renegotiation
::negotiate can be called several times before the CAPS event is sent downstream so use the currently configured output state caps instead of the pad current caps when deciding whether to recreate the VTSession or not. This leads to creating/destroying less VTSessions which makes renegotiation more reliable especially when using hw decoding.
-rw-r--r--sys/applemedia/vtdec.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/applemedia/vtdec.c b/sys/applemedia/vtdec.c
index e9c6a5564..9309b2a39 100644
--- a/sys/applemedia/vtdec.c
+++ b/sys/applemedia/vtdec.c
@@ -245,6 +245,12 @@ gst_vtdec_negotiate (GstVideoDecoder * decoder)
if (features)
features = gst_caps_features_copy (features);
+ output_state = gst_video_decoder_get_output_state (GST_VIDEO_DECODER (vtdec));
+ if (output_state) {
+ prevcaps = gst_caps_ref (output_state->caps);
+ gst_video_codec_state_unref (output_state);
+ }
+
output_state = gst_video_decoder_set_output_state (GST_VIDEO_DECODER (vtdec),
format, vtdec->video_info.width, vtdec->video_info.height,
vtdec->input_state);
@@ -265,10 +271,10 @@ gst_vtdec_negotiate (GstVideoDecoder * decoder)
}
gst_caps_unref (caps);
- prevcaps = gst_pad_get_current_caps (decoder->srcpad);
if (!prevcaps || !gst_caps_is_equal (prevcaps, output_state->caps)) {
- GST_INFO_OBJECT (vtdec, "negotiated output format %" GST_PTR_FORMAT,
- output_state->caps);
+ GST_INFO_OBJECT (vtdec,
+ "negotiated output format %" GST_PTR_FORMAT " previous %"
+ GST_PTR_FORMAT, output_state->caps, prevcaps);
if (vtdec->session) {
gst_vtdec_push_frames_if_needed (vtdec, TRUE, FALSE);