From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH v3] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled
Date: Tue, 7 May 2024 00:37:58 +0200
Message-ID: <GV1P250MB0737A29C0776175536E98E1D8F1C2@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> (raw)
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.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
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..ee31e2fcde 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 *L, void *R);
void ff_aac_sbr_apply_fixed(AACDecContext *ac, ChannelElement *che,
- int id_aac, int *L, int *R);
+ int id_aac, void *L, void *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;
--
2.40.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2024-05-06 22:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-06 22:37 Andreas Rheinhardt [this message]
2024-05-06 22:47 ` Lynne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=GV1P250MB0737A29C0776175536E98E1D8F1C2@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM \
--to=andreas.rheinhardt@outlook.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git