aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-05-07 05:08:13 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-05-12 06:00:14 +0200
commit99ed54334053bb78a37545c4844cff6b4c9e658d (patch)
treef35d303d7d8bc766c4a39df0c74ec5707085432a /libavcodec
parent3c26773ae28ebd6a549491d432a6990450b068cf (diff)
downloadffmpeg-99ed54334053bb78a37545c4844cff6b4c9e658d.tar.gz
avcodec/j2kenc: Make encoder init-threadsafe
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/j2kenc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 17eb959d73..82ad3284b5 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -74,6 +74,7 @@
#include "libavutil/opt.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/avstring.h"
+#include "libavutil/thread.h"
#define NMSEDEC_BITS 7
#define NMSEDEC_FRACBITS (NMSEDEC_BITS-1)
@@ -591,6 +592,7 @@ static void init_luts(void)
lut_nmsedec_ref0[i] = FFMAX(((i * i - (i << NMSEDEC_BITS) + (1 << 2 * NMSEDEC_FRACBITS) + (1 << (NMSEDEC_FRACBITS - 1))) & mask)
<< 1, 0);
}
+ ff_jpeg2000_init_tier1_luts();
}
/* tier-1 routines */
@@ -1713,6 +1715,7 @@ static int parse_layer_rates(Jpeg2000EncoderContext *s)
static av_cold int j2kenc_init(AVCodecContext *avctx)
{
+ static AVOnce init_static_once = AV_ONCE_INIT;
int i, ret;
Jpeg2000EncoderContext *s = avctx->priv_data;
Jpeg2000CodingStyle *codsty = &s->codsty;
@@ -1779,8 +1782,7 @@ static av_cold int j2kenc_init(AVCodecContext *avctx)
return ret;
}
- ff_jpeg2000_init_tier1_luts();
- init_luts();
+ ff_thread_once(&init_static_once, init_luts);
init_quantization(s);
if ((ret=init_tiles(s)) < 0)
@@ -1849,5 +1851,5 @@ const AVCodec ff_jpeg2000_encoder = {
AV_PIX_FMT_NONE
},
.priv_class = &j2k_class,
- .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
};