From bf444301f998b5aff1fd7e7d18cf7edc2a42b68b Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Thu, 2 Jun 2016 11:36:57 +1000 Subject: [PATCH] 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. --- sys/applemedia/vtdec.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/applemedia/vtdec.c b/sys/applemedia/vtdec.c index cf736b2..7f96bd9 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); -- 2.7.4