diff options
author | Matej Knopp <matej.knopp@gmail.com> | 2011-12-11 06:25:23 +0100 |
---|---|---|
committer | Wim Taymans <wim.taymans@collabora.co.uk> | 2012-02-20 16:23:57 +0100 |
commit | a079886388399ae4eb6a15b7641b4b0a6ad7dcff (patch) | |
tree | fb4fca88504f91e08e0fb238c3f7458cafb2eb7a | |
parent | 8f20bd588e6696ec9f57abe109c8205326bef74a (diff) |
only reopen decoder when new caps are different
-rw-r--r-- | ext/ffmpeg/gstffmpegdec.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/ext/ffmpeg/gstffmpegdec.c b/ext/ffmpeg/gstffmpegdec.c index 2dd5217..3dba1e3 100644 --- a/ext/ffmpeg/gstffmpegdec.c +++ b/ext/ffmpeg/gstffmpegdec.c @@ -152,6 +152,9 @@ struct _GstFFMpegDec /* reverse playback queue */ GList *queued; + + /* prevent reopening the decoder on GST_EVENT_CAPS when caps are same as last time. */ + GstCaps *last_caps; }; typedef struct _GstFFMpegDecClass GstFFMpegDecClass; @@ -603,6 +606,8 @@ gst_ffmpegdec_close (GstFFMpegDec * ffmpegdec) GST_LOG_OBJECT (ffmpegdec, "closing ffmpeg codec"); + gst_caps_replace (&ffmpegdec->last_caps, NULL); + if (ffmpegdec->context->priv_data) gst_ffmpeg_avcodec_close (ffmpegdec->context); ffmpegdec->opened = FALSE; @@ -1934,7 +1939,7 @@ gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec, GstStructure *s = gst_caps_get_structure (GST_BUFFER_CAPS (buffer), 0); gboolean interlaced; gboolean found = gst_structure_get_boolean (s, "interlaced", &interlaced); - if (!found || (! !interlaced != ! !ffmpegdec->format.video.interlaced)) { + if (!found || (!!interlaced != !!ffmpegdec->format.video.interlaced)) { GST_DEBUG_OBJECT (ffmpegdec, "Buffer interlacing does not match pad, updating"); buffer = gst_buffer_make_metadata_writable (buffer); @@ -2570,7 +2575,15 @@ gst_ffmpegdec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) gst_event_parse_caps (event, &caps); - ret = gst_ffmpegdec_setcaps (ffmpegdec, caps); + if (!ffmpegdec->last_caps + || !gst_caps_is_equal (ffmpegdec->last_caps, caps)) { + ret = gst_ffmpegdec_setcaps (ffmpegdec, caps); + if (ret) { + gst_caps_replace (&ffmpegdec->last_caps, caps); + } + } else { + ret = TRUE; + } gst_event_unref (event); goto done; |