Files
FFmpeg/libavcodec
Andreas Rheinhardt 4e1fee405f avcodec: Fix invalid uses of ff_codec_open2_recursive()
Normally no two codecs with FF_CODEC_CAP_INIT_THREADSAFE unset
can be initialized at the same time: a mutex in avcodec_open2()
ensures this. This implies that one cannot simply open a codec
with a non-threadsafe init-function from the init function of
a codec whose own init function is not threadsafe either as the child
codec couldn't acquire the lock.

ff_codec_open2_recursive() exists to get around this limitation:
If the init function of the child codec to be initialized is not
thread-safe, the mutex is unlocked, the child is initialized and
the mutex is locked again. This of course has as a prerequisite that
the parent AVCodecContext actually holds the lock, i.e. that the
parent codec's init function is not thread-safe. If it is, then one
can (and has to) just use avcodec_open2() directly (if the child's
init function is not thread-safe, then avcodec_open2() will have to
acquire the mutex itself (and potentially wait for it), so that it is
perfectly fine for an otherwise thread-safe init function to open
a codec with a potentially non-thread-safe init function via
avcodec_open2()).

Yet several of the users of ff_codec_open2_recursive() have the
FF_CODEC_CAP_INIT_THREADSAFE flag set; this only worked because
all the child codecs' init functions were thread-safe themselves
so that ff_codec_open2_recursive() didn't touch the mutex at all.
But of course the real solution to this is to directly use
avcodec_open2().

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-12-04 15:46:46 +01:00
..
2020-11-24 09:38:35 +01:00
2020-10-15 22:53:56 +02:00
2020-06-10 12:36:44 +02:00
2020-08-26 21:13:38 +02:00
2020-08-26 21:13:38 +02:00
2020-10-07 22:16:09 +02:00
2020-10-07 22:16:09 +02:00
2020-11-12 15:55:16 +01:00
2020-10-24 19:11:12 +02:00
2020-11-10 02:14:29 +01:00
2020-06-05 18:14:17 +02:00
2020-11-24 11:35:03 +01:00
2020-11-24 11:35:03 +01:00
2020-06-14 18:20:37 +02:00
2020-06-15 04:22:28 +02:00
2020-10-24 16:50:29 +02:00
2020-07-20 18:41:09 +02:00
2020-07-20 18:41:09 +02:00
2020-11-24 09:38:35 +01:00
2020-10-19 05:15:00 +02:00
2020-11-24 09:38:35 +01:00
2020-11-24 09:38:35 +01:00
2020-11-24 09:38:35 +01:00
2020-11-11 18:36:09 +01:00
2020-11-11 18:36:09 +01:00
2020-05-26 10:52:12 +01:00
2020-05-26 10:52:12 +01:00
2020-05-26 10:52:12 +01:00
2020-06-08 20:45:56 +02:00
2020-05-30 18:02:55 +02:00
2020-07-05 19:59:49 +02:00
2020-11-24 11:35:03 +01:00
2020-09-01 14:19:19 +02:00
2020-11-24 11:35:03 +01:00
2020-05-22 22:23:18 +02:00
2020-11-24 09:38:35 +01:00
2020-11-24 09:38:35 +01:00
2020-11-24 09:38:35 +01:00
2020-07-20 18:41:09 +02:00
2020-11-02 22:57:23 +00:00
2020-10-23 10:37:04 +02:00
2020-05-23 07:07:36 +02:00
2020-10-16 00:38:50 +02:00