From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 9AD564A98A for ; Mon, 6 May 2024 17:54:03 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C8C3C68D668; Mon, 6 May 2024 20:54:00 +0300 (EEST) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8BE4F68D510 for ; Mon, 6 May 2024 20:53:54 +0300 (EEST) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id F2E6A1060154 for ; Mon, 6 May 2024 17:53:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1715018033; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=TRgULrNS86fKBGWQqJi3DT3KOxF9mz5Dkeug5iY/beA=; b=mG8x+NfSfgJI8qRa1fywJX5RiREyXTuuK5ehVmXx9kA40WLhARX3VrQw9mrGT19Q ywQ3ZnAeg5oTEaZKVGKOGNBWqqMdZw7n5Qk47hrdxGMg1OORIapQBFp/VFagW4qwGwo AJoY/ISg+yPye9hnyN9gYSxZP4nqkRGEkNe09u1xsZk30eRPOyoxdKaAf2UEzm8VAA/ gbbDoIbd3X4QnFv92B3+fhjlUeCw32PihdBNfbRwpx8uahqh7lfdBAA+OQlp23ha/8Q wWH1u30wwf/ePDVnpR6mysqSdUTnHb5YxaPW7gDmbHC8SShOB9y8EsnWb83ub4Qi3++ sD18z5dP0Q== Date: Mon, 6 May 2024 19:53:53 +0200 (CEST) From: Lynne To: FFmpeg development discussions and patches Message-ID: In-Reply-To: References: MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 3/3] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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 > --- > 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".