only reopen decoder when new caps are different

This commit is contained in:
Matej Knopp 2011-12-11 06:25:23 +01:00 committed by Wim Taymans
parent 8f20bd588e
commit a079886388

View file

@ -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;