History

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

The fixed decoder derives the values from floats anyway.

Lynne committed 2 years ago

Commit 905fdb01 parent 49e7be12 files · +9 −55Browse files

Showing the changes to libavcodec (2 of 2 files). Show all

Unified · Split

2 files
  1. libavcodec/aacdec_fixed.c +0 −50
  2. libavcodec/aacdec_template.c +9 −5
libavcodec/aacdec_fixed.c+0−50
@@ -79,56 +79,6 @@ · 78 unmodified lines
7979 #include <math.h>
8080 #include <string.h>
8181
82−DECLARE_ALIGNED(32, int, AAC_RENAME2(aac_kbd_long_1024))[1024];
83−DECLARE_ALIGNED(32, int, AAC_RENAME2(aac_kbd_short_128))[128];
84−DECLARE_ALIGNED(32, int, AAC_RENAME2(aac_kbd_long_960))[960];
85−DECLARE_ALIGNED(32, int, AAC_RENAME2(aac_kbd_short_120))[120];
86−
87−/* @name ltp_coef
88− * Table of the LTP coefficients
89− */
90−static const int ltp_coef_fixed[8] = {
91− Q30(0.570829), Q30(0.696616), Q30(0.813004), Q30(0.911304),
92− Q30(0.984900), Q30(1.067894), Q30(1.194601), Q30(1.369533),
93−};
94−
95−/* @name tns_tmp2_map
96− * Tables of the tmp2[] arrays of LPC coefficients used for TNS.
97− * The suffix _M_N[] indicate the values of coef_compress and coef_res
98− * respectively.
99− * @{
100− */
101−static const int tns_tmp2_map_1_3[4] = {
102− Q31(0.00000000), Q31(-0.43388373), Q31(0.64278758), Q31(0.34202015),
103−};
104−
105−static const int tns_tmp2_map_0_3[8] = {
106− Q31(0.00000000), Q31(-0.43388373), Q31(-0.78183150), Q31(-0.97492790),
107− Q31(0.98480773), Q31( 0.86602539), Q31( 0.64278758), Q31( 0.34202015),
108−};
109−
110−static const int tns_tmp2_map_1_4[8] = {
111− Q31(0.00000000), Q31(-0.20791170), Q31(-0.40673664), Q31(-0.58778524),
112− Q31(0.67369562), Q31( 0.52643216), Q31( 0.36124167), Q31( 0.18374951),
113−};
114−
115−static const int tns_tmp2_map_0_4[16] = {
116− Q31( 0.00000000), Q31(-0.20791170), Q31(-0.40673664), Q31(-0.58778524),
117− Q31(-0.74314481), Q31(-0.86602539), Q31(-0.95105654), Q31(-0.99452192),
118− Q31( 0.99573416), Q31( 0.96182561), Q31( 0.89516330), Q31( 0.79801720),
119− Q31( 0.67369562), Q31( 0.52643216), Q31( 0.36124167), Q31( 0.18374951),
120−};
121−
122−static const int * const tns_tmp2_map_fixed[4] = {
123− tns_tmp2_map_0_3,
124− tns_tmp2_map_0_4,
125− tns_tmp2_map_1_3,
126− tns_tmp2_map_1_4
127−};
128−// @}
129−
130−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
131−
13282 #include "aacdec_template.c"
13383
13484 const FFCodec ff_aac_fixed_decoder = {
libavcodec/aacdec_template.c+9−5
@@ -1218,13 +1218,17 @@ static int decode_prediction(AACDecContext *ac, IndividualChannelStream *ics, · 1217 unmodified lines
12181218 /**
12191219 * Decode Long Term Prediction data; reference: table 4.xx.
12201220 */
1221−static void decode_ltp(LongTermPrediction *ltp,
1221+static void decode_ltp(AACDecContext *ac, LongTermPrediction *ltp,
12221222 GetBitContext *gb, uint8_t max_sfb)
12231223 {
12241224 int sfb;
12251225
12261226 ltp->lag = get_bits(gb, 11);
1227− ltp->AAC_RENAME(coef) = AAC_RENAME2(ltp_coef)[get_bits(gb, 3)];
1227+ if (ac->is_fixed)
1228+ ltp->coef_fixed = Q30(ff_ltp_coef[get_bits(gb, 3)]);
1229+ else
1230+ ltp->coef = ff_ltp_coef[get_bits(gb, 3)];
1231+
12281232 for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++)
12291233 ltp->used[sfb] = get_bits1(gb);
12301234 }
@@ -1331,7 +1335,7 @@ static int decode_ics_info(AACDecContext *ac, IndividualChannelStream *ics, · 100 unmodified lines
13311335 goto fail;
13321336 }
13331337 if ((ics->ltp.present = get_bits(gb, 1)))
1334− decode_ltp(&ics->ltp, gb, ics->max_sfb);
1338+ decode_ltp(ac, &ics->ltp, gb, ics->max_sfb);
13351339 }
13361340 }
13371341 }
@@ -1531,7 +1535,7 @@ static int decode_tns(AACDecContext *ac, TemporalNoiseShaping *tns, · 193 unmodified lines
15311535 tmp2_idx = 2 * coef_compress + coef_res;
15321536
15331537 for (i = 0; i < tns->order[w][filt]; i++)
1534− tns->AAC_RENAME(coef)[w][filt][i] = AAC_RENAME2(tns_tmp2_map)[tmp2_idx][get_bits(gb, coef_len)];
1538+ tns->AAC_RENAME(coef)[w][filt][i] = Q31(ff_tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)]);
15351539 }
15361540 }
15371541 }
@@ -1704,7 +1708,7 @@ static int decode_cpe(AACDecContext *ac, GetBitContext *gb, ChannelElement *cpe) · 166 unmodified lines
17041708 if (cpe->ch[1].ics.predictor_present &&
17051709 (ac->oc[1].m4ac.object_type != AOT_AAC_MAIN))
17061710 if ((cpe->ch[1].ics.ltp.present = get_bits(gb, 1)))
1707− decode_ltp(&cpe->ch[1].ics.ltp, gb, cpe->ch[1].ics.max_sfb);
1711+ decode_ltp(ac, &cpe->ch[1].ics.ltp, gb, cpe->ch[1].ics.max_sfb);
17081712 ms_present = get_bits(gb, 2);
17091713 if (ms_present == 3) {
17101714 av_log(ac->avctx, AV_LOG_ERROR, "ms_present = 3 is reserved.\n");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t