[FFmpeg-cvslog] aacdec: reuse TNS and LTP tables between fixed and float decoders

Lynne git at videolan.org
Tue Apr 23 09:58:58 EEST 2024


ffmpeg | branch: master | Lynne <dev at lynne.ee> | Sat Mar 16 05:55:13 2024 +0100| [905fdb06010e554262fca3c12b362bb69a11de85] | committer: Lynne

aacdec: reuse TNS and LTP tables between fixed and float decoders

The fixed decoder derives the values from floats anyway.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=905fdb06010e554262fca3c12b362bb69a11de85
---

 libavcodec/aacdec_fixed.c    | 50 --------------------------------------------
 libavcodec/aacdec_template.c | 14 ++++++++-----
 2 files changed, 9 insertions(+), 55 deletions(-)

diff --git a/libavcodec/aacdec_fixed.c b/libavcodec/aacdec_fixed.c
index 880c18b0f8..91ec616644 100644
--- a/libavcodec/aacdec_fixed.c
+++ b/libavcodec/aacdec_fixed.c
@@ -79,56 +79,6 @@
 #include <math.h>
 #include <string.h>
 
-DECLARE_ALIGNED(32, int, AAC_RENAME2(aac_kbd_long_1024))[1024];
-DECLARE_ALIGNED(32, int, AAC_RENAME2(aac_kbd_short_128))[128];
-DECLARE_ALIGNED(32, int, AAC_RENAME2(aac_kbd_long_960))[960];
-DECLARE_ALIGNED(32, 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 const int exp2tab[4] = { Q31(1.0000000000/2), Q31(1.1892071150/2), Q31(1.4142135624/2), Q31(1.6817928305/2) };  // 2^0, 2^0.25, 2^0.5, 2^0.75
-
 #include "aacdec_template.c"
 
 const FFCodec ff_aac_fixed_decoder = {
diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 1bc36809eb..30ec914520 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -1218,13 +1218,17 @@ static int decode_prediction(AACDecContext *ac, IndividualChannelStream *ics,
 /**
  * Decode Long Term Prediction data; reference: table 4.xx.
  */
-static void decode_ltp(LongTermPrediction *ltp,
+static void decode_ltp(AACDecContext *ac, LongTermPrediction *ltp,
                        GetBitContext *gb, uint8_t max_sfb)
 {
     int sfb;
 
     ltp->lag  = get_bits(gb, 11);
-    ltp->AAC_RENAME(coef) = AAC_RENAME2(ltp_coef)[get_bits(gb, 3)];
+    if (ac->is_fixed)
+        ltp->coef_fixed = Q30(ff_ltp_coef[get_bits(gb, 3)]);
+    else
+        ltp->coef = ff_ltp_coef[get_bits(gb, 3)];
+
     for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++)
         ltp->used[sfb] = get_bits1(gb);
 }
@@ -1331,7 +1335,7 @@ static int decode_ics_info(AACDecContext *ac, IndividualChannelStream *ics,
                     goto fail;
                 }
                 if ((ics->ltp.present = get_bits(gb, 1)))
-                    decode_ltp(&ics->ltp, gb, ics->max_sfb);
+                    decode_ltp(ac, &ics->ltp, gb, ics->max_sfb);
             }
         }
     }
@@ -1531,7 +1535,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->AAC_RENAME(coef)[w][filt][i] = AAC_RENAME2(tns_tmp2_map)[tmp2_idx][get_bits(gb, coef_len)];
+                        tns->AAC_RENAME(coef)[w][filt][i] = Q31(ff_tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)]);
                 }
             }
         }
@@ -1704,7 +1708,7 @@ static int decode_cpe(AACDecContext *ac, GetBitContext *gb, ChannelElement *cpe)
         if (cpe->ch[1].ics.predictor_present &&
             (ac->oc[1].m4ac.object_type != AOT_AAC_MAIN))
             if ((cpe->ch[1].ics.ltp.present = get_bits(gb, 1)))
-                decode_ltp(&cpe->ch[1].ics.ltp, gb, cpe->ch[1].ics.max_sfb);
+                decode_ltp(ac, &cpe->ch[1].ics.ltp, gb, cpe->ch[1].ics.max_sfb);
         ms_present = get_bits(gb, 2);
         if (ms_present == 3) {
             av_log(ac->avctx, AV_LOG_ERROR, "ms_present = 3 is reserved.\n");



More information about the ffmpeg-cvslog mailing list