GNOME Bugzilla – Bug 321662
reenable our get_buffer function in gst-ffmpeg
Last modified: 2008-01-22 16:33:43 UTC
When seeking in a pipeline using ffdec_* elements it can happens an error like: (lt-totem:7911): GLib-GObject-WARNING **: invalid uninstantiatable type `<invalid>' in cast to `GstMiniObject' and some segfaults. I've tried to fix it but my fix doesn't really works.. Some info: - a buffer is allocated in _get_buffer. The buffer exits this function with a ref count of 2. - a buffer is deallocated in _release_buffer and in _frame. It can also be deallocated when another element unrefs it. _release_buffer is called when we call avcodec_decode_video or avcodec_flush_buffers. So, every buffer has a refcount of 2 when it's created using our _geT_buffer function. Every buffer should also be unreffed exactly two times :) This is not the case right now so i've disabled our _get_buffer function (ffdec_* elements will use more cpu but they should work fine).
Make sure to set our external picture reference in GstFFMpegDec to NULL after calling __flush_buffers(), that is the most likely culprit.
After looking a bit further into it, the problem is when ffmpeg calls our get_buffer when the src pad is flushing. When we return -1, ffmpeg assumes the previous allocated buffer is to be re-used. And all hell breaks loose, because that means ffmpeg will call our release_buffer functions twice ! A quick fix for this is to always allocate a valid buffer in get_buffer(). It works fine with the attached patch.
Created attachment 59255 [details] [review] patch for our get/release buffer functions in gstffmpeggdecoders
I've not tested the patch but i think you should leave FORCE_OUR_GET_BUFFER disabled. I remember there were some problems with some qt video in 0.8 with that flag enabled. To enable our get_buffer function on supported buffer size you should just remove the "|| 1" before the "#ifdef FORCE_OUR_GET_BUFFER".
ping?
ping²?
Still has issues. ffmpeg is STILL writing outside of the allocated memory.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init), (gst_ffmpegdec_init), (gst_ffmpegdec_close), (gst_ffmpegdec_open), (gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer), (get_output_buffer), (gst_ffmpegdec_video_frame), (gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame), (gst_ffmpegdec_change_state), (gst_ffmpegdec_set_property), (gst_ffmpegdec_get_property): Reenable pad_alloc, seem to work now. Added property to easily disable it later on. Remove some old code that tried hard to break the get_buffer functions. Fixes #321662.