diff options
author | Lynne <dev@lynne.ee> | 2024-03-16 06:05:45 +0100 |
---|---|---|
committer | Lynne <dev@lynne.ee> | 2024-04-23 08:31:38 +0200 |
commit | 2f90d8398148b04db31e197f49154240c36e1849 (patch) | |
tree | 0d5af2110231e5ceb87b6b9220f6727874f3bc04 /libavcodec | |
parent | 905fdb06010e554262fca3c12b362bb69a11de85 (diff) | |
download | ffmpeg-2f90d8398148b04db31e197f49154240c36e1849.tar.gz |
aacdec: move fixed/float DSP initialization to templated init functions
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/aac/aacdec.c | 4 | ||||
-rw-r--r-- | libavcodec/aac/aacdec_dsp_template.c | 2 | ||||
-rw-r--r-- | libavcodec/aac/aacdec_fixed.c | 10 | ||||
-rw-r--r-- | libavcodec/aac/aacdec_float.c | 16 | ||||
-rw-r--r-- | libavcodec/aacdec.h | 2 | ||||
-rw-r--r-- | libavcodec/aacdec_template.c | 35 |
6 files changed, 31 insertions, 38 deletions
diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c index d31c64d08d..3af0e808fd 100644 --- a/libavcodec/aac/aacdec.c +++ b/libavcodec/aac/aacdec.c @@ -124,9 +124,7 @@ av_cold int ff_aac_decode_init_common(AVCodecContext *avctx) ac->dsp = is_fixed ? aac_dsp_fixed : aac_dsp; ac->proc = is_fixed ? aac_proc_fixed : aac_proc; - ac->dsp.init_tables(); - - return 0; + return ac->dsp.init(ac); } #define AACDEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM diff --git a/libavcodec/aac/aacdec_dsp_template.c b/libavcodec/aac/aacdec_dsp_template.c index 338e512ed2..f260d32e4a 100644 --- a/libavcodec/aac/aacdec_dsp_template.c +++ b/libavcodec/aac/aacdec_dsp_template.c @@ -616,7 +616,7 @@ static void AAC_RENAME(apply_prediction)(AACDecContext *ac, SingleChannelElement } const AACDecDSP AAC_RENAME(aac_dsp) = { - .init_tables = &AAC_RENAME(init_tables), + .init = &AAC_RENAME(init), .dequant_scalefactors = &AAC_RENAME(dequant_scalefactors), .apply_mid_side_stereo = &AAC_RENAME(apply_mid_side_stereo), diff --git a/libavcodec/aac/aacdec_fixed.c b/libavcodec/aac/aacdec_fixed.c index 41f25d8148..d706cfcc92 100644 --- a/libavcodec/aac/aacdec_fixed.c +++ b/libavcodec/aac/aacdec_fixed.c @@ -35,6 +35,8 @@ #include "libavcodec/aac_defines.h" +#include "libavcodec/avcodec.h" +#include "libavcodec/aacdec.h" #include "libavcodec/aactab.h" #include "libavcodec/sinewin_fixed_tablegen.h" #include "libavcodec/kbdwin.h" @@ -58,10 +60,16 @@ static void init_tables_fixed_fn(void) init_sine_windows_fixed(); } -static void init_tables_fixed(void) +static int init_fixed(AACDecContext *ac) { static AVOnce init_fixed_once = AV_ONCE_INIT; ff_thread_once(&init_fixed_once, init_tables_fixed_fn); + + ac->fdsp = avpriv_alloc_fixed_dsp(ac->avctx->flags & AV_CODEC_FLAG_BITEXACT); + if (!ac->fdsp) + return AVERROR(ENOMEM); + + return 0; } static const int cce_scale_fixed[8] = { diff --git a/libavcodec/aac/aacdec_float.c b/libavcodec/aac/aacdec_float.c index 73aaa72f68..6801085098 100644 --- a/libavcodec/aac/aacdec_float.c +++ b/libavcodec/aac/aacdec_float.c @@ -35,6 +35,8 @@ #include "libavcodec/aac_defines.h" +#include "libavcodec/avcodec.h" +#include "libavcodec/aacdec.h" #include "libavcodec/aactab.h" #include "libavcodec/sinewin.h" #include "libavcodec/kbdwin.h" @@ -61,10 +63,22 @@ static void init_tables_float_fn(void) AAC_RENAME(ff_init_ff_sine_windows)(9); } -static void init_tables(void) +static int init(AACDecContext *ac) { static AVOnce init_float_once = AV_ONCE_INIT; ff_thread_once(&init_float_once, init_tables_float_fn); + + ac->fdsp = avpriv_float_dsp_alloc(ac->avctx->flags & AV_CODEC_FLAG_BITEXACT); + if (!ac->fdsp) + return AVERROR(ENOMEM); + + ff_aac_float_common_init(); + +#if ARCH_MIPS + ff_aacdec_init_mips(ac); +#endif + + return 0; } static const float cce_scale[] = { diff --git a/libavcodec/aacdec.h b/libavcodec/aacdec.h index 2a997823ee..2e3ee961b0 100644 --- a/libavcodec/aacdec.h +++ b/libavcodec/aacdec.h @@ -216,7 +216,7 @@ typedef struct AACDecProc { * DSP-specific primitives */ typedef struct AACDecDSP { - void (*init_tables)(void); + int (*init)(AACDecContext *ac); void (*dequant_scalefactors)(SingleChannelElement *sce); diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index 30ec914520..ad40c0ca09 100644 --- a/libavcodec/aacdec_template.c +++ b/libavcodec/aacdec_template.c @@ -1088,18 +1088,11 @@ static int sample_rate_idx (int rate) else return 11; } -static void aacdec_init(AACDecContext *ac); - static av_cold void aac_static_table_init(void) { AAC_RENAME(ff_aac_sbr_init)(); ff_aacdec_common_init_once(); - -#if !USE_FIXED - ff_aac_float_common_init(); -#else -#endif } static AVOnce aac_table_init = AV_ONCE_INIT; @@ -1121,12 +1114,10 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) ac->avctx = avctx; ac->oc[1].m4ac.sample_rate = avctx->sample_rate; - aacdec_init(ac); -#if USE_FIXED - avctx->sample_fmt = AV_SAMPLE_FMT_S32P; -#else - avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; -#endif /* USE_FIXED */ + if (ac->is_fixed) + avctx->sample_fmt = AV_SAMPLE_FMT_S32P; + else + avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; if (avctx->extradata_size > 0) { if ((ret = decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac, @@ -1164,15 +1155,6 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) } } -#if USE_FIXED - ac->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & AV_CODEC_FLAG_BITEXACT); -#else - ac->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); -#endif /* USE_FIXED */ - if (!ac->fdsp) { - return AVERROR(ENOMEM); - } - return ff_aac_decode_init_common(avctx); } @@ -2411,12 +2393,3 @@ static int aac_decode_frame(AVCodecContext *avctx, AVFrame *frame, return buf_size > buf_offset ? buf_consumed : buf_size; } - -static void aacdec_init(AACDecContext *c) -{ -#if !USE_FIXED -#if ARCH_MIPS - ff_aacdec_init_mips(c); -#endif -#endif /* !USE_FIXED */ -} |