From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 4/4] avcodec/aactab: Deduplicate ltp_coef and tns_tmp2_map tables Date: Fri, 1 Mar 2024 04:08:35 +0100 Message-ID: <AS8P250MB07442A344FB3995DBEFEDACF8F5E2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw) In-Reply-To: <AS8P250MB0744A646E399E368268A93478F5E2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> This will allow to make aac_defines.h decoder-only. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/aacdec_fixed.c | 43 ++++++++++++++++++++++++++++++++++++ libavcodec/aacdec_template.c | 4 ++-- libavcodec/aacenc_ltp.c | 4 ++-- libavcodec/aacenc_tns.c | 2 +- libavcodec/aactab.c | 39 ++++++++++++++++++++++++++++++++ libavcodec/aactab.h | 36 ++---------------------------- 6 files changed, 89 insertions(+), 39 deletions(-) diff --git a/libavcodec/aacdec_fixed.c b/libavcodec/aacdec_fixed.c index 2abe6acb6b..5d5ae34838 100644 --- a/libavcodec/aacdec_fixed.c +++ b/libavcodec/aacdec_fixed.c @@ -89,6 +89,49 @@ DECLARE_ALIGNED(32, static int, AAC_RENAME2(aac_kbd_short_128))[128]; DECLARE_ALIGNED(32, static int, AAC_RENAME2(aac_kbd_long_960))[960]; DECLARE_ALIGNED(32, static int, AAC_RENAME2(aac_kbd_short_120))[120]; +/* @name ltp_coef + * Table of the LTP coefficients + */ +static const int ltp_coef_fixed[8] = { + Q30(0.570829), Q30(0.696616), Q30(0.813004), Q30(0.911304), + Q30(0.984900), Q30(1.067894), Q30(1.194601), Q30(1.369533), +}; + +/* @name tns_tmp2_map + * Tables of the tmp2[] arrays of LPC coefficients used for TNS. + * The suffix _M_N[] indicate the values of coef_compress and coef_res + * respectively. + * @{ + */ +static const int tns_tmp2_map_1_3[4] = { + Q31(0.00000000), Q31(-0.43388373), Q31(0.64278758), Q31(0.34202015), +}; + +static const int tns_tmp2_map_0_3[8] = { + Q31(0.00000000), Q31(-0.43388373), Q31(-0.78183150), Q31(-0.97492790), + Q31(0.98480773), Q31( 0.86602539), Q31( 0.64278758), Q31( 0.34202015), +}; + +static const int tns_tmp2_map_1_4[8] = { + Q31(0.00000000), Q31(-0.20791170), Q31(-0.40673664), Q31(-0.58778524), + Q31(0.67369562), Q31( 0.52643216), Q31( 0.36124167), Q31( 0.18374951), +}; + +static const int tns_tmp2_map_0_4[16] = { + Q31( 0.00000000), Q31(-0.20791170), Q31(-0.40673664), Q31(-0.58778524), + Q31(-0.74314481), Q31(-0.86602539), Q31(-0.95105654), Q31(-0.99452192), + Q31( 0.99573416), Q31( 0.96182561), Q31( 0.89516330), Q31( 0.79801720), + Q31( 0.67369562), Q31( 0.52643216), Q31( 0.36124167), Q31( 0.18374951), +}; + +static const int * const tns_tmp2_map_fixed[4] = { + tns_tmp2_map_0_3, + tns_tmp2_map_0_4, + tns_tmp2_map_1_3, + tns_tmp2_map_1_4 +}; +// @} + static av_always_inline void reset_predict_state(PredictorState *ps) { ps->r0.mant = 0; diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index 6561abb14e..3d96ed6f29 100644 --- a/libavcodec/aacdec_template.c +++ b/libavcodec/aacdec_template.c @@ -1298,7 +1298,7 @@ static void decode_ltp(LongTermPrediction *ltp, int sfb; ltp->lag = get_bits(gb, 11); - ltp->coef = ltp_coef[get_bits(gb, 3)]; + ltp->coef = AAC_RENAME2(ltp_coef)[get_bits(gb, 3)]; for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++) ltp->used[sfb] = get_bits1(gb); } @@ -1611,7 +1611,7 @@ static int decode_tns(AACDecContext *ac, TemporalNoiseShaping *tns, tmp2_idx = 2 * coef_compress + coef_res; for (i = 0; i < tns->order[w][filt]; i++) - tns->coef[w][filt][i] = tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)]; + tns->coef[w][filt][i] = AAC_RENAME2(tns_tmp2_map)[tmp2_idx][get_bits(gb, coef_len)]; } } } diff --git a/libavcodec/aacenc_ltp.c b/libavcodec/aacenc_ltp.c index f3075f0e71..9901891d68 100644 --- a/libavcodec/aacenc_ltp.c +++ b/libavcodec/aacenc_ltp.c @@ -92,8 +92,8 @@ static void get_lag(float *buf, const float *new, LongTermPrediction *ltp) } } ltp->lag = FFMAX(av_clip_uintp2(lag, 11), 0); - ltp->coef_idx = quant_array_idx(max_ratio, ltp_coef, 8); - ltp->coef = ltp_coef[ltp->coef_idx]; + ltp->coef_idx = quant_array_idx(max_ratio, ff_ltp_coef, 8); + ltp->coef = ff_ltp_coef[ltp->coef_idx]; } static void generate_samples(float *buf, LongTermPrediction *ltp) diff --git a/libavcodec/aacenc_tns.c b/libavcodec/aacenc_tns.c index b2418a0236..60888fece7 100644 --- a/libavcodec/aacenc_tns.c +++ b/libavcodec/aacenc_tns.c @@ -148,7 +148,7 @@ static inline void quantize_coefs(double *coef, int *idx, float *lpc, int order, int c_bits) { int i; - const float *quant_arr = tns_tmp2_map[c_bits]; + const float *quant_arr = ff_tns_tmp2_map[c_bits]; for (i = 0; i < order; i++) { idx[i] = quant_array_idx(coef[i], quant_arr, c_bits ? 16 : 8); lpc[i] = quant_arr[idx[i]]; diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c index 63a478f33f..020267f389 100644 --- a/libavcodec/aactab.c +++ b/libavcodec/aactab.c @@ -105,6 +105,45 @@ 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); } + +const float ff_ltp_coef[8] = { + 0.570829, 0.696616, 0.813004, 0.911304, + 0.984900, 1.067894, 1.194601, 1.369533, +}; + +/* @name tns_tmp2_map + * Tables of the tmp2[] arrays of LPC coefficients used for TNS. + * The suffix _M_N[] indicate the values of coef_compress and coef_res + * respectively. + * @{ + */ +static const float tns_tmp2_map_1_3[4] = { + 0.00000000, -0.43388373, 0.64278758, 0.34202015, +}; + +static const float tns_tmp2_map_0_3[8] = { + 0.00000000, -0.43388373, -0.78183150, -0.97492790, + 0.98480773, 0.86602539, 0.64278758, 0.34202015, +}; + +static const float tns_tmp2_map_1_4[8] = { + 0.00000000, -0.20791170, -0.40673664, -0.58778524, + 0.67369562, 0.52643216, 0.36124167, 0.18374951, +}; + +static const float tns_tmp2_map_0_4[16] = { + 0.00000000, -0.20791170, -0.40673664, -0.58778524, + -0.74314481, -0.86602539, -0.95105654, -0.99452192, + 0.99573416, 0.96182561, 0.89516330, 0.79801720, + 0.67369562, 0.52643216, 0.36124167, 0.18374951, +}; + +const float * const ff_tns_tmp2_map[4] = { + tns_tmp2_map_0_3, + tns_tmp2_map_0_4, + tns_tmp2_map_1_3, + tns_tmp2_map_1_4 +}; #endif const uint8_t ff_aac_num_swb_1024[] = { diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h index 81db29a4e4..e1a2d8b9a1 100644 --- a/libavcodec/aactab.h +++ b/libavcodec/aactab.h @@ -31,7 +31,6 @@ #define AVCODEC_AACTAB_H #include "libavutil/mem_internal.h" -#include "aac_defines.h" #include <stdint.h> @@ -45,44 +44,13 @@ extern float ff_aac_pow34sf_tab[428]; /* @name ltp_coef * Table of the LTP coefficients */ -static const INTFLOAT ltp_coef[8] = { - Q30(0.570829), Q30(0.696616), Q30(0.813004), Q30(0.911304), - Q30(0.984900), Q30(1.067894), Q30(1.194601), Q30(1.369533), -}; +extern const float ff_ltp_coef[8]; /* @name tns_tmp2_map * Tables of the tmp2[] arrays of LPC coefficients used for TNS. - * The suffix _M_N[] indicate the values of coef_compress and coef_res - * respectively. * @{ */ -static const INTFLOAT tns_tmp2_map_1_3[4] = { - Q31(0.00000000), Q31(-0.43388373), Q31(0.64278758), Q31(0.34202015), -}; - -static const INTFLOAT tns_tmp2_map_0_3[8] = { - Q31(0.00000000), Q31(-0.43388373), Q31(-0.78183150), Q31(-0.97492790), - Q31(0.98480773), Q31( 0.86602539), Q31( 0.64278758), Q31( 0.34202015), -}; - -static const INTFLOAT tns_tmp2_map_1_4[8] = { - Q31(0.00000000), Q31(-0.20791170), Q31(-0.40673664), Q31(-0.58778524), - Q31(0.67369562), Q31( 0.52643216), Q31( 0.36124167), Q31( 0.18374951), -}; - -static const INTFLOAT tns_tmp2_map_0_4[16] = { - Q31( 0.00000000), Q31(-0.20791170), Q31(-0.40673664), Q31(-0.58778524), - Q31(-0.74314481), Q31(-0.86602539), Q31(-0.95105654), Q31(-0.99452192), - Q31( 0.99573416), Q31( 0.96182561), Q31( 0.89516330), Q31( 0.79801720), - Q31( 0.67369562), Q31( 0.52643216), Q31( 0.36124167), Q31( 0.18374951), -}; - -static const INTFLOAT * const tns_tmp2_map[4] = { - tns_tmp2_map_0_3, - tns_tmp2_map_0_4, - tns_tmp2_map_1_3, - tns_tmp2_map_1_4 -}; +extern const float *const ff_tns_tmp2_map[4]; // @} /* @name window coefficients -- 2.40.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2024-03-01 3:07 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-01 3:04 [FFmpeg-devel] [PATCH 1/4] avcodec/lpc: Don't use AAC defines directly Andreas Rheinhardt 2024-03-01 3:08 ` [FFmpeg-devel] [PATCH 2/4] avcodec/lpc: Split inline functions into a header of their own Andreas Rheinhardt 2024-03-01 3:08 ` [FFmpeg-devel] [PATCH 3/4] avcodec/aacdec: Move buffer to reduce padding Andreas Rheinhardt 2024-03-01 3:08 ` Andreas Rheinhardt [this message] 2024-03-03 18:45 ` [FFmpeg-devel] [PATCH 1/4] avcodec/lpc: Don't use AAC defines directly Andreas Rheinhardt 2024-03-03 21:44 ` 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=AS8P250MB07442A344FB3995DBEFEDACF8F5E2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \ --to=andreas.rheinhardt@outlook.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git