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 <[email protected]>
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index ca6c9dd..d6cac47 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -986,7 +986,8 @@
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 @@
.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,