From: Lynne <dev@lynne.ee>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH 3/3] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled
Date: Mon, 6 May 2024 19:53:53 +0200 (CEST)
Message-ID: <NxE1aaD--3-9@lynne.ee> (raw)
In-Reply-To: <GV1P250MB07376D404340C2B7ABC096108F1C2@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM>
May 6, 2024, 11:31 by andreas.rheinhardt@outlook.com:
> The approach used here has the advantage not to rely
> on any DCE.
> Also improve certain the checks from
> 3390693bfb907765f833766f370e0ba8c7894f44 a bit.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/aac/aacdec.c | 62 ++++++++++++++++++++---------------------
> 1 file changed, 31 insertions(+), 31 deletions(-)
>
> diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
> index c6b93e33a2..6a74b05168 100644
> --- a/libavcodec/aac/aacdec.c
> +++ b/libavcodec/aac/aacdec.c
> @@ -63,6 +63,20 @@
> #include "libavutil/version.h"
> #include "libavutil/thread.h"
>
> +#if CONFIG_AAC_DECODER && CONFIG_AAC_FIXED_DECODER
> +#define IS_FIXED(is_fixed) (is_fixed)
> +#define FIXED_OR_FLOAT(is_fixed, func_or_obj, func_args) \
> + ((is_fixed) ? RENAME_FIXED(func_or_obj) func_args : (func_or_obj) func_args)
> +#elif CONFIG_AAC_DECODER
> +#define IS_FIXED(is_fixed) 0
> +#define FIXED_OR_FLOAT(is_fixed, func_or_obj, func_args) \
> + ((func_or_obj) func_args)
> +#else
> +#define IS_FIXED(is_fixed) 1
> +#define FIXED_OR_FLOAT(is_fixed, func_or_obj, func_args) \
> + (RENAME_FIXED(func_or_obj) func_args)
> +#endif
> +
> /*
> * supported tools
> *
> @@ -150,11 +164,8 @@ 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 = FIXED_OR_FLOAT(ac->is_fixed, ff_aac_sbr_ctx_alloc_init,
> + (ac, &ac->che[type][id], type));
> if (ret < 0)
> return ret;
> }
> @@ -171,10 +182,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]);
> + FIXED_OR_FLOAT(ac->is_fixed, ff_aac_sbr_ctx_close, (ac->che[type][id]));
> }
> av_freep(&ac->che[type][id]);
> }
> @@ -1122,8 +1130,7 @@ 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;
> + void (*sbr_close)(ChannelElement *che) = FIXED_OR_FLOAT(is_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++) {
> @@ -1154,7 +1161,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
> static av_cold int init_dsp(AVCodecContext *avctx)
> {
> AACDecContext *ac = avctx->priv_data;
> - int is_fixed = ac->is_fixed, ret;
> + int is_fixed = IS_FIXED(ac->is_fixed), ret;
> float scale_fixed, scale_float;
> const float *const scalep = is_fixed ? &scale_fixed : &scale_float;
> enum AVTXType tx_type = is_fixed ? AV_TX_INT32_MDCT : AV_TX_FLOAT_MDCT;
> @@ -1188,8 +1195,8 @@ static av_cold int init_dsp(AVCodecContext *avctx)
> if (ret < 0)
> return ret;
>
> - ac->dsp = is_fixed ? aac_dsp_fixed : aac_dsp;
> - ac->proc = is_fixed ? aac_proc_fixed : aac_proc;
> + ac->dsp = FIXED_OR_FLOAT(is_fixed, aac_dsp, );
> + ac->proc = FIXED_OR_FLOAT(is_fixed, aac_proc, );
>
> return ac->dsp.init(ac);
> }
> @@ -1315,9 +1322,9 @@ static void decode_ltp(AACDecContext *ac, LongTermPrediction *ltp,
> int sfb;
>
> ltp->lag = get_bits(gb, 11);
> - if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
> + if (IS_FIXED(ac->is_fixed))
> ltp->coef_fixed = Q30(ff_ltp_coef[get_bits(gb, 3)]);
> - else if (CONFIG_AAC_DECODER)
> + else
> ltp->coef = ff_ltp_coef[get_bits(gb, 3)];
>
> for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++)
> @@ -1626,9 +1633,9 @@ static int decode_tns(AACDecContext *ac, TemporalNoiseShaping *tns,
> tmp2_idx = 2 * coef_compress + coef_res;
>
> for (i = 0; i < tns->order[w][filt]; i++) {
> - if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
> + if (IS_FIXED(ac->is_fixed))
> tns->coef_fixed[w][filt][i] = Q31(ff_tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)]);
> - else if (CONFIG_AAC_DECODER)
> + else
> tns->coef[w][filt][i] = ff_tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)];
> }
> }
> @@ -1977,11 +1984,8 @@ 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);
> -
> + res = FIXED_OR_FLOAT(ac->is_fixed, ff_aac_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");
> @@ -2090,14 +2094,10 @@ 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);
> + FIXED_OR_FLOAT(ac->is_fixed,ff_aac_sbr_apply,
> + (ac, che, type,
> + (void *)che->ch[0].output,
> + (void *)che->ch[1].output));
>
I'm not particularly a fan of FIXED_OR_FLOAT, with the
way that function arguments are given to the macro.
We already rely on DCE globally, and the code only
has a few different paths for fixed vs float.
Would it be possible to fix the linking errors without
adding more abstractions?
_______________________________________________
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 prev parent reply other threads:[~2024-05-06 17:54 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-06 9:29 [FFmpeg-devel] [PATCH 1/3] avcodec/aactab: Provide ff_ltp_coef, ff_tns_tmp2_map unconditionally Andreas Rheinhardt
2024-05-06 9:30 ` [FFmpeg-devel] [PATCH 2/3] avcodec/aacsbr: Fix type mismatch Andreas Rheinhardt
2024-05-06 17:54 ` Lynne
2024-05-06 9:30 ` [FFmpeg-devel] [PATCH 3/3] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled Andreas Rheinhardt
2024-05-06 14:03 ` [FFmpeg-devel] [PATCH v2 3/12] " Andreas Rheinhardt
2024-05-06 17:53 ` Lynne [this message]
2024-05-06 19:39 ` [FFmpeg-devel] [PATCH 3/3] " Andreas Rheinhardt
2024-05-06 20:00 ` Lynne
2024-05-06 20:08 ` Andreas Rheinhardt
2024-05-06 12:14 ` [FFmpeg-devel] [PATCH 04/12] avcodec/aac/aacdec: Remove unnecessary ff_thread_once() Andreas Rheinhardt
2024-05-06 12:14 ` [FFmpeg-devel] [PATCH 05/12] avcodec/aac/aacdec: Move channel number check out of init_dsp() Andreas Rheinhardt
2024-05-06 12:14 ` [FFmpeg-devel] [PATCH 06/12] avcodec/aac/aacdec: Avoid branch to set sample_fmt Andreas Rheinhardt
2024-05-06 12:14 ` [FFmpeg-devel] [PATCH 07/12] avcodec/aac/aacdec_float: Call ff_aac_float_common_init() only once Andreas Rheinhardt
2024-05-06 12:14 ` [FFmpeg-devel] [PATCH 08/12] avcodec/aac/aacdec_(fixed|float): Avoid AAC_RENAME, INTFLOAT Andreas Rheinhardt
2024-05-06 12:14 ` [FFmpeg-devel] [PATCH 09/12] avcodec/aac/aacdec: Mark flush as cold Andreas Rheinhardt
2024-05-06 12:14 ` [FFmpeg-devel] [PATCH 10/12] avcodec/aac/aacdec: Avoid compiling latm decoder if disabled Andreas Rheinhardt
2024-05-06 12:14 ` [FFmpeg-devel] [PATCH 11/12] avcodec/aac/aacdec: Move init functions to aacdec_fixed/float Andreas Rheinhardt
2024-05-06 12:14 ` [FFmpeg-devel] [PATCH 12/12] avcodec/aac/aacdec_(fixed|float): Set AACDecDSP, AACDecProc directly Andreas Rheinhardt
2024-05-06 17:59 ` 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=NxE1aaD--3-9@lynne.ee \
--to=dev@lynne.ee \
--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