mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-01-30 19:34:43 +00:00
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 <atomnuker@gmail.com>
This commit is contained in:
parent
8000d484b8
commit
3d62e7a30f
@ -1103,14 +1103,12 @@ static av_cold void aac_static_table_init(void)
|
|||||||
AAC_RENAME(cbrt_tableinit)();
|
AAC_RENAME(cbrt_tableinit)();
|
||||||
}
|
}
|
||||||
|
|
||||||
static AVOnce aac_init = AV_ONCE_INIT;
|
|
||||||
|
|
||||||
static av_cold int aac_decode_init(AVCodecContext *avctx)
|
static av_cold int aac_decode_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
AACContext *ac = avctx->priv_data;
|
AACContext *ac = avctx->priv_data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = ff_thread_once(&aac_init, &aac_static_table_init);
|
ret = ff_thread_once(&aac_table_init, &aac_static_table_init);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return AVERROR_UNKNOWN;
|
return AVERROR_UNKNOWN;
|
||||||
|
|
||||||
|
@ -986,7 +986,8 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
|
|||||||
if (HAVE_MIPSDSPR1)
|
if (HAVE_MIPSDSPR1)
|
||||||
ff_aac_coder_init_mips(s);
|
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);
|
ff_af_queue_init(avctx, &s->afq);
|
||||||
|
|
||||||
@ -1029,6 +1030,7 @@ AVCodec ff_aac_encoder = {
|
|||||||
.encode2 = aac_encode_frame,
|
.encode2 = aac_encode_frame,
|
||||||
.close = aac_encode_end,
|
.close = aac_encode_end,
|
||||||
.supported_samplerates = mpeg4audio_sample_rates,
|
.supported_samplerates = mpeg4audio_sample_rates,
|
||||||
|
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
|
||||||
.capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY |
|
.capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY |
|
||||||
AV_CODEC_CAP_EXPERIMENTAL,
|
AV_CODEC_CAP_EXPERIMENTAL,
|
||||||
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP,
|
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP,
|
||||||
|
@ -27,12 +27,15 @@
|
|||||||
* @author Maxim Gavrilov ( maxim.gavrilov gmail com )
|
* @author Maxim Gavrilov ( maxim.gavrilov gmail com )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "libavutil/thread.h"
|
||||||
#include "libavutil/mem.h"
|
#include "libavutil/mem.h"
|
||||||
#include "aac.h"
|
#include "aac.h"
|
||||||
#include "aac_tablegen.h"
|
#include "aac_tablegen.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
AVOnce aac_table_init = AV_ONCE_INIT;
|
||||||
|
|
||||||
DECLARE_ALIGNED(32, float, ff_aac_kbd_long_1024)[1024];
|
DECLARE_ALIGNED(32, float, ff_aac_kbd_long_1024)[1024];
|
||||||
DECLARE_ALIGNED(32, float, ff_aac_kbd_short_128)[128];
|
DECLARE_ALIGNED(32, float, ff_aac_kbd_short_128)[128];
|
||||||
DECLARE_ALIGNED(32, int, ff_aac_kbd_long_1024_fixed)[1024];
|
DECLARE_ALIGNED(32, int, ff_aac_kbd_long_1024_fixed)[1024];
|
||||||
|
@ -30,12 +30,15 @@
|
|||||||
#ifndef AVCODEC_AACTAB_H
|
#ifndef AVCODEC_AACTAB_H
|
||||||
#define AVCODEC_AACTAB_H
|
#define AVCODEC_AACTAB_H
|
||||||
|
|
||||||
|
#include "libavutil/thread.h"
|
||||||
#include "libavutil/mem.h"
|
#include "libavutil/mem.h"
|
||||||
#include "aac.h"
|
#include "aac.h"
|
||||||
#include "aac_tablegen_decl.h"
|
#include "aac_tablegen_decl.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
extern AVOnce aac_table_init; /* Protects ff_aac_tableinit() */
|
||||||
|
|
||||||
/* NOTE:
|
/* NOTE:
|
||||||
* Tables in this file are used by the AAC decoder and will be used by the AAC
|
* Tables in this file are used by the AAC decoder and will be used by the AAC
|
||||||
* encoder.
|
* encoder.
|
||||||
|
Loading…
Reference in New Issue
Block a user