GNOME Bugzilla – Bug 433245
Non-mutex-protected calls to avcodec_open/_close
Last modified: 2007-05-09 15:33:25 UTC
We have mutexes to protect our explicit calls to avcodec_open/_close in gst-ffmpeg since it's not thread-safe. The problem is that some code in ffmpeg does call avcodec_open/_close, so we need to protect some other ffmpeg calls with the same mutex. * libavformat/utils.c . avcodec_open() is called in try_to_decode_frame() which is called by av_find_stream_info(). avcodec_close() is also called in av_find_stream_info(). Therefore any calls to av_find_stream_info() should be protected by the avcodec_open/_close mutex. * libavformat/jpeg.c . avcodec_open() is called in the read function. BUT considering that we don't use the jpeg "demuxer", we don't need to do anything. * libavcodec/mpegvideo.c . This is a tricky one. Called in estimate_best_b_count(), which is called in select_input_picture() IF the b_frame_strategy == 2, which is called in MPV_encode_picture(), which is the encoding entry point for mpeg video encoders... BUT AFAIK, we don't modify b_frame_strategy in gst-ffmpeg encoders, so it's always 0, and therefore the call to avcodec_open/close is never done.
Created attachment 86982 [details] [review] thread-safe call to av_find_stream_info()
ffmpeg is pathetic. And this is my 1000th comment !
Created attachment 86983 [details] [review] previous patch was... not really effective :) This one properly fixes it.
2007-05-09 Edward Hervey <edward@fluendo.com> * ext/ffmpeg/gstffmpeg.c: (gst_ffmpeg_av_find_stream_info): * ext/ffmpeg/gstffmpeg.h: * ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_open): Protect calls to ffmpeg functions that will implicitly call avcodec_open/close with the avcodec mutex. Fixes #433245