aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/h263data.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-12-02 03:26:41 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-01-25 14:52:58 +0100
commit61fe481586425a41d45e371de1e875b49882477d (patch)
tree04dbbd211420e71fea74a9b87807fd9d17ed8566 /libavcodec/h263data.c
parent12d0bb382b7f8f67981ec61aad1ce4f6840ab2dc (diff)
downloadffmpeg-61fe481586425a41d45e371de1e875b49882477d.tar.gz
avcodec/h263data, ituh263*: Make initializing RL inter table thread-safe
Up until now, ff_h263_rl_inter was initialized by both ituh263dec and ituh263enc; this is an obstacle in making the codecs that use this code init-threadsafe. This obstacle is eliminated by only initializing this RLTable from a single place 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/h263data.c')
-rw-r--r--libavcodec/h263data.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/libavcodec/h263data.c b/libavcodec/h263data.c
index f649d58f4e..604a0425e1 100644
--- a/libavcodec/h263data.c
+++ b/libavcodec/h263data.c
@@ -25,11 +25,11 @@
#include <stdint.h>
+#include "libavutil/thread.h"
+
#include "h263data.h"
#include "mpegvideo.h"
-uint8_t ff_h263_static_rl_table_store[2][2][2 * MAX_RUN + MAX_LEVEL + 3];
-
/* intra MCBPC, mb_type = (intra), then (intraq) */
const uint8_t ff_h263_intra_MCBPC_code[9] = { 1, 1, 2, 3, 1, 1, 2, 3, 1 };
const uint8_t ff_h263_intra_MCBPC_bits[9] = { 1, 3, 3, 3, 4, 6, 6, 6, 9 };
@@ -290,3 +290,15 @@ const AVRational ff_h263_pixel_aspect[16] = {
{ 0, 1 },
{ 0, 1 },
};
+
+static av_cold void h263_init_rl_inter(void)
+{
+ static uint8_t h263_rl_inter_table[2][2 * MAX_RUN + MAX_LEVEL + 3];
+ ff_rl_init(&ff_h263_rl_inter, h263_rl_inter_table);
+}
+
+av_cold void ff_h263_init_rl_inter(void)
+{
+ static AVOnce init_static_once = AV_ONCE_INIT;
+ ff_thread_once(&init_static_once, h263_init_rl_inter);
+}