[FFmpeg-cvslog] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled
Andreas Rheinhardt
git at videolan.org
Tue May 7 13:39:52 EEST 2024
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Tue May 7 00:33:01 2024 +0200| [2eab5a1f54cd08ea8b5a2b55a805718c51b26436] | committer: Andreas Rheinhardt
avcodec/aac/aacdec: Fix linking errors with only one decoder enabled
This is achieved by using function pointers for AAC SBR functions.
This unfortunately necessitated to use void* in
ff_aac_sbr_apply(_fixed).
Fixes ticket #10999.
Reviewed-by: Lynne <dev at lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2eab5a1f54cd08ea8b5a2b55a805718c51b26436
---
libavcodec/aac/aacdec.c | 35 ++++++++---------------------------
libavcodec/aac/aacdec.h | 7 +++++++
libavcodec/aac/aacdec_proc_template.c | 6 ++++++
libavcodec/aacsbr.h | 4 ++--
libavcodec/aacsbr_template.c | 3 ++-
5 files changed, 25 insertions(+), 30 deletions(-)
diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index 4206ad1b5d..7457fe6c97 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -149,11 +149,7 @@ static av_cold int che_configure(AACDecContext *ac,
return AVERROR_INVALIDDATA;
if (che_pos) {
if (!ac->che[type][id]) {
- int ret;
- if (ac->is_fixed)
- ret = ff_aac_sbr_ctx_alloc_init_fixed(ac, &ac->che[type][id], type);
- else
- ret = ff_aac_sbr_ctx_alloc_init(ac, &ac->che[type][id], type);
+ int ret = ac->proc.sbr_ctx_alloc_init(ac, &ac->che[type][id], type);
if (ret < 0)
return ret;
}
@@ -170,10 +166,7 @@ static av_cold int che_configure(AACDecContext *ac,
}
} else {
if (ac->che[type][id]) {
- if (ac->is_fixed)
- ff_aac_sbr_ctx_close_fixed(ac->che[type][id]);
- else
- ff_aac_sbr_ctx_close(ac->che[type][id]);
+ ac->proc.sbr_ctx_close(ac->che[type][id]);
}
av_freep(&ac->che[type][id]);
}
@@ -1114,14 +1107,11 @@ static int sample_rate_idx (int rate)
static av_cold int decode_close(AVCodecContext *avctx)
{
AACDecContext *ac = avctx->priv_data;
- int is_fixed = ac->is_fixed;
- void (*sbr_close)(ChannelElement *che) = is_fixed ? ff_aac_sbr_ctx_close_fixed :
- ff_aac_sbr_ctx_close;
for (int type = 0; type < FF_ARRAY_ELEMS(ac->che); type++) {
for (int i = 0; i < MAX_ELEM_ID; i++) {
if (ac->che[type][i]) {
- sbr_close(ac->che[type][i]);
+ ac->proc.sbr_ctx_close(ac->che[type][i]);
av_freep(&ac->che[type][i]);
}
}
@@ -1136,7 +1126,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
av_tx_uninit(&ac->mdct_ltp);
// Compiler will optimize this branch away.
- if (is_fixed)
+ if (ac->is_fixed)
av_freep(&ac->RENAME_FIXED(fdsp));
else
av_freep(&ac->fdsp);
@@ -1946,11 +1936,7 @@ static int decode_extension_payload(AACDecContext *ac, GetBitContext *gb, int cn
ac->avctx->profile = AV_PROFILE_AAC_HE;
}
- if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
- res = ff_aac_sbr_decode_extension_fixed(ac, che, gb, crc_flag, cnt, elem_type);
- else if (CONFIG_AAC_DECODER)
- res = ff_aac_sbr_decode_extension(ac, che, gb, crc_flag, cnt, elem_type);
-
+ ac->proc.sbr_decode_extension(ac, che, gb, crc_flag, cnt, elem_type);
if (ac->oc[1].m4ac.ps == 1 && !ac->warned_he_aac_mono) {
av_log(ac->avctx, AV_LOG_VERBOSE, "Treating HE-AAC mono as stereo.\n");
@@ -2059,14 +2045,9 @@ static void spectral_to_sample(AACDecContext *ac, int samples)
ac->dsp.update_ltp(ac, &che->ch[1]);
}
if (ac->oc[1].m4ac.sbr > 0) {
- if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
- ff_aac_sbr_apply_fixed(ac, che, type,
- (void *)che->ch[0].output,
- (void *)che->ch[1].output);
- else if (CONFIG_AAC_DECODER)
- ff_aac_sbr_apply(ac, che, type,
- (void *)che->ch[0].output,
- (void *)che->ch[1].output);
+ ac->proc.sbr_apply(ac, che, type,
+ che->ch[0].output,
+ che->ch[1].output);
}
}
if (type <= TYPE_CCE)
diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h
index 775c007aeb..eed53c6c96 100644
--- a/libavcodec/aac/aacdec.h
+++ b/libavcodec/aac/aacdec.h
@@ -210,6 +210,13 @@ typedef struct AACDecProc {
SingleChannelElement *sce);
int (*decode_cce)(AACDecContext *ac, GetBitContext *gb, ChannelElement *che);
+
+ int (*sbr_ctx_alloc_init)(AACDecContext *ac, ChannelElement **che, int id_aac);
+ int (*sbr_decode_extension)(AACDecContext *ac, ChannelElement *che,
+ GetBitContext *gb, int crc, int cnt, int id_aac);
+ void (*sbr_apply)(AACDecContext *ac, ChannelElement *che,
+ int id_aac, void /* INTFLOAT */ *L, void /* INTFLOAT */ *R);
+ void (*sbr_ctx_close)(ChannelElement *che);
} AACDecProc;
/**
diff --git a/libavcodec/aac/aacdec_proc_template.c b/libavcodec/aac/aacdec_proc_template.c
index fecf228b3b..327f3117b5 100644
--- a/libavcodec/aac/aacdec_proc_template.c
+++ b/libavcodec/aac/aacdec_proc_template.c
@@ -439,4 +439,10 @@ static av_cold void AAC_RENAME(aac_proc_init)(AACDecProc *aac_proc)
SET(decode_spectrum_and_dequant);
SET(decode_cce);
#undef SET
+#define SET(member) aac_proc->member = AV_JOIN(ff_aac_, AAC_RENAME(member));
+ SET(sbr_ctx_alloc_init);
+ SET(sbr_decode_extension);
+ SET(sbr_apply);
+ SET(sbr_ctx_close);
+#undef SET
}
diff --git a/libavcodec/aacsbr.h b/libavcodec/aacsbr.h
index 656ef5258e..d4582d1100 100644
--- a/libavcodec/aacsbr.h
+++ b/libavcodec/aacsbr.h
@@ -90,9 +90,9 @@ int ff_aac_sbr_decode_extension_fixed(AACDecContext *ac, ChannelElement *che,
/** Apply one SBR element to one AAC element. */
void ff_aac_sbr_apply(AACDecContext *ac, ChannelElement *che,
- int id_aac, float *L, float *R);
+ int id_aac, void /* float */ *L, void /* float */ *R);
void ff_aac_sbr_apply_fixed(AACDecContext *ac, ChannelElement *che,
- int id_aac, int *L, int *R);
+ int id_aac, void /* int */ *L, void /* int */ *R);
FF_VISIBILITY_POP_HIDDEN
diff --git a/libavcodec/aacsbr_template.c b/libavcodec/aacsbr_template.c
index a6e3bc54bd..86f4d8c26e 100644
--- a/libavcodec/aacsbr_template.c
+++ b/libavcodec/aacsbr_template.c
@@ -1469,8 +1469,9 @@ static void sbr_env_estimate(AAC_FLOAT (*e_curr)[48], INTFLOAT X_high[64][40][2]
}
void AAC_RENAME(ff_aac_sbr_apply)(AACDecContext *ac, ChannelElement *che,
- int id_aac, INTFLOAT* L, INTFLOAT* R)
+ int id_aac, void *L_, void *R_)
{
+ INTFLOAT *L = L_, *R = R_;
SpectralBandReplication *sbr = get_sbr(che);
int downsampled = ac->oc[1].m4ac.ext_sample_rate < sbr->sample_rate;
int ch;
More information about the ffmpeg-cvslog
mailing list