History

avcodec/aacdec_common: Combine huffman tabs

This allows to avoid the relocations inherent in a table to individual tables; it also reduces padding.

Andreas Rheinhardt committed 3 years ago

Commit 1aca4e71 parent 2c131f11 file · +10 −49Browse files

Unified · Split

libavcodec/aacdec_common.c+10−49
@@ -128,8 +128,8 @@ const VLCElem *ff_vlc_spectral[11]; · 127 unmodified lines
128 128
129/// Huffman tables for SBR129/// Huffman tables for SBR
130 130
131static const uint8_t sbr_huffman_tab[][2] = {
131 /* t_huffman_env_1_5dB - 121 entries */132 /* t_huffman_env_1_5dB - 121 entries */
132static const uint8_t t_huffman_env_1_5dB_tab[][2] = {
133 { 60, 2 }, { 59, 2 }, { 61, 3 }, { 58, 3 }, { 62, 4 },133 { 60, 2 }, { 59, 2 }, { 61, 3 }, { 58, 3 }, { 62, 4 },
134 { 57, 4 }, { 63, 5 }, { 56, 5 }, { 64, 6 }, { 55, 6 },134 { 57, 4 }, { 63, 5 }, { 56, 5 }, { 64, 6 }, { 55, 6 },
135 { 65, 7 }, { 54, 7 }, { 66, 8 }, { 53, 8 }, { 67, 9 },135 { 65, 7 }, { 54, 7 }, { 66, 8 }, { 53, 8 }, { 67, 9 },
@@ -155,10 +155,7 @@ static const uint8_t t_huffman_env_1_5dB_tab[][2] = { · 19 unmodified lines
155 { 110, 19 }, { 111, 19 }, { 112, 19 }, { 113, 19 }, { 114, 19 },155 { 110, 19 }, { 111, 19 }, { 112, 19 }, { 113, 19 }, { 114, 19 },
156 { 115, 19 }, { 116, 19 }, { 117, 19 }, { 118, 19 }, { 119, 19 },156 { 115, 19 }, { 116, 19 }, { 117, 19 }, { 118, 19 }, { 119, 19 },
157 { 120, 19 },157 { 120, 19 },
158};
159
160 /* f_huffman_env_1_5dB - 121 entries */158 /* f_huffman_env_1_5dB - 121 entries */
161static const uint8_t f_huffman_env_1_5dB_tab[][2] = {
162 { 60, 2 }, { 59, 2 }, { 61, 3 }, { 58, 3 }, { 57, 4 },159 { 60, 2 }, { 59, 2 }, { 61, 3 }, { 58, 3 }, { 57, 4 },
163 { 62, 4 }, { 56, 5 }, { 63, 5 }, { 55, 6 }, { 64, 6 },160 { 62, 4 }, { 56, 5 }, { 63, 5 }, { 55, 6 }, { 64, 6 },
164 { 54, 7 }, { 65, 8 }, { 53, 8 }, { 66, 8 }, { 52, 9 },161 { 54, 7 }, { 65, 8 }, { 53, 8 }, { 66, 8 }, { 52, 9 },
@@ -184,10 +181,7 @@ static const uint8_t f_huffman_env_1_5dB_tab[][2] = { · 19 unmodified lines
184 { 110, 20 }, { 111, 20 }, { 112, 20 }, { 113, 20 }, { 114, 20 },181 { 110, 20 }, { 111, 20 }, { 112, 20 }, { 113, 20 }, { 114, 20 },
185 { 115, 20 }, { 116, 20 }, { 117, 20 }, { 118, 20 }, { 119, 20 },182 { 115, 20 }, { 116, 20 }, { 117, 20 }, { 118, 20 }, { 119, 20 },
186 { 120, 20 },183 { 120, 20 },
187};
188
189 /* t_huffman_env_bal_1_5dB - 49 entries */184 /* t_huffman_env_bal_1_5dB - 49 entries */
190static const uint8_t t_huffman_env_bal_1_5dB_tab[][2] = {
191 { 24, 1 }, { 25, 2 }, { 23, 3 }, { 26, 4 }, { 22, 5 },185 { 24, 1 }, { 25, 2 }, { 23, 3 }, { 26, 4 }, { 22, 5 },
192 { 27, 6 }, { 21, 7 }, { 28, 8 }, { 20, 9 }, { 19, 11 },186 { 27, 6 }, { 21, 7 }, { 28, 8 }, { 20, 9 }, { 19, 11 },
193 { 29, 11 }, { 18, 12 }, { 30, 12 }, { 31, 15 }, { 17, 16 },187 { 29, 11 }, { 18, 12 }, { 30, 12 }, { 31, 15 }, { 17, 16 },
@@ -198,10 +192,7 @@ static const uint8_t t_huffman_env_bal_1_5dB_tab[][2] = { · 4 unmodified lines
198 { 35, 16 }, { 36, 16 }, { 37, 16 }, { 38, 16 }, { 39, 17 },192 { 35, 16 }, { 36, 16 }, { 37, 16 }, { 38, 16 }, { 39, 17 },
199 { 40, 17 }, { 41, 17 }, { 42, 17 }, { 43, 17 }, { 44, 17 },193 { 40, 17 }, { 41, 17 }, { 42, 17 }, { 43, 17 }, { 44, 17 },
200 { 45, 17 }, { 46, 17 }, { 47, 17 }, { 48, 17 },194 { 45, 17 }, { 46, 17 }, { 47, 17 }, { 48, 17 },
201};
202
203 /* f_huffman_env_bal_1_5dB - 49 entries */195 /* f_huffman_env_bal_1_5dB - 49 entries */
204static const uint8_t f_huffman_env_bal_1_5dB_tab[][2] = {
205 { 24, 1 }, { 23, 2 }, { 25, 3 }, { 22, 4 }, { 26, 5 },196 { 24, 1 }, { 23, 2 }, { 25, 3 }, { 22, 4 }, { 26, 5 },
206 { 27, 6 }, { 21, 7 }, { 20, 8 }, { 28, 9 }, { 19, 11 },197 { 27, 6 }, { 21, 7 }, { 20, 8 }, { 28, 9 }, { 19, 11 },
207 { 29, 11 }, { 18, 11 }, { 30, 12 }, { 17, 14 }, { 31, 15 },198 { 29, 11 }, { 18, 11 }, { 30, 12 }, { 17, 14 }, { 31, 15 },
@@ -212,10 +203,7 @@ static const uint8_t f_huffman_env_bal_1_5dB_tab[][2] = { · 4 unmodified lines
212 { 35, 18 }, { 36, 18 }, { 37, 18 }, { 38, 18 }, { 39, 18 },203 { 35, 18 }, { 36, 18 }, { 37, 18 }, { 38, 18 }, { 39, 18 },
213 { 40, 18 }, { 41, 18 }, { 42, 18 }, { 43, 18 }, { 44, 18 },204 { 40, 18 }, { 41, 18 }, { 42, 18 }, { 43, 18 }, { 44, 18 },
214 { 45, 18 }, { 46, 18 }, { 47, 19 }, { 48, 19 },205 { 45, 18 }, { 46, 18 }, { 47, 19 }, { 48, 19 },
215};
216
217 /* t_huffman_env_3_0dB - 63 entries */206 /* t_huffman_env_3_0dB - 63 entries */
218static const uint8_t t_huffman_env_3_0dB_tab[][2] = {
219 { 31, 1 }, { 30, 2 }, { 32, 3 }, { 29, 4 }, { 33, 5 },207 { 31, 1 }, { 30, 2 }, { 32, 3 }, { 29, 4 }, { 33, 5 },
220 { 28, 6 }, { 34, 7 }, { 27, 8 }, { 35, 9 }, { 26, 11 },208 { 28, 6 }, { 34, 7 }, { 27, 8 }, { 35, 9 }, { 26, 11 },
221 { 36, 11 }, { 25, 12 }, { 24, 13 }, { 37, 13 }, { 23, 14 },209 { 36, 11 }, { 25, 12 }, { 24, 13 }, { 37, 13 }, { 23, 14 },
@@ -229,10 +217,7 @@ static const uint8_t t_huffman_env_3_0dB_tab[][2] = { · 7 unmodified lines
229 { 50, 19 }, { 51, 19 }, { 52, 19 }, { 53, 19 }, { 54, 19 },217 { 50, 19 }, { 51, 19 }, { 52, 19 }, { 53, 19 }, { 54, 19 },
230 { 55, 19 }, { 56, 19 }, { 57, 19 }, { 58, 19 }, { 59, 19 },218 { 55, 19 }, { 56, 19 }, { 57, 19 }, { 58, 19 }, { 59, 19 },
231 { 60, 19 }, { 61, 19 }, { 62, 19 },219 { 60, 19 }, { 61, 19 }, { 62, 19 },
232};
233
234 /* f_huffman_env_3_0dB - 63 entries */220 /* f_huffman_env_3_0dB - 63 entries */
235static const uint8_t f_huffman_env_3_0dB_tab[][2] = {
236 { 31, 1 }, { 30, 2 }, { 32, 3 }, { 29, 4 }, { 33, 5 },221 { 31, 1 }, { 30, 2 }, { 32, 3 }, { 29, 4 }, { 33, 5 },
237 { 28, 6 }, { 34, 8 }, { 27, 8 }, { 35, 9 }, { 26, 9 },222 { 28, 6 }, { 34, 8 }, { 27, 8 }, { 35, 9 }, { 26, 9 },
238 { 36, 10 }, { 25, 10 }, { 37, 11 }, { 24, 11 }, { 38, 12 },223 { 36, 10 }, { 25, 10 }, { 37, 11 }, { 24, 11 }, { 38, 12 },
@@ -246,28 +231,19 @@ static const uint8_t f_huffman_env_3_0dB_tab[][2] = { · 7 unmodified lines
246 { 3, 20 }, { 4, 20 }, { 5, 20 }, { 6, 20 }, { 14, 20 },231 { 3, 20 }, { 4, 20 }, { 5, 20 }, { 6, 20 }, { 14, 20 },
247 { 50, 20 }, { 54, 20 }, { 57, 20 }, { 58, 20 }, { 59, 20 },232 { 50, 20 }, { 54, 20 }, { 57, 20 }, { 58, 20 }, { 59, 20 },
248 { 60, 20 }, { 61, 20 }, { 62, 20 },233 { 60, 20 }, { 61, 20 }, { 62, 20 },
249};
250
251 /* t_huffman_env_bal_3_0dB - 25 entries */234 /* t_huffman_env_bal_3_0dB - 25 entries */
252static const uint8_t t_huffman_env_bal_3_0dB_tab[][2] = {
253 { 12, 1 }, { 13, 2 }, { 11, 3 }, { 10, 4 }, { 14, 5 },235 { 12, 1 }, { 13, 2 }, { 11, 3 }, { 10, 4 }, { 14, 5 },
254 { 15, 6 }, { 9, 7 }, { 8, 8 }, { 16, 9 }, { 7, 12 },236 { 15, 6 }, { 9, 7 }, { 8, 8 }, { 16, 9 }, { 7, 12 },
255 { 0, 13 }, { 1, 13 }, { 2, 13 }, { 3, 13 }, { 4, 13 },237 { 0, 13 }, { 1, 13 }, { 2, 13 }, { 3, 13 }, { 4, 13 },
256 { 5, 13 }, { 6, 13 }, { 17, 13 }, { 18, 13 }, { 19, 13 },238 { 5, 13 }, { 6, 13 }, { 17, 13 }, { 18, 13 }, { 19, 13 },
257 { 20, 13 }, { 21, 13 }, { 22, 13 }, { 23, 14 }, { 24, 14 },239 { 20, 13 }, { 21, 13 }, { 22, 13 }, { 23, 14 }, { 24, 14 },
258};
259
260 /* f_huffman_env_bal_3_0dB - 25 entries */240 /* f_huffman_env_bal_3_0dB - 25 entries */
261static const uint8_t f_huffman_env_bal_3_0dB_tab[][2] = {
262 { 12, 1 }, { 11, 2 }, { 13, 3 }, { 10, 4 }, { 14, 5 },241 { 12, 1 }, { 11, 2 }, { 13, 3 }, { 10, 4 }, { 14, 5 },
263 { 15, 6 }, { 9, 7 }, { 8, 8 }, { 16, 9 }, { 7, 11 },242 { 15, 6 }, { 9, 7 }, { 8, 8 }, { 16, 9 }, { 7, 11 },
264 { 17, 12 }, { 18, 13 }, { 0, 13 }, { 1, 13 }, { 2, 13 },243 { 17, 12 }, { 18, 13 }, { 0, 13 }, { 1, 13 }, { 2, 13 },
265 { 3, 13 }, { 4, 13 }, { 5, 14 }, { 6, 14 }, { 19, 14 },244 { 3, 13 }, { 4, 13 }, { 5, 14 }, { 6, 14 }, { 19, 14 },
266 { 20, 14 }, { 21, 14 }, { 22, 14 }, { 23, 14 }, { 24, 14 },245 { 20, 14 }, { 21, 14 }, { 22, 14 }, { 23, 14 }, { 24, 14 },
267};
268
269 /* t_huffman_noise_3_0dB - 63 entries */246 /* t_huffman_noise_3_0dB - 63 entries */
270static const uint8_t t_huffman_noise_3_0dB_tab[][2] = {
271 { 31, 1 }, { 32, 2 }, { 30, 3 }, { 29, 4 }, { 33, 5 },247 { 31, 1 }, { 32, 2 }, { 30, 3 }, { 29, 4 }, { 33, 5 },
272 { 28, 6 }, { 34, 8 }, { 27, 8 }, { 35, 10 }, { 26, 11 },248 { 28, 6 }, { 34, 8 }, { 27, 8 }, { 35, 10 }, { 26, 11 },
273 { 36, 13 }, { 42, 13 }, { 0, 13 }, { 1, 13 }, { 2, 13 },249 { 36, 13 }, { 42, 13 }, { 0, 13 }, { 1, 13 }, { 2, 13 },
@@ -281,10 +257,7 @@ static const uint8_t t_huffman_noise_3_0dB_tab[][2] = { · 7 unmodified lines
281 { 50, 13 }, { 51, 13 }, { 52, 13 }, { 53, 13 }, { 54, 13 },257 { 50, 13 }, { 51, 13 }, { 52, 13 }, { 53, 13 }, { 54, 13 },
282 { 55, 13 }, { 56, 13 }, { 57, 13 }, { 58, 13 }, { 59, 13 },258 { 55, 13 }, { 56, 13 }, { 57, 13 }, { 58, 13 }, { 59, 13 },
283 { 60, 13 }, { 61, 14 }, { 62, 14 },259 { 60, 13 }, { 61, 14 }, { 62, 14 },
284};
285
286 /* t_huffman_noise_bal_3_0dB - 25 entries */260 /* t_huffman_noise_bal_3_0dB - 25 entries */
287static const uint8_t t_huffman_noise_bal_3_0dB_tab[][2] = {
288 { 12, 1 }, { 11, 2 }, { 13, 3 }, { 10, 5 }, { 14, 6 },261 { 12, 1 }, { 11, 2 }, { 13, 3 }, { 10, 5 }, { 14, 6 },
289 { 0, 8 }, { 1, 8 }, { 2, 8 }, { 3, 8 }, { 4, 8 },262 { 0, 8 }, { 1, 8 }, { 2, 8 }, { 3, 8 }, { 4, 8 },
290 { 5, 8 }, { 6, 8 }, { 7, 8 }, { 8, 8 }, { 9, 8 },263 { 5, 8 }, { 6, 8 }, { 7, 8 }, { 8, 8 }, { 9, 8 },
@@ -292,33 +265,20 @@ static const uint8_t t_huffman_noise_bal_3_0dB_tab[][2] = { · 1 unmodified line
292 { 20, 8 }, { 21, 8 }, { 22, 8 }, { 23, 8 }, { 24, 8 },265 { 20, 8 }, { 21, 8 }, { 22, 8 }, { 23, 8 }, { 24, 8 },
293};266};
294 267
268static const uint8_t sbr_huffman_nb_codes[] = {
269 121, 121, 49, 49, 63, 63, 25, 25, 63, 25
270};
271
295const VLCElem *ff_aac_sbr_vlc[10];272const VLCElem *ff_aac_sbr_vlc[10];
296 273
297static av_cold void aacdec_common_init(void)274static av_cold void aacdec_common_init(void)
298{275{
299#define SBR_VLC_ROW(name) \
300 { name ## _tab, FF_ARRAY_ELEMS(name ## _tab) }
301 static const struct {
302 const uint8_t (*sbr_tab)[2];
303 const unsigned int table_size;
304 } sbr_tmp[] = {
305 SBR_VLC_ROW(t_huffman_env_1_5dB),
306 SBR_VLC_ROW(f_huffman_env_1_5dB),
307 SBR_VLC_ROW(t_huffman_env_bal_1_5dB),
308 SBR_VLC_ROW(f_huffman_env_bal_1_5dB),
309 SBR_VLC_ROW(t_huffman_env_3_0dB),
310 SBR_VLC_ROW(f_huffman_env_3_0dB),
311 SBR_VLC_ROW(t_huffman_env_bal_3_0dB),
312 SBR_VLC_ROW(f_huffman_env_bal_3_0dB),
313 SBR_VLC_ROW(t_huffman_noise_3_0dB),
314 SBR_VLC_ROW(t_huffman_noise_bal_3_0dB),
315 };
316
317 static VLCElem vlc_buf[(304 + 270 + 550 + 300 + 328 +276 static VLCElem vlc_buf[(304 + 270 + 550 + 300 + 328 +
318 294 + 306 + 268 + 510 + 366 + 462) +277 294 + 306 + 268 + 510 + 366 + 462) +
319 (1098 + 1092 + 768 + 1026 + 1058 +278 (1098 + 1092 + 768 + 1026 + 1058 +
320 1052 + 544 + 544 + 592 + 512)];279 1052 + 544 + 544 + 592 + 512)];
321 VLCInitState state = VLC_INIT_STATE(vlc_buf);280 VLCInitState state = VLC_INIT_STATE(vlc_buf);
281 const uint8_t (*tab)[2] = sbr_huffman_tab;
322 282
323 for (unsigned i = 0; i < 11; i++) {283 for (unsigned i = 0; i < 11; i++) {
324#define TAB_WRAP_SIZE(name) name[i], sizeof(name[i][0]), sizeof(name[i][0])284#define TAB_WRAP_SIZE(name) name[i], sizeof(name[i][0]), sizeof(name[i][0])
@@ -342,10 +302,11 @@ static av_cold void aacdec_common_init(void) · 17 unmodified lines
342 // SBR VLC table initialization302 // SBR VLC table initialization
343 for (int i = 0; i < FF_ARRAY_ELEMS(ff_aac_sbr_vlc); i++) {303 for (int i = 0; i < FF_ARRAY_ELEMS(ff_aac_sbr_vlc); i++) {
344 ff_aac_sbr_vlc[i] =304 ff_aac_sbr_vlc[i] =
345 ff_vlc_init_tables_from_lengths(&state, 9, sbr_tmp[i].table_size,305 ff_vlc_init_tables_from_lengths(&state, 9, sbr_huffman_nb_codes[i],
346 &sbr_tmp[i].sbr_tab[0][1], 2,306 &tab[0][1], 2,
347 &sbr_tmp[i].sbr_tab[0][0], 2, 1,307 &tab[0][0], 2, 1,
348 0, 0);308 0, 0);
309 tab += sbr_huffman_nb_codes[i];
349 }310 }
350}311}
351 312

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