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

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/aacdec_common.c+10−49
@@ -128,8 +128,8 @@ const VLCElem *ff_vlc_spectral[11]; · 127 unmodified lines
128128
129129 /// Huffman tables for SBR
130130
131+static const uint8_t sbr_huffman_tab[][2] = {
131132 /* t_huffman_env_1_5dB - 121 entries */
132−static const uint8_t t_huffman_env_1_5dB_tab[][2] = {
133133 { 60, 2 }, { 59, 2 }, { 61, 3 }, { 58, 3 }, { 62, 4 },
134134 { 57, 4 }, { 63, 5 }, { 56, 5 }, { 64, 6 }, { 55, 6 },
135135 { 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
155155 { 110, 19 }, { 111, 19 }, { 112, 19 }, { 113, 19 }, { 114, 19 },
156156 { 115, 19 }, { 116, 19 }, { 117, 19 }, { 118, 19 }, { 119, 19 },
157157 { 120, 19 },
158−};
159−
160158 /* f_huffman_env_1_5dB - 121 entries */
161−static const uint8_t f_huffman_env_1_5dB_tab[][2] = {
162159 { 60, 2 }, { 59, 2 }, { 61, 3 }, { 58, 3 }, { 57, 4 },
163160 { 62, 4 }, { 56, 5 }, { 63, 5 }, { 55, 6 }, { 64, 6 },
164161 { 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
184181 { 110, 20 }, { 111, 20 }, { 112, 20 }, { 113, 20 }, { 114, 20 },
185182 { 115, 20 }, { 116, 20 }, { 117, 20 }, { 118, 20 }, { 119, 20 },
186183 { 120, 20 },
187−};
188−
189184 /* t_huffman_env_bal_1_5dB - 49 entries */
190−static const uint8_t t_huffman_env_bal_1_5dB_tab[][2] = {
191185 { 24, 1 }, { 25, 2 }, { 23, 3 }, { 26, 4 }, { 22, 5 },
192186 { 27, 6 }, { 21, 7 }, { 28, 8 }, { 20, 9 }, { 19, 11 },
193187 { 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
198192 { 35, 16 }, { 36, 16 }, { 37, 16 }, { 38, 16 }, { 39, 17 },
199193 { 40, 17 }, { 41, 17 }, { 42, 17 }, { 43, 17 }, { 44, 17 },
200194 { 45, 17 }, { 46, 17 }, { 47, 17 }, { 48, 17 },
201−};
202−
203195 /* f_huffman_env_bal_1_5dB - 49 entries */
204−static const uint8_t f_huffman_env_bal_1_5dB_tab[][2] = {
205196 { 24, 1 }, { 23, 2 }, { 25, 3 }, { 22, 4 }, { 26, 5 },
206197 { 27, 6 }, { 21, 7 }, { 20, 8 }, { 28, 9 }, { 19, 11 },
207198 { 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
212203 { 35, 18 }, { 36, 18 }, { 37, 18 }, { 38, 18 }, { 39, 18 },
213204 { 40, 18 }, { 41, 18 }, { 42, 18 }, { 43, 18 }, { 44, 18 },
214205 { 45, 18 }, { 46, 18 }, { 47, 19 }, { 48, 19 },
215−};
216−
217206 /* t_huffman_env_3_0dB - 63 entries */
218−static const uint8_t t_huffman_env_3_0dB_tab[][2] = {
219207 { 31, 1 }, { 30, 2 }, { 32, 3 }, { 29, 4 }, { 33, 5 },
220208 { 28, 6 }, { 34, 7 }, { 27, 8 }, { 35, 9 }, { 26, 11 },
221209 { 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
229217 { 50, 19 }, { 51, 19 }, { 52, 19 }, { 53, 19 }, { 54, 19 },
230218 { 55, 19 }, { 56, 19 }, { 57, 19 }, { 58, 19 }, { 59, 19 },
231219 { 60, 19 }, { 61, 19 }, { 62, 19 },
232−};
233−
234220 /* f_huffman_env_3_0dB - 63 entries */
235−static const uint8_t f_huffman_env_3_0dB_tab[][2] = {
236221 { 31, 1 }, { 30, 2 }, { 32, 3 }, { 29, 4 }, { 33, 5 },
237222 { 28, 6 }, { 34, 8 }, { 27, 8 }, { 35, 9 }, { 26, 9 },
238223 { 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
246231 { 3, 20 }, { 4, 20 }, { 5, 20 }, { 6, 20 }, { 14, 20 },
247232 { 50, 20 }, { 54, 20 }, { 57, 20 }, { 58, 20 }, { 59, 20 },
248233 { 60, 20 }, { 61, 20 }, { 62, 20 },
249−};
250−
251234 /* t_huffman_env_bal_3_0dB - 25 entries */
252−static const uint8_t t_huffman_env_bal_3_0dB_tab[][2] = {
253235 { 12, 1 }, { 13, 2 }, { 11, 3 }, { 10, 4 }, { 14, 5 },
254236 { 15, 6 }, { 9, 7 }, { 8, 8 }, { 16, 9 }, { 7, 12 },
255237 { 0, 13 }, { 1, 13 }, { 2, 13 }, { 3, 13 }, { 4, 13 },
256238 { 5, 13 }, { 6, 13 }, { 17, 13 }, { 18, 13 }, { 19, 13 },
257239 { 20, 13 }, { 21, 13 }, { 22, 13 }, { 23, 14 }, { 24, 14 },
258−};
259−
260240 /* f_huffman_env_bal_3_0dB - 25 entries */
261−static const uint8_t f_huffman_env_bal_3_0dB_tab[][2] = {
262241 { 12, 1 }, { 11, 2 }, { 13, 3 }, { 10, 4 }, { 14, 5 },
263242 { 15, 6 }, { 9, 7 }, { 8, 8 }, { 16, 9 }, { 7, 11 },
264243 { 17, 12 }, { 18, 13 }, { 0, 13 }, { 1, 13 }, { 2, 13 },
265244 { 3, 13 }, { 4, 13 }, { 5, 14 }, { 6, 14 }, { 19, 14 },
266245 { 20, 14 }, { 21, 14 }, { 22, 14 }, { 23, 14 }, { 24, 14 },
267−};
268−
269246 /* t_huffman_noise_3_0dB - 63 entries */
270−static const uint8_t t_huffman_noise_3_0dB_tab[][2] = {
271247 { 31, 1 }, { 32, 2 }, { 30, 3 }, { 29, 4 }, { 33, 5 },
272248 { 28, 6 }, { 34, 8 }, { 27, 8 }, { 35, 10 }, { 26, 11 },
273249 { 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
281257 { 50, 13 }, { 51, 13 }, { 52, 13 }, { 53, 13 }, { 54, 13 },
282258 { 55, 13 }, { 56, 13 }, { 57, 13 }, { 58, 13 }, { 59, 13 },
283259 { 60, 13 }, { 61, 14 }, { 62, 14 },
284−};
285−
286260 /* t_huffman_noise_bal_3_0dB - 25 entries */
287−static const uint8_t t_huffman_noise_bal_3_0dB_tab[][2] = {
288261 { 12, 1 }, { 11, 2 }, { 13, 3 }, { 10, 5 }, { 14, 6 },
289262 { 0, 8 }, { 1, 8 }, { 2, 8 }, { 3, 8 }, { 4, 8 },
290263 { 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
292265 { 20, 8 }, { 21, 8 }, { 22, 8 }, { 23, 8 }, { 24, 8 },
293266 };
294267
268+static const uint8_t sbr_huffman_nb_codes[] = {
269+ 121, 121, 49, 49, 63, 63, 25, 25, 63, 25
270+};
271+
295272 const VLCElem *ff_aac_sbr_vlc[10];
296273
297274 static av_cold void aacdec_common_init(void)
298275 {
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−
317276 static VLCElem vlc_buf[(304 + 270 + 550 + 300 + 328 +
318277 294 + 306 + 268 + 510 + 366 + 462) +
319278 (1098 + 1092 + 768 + 1026 + 1058 +
320279 1052 + 544 + 544 + 592 + 512)];
321280 VLCInitState state = VLC_INIT_STATE(vlc_buf);
281+ const uint8_t (*tab)[2] = sbr_huffman_tab;
322282
323283 for (unsigned i = 0; i < 11; i++) {
324284 #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
342302 // SBR VLC table initialization
343303 for (int i = 0; i < FF_ARRAY_ELEMS(ff_aac_sbr_vlc); i++) {
344304 ff_aac_sbr_vlc[i] =
345− ff_vlc_init_tables_from_lengths(&state, 9, sbr_tmp[i].table_size,
346− &sbr_tmp[i].sbr_tab[0][1], 2,
347− &sbr_tmp[i].sbr_tab[0][0], 2, 1,
305+ ff_vlc_init_tables_from_lengths(&state, 9, sbr_huffman_nb_codes[i],
306+ &tab[0][1], 2,
307+ &tab[0][0], 2, 1,
348308 0, 0);
309+ tab += sbr_huffman_nb_codes[i];
349310 }
350311 }
351312

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