From 3d62e7a30fa552be52d12b31e3e0f79153aff891 Mon Sep 17 00:00:00 2001 From: Rostislav Pehlivanov Date: Fri, 27 Nov 2015 14:52:35 +0000 Subject: aacenc: make threadsafe Since the ff_aac_tableinit() can be called by both the encoder and the decoder (in case of transcoding) this commit shares the AVOnce variable to prevent this. Signed-off-by: Rostislav Pehlivanov --- libavcodec/aacenc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libavcodec/aacenc.c') diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index ca6c9dde07..d6cac47f62 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -986,7 +986,8 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) if (HAVE_MIPSDSPR1) ff_aac_coder_init_mips(s); - ff_aac_tableinit(); + if ((ret = ff_thread_once(&aac_table_init, &ff_aac_tableinit)) != 0) + return AVERROR_UNKNOWN; ff_af_queue_init(avctx, &s->afq); @@ -1029,6 +1030,7 @@ AVCodec ff_aac_encoder = { .encode2 = aac_encode_frame, .close = aac_encode_end, .supported_samplerates = mpeg4audio_sample_rates, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_EXPERIMENTAL, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP, -- cgit v1.2.3