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