diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-12-10 04:32:17 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-04-27 00:40:18 +0200 |
commit | d99707b42a55b2fcfc17b8c9bf3f38c1879dbaa7 (patch) | |
tree | eadd12b2001dee25c4accb123d7b881173306645 /libavcodec/mpeg4video.c | |
parent | fea1f42e5f82db01ef3eec6ee8b0862944a5e319 (diff) |
avcodec/mpeg4video: Make initializing RLTable thread-safe
Up until now the RLTable ff_mpeg4_rl_intra was initialized by both mpeg4
decoder and encoder (except the VLCs that are only used by the decoder).
This is an obstacle to making these codecs init-threadsafe, so move
initializing this to a single function that is guarded by a dedicated
AVOnce.
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/mpeg4video.c')
-rw-r--r-- | libavcodec/mpeg4video.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libavcodec/mpeg4video.c b/libavcodec/mpeg4video.c index 2aaa9f734c..ffeaf822b2 100644 --- a/libavcodec/mpeg4video.c +++ b/libavcodec/mpeg4video.c @@ -20,12 +20,24 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/thread.h" + #include "mpegutils.h" #include "mpegvideo.h" #include "mpeg4video.h" #include "mpeg4data.h" -uint8_t ff_mpeg4_static_rl_table_store[3][2][2 * MAX_RUN + MAX_LEVEL + 3]; +static av_cold void mpeg4_init_rl_intra(void) +{ + static uint8_t mpeg4_rl_intra_table[2][2 * MAX_RUN + MAX_LEVEL + 3]; + ff_rl_init(&ff_mpeg4_rl_intra, mpeg4_rl_intra_table); +} + +av_cold void ff_mpeg4_init_rl_intra(void) +{ + static AVOnce init_static_once = AV_ONCE_INIT; + ff_thread_once(&init_static_once, mpeg4_init_rl_intra); +} int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s) { |