* [FFmpeg-devel] [PATCH 1/3] avcodec/aactab: Provide ff_ltp_coef, ff_tns_tmp2_map unconditionally
@ 2024-05-06 9:29 Andreas Rheinhardt
2024-05-06 9:30 ` [FFmpeg-devel] [PATCH 2/3] avcodec/aacsbr: Fix type mismatch Andreas Rheinhardt
` (10 more replies)
0 siblings, 11 replies; 19+ messages in thread
From: Andreas Rheinhardt @ 2024-05-06 9:29 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
The fixed point decoder needs it since
905fdb06010e554262fca3c12b362bb69a11de85.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/aactab.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c
index 3cef9c5d2b..3718b81a07 100644
--- a/libavcodec/aactab.c
+++ b/libavcodec/aactab.c
@@ -105,6 +105,7 @@ av_cold void ff_aac_float_common_init(void)
static AVOnce init_static_once = AV_ONCE_INIT;
ff_thread_once(&init_static_once, aac_float_common_init);
}
+#endif
const float ff_ltp_coef[8] = {
0.570829, 0.696616, 0.813004, 0.911304,
@@ -144,7 +145,6 @@ const float * const ff_tns_tmp2_map[4] = {
tns_tmp2_map_1_3,
tns_tmp2_map_1_4
};
-#endif
const uint8_t ff_aac_num_swb_1024[] = {
41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40, 40
--
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".
^ permalink raw reply [flat|nested] 19+ messages in thread
* [FFmpeg-devel] [PATCH 2/3] avcodec/aacsbr: Fix type mismatch
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 ` 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
` (9 subsequent siblings)
10 siblings, 1 reply; 19+ messages in thread
From: Andreas Rheinhardt @ 2024-05-06 9:30 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
ff_aac_sbr_apply() and ff_aac_sbr_apply_fixed() still used
pointers to INTFLOAT which is float or int depending upon
whether USE_FIXED is set or not; in particular, according
to these declarations both functions have the same type.
But that is wrong and given that aacdec.c sets USE_FIXED,
it sees the wrong type for ff_aac_sbr_apply().
Fix this by avoiding INTFLOAT in aacsbr.h (which also means
that aac_defines.h need not be included there any more).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/aac/aacdec.c | 1 +
libavcodec/aacsbr.h | 5 ++---
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index 72f2d7e7ba..c6b93e33a2 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -42,6 +42,7 @@
#include "aacdec_tab.h"
#include "libavcodec/aac.h"
+#include "libavcodec/aac_defines.h"
#include "libavcodec/aacsbr.h"
#include "libavcodec/aactab.h"
#include "libavcodec/adts_header.h"
diff --git a/libavcodec/aacsbr.h b/libavcodec/aacsbr.h
index cd030aa801..656ef5258e 100644
--- a/libavcodec/aacsbr.h
+++ b/libavcodec/aacsbr.h
@@ -31,7 +31,6 @@
#include "get_bits.h"
#include "aac/aacdec.h"
-#include "aac_defines.h"
#include "libavutil/attributes_internal.h"
@@ -91,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, INTFLOAT* L, INTFLOAT* R);
+ int id_aac, float *L, float *R);
void ff_aac_sbr_apply_fixed(AACDecContext *ac, ChannelElement *che,
- int id_aac, INTFLOAT* L, INTFLOAT* R);
+ int id_aac, int *L, int *R);
FF_VISIBILITY_POP_HIDDEN
--
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".
^ permalink raw reply [flat|nested] 19+ messages in thread
* [FFmpeg-devel] [PATCH 3/3] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled
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 9:30 ` Andreas Rheinhardt
2024-05-06 14:03 ` [FFmpeg-devel] [PATCH v2 3/12] " Andreas Rheinhardt
2024-05-06 17:53 ` [FFmpeg-devel] [PATCH 3/3] " Lynne
2024-05-06 12:14 ` [FFmpeg-devel] [PATCH 04/12] avcodec/aac/aacdec: Remove unnecessary ff_thread_once() Andreas Rheinhardt
` (8 subsequent siblings)
10 siblings, 2 replies; 19+ messages in thread
From: Andreas Rheinhardt @ 2024-05-06 9:30 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
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));
}
}
if (type <= TYPE_CCE)
--
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".
^ permalink raw reply [flat|nested] 19+ messages in thread
* [FFmpeg-devel] [PATCH 04/12] avcodec/aac/aacdec: Remove unnecessary ff_thread_once()
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 9:30 ` [FFmpeg-devel] [PATCH 3/3] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled Andreas Rheinhardt
@ 2024-05-06 12:14 ` 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
` (7 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Andreas Rheinhardt @ 2024-05-06 12:14 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
ff_aacdec_common_init_once() already uses its own AVOnce.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/aac/aacdec.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index 6a74b05168..f6a7266123 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -61,7 +61,6 @@
#include "libavutil/opt.h"
#include "libavutil/tx.h"
#include "libavutil/version.h"
-#include "libavutil/thread.h"
#if CONFIG_AAC_DECODER && CONFIG_AAC_FIXED_DECODER
#define IS_FIXED(is_fixed) (is_fixed)
@@ -1120,12 +1119,6 @@ static int sample_rate_idx (int rate)
else return 11;
}
-static av_cold void aac_static_table_init(void)
-{
- ff_aacdec_common_init_once();
-}
-static AVOnce aac_table_init = AV_ONCE_INIT;
-
static av_cold int decode_close(AVCodecContext *avctx)
{
AACDecContext *ac = avctx->priv_data;
@@ -1209,9 +1202,7 @@ static av_cold int aac_decode_init_internal(AVCodecContext *avctx)
if (avctx->sample_rate > 96000)
return AVERROR_INVALIDDATA;
- ret = ff_thread_once(&aac_table_init, &aac_static_table_init);
- if (ret != 0)
- return AVERROR_UNKNOWN;
+ ff_aacdec_common_init_once();
ac->avctx = avctx;
ac->oc[1].m4ac.sample_rate = avctx->sample_rate;
--
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".
^ permalink raw reply [flat|nested] 19+ messages in thread
* [FFmpeg-devel] [PATCH 05/12] avcodec/aac/aacdec: Move channel number check out of init_dsp()
2024-05-06 9:29 [FFmpeg-devel] [PATCH 1/3] avcodec/aactab: Provide ff_ltp_coef, ff_tns_tmp2_map unconditionally Andreas Rheinhardt
` (2 preceding siblings ...)
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 ` Andreas Rheinhardt
2024-05-06 12:14 ` [FFmpeg-devel] [PATCH 06/12] avcodec/aac/aacdec: Avoid branch to set sample_fmt Andreas Rheinhardt
` (6 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Andreas Rheinhardt @ 2024-05-06 12:14 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Also move initializing random_state.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/aac/aacdec.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index f6a7266123..a78a669602 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -1159,13 +1159,6 @@ static av_cold int init_dsp(AVCodecContext *avctx)
const float *const scalep = is_fixed ? &scale_fixed : &scale_float;
enum AVTXType tx_type = is_fixed ? AV_TX_INT32_MDCT : AV_TX_FLOAT_MDCT;
- if (avctx->ch_layout.nb_channels > MAX_CHANNELS) {
- av_log(avctx, AV_LOG_ERROR, "Too many channels\n");
- return AVERROR_INVALIDDATA;
- }
-
- ac->random_state = 0x1f2e3d4c;
-
#define MDCT_INIT(s, fn, len, sval) \
scale_fixed = (sval) * 128.0f; \
scale_float = (sval) / 32768.0f; \
@@ -1248,6 +1241,13 @@ static av_cold int aac_decode_init_internal(AVCodecContext *avctx)
}
}
+ if (avctx->ch_layout.nb_channels > MAX_CHANNELS) {
+ av_log(avctx, AV_LOG_ERROR, "Too many channels\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ ac->random_state = 0x1f2e3d4c;
+
return init_dsp(avctx);
}
--
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".
^ permalink raw reply [flat|nested] 19+ messages in thread
* [FFmpeg-devel] [PATCH 06/12] avcodec/aac/aacdec: Avoid branch to set sample_fmt
2024-05-06 9:29 [FFmpeg-devel] [PATCH 1/3] avcodec/aactab: Provide ff_ltp_coef, ff_tns_tmp2_map unconditionally Andreas Rheinhardt
` (3 preceding siblings ...)
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 ` 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
` (5 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Andreas Rheinhardt @ 2024-05-06 12:14 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/aac/aacdec.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index a78a669602..1dc4af8a0d 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -1200,11 +1200,6 @@ static av_cold int aac_decode_init_internal(AVCodecContext *avctx)
ac->avctx = avctx;
ac->oc[1].m4ac.sample_rate = avctx->sample_rate;
- 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,
avctx->extradata,
@@ -1254,14 +1249,20 @@ static av_cold int aac_decode_init_internal(AVCodecContext *avctx)
static av_cold int aac_decode_init(AVCodecContext *avctx)
{
AACDecContext *ac = avctx->priv_data;
+
ac->is_fixed = 0;
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
+
return aac_decode_init_internal(avctx);
}
static av_cold int aac_decode_init_fixed(AVCodecContext *avctx)
{
AACDecContext *ac = avctx->priv_data;
+
ac->is_fixed = 1;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S32P;
+
return aac_decode_init_internal(avctx);
}
--
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".
^ permalink raw reply [flat|nested] 19+ messages in thread
* [FFmpeg-devel] [PATCH 07/12] avcodec/aac/aacdec_float: Call ff_aac_float_common_init() only once
2024-05-06 9:29 [FFmpeg-devel] [PATCH 1/3] avcodec/aactab: Provide ff_ltp_coef, ff_tns_tmp2_map unconditionally Andreas Rheinhardt
` (4 preceding siblings ...)
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 ` Andreas Rheinhardt
2024-05-06 12:14 ` [FFmpeg-devel] [PATCH 08/12] avcodec/aac/aacdec_(fixed|float): Avoid AAC_RENAME, INTFLOAT Andreas Rheinhardt
` (4 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Andreas Rheinhardt @ 2024-05-06 12:14 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
That's enough.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/aac/aacdec_float.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/aac/aacdec_float.c b/libavcodec/aac/aacdec_float.c
index 5c4eec1204..511db1a604 100644
--- a/libavcodec/aac/aacdec_float.c
+++ b/libavcodec/aac/aacdec_float.c
@@ -64,6 +64,8 @@ static void init_tables_float_fn(void)
AAC_RENAME(ff_init_ff_sine_windows)(9);
AAC_RENAME(ff_aac_sbr_init)();
+
+ ff_aac_float_common_init();
}
static int init(AACDecContext *ac)
@@ -75,8 +77,6 @@ static int init(AACDecContext *ac)
if (!ac->fdsp)
return AVERROR(ENOMEM);
- ff_aac_float_common_init();
-
return 0;
}
--
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".
^ permalink raw reply [flat|nested] 19+ messages in thread
* [FFmpeg-devel] [PATCH 08/12] avcodec/aac/aacdec_(fixed|float): Avoid AAC_RENAME, INTFLOAT
2024-05-06 9:29 [FFmpeg-devel] [PATCH 1/3] avcodec/aactab: Provide ff_ltp_coef, ff_tns_tmp2_map unconditionally Andreas Rheinhardt
` (5 preceding siblings ...)
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 ` Andreas Rheinhardt
2024-05-06 12:14 ` [FFmpeg-devel] [PATCH 09/12] avcodec/aac/aacdec: Mark flush as cold Andreas Rheinhardt
` (3 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Andreas Rheinhardt @ 2024-05-06 12:14 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Unnecessary now that this has been detemplatized.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/aac/aacdec_fixed.c | 20 ++++++++++----------
libavcodec/aac/aacdec_float.c | 18 +++++++++---------
2 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/libavcodec/aac/aacdec_fixed.c b/libavcodec/aac/aacdec_fixed.c
index 92204180a1..083f3b073e 100644
--- a/libavcodec/aac/aacdec_fixed.c
+++ b/libavcodec/aac/aacdec_fixed.c
@@ -43,22 +43,22 @@
#include "libavcodec/cbrt_data.h"
#include "libavcodec/aacsbr.h"
-DECLARE_ALIGNED(32, static INTFLOAT, AAC_RENAME2(aac_kbd_long_1024))[1024];
-DECLARE_ALIGNED(32, static INTFLOAT, AAC_RENAME2(aac_kbd_short_128))[128];
-DECLARE_ALIGNED(32, static INTFLOAT, AAC_RENAME(aac_kbd_long_960))[960];
-DECLARE_ALIGNED(32, static INTFLOAT, AAC_RENAME(aac_kbd_short_120))[120];
+DECLARE_ALIGNED(32, static int, aac_kbd_long_1024_fixed)[1024];
+DECLARE_ALIGNED(32, static int, aac_kbd_short_128_fixed)[128];
+DECLARE_ALIGNED(32, static int, aac_kbd_long_960_fixed)[960];
+DECLARE_ALIGNED(32, static int, aac_kbd_short_120_fixed)[120];
static void init_tables_fixed_fn(void)
{
- AAC_RENAME(ff_cbrt_tableinit)();
+ ff_cbrt_tableinit_fixed();
- AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_long_1024), 4.0, 1024);
- AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_short_128), 6.0, 128);
+ ff_kbd_window_init_fixed(aac_kbd_long_1024_fixed, 4.0, 1024);
+ ff_kbd_window_init_fixed(aac_kbd_short_128_fixed, 6.0, 128);
- AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_long_960), 4.0, 960);
- AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_short_120), 6.0, 120);
+ ff_kbd_window_init_fixed(aac_kbd_long_960_fixed, 4.0, 960);
+ ff_kbd_window_init_fixed(aac_kbd_short_120_fixed, 6.0, 120);
- AAC_RENAME(ff_aac_sbr_init)();
+ ff_aac_sbr_init_fixed();
init_sine_windows_fixed();
}
diff --git a/libavcodec/aac/aacdec_float.c b/libavcodec/aac/aacdec_float.c
index 511db1a604..5efc0c1e54 100644
--- a/libavcodec/aac/aacdec_float.c
+++ b/libavcodec/aac/aacdec_float.c
@@ -51,19 +51,19 @@ DECLARE_ALIGNED(32, static float, aac_kbd_short_120)[120];
static void init_tables_float_fn(void)
{
- AAC_RENAME(ff_cbrt_tableinit)();
+ ff_cbrt_tableinit();
- AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_long_1024), 4.0, 1024);
- AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_short_128), 6.0, 128);
+ ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
+ ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
- AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_long_960), 4.0, 960);
- AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_short_120), 6.0, 120);
+ ff_kbd_window_init(aac_kbd_long_960, 4.0, 960);
+ ff_kbd_window_init(aac_kbd_short_120, 6.0, 120);
- AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_960), 960);
- AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_120), 120);
- AAC_RENAME(ff_init_ff_sine_windows)(9);
+ ff_sine_window_init(sine_960, 960);
+ ff_sine_window_init(sine_120, 120);
+ ff_init_ff_sine_windows(9);
- AAC_RENAME(ff_aac_sbr_init)();
+ ff_aac_sbr_init();
ff_aac_float_common_init();
}
--
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".
^ permalink raw reply [flat|nested] 19+ messages in thread
* [FFmpeg-devel] [PATCH 09/12] avcodec/aac/aacdec: Mark flush as cold
2024-05-06 9:29 [FFmpeg-devel] [PATCH 1/3] avcodec/aactab: Provide ff_ltp_coef, ff_tns_tmp2_map unconditionally Andreas Rheinhardt
` (6 preceding siblings ...)
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 ` Andreas Rheinhardt
2024-05-06 12:14 ` [FFmpeg-devel] [PATCH 10/12] avcodec/aac/aacdec: Avoid compiling latm decoder if disabled Andreas Rheinhardt
` (2 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Andreas Rheinhardt @ 2024-05-06 12:14 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/aac/aacdec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index 1dc4af8a0d..07dcc2672a 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -539,7 +539,7 @@ static int output_configure(AACDecContext *ac,
return 0;
}
-static void flush(AVCodecContext *avctx)
+static av_cold void flush(AVCodecContext *avctx)
{
AACDecContext *ac= avctx->priv_data;
int type, i, j;
--
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".
^ permalink raw reply [flat|nested] 19+ messages in thread
* [FFmpeg-devel] [PATCH 10/12] avcodec/aac/aacdec: Avoid compiling latm decoder if disabled
2024-05-06 9:29 [FFmpeg-devel] [PATCH 1/3] avcodec/aactab: Provide ff_ltp_coef, ff_tns_tmp2_map unconditionally Andreas Rheinhardt
` (7 preceding siblings ...)
2024-05-06 12:14 ` [FFmpeg-devel] [PATCH 09/12] avcodec/aac/aacdec: Mark flush as cold Andreas Rheinhardt
@ 2024-05-06 12:14 ` 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
10 siblings, 0 replies; 19+ messages in thread
From: Andreas Rheinhardt @ 2024-05-06 12:14 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/aac/aacdec.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index 07dcc2672a..cd80dd1d7a 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -2510,7 +2510,9 @@ static int aac_decode_frame(AVCodecContext *avctx, AVFrame *frame,
return buf_size > buf_offset ? buf_consumed : buf_size;
}
+#if CONFIG_AAC_LATM_DECODER
#include "aacdec_latm.h"
+#endif
#define AACDEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
#define OFF(field) offsetof(AACDecContext, field)
--
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".
^ permalink raw reply [flat|nested] 19+ messages in thread
* [FFmpeg-devel] [PATCH 11/12] avcodec/aac/aacdec: Move init functions to aacdec_fixed/float
2024-05-06 9:29 [FFmpeg-devel] [PATCH 1/3] avcodec/aactab: Provide ff_ltp_coef, ff_tns_tmp2_map unconditionally Andreas Rheinhardt
` (8 preceding siblings ...)
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 ` Andreas Rheinhardt
2024-05-06 12:14 ` [FFmpeg-devel] [PATCH 12/12] avcodec/aac/aacdec_(fixed|float): Set AACDecDSP, AACDecProc directly Andreas Rheinhardt
10 siblings, 0 replies; 19+ messages in thread
From: Andreas Rheinhardt @ 2024-05-06 12:14 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This allows to merge it with AACDecDSP.init and remove the latter
(it is called only once anyway); it also allows to make
the fixed/float AACDecDSP and AACDecProc implementations internal
to aacdec_fixed/float.c (which also fixes a violation of our
naming conventions). And it avoids a -Wunused-function warning
when either decoder is disabled.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
One could also move the FFCodecs, too. This would necessitate
using external linkage for several decode_frame-related functions
as well as flush and close; but it would allow to make the
fixed/float init function static.
libavcodec/aac/aacdec.c | 31 ++++----------------------
libavcodec/aac/aacdec.h | 11 +++------
libavcodec/aac/aacdec_dsp_template.c | 4 +---
libavcodec/aac/aacdec_fixed.c | 32 +++++++++++++++++----------
libavcodec/aac/aacdec_float.c | 32 +++++++++++++++++----------
libavcodec/aac/aacdec_latm.h | 2 +-
libavcodec/aac/aacdec_proc_template.c | 2 +-
7 files changed, 50 insertions(+), 64 deletions(-)
diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index cd80dd1d7a..dc81df174c 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -1181,13 +1181,10 @@ static av_cold int init_dsp(AVCodecContext *avctx)
if (ret < 0)
return ret;
- ac->dsp = FIXED_OR_FLOAT(is_fixed, aac_dsp, );
- ac->proc = FIXED_OR_FLOAT(is_fixed, aac_proc, );
-
- return ac->dsp.init(ac);
+ return 0;
}
-static av_cold int aac_decode_init_internal(AVCodecContext *avctx)
+av_cold int ff_aac_decode_init(AVCodecContext *avctx)
{
AACDecContext *ac = avctx->priv_data;
int ret;
@@ -1246,26 +1243,6 @@ static av_cold int aac_decode_init_internal(AVCodecContext *avctx)
return init_dsp(avctx);
}
-static av_cold int aac_decode_init(AVCodecContext *avctx)
-{
- AACDecContext *ac = avctx->priv_data;
-
- ac->is_fixed = 0;
- avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
-
- return aac_decode_init_internal(avctx);
-}
-
-static av_cold int aac_decode_init_fixed(AVCodecContext *avctx)
-{
- AACDecContext *ac = avctx->priv_data;
-
- ac->is_fixed = 1;
- avctx->sample_fmt = AV_SAMPLE_FMT_S32P;
-
- return aac_decode_init_internal(avctx);
-}
-
/**
* Skip data_stream_element; reference: table 4.10.
*/
@@ -2555,7 +2532,7 @@ const FFCodec ff_aac_decoder = {
.p.id = AV_CODEC_ID_AAC,
.p.priv_class = &decoder_class,
.priv_data_size = sizeof(AACDecContext),
- .init = aac_decode_init,
+ .init = ff_aac_decode_init_float,
.close = decode_close,
FF_CODEC_DECODE_CB(aac_decode_frame),
.p.sample_fmts = (const enum AVSampleFormat[]) {
@@ -2577,7 +2554,7 @@ const FFCodec ff_aac_fixed_decoder = {
.p.id = AV_CODEC_ID_AAC,
.p.priv_class = &decoder_class,
.priv_data_size = sizeof(AACDecContext),
- .init = aac_decode_init_fixed,
+ .init = ff_aac_decode_init_fixed,
.close = decode_close,
FF_CODEC_DECODE_CB(aac_decode_frame),
.p.sample_fmts = (const enum AVSampleFormat[]) {
diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h
index 4cf764e2e9..775c007aeb 100644
--- a/libavcodec/aac/aacdec.h
+++ b/libavcodec/aac/aacdec.h
@@ -216,8 +216,6 @@ typedef struct AACDecProc {
* DSP-specific primitives
*/
typedef struct AACDecDSP {
- int (*init)(AACDecContext *ac);
-
void (*dequant_scalefactors)(SingleChannelElement *sce);
void (*apply_mid_side_stereo)(AACDecContext *ac, ChannelElement *cpe);
@@ -339,12 +337,9 @@ struct AACDecContext {
#define fdsp RENAME_FIXED(fdsp)
#endif
-extern const AACDecDSP aac_dsp;
-extern const AACDecDSP aac_dsp_fixed;
-
-extern const AACDecProc aac_proc;
-extern const AACDecProc aac_proc_fixed;
-
+int ff_aac_decode_init(struct AVCodecContext *avctx);
+int ff_aac_decode_init_float(struct AVCodecContext *avctx);
+int ff_aac_decode_init_fixed(struct AVCodecContext *avctx);
int ff_aac_decode_ics(AACDecContext *ac, SingleChannelElement *sce,
GetBitContext *gb, int common_window, int scale_flag);
diff --git a/libavcodec/aac/aacdec_dsp_template.c b/libavcodec/aac/aacdec_dsp_template.c
index a42b40f674..70f0a3cce6 100644
--- a/libavcodec/aac/aacdec_dsp_template.c
+++ b/libavcodec/aac/aacdec_dsp_template.c
@@ -615,9 +615,7 @@ static void AAC_RENAME(apply_prediction)(AACDecContext *ac, SingleChannelElement
reset_all_predictors(sce->AAC_RENAME(predictor_state));
}
-const AACDecDSP AAC_RENAME(aac_dsp) = {
- .init = &AAC_RENAME(init),
-
+static const AACDecDSP AAC_RENAME(aac_dsp) = {
.dequant_scalefactors = &AAC_RENAME(dequant_scalefactors),
.apply_mid_side_stereo = &AAC_RENAME(apply_mid_side_stereo),
.apply_intensity_stereo = &AAC_RENAME(apply_intensity_stereo),
diff --git a/libavcodec/aac/aacdec_fixed.c b/libavcodec/aac/aacdec_fixed.c
index 083f3b073e..79d35e05fb 100644
--- a/libavcodec/aac/aacdec_fixed.c
+++ b/libavcodec/aac/aacdec_fixed.c
@@ -63,18 +63,6 @@ static void init_tables_fixed_fn(void)
init_sine_windows_fixed();
}
-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] = {
Q30(1.0), //2^(0/8)
Q30(1.0905077327), //2^(1/8)
@@ -93,3 +81,23 @@ static const int cce_scale_fixed[8] = {
#include "aacdec_fixed_prediction.h"
#include "aacdec_dsp_template.c"
#include "aacdec_proc_template.c"
+
+av_cold int ff_aac_decode_init_fixed(AVCodecContext *avctx)
+{
+ static AVOnce init_fixed_once = AV_ONCE_INIT;
+ AACDecContext *ac = avctx->priv_data;
+
+ ac->is_fixed = 1;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S32P;
+
+ ac->dsp = aac_dsp_fixed;
+ ac->proc = aac_proc_fixed;
+
+ ac->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & AV_CODEC_FLAG_BITEXACT);
+ if (!ac->fdsp)
+ return AVERROR(ENOMEM);
+
+ ff_thread_once(&init_fixed_once, init_tables_fixed_fn);
+
+ return ff_aac_decode_init(avctx);
+}
diff --git a/libavcodec/aac/aacdec_float.c b/libavcodec/aac/aacdec_float.c
index 5efc0c1e54..d48a21eef2 100644
--- a/libavcodec/aac/aacdec_float.c
+++ b/libavcodec/aac/aacdec_float.c
@@ -68,18 +68,6 @@ static void init_tables_float_fn(void)
ff_aac_float_common_init();
}
-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);
-
- return 0;
-}
-
static const float cce_scale[] = {
1.09050773266525765921, //2^(1/8)
1.18920711500272106672, //2^(1/4)
@@ -163,3 +151,23 @@ static inline float *VMUL4S(float *dst, const float *v, unsigned idx,
#include "aacdec_float_prediction.h"
#include "aacdec_dsp_template.c"
#include "aacdec_proc_template.c"
+
+av_cold int ff_aac_decode_init_float(AVCodecContext *avctx)
+{
+ static AVOnce init_float_once = AV_ONCE_INIT;
+ AACDecContext *ac = avctx->priv_data;
+
+ ac->is_fixed = 0;
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
+
+ ac->dsp = aac_dsp;
+ ac->proc = aac_proc;
+
+ ac->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
+ if (!ac->fdsp)
+ return AVERROR(ENOMEM);
+
+ ff_thread_once(&init_float_once, init_tables_float_fn);
+
+ return ff_aac_decode_init(avctx);
+}
diff --git a/libavcodec/aac/aacdec_latm.h b/libavcodec/aac/aacdec_latm.h
index 22153dec83..e40a2fe1a7 100644
--- a/libavcodec/aac/aacdec_latm.h
+++ b/libavcodec/aac/aacdec_latm.h
@@ -315,7 +315,7 @@ static int latm_decode_frame(AVCodecContext *avctx, AVFrame *out,
static av_cold int latm_decode_init(AVCodecContext *avctx)
{
struct LATMContext *latmctx = avctx->priv_data;
- int ret = aac_decode_init(avctx);
+ int ret = ff_aac_decode_init_float(avctx);
if (avctx->extradata_size > 0)
latmctx->initialized = !ret;
diff --git a/libavcodec/aac/aacdec_proc_template.c b/libavcodec/aac/aacdec_proc_template.c
index 319bf61993..1ffea2f93b 100644
--- a/libavcodec/aac/aacdec_proc_template.c
+++ b/libavcodec/aac/aacdec_proc_template.c
@@ -433,7 +433,7 @@ static int AAC_RENAME(decode_cce)(AACDecContext *ac, GetBitContext *gb, ChannelE
return 0;
}
-const AACDecProc AAC_RENAME(aac_proc) = {
+static const AACDecProc AAC_RENAME(aac_proc) = {
.decode_spectrum_and_dequant = AAC_RENAME(decode_spectrum_and_dequant),
.decode_cce = AAC_RENAME(decode_cce),
};
--
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".
^ permalink raw reply [flat|nested] 19+ messages in thread
* [FFmpeg-devel] [PATCH 12/12] avcodec/aac/aacdec_(fixed|float): Set AACDecDSP, AACDecProc directly
2024-05-06 9:29 [FFmpeg-devel] [PATCH 1/3] avcodec/aactab: Provide ff_ltp_coef, ff_tns_tmp2_map unconditionally Andreas Rheinhardt
` (9 preceding siblings ...)
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 ` Andreas Rheinhardt
2024-05-06 17:59 ` Lynne
10 siblings, 1 reply; 19+ messages in thread
From: Andreas Rheinhardt @ 2024-05-06 12:14 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This is more in line with how we initialize DSP functions
and avoids tables of function pointers as well as relocations
for these.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/aac/aacdec_dsp_template.c | 43 ++++++++++++++-------------
libavcodec/aac/aacdec_fixed.c | 4 +--
libavcodec/aac/aacdec_float.c | 4 +--
libavcodec/aac/aacdec_proc_template.c | 11 ++++---
4 files changed, 34 insertions(+), 28 deletions(-)
diff --git a/libavcodec/aac/aacdec_dsp_template.c b/libavcodec/aac/aacdec_dsp_template.c
index 70f0a3cce6..621baef8ca 100644
--- a/libavcodec/aac/aacdec_dsp_template.c
+++ b/libavcodec/aac/aacdec_dsp_template.c
@@ -615,23 +615,26 @@ static void AAC_RENAME(apply_prediction)(AACDecContext *ac, SingleChannelElement
reset_all_predictors(sce->AAC_RENAME(predictor_state));
}
-static const AACDecDSP AAC_RENAME(aac_dsp) = {
- .dequant_scalefactors = &AAC_RENAME(dequant_scalefactors),
- .apply_mid_side_stereo = &AAC_RENAME(apply_mid_side_stereo),
- .apply_intensity_stereo = &AAC_RENAME(apply_intensity_stereo),
- .apply_tns = &AAC_RENAME(apply_tns),
- .apply_ltp = &AAC_RENAME(apply_ltp),
- .update_ltp = &AAC_RENAME(update_ltp),
-
- .apply_prediction = AAC_RENAME(apply_prediction),
-
- .imdct_and_windowing = AAC_RENAME(imdct_and_windowing),
- .imdct_and_windowing_960 = AAC_RENAME(imdct_and_windowing_960),
- .imdct_and_windowing_ld = AAC_RENAME(imdct_and_windowing_ld),
- .imdct_and_windowing_eld = AAC_RENAME(imdct_and_windowing_eld),
-
- .apply_dependent_coupling = AAC_RENAME(apply_dependent_coupling),
- .apply_independent_coupling = AAC_RENAME(apply_independent_coupling),
-
- .clip_output = AAC_RENAME(clip_output),
-};
+static av_cold void AAC_RENAME(aac_dsp_init)(AACDecDSP *aac_dsp)
+{
+#define SET(member) aac_dsp->member = AAC_RENAME(member)
+ SET(dequant_scalefactors);
+ SET(apply_mid_side_stereo);
+ SET(apply_intensity_stereo);
+ SET(apply_tns);
+ SET(apply_ltp);
+ SET(update_ltp);
+
+ SET(apply_prediction);
+
+ SET(imdct_and_windowing);
+ SET(imdct_and_windowing_960);
+ SET(imdct_and_windowing_ld);
+ SET(imdct_and_windowing_eld);
+
+ SET(apply_dependent_coupling);
+ SET(apply_independent_coupling);
+
+ SET(clip_output);
+#undef SET
+}
diff --git a/libavcodec/aac/aacdec_fixed.c b/libavcodec/aac/aacdec_fixed.c
index 79d35e05fb..de90880884 100644
--- a/libavcodec/aac/aacdec_fixed.c
+++ b/libavcodec/aac/aacdec_fixed.c
@@ -90,8 +90,8 @@ av_cold int ff_aac_decode_init_fixed(AVCodecContext *avctx)
ac->is_fixed = 1;
avctx->sample_fmt = AV_SAMPLE_FMT_S32P;
- ac->dsp = aac_dsp_fixed;
- ac->proc = aac_proc_fixed;
+ aac_dsp_init_fixed(&ac->dsp);
+ aac_proc_init_fixed(&ac->proc);
ac->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & AV_CODEC_FLAG_BITEXACT);
if (!ac->fdsp)
diff --git a/libavcodec/aac/aacdec_float.c b/libavcodec/aac/aacdec_float.c
index d48a21eef2..885d824fa7 100644
--- a/libavcodec/aac/aacdec_float.c
+++ b/libavcodec/aac/aacdec_float.c
@@ -160,8 +160,8 @@ av_cold int ff_aac_decode_init_float(AVCodecContext *avctx)
ac->is_fixed = 0;
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
- ac->dsp = aac_dsp;
- ac->proc = aac_proc;
+ aac_dsp_init(&ac->dsp);
+ aac_proc_init(&ac->proc);
ac->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
if (!ac->fdsp)
diff --git a/libavcodec/aac/aacdec_proc_template.c b/libavcodec/aac/aacdec_proc_template.c
index 1ffea2f93b..fecf228b3b 100644
--- a/libavcodec/aac/aacdec_proc_template.c
+++ b/libavcodec/aac/aacdec_proc_template.c
@@ -433,7 +433,10 @@ static int AAC_RENAME(decode_cce)(AACDecContext *ac, GetBitContext *gb, ChannelE
return 0;
}
-static const AACDecProc AAC_RENAME(aac_proc) = {
- .decode_spectrum_and_dequant = AAC_RENAME(decode_spectrum_and_dequant),
- .decode_cce = AAC_RENAME(decode_cce),
-};
+static av_cold void AAC_RENAME(aac_proc_init)(AACDecProc *aac_proc)
+{
+#define SET(member) aac_proc->member = AAC_RENAME(member)
+ SET(decode_spectrum_and_dequant);
+ SET(decode_cce);
+#undef SET
+}
--
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".
^ permalink raw reply [flat|nested] 19+ messages in thread
* [FFmpeg-devel] [PATCH v2 3/12] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled
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 ` Andreas Rheinhardt
2024-05-06 17:53 ` [FFmpeg-devel] [PATCH 3/3] " Lynne
1 sibling, 0 replies; 19+ messages in thread
From: Andreas Rheinhardt @ 2024-05-06 14:03 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
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>
---
Now also avoiding the casts in ff_aac_sbr_apply().
libavcodec/aac/aacdec.c | 63 +++++++++++++++++++++--------------------
1 file changed, 32 insertions(+), 31 deletions(-)
diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index c6b93e33a2..4f2a634de7 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_EXT(is_fixed, fixed, float) \
+ ((is_fixed) ? (fixed) : (float))
+#elif CONFIG_AAC_DECODER
+#define IS_FIXED(is_fixed) 0
+#define FIXED_OR_FLOAT_EXT(is_fixed, fixed, float) (float)
+#else
+#define IS_FIXED(is_fixed) 1
+#define FIXED_OR_FLOAT_EXT(is_fixed, fixed, float) (fixed)
+#endif
+#define FIXED_OR_FLOAT(is_fixed, func_or_obj) \
+ FIXED_OR_FLOAT_EXT((is_fixed), RENAME_FIXED(func_or_obj), func_or_obj)
+
/*
* supported tools
*
@@ -150,11 +164,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 = 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 +181,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 +1129,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 +1160,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 +1194,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 +1321,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 +1632,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 +1983,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);
-
+ 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 +2092,13 @@ 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_EXT(ac->is_fixed,
+ ff_aac_sbr_apply_fixed(ac, che, type,
+ che->ch[0].output_fixed,
+ che->ch[1].output_fixed),
+ ff_aac_sbr_apply(ac, che, type,
+ che->ch[0].output,
+ che->ch[1].output));
}
}
if (type <= TYPE_CCE)
--
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".
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [FFmpeg-devel] [PATCH 3/3] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled
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
2024-05-06 19:39 ` Andreas Rheinhardt
1 sibling, 1 reply; 19+ messages in thread
From: Lynne @ 2024-05-06 17:53 UTC (permalink / raw)
To: FFmpeg development discussions and patches
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".
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/3] avcodec/aacsbr: Fix type mismatch
2024-05-06 9:30 ` [FFmpeg-devel] [PATCH 2/3] avcodec/aacsbr: Fix type mismatch Andreas Rheinhardt
@ 2024-05-06 17:54 ` Lynne
0 siblings, 0 replies; 19+ messages in thread
From: Lynne @ 2024-05-06 17:54 UTC (permalink / raw)
To: FFmpeg development discussions and patches
May 6, 2024, 11:31 by andreas.rheinhardt@outlook.com:
> ff_aac_sbr_apply() and ff_aac_sbr_apply_fixed() still used
> pointers to INTFLOAT which is float or int depending upon
> whether USE_FIXED is set or not; in particular, according
> to these declarations both functions have the same type.
> But that is wrong and given that aacdec.c sets USE_FIXED,
> it sees the wrong type for ff_aac_sbr_apply().
> Fix this by avoiding INTFLOAT in aacsbr.h (which also means
> that aac_defines.h need not be included there any more).
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/aac/aacdec.c | 1 +
> libavcodec/aacsbr.h | 5 ++---
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
> index 72f2d7e7ba..c6b93e33a2 100644
> --- a/libavcodec/aac/aacdec.c
> +++ b/libavcodec/aac/aacdec.c
> @@ -42,6 +42,7 @@
> #include "aacdec_tab.h"
>
> #include "libavcodec/aac.h"
> +#include "libavcodec/aac_defines.h"
> #include "libavcodec/aacsbr.h"
> #include "libavcodec/aactab.h"
> #include "libavcodec/adts_header.h"
> diff --git a/libavcodec/aacsbr.h b/libavcodec/aacsbr.h
> index cd030aa801..656ef5258e 100644
> --- a/libavcodec/aacsbr.h
> +++ b/libavcodec/aacsbr.h
> @@ -31,7 +31,6 @@
>
> #include "get_bits.h"
> #include "aac/aacdec.h"
> -#include "aac_defines.h"
>
> #include "libavutil/attributes_internal.h"
>
> @@ -91,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, INTFLOAT* L, INTFLOAT* R);
> + int id_aac, float *L, float *R);
> void ff_aac_sbr_apply_fixed(AACDecContext *ac, ChannelElement *che,
> - int id_aac, INTFLOAT* L, INTFLOAT* R);
> + int id_aac, int *L, int *R);
>
Patch 1 and 2 look good to me
_______________________________________________
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".
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [FFmpeg-devel] [PATCH 12/12] avcodec/aac/aacdec_(fixed|float): Set AACDecDSP, AACDecProc directly
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
0 siblings, 0 replies; 19+ messages in thread
From: Lynne @ 2024-05-06 17:59 UTC (permalink / raw)
To: FFmpeg development discussions and patches
May 6, 2024, 14:16 by andreas.rheinhardt@outlook.com:
> This is more in line with how we initialize DSP functions
> and avoids tables of function pointers as well as relocations
> for these.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/aac/aacdec_dsp_template.c | 43 ++++++++++++++-------------
> libavcodec/aac/aacdec_fixed.c | 4 +--
> libavcodec/aac/aacdec_float.c | 4 +--
> libavcodec/aac/aacdec_proc_template.c | 11 ++++---
> 4 files changed, 34 insertions(+), 28 deletions(-)
>
Nice
Patch 4 to 12 LGTM
_______________________________________________
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".
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [FFmpeg-devel] [PATCH 3/3] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled
2024-05-06 17:53 ` [FFmpeg-devel] [PATCH 3/3] " Lynne
@ 2024-05-06 19:39 ` Andreas Rheinhardt
2024-05-06 20:00 ` Lynne
0 siblings, 1 reply; 19+ messages in thread
From: Andreas Rheinhardt @ 2024-05-06 19:39 UTC (permalink / raw)
To: ffmpeg-devel
Lynne:
> 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?
If you don't like the way function arguments are given to the macro,
then you can take a look at v2. It avoids this (except for the one
special case where the current code uses casts...).
And we should actually not rely on DCE. It is not mandated by ISO C.
- Andreas
_______________________________________________
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".
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [FFmpeg-devel] [PATCH 3/3] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled
2024-05-06 19:39 ` Andreas Rheinhardt
@ 2024-05-06 20:00 ` Lynne
2024-05-06 20:08 ` Andreas Rheinhardt
0 siblings, 1 reply; 19+ messages in thread
From: Lynne @ 2024-05-06 20:00 UTC (permalink / raw)
To: FFmpeg development discussions and patches
May 6, 2024, 21:39 by andreas.rheinhardt@outlook.com:
> Lynne:
>
>> 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?
>>
>
> If you don't like the way function arguments are given to the macro,
> then you can take a look at v2. It avoids this (except for the one
> special case where the current code uses casts...).
>
I'm still not a fan of adding as many lines of macros to deal with it
when that would be basically the same amount of lines as ifdefs.
> And we should actually not rely on DCE. It is not mandated by ISO C.
>
As long as there's no effort done to reduce it, I don't think
it will be a problem to introduce more of it. Its everywhere so
much that adding more doesn't increase the work significantly.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [FFmpeg-devel] [PATCH 3/3] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled
2024-05-06 20:00 ` Lynne
@ 2024-05-06 20:08 ` Andreas Rheinhardt
0 siblings, 0 replies; 19+ messages in thread
From: Andreas Rheinhardt @ 2024-05-06 20:08 UTC (permalink / raw)
To: ffmpeg-devel
Lynne:
> May 6, 2024, 21:39 by andreas.rheinhardt@outlook.com:
>
>> Lynne:
>>
>>> 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?
>>>
>>
>> If you don't like the way function arguments are given to the macro,
>> then you can take a look at v2. It avoids this (except for the one
>> special case where the current code uses casts...).
>>
>
> I'm still not a fan of adding as many lines of macros to deal with it
> when that would be basically the same amount of lines as ifdefs.
>
The same amount of lines as ifdefs? V1 adds as many lines as it removes,
v2 adds one line. Fixing this via ifdefs (or even ordinary CONFIG checks
with dce) will certainly amount to more.
>
>> And we should actually not rely on DCE. It is not mandated by ISO C.
>>
>
> As long as there's no effort done to reduce it, I don't think
> it will be a problem to introduce more of it. Its everywhere so
> much that adding more doesn't increase the work significantly.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2024-05-06 20:09 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [FFmpeg-devel] [PATCH 3/3] " Lynne
2024-05-06 19:39 ` 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
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