From e65e6b8042d34e86035c2f4ce549c1d481ce86f7 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Fri, 1 Apr 2005 10:09:15 +0000 Subject: [PATCH] ext/ffmpeg/gstffmpegdec.c: Implement keyframe syncing. Original commit message from CVS: * ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init), (gst_ffmpegdec_open), (gst_ffmpegdec_frame), (gst_ffmpegdec_handle_event): Implement keyframe syncing. --- ChangeLog | 7 +++++++ ext/ffmpeg/gstffmpegdec.c | 10 +++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9190419..0562bbb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-04-01 Ronald S. Bultje + + * ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init), + (gst_ffmpegdec_open), (gst_ffmpegdec_frame), + (gst_ffmpegdec_handle_event): + Implement keyframe syncing. + 2005-03-14 Ronald S. Bultje * ext/ffmpeg/gstffmpeg.c: (plugin_init): diff --git a/ext/ffmpeg/gstffmpegdec.c b/ext/ffmpeg/gstffmpegdec.c index 14e819c..b51b8ab 100644 --- a/ext/ffmpeg/gstffmpegdec.c +++ b/ext/ffmpeg/gstffmpegdec.c @@ -57,6 +57,7 @@ struct _GstFFMpegDec gint channels, samplerate; } audio; } format; + gboolean waiting_for_key; guint64 next_ts; /* parsing */ @@ -273,6 +274,7 @@ gst_ffmpegdec_init (GstFFMpegDec * ffmpegdec) ffmpegdec->pcache = NULL; ffmpegdec->par = NULL; ffmpegdec->opened = FALSE; + ffmpegdec->waiting_for_key = FALSE; ffmpegdec->hurry_up = ffmpegdec->lowres = 0; GST_FLAG_SET (ffmpegdec, GST_ELEMENT_EVENT_AWARE); @@ -413,6 +415,7 @@ gst_ffmpegdec_open (GstFFMpegDec *ffmpegdec) default: break; } + ffmpegdec->waiting_for_key = TRUE; ffmpegdec->next_ts = 0; return TRUE; @@ -631,7 +634,10 @@ gst_ffmpegdec_frame (GstFFMpegDec * ffmpegdec, GST_DEBUG_OBJECT (ffmpegdec, "Decode video: len=%d, have_data=%d", len, have_data); - if (len >= 0 && have_data > 0) { + if (ffmpegdec->waiting_for_key && + ffmpegdec->picture->pict_type != FF_I_TYPE) { + have_data = 0; + } else if (len >= 0 && have_data > 0) { /* libavcodec constantly crashes on stupid buffer allocation * errors inside. This drives me crazy, so we let it allocate * it's own buffers and copy to our own buffer afterwards... */ @@ -639,6 +645,7 @@ gst_ffmpegdec_frame (GstFFMpegDec * ffmpegdec, gint fsize = gst_ffmpeg_avpicture_get_size (ffmpegdec->context->pix_fmt, ffmpegdec->context->width, ffmpegdec->context->height); + ffmpegdec->waiting_for_key = FALSE; outbuf = gst_buffer_new_and_alloc (fsize); /* original ffmpeg code does not handle odd sizes correctly. @@ -812,6 +819,7 @@ gst_ffmpegdec_handle_event (GstFFMpegDec * ffmpegdec, GstEvent * event) } if (ffmpegdec->opened) { avcodec_flush_buffers (ffmpegdec->context); + ffmpegdec->waiting_for_key = TRUE; } /* fall-through */ } -- 2.7.4