comparison ac3.c @ 10278:1a4af35efbda libavcodec

Hardcode AC-3 critical band tables when CONFIG_HARDCODED_TABLES is set.
author jbr
date Sun, 27 Sep 2009 04:07:49 +0000
parents 0dce4fe6e6f3
children fa3c28329d2f
comparison
equal deleted inserted replaced
10277:ddd69069dfa5 10278:1a4af35efbda
26 26
27 #include "avcodec.h" 27 #include "avcodec.h"
28 #include "ac3.h" 28 #include "ac3.h"
29 #include "get_bits.h" 29 #include "get_bits.h"
30 30
31 #if CONFIG_HARDCODED_TABLES
32
33 /**
34 * Starting frequency coefficient bin for each critical band.
35 */
36 static const uint8_t band_start_tab[51] = {
37 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
38 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
39 20, 21, 22, 23, 24, 25, 26, 27, 28, 31,
40 34, 37, 40, 43, 46, 49, 55, 61, 67, 73,
41 79, 85, 97, 109, 121, 133, 157, 181, 205, 229, 253
42 };
43
44 /**
45 * Maps each frequency coefficient bin to the critical band that contains it.
46 */
47 static const uint8_t bin_to_band_tab[253] = {
48 0,
49 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
50 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
51 25, 26, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30,
52 31, 31, 31, 32, 32, 32, 33, 33, 33, 34, 34, 34,
53 35, 35, 35, 35, 35, 35, 36, 36, 36, 36, 36, 36,
54 37, 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, 38,
55 39, 39, 39, 39, 39, 39, 40, 40, 40, 40, 40, 40,
56 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
57 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
58 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
59 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
60 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
61 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
62 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
63 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
64 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
65 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
66 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
67 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
68 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
69 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49
70 };
71
72 #else /* CONFIG_HARDCODED_TABLES */
31 static uint8_t band_start_tab[51]; 73 static uint8_t band_start_tab[51];
32 static uint8_t bin_to_band_tab[253]; 74 static uint8_t bin_to_band_tab[253];
75 #endif
33 76
34 static inline int calc_lowcomp1(int a, int b0, int b1, int c) 77 static inline int calc_lowcomp1(int a, int b0, int b1, int c)
35 { 78 {
36 if ((b0 + 256) == b1) { 79 if ((b0 + 256) == b1) {
37 a = c; 80 a = c;
230 * note: This function must remain thread safe because it is called by the 273 * note: This function must remain thread safe because it is called by the
231 * AVParser init code. 274 * AVParser init code.
232 */ 275 */
233 av_cold void ac3_common_init(void) 276 av_cold void ac3_common_init(void)
234 { 277 {
278 #if !CONFIG_HARDCODED_TABLES
235 int i, j, k, l, v; 279 int i, j, k, l, v;
236 /* compute bndtab and masktab from bandsz */ 280 /* compute bndtab and masktab from bandsz */
237 k = 0; 281 k = 0;
238 l = 0; 282 l = 0;
239 for(i=0;i<50;i++) { 283 for(i=0;i<50;i++) {
241 v = ff_ac3_critical_band_size_tab[i]; 285 v = ff_ac3_critical_band_size_tab[i];
242 for(j=0;j<v;j++) bin_to_band_tab[k++]=i; 286 for(j=0;j<v;j++) bin_to_band_tab[k++]=i;
243 l += v; 287 l += v;
244 } 288 }
245 band_start_tab[50] = l; 289 band_start_tab[50] = l;
246 } 290 #endif /* !CONFIG_HARDCODED_TABLES */
291 }