After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 433245 - Non-mutex-protected calls to avcodec_open/_close
Non-mutex-protected calls to avcodec_open/_close
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-libav
git master
Other Linux
: Normal normal
: 0.10.3
Assigned To: Edward Hervey
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2007-04-25 08:55 UTC by Edward Hervey
Modified: 2007-05-09 15:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
thread-safe call to av_find_stream_info() (1.97 KB, patch)
2007-04-25 08:57 UTC, Edward Hervey
none Details | Review
previous patch was... not really effective :) This one properly fixes it. (1.96 KB, patch)
2007-04-25 10:02 UTC, Edward Hervey
committed Details | Review

Description Edward Hervey 2007-04-25 08:55:38 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.
Comment 1 Edward Hervey 2007-04-25 08:57:59 UTC
Created attachment 86982 [details] [review]
thread-safe call to av_find_stream_info()
Comment 2 Edward Hervey 2007-04-25 09:15:50 UTC
ffmpeg is pathetic. And this is my 1000th comment !
Comment 3 Edward Hervey 2007-04-25 10:02:18 UTC
Created attachment 86983 [details] [review]
previous patch was... not really effective :) This one properly fixes it.
Comment 4 Edward Hervey 2007-05-09 15:33:25 UTC
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