Mercurial > mplayer.hg
comparison libfaad2/drm_dec.c @ 29264:e83eef58b30a
Remove all kind of trailing whitespaces from all MPlayer's files.
This affects all kind of spaces (' ',^I,^M,^L,...): actually
[:space:] regex character set.
author | bircoph |
---|---|
date | Wed, 13 May 2009 15:22:13 +0000 |
parents | 59b6fa5b4201 |
children |
comparison
equal
deleted
inserted
replaced
29263:0f1b5b68af32 | 29264:e83eef58b30a |
---|---|
44 /* type definitaions */ | 44 /* type definitaions */ |
45 typedef const int8_t (*drm_ps_huff_tab)[2]; | 45 typedef const int8_t (*drm_ps_huff_tab)[2]; |
46 | 46 |
47 | 47 |
48 /* binary search huffman tables */ | 48 /* binary search huffman tables */ |
49 static const int8_t f_huffman_sa[][2] = | 49 static const int8_t f_huffman_sa[][2] = |
50 { | 50 { |
51 { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ | 51 { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ |
52 { 2, 3 }, /* index 1: 2 bits: 1x */ | 52 { 2, 3 }, /* index 1: 2 bits: 1x */ |
53 { /*7*/ -8, 4 }, /* index 2: 3 bits: 10x */ | 53 { /*7*/ -8, 4 }, /* index 2: 3 bits: 10x */ |
54 { 5, 6 }, /* index 3: 3 bits: 11x */ | 54 { 5, 6 }, /* index 3: 3 bits: 11x */ |
62 { /*-4*/ -19, /*-5*/ -20 }, /* index 11: 6 bits: 11110x */ | 62 { /*-4*/ -19, /*-5*/ -20 }, /* index 11: 6 bits: 11110x */ |
63 { /*6*/ -9, 13 }, /* index 12: 6 bits: 11111x */ | 63 { /*6*/ -9, 13 }, /* index 12: 6 bits: 11111x */ |
64 { /*-7*/ -22, /*-6*/ -21 } /* index 13: 7 bits: 111111x */ | 64 { /*-7*/ -22, /*-6*/ -21 } /* index 13: 7 bits: 111111x */ |
65 }; | 65 }; |
66 | 66 |
67 static const int8_t t_huffman_sa[][2] = | 67 static const int8_t t_huffman_sa[][2] = |
68 { | 68 { |
69 { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ | 69 { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ |
70 { 2, 3 }, /* index 1: 2 bits: 1x */ | 70 { 2, 3 }, /* index 1: 2 bits: 1x */ |
71 { /*-1*/ -16, /*1*/ -14 }, /* index 2: 3 bits: 10x */ | 71 { /*-1*/ -16, /*1*/ -14 }, /* index 2: 3 bits: 10x */ |
72 { 4, 5 }, /* index 3: 3 bits: 11x */ | 72 { 4, 5 }, /* index 3: 3 bits: 11x */ |
80 { /*-6*/ -21, 12 }, /* index 11: 7 bits: 111111x */ | 80 { /*-6*/ -21, 12 }, /* index 11: 7 bits: 111111x */ |
81 { /*-7*/ -22, 13 }, /* index 12: 8 bits: 1111111x */ | 81 { /*-7*/ -22, 13 }, /* index 12: 8 bits: 1111111x */ |
82 { /*6*/ -9, /*7*/ -8 } /* index 13: 9 bits: 11111111x */ | 82 { /*6*/ -9, /*7*/ -8 } /* index 13: 9 bits: 11111111x */ |
83 }; | 83 }; |
84 | 84 |
85 static const int8_t f_huffman_pan[][2] = | 85 static const int8_t f_huffman_pan[][2] = |
86 { | 86 { |
87 { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ | 87 { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ |
88 { /*-1*/ -16, 2 }, /* index 1: 2 bits: 1x */ | 88 { /*-1*/ -16, 2 }, /* index 1: 2 bits: 1x */ |
89 { /*1*/ -14, 3 }, /* index 2: 3 bits: 11x */ | 89 { /*1*/ -14, 3 }, /* index 2: 3 bits: 11x */ |
90 { 4, 5 }, /* index 3: 4 bits: 111x */ | 90 { 4, 5 }, /* index 3: 4 bits: 111x */ |
112 { 26, 27 }, /* index 25: 15 bits: 11111111111111x */ | 112 { 26, 27 }, /* index 25: 15 bits: 11111111111111x */ |
113 { /*-14*/ -29, /*-12*/ -27 }, /* index 26: 16 bits: 111111111111110x */ | 113 { /*-14*/ -29, /*-12*/ -27 }, /* index 26: 16 bits: 111111111111110x */ |
114 { /*12*/ -3, /*14*/ -1 } /* index 27: 16 bits: 111111111111111x */ | 114 { /*12*/ -3, /*14*/ -1 } /* index 27: 16 bits: 111111111111111x */ |
115 }; | 115 }; |
116 | 116 |
117 static const int8_t t_huffman_pan[][2] = | 117 static const int8_t t_huffman_pan[][2] = |
118 { | 118 { |
119 { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ | 119 { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ |
120 { /*-1*/ -16, 2 }, /* index 1: 2 bits: 1x */ | 120 { /*-1*/ -16, 2 }, /* index 1: 2 bits: 1x */ |
121 { /*1*/ -14, 3 }, /* index 2: 3 bits: 11x */ | 121 { /*1*/ -14, 3 }, /* index 2: 3 bits: 11x */ |
122 { /*-2*/ -17, 4 }, /* index 3: 4 bits: 111x */ | 122 { /*-2*/ -17, 4 }, /* index 3: 4 bits: 111x */ |
145 { /*11*/ -4, /*12*/ -3 }, /* index 26: 18 bits: 11111111111111110x */ | 145 { /*11*/ -4, /*12*/ -3 }, /* index 26: 18 bits: 11111111111111110x */ |
146 { /*13*/ -2, /*14*/ -1 } /* index 27: 18 bits: 11111111111111111x */ | 146 { /*13*/ -2, /*14*/ -1 } /* index 27: 18 bits: 11111111111111111x */ |
147 }; | 147 }; |
148 | 148 |
149 /* There are 3 classes in the standard but the last 2 are identical */ | 149 /* There are 3 classes in the standard but the last 2 are identical */ |
150 static const real_t sa_quant[8][2] = | 150 static const real_t sa_quant[8][2] = |
151 { | 151 { |
152 { FRAC_CONST(0.0000), FRAC_CONST(0.0000) }, | 152 { FRAC_CONST(0.0000), FRAC_CONST(0.0000) }, |
153 { FRAC_CONST(0.0501), FRAC_CONST(0.1778) }, | 153 { FRAC_CONST(0.0501), FRAC_CONST(0.1778) }, |
154 { FRAC_CONST(0.0706), FRAC_CONST(0.2818) }, | 154 { FRAC_CONST(0.0706), FRAC_CONST(0.2818) }, |
155 { FRAC_CONST(0.0995), FRAC_CONST(0.4467) }, | 155 { FRAC_CONST(0.0995), FRAC_CONST(0.4467) }, |
159 { FRAC_CONST(0.3699), FRAC_CONST(1.0000) }, | 159 { FRAC_CONST(0.3699), FRAC_CONST(1.0000) }, |
160 }; | 160 }; |
161 | 161 |
162 /* We don't need the actual quantizer values */ | 162 /* We don't need the actual quantizer values */ |
163 #if 0 | 163 #if 0 |
164 static const real_t pan_quant[8][5] = | 164 static const real_t pan_quant[8][5] = |
165 { | 165 { |
166 { COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000) }, | 166 { COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000) }, |
167 { COEF_CONST(0.1661), COEF_CONST(0.1661), COEF_CONST(0.3322), COEF_CONST(0.3322), COEF_CONST(0.3322) }, | 167 { COEF_CONST(0.1661), COEF_CONST(0.1661), COEF_CONST(0.3322), COEF_CONST(0.3322), COEF_CONST(0.3322) }, |
168 { COEF_CONST(0.3322), COEF_CONST(0.3322), COEF_CONST(0.6644), COEF_CONST(0.8305), COEF_CONST(0.8305) }, | 168 { COEF_CONST(0.3322), COEF_CONST(0.3322), COEF_CONST(0.6644), COEF_CONST(0.8305), COEF_CONST(0.8305) }, |
169 { COEF_CONST(0.4983), COEF_CONST(0.6644), COEF_CONST(0.9966), COEF_CONST(1.4949), COEF_CONST(1.6610) }, | 169 { COEF_CONST(0.4983), COEF_CONST(0.6644), COEF_CONST(0.9966), COEF_CONST(1.4949), COEF_CONST(1.6610) }, |
198 { REAL_CONST(0.3980992), REAL_CONST(0.1995331), REAL_CONST(0.0891267), REAL_CONST(0.0398107), REAL_CONST(0.0177825) } | 198 { REAL_CONST(0.3980992), REAL_CONST(0.1995331), REAL_CONST(0.0891267), REAL_CONST(0.0398107), REAL_CONST(0.0177825) } |
199 }; | 199 }; |
200 | 200 |
201 /* 2^(pan_quant[x][y]/30) */ | 201 /* 2^(pan_quant[x][y]/30) */ |
202 static const real_t pan_pow_2_30_pos[8][5] = { | 202 static const real_t pan_pow_2_30_pos[8][5] = { |
203 { COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1) }, | 203 { COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1) }, |
204 { COEF_CONST(1.003845098), COEF_CONST(1.003845098), COEF_CONST(1.007704982), COEF_CONST(1.007704982), COEF_CONST(1.007704982) }, | 204 { COEF_CONST(1.003845098), COEF_CONST(1.003845098), COEF_CONST(1.007704982), COEF_CONST(1.007704982), COEF_CONST(1.007704982) }, |
205 { COEF_CONST(1.007704982), COEF_CONST(1.007704982), COEF_CONST(1.01546933), COEF_CONST(1.019373909), COEF_CONST(1.019373909) }, | 205 { COEF_CONST(1.007704982), COEF_CONST(1.007704982), COEF_CONST(1.01546933), COEF_CONST(1.019373909), COEF_CONST(1.019373909) }, |
206 { COEF_CONST(1.011579706), COEF_CONST(1.01546933), COEF_CONST(1.023293502), COEF_CONST(1.035142941), COEF_CONST(1.039123167) }, | 206 { COEF_CONST(1.011579706), COEF_CONST(1.01546933), COEF_CONST(1.023293502), COEF_CONST(1.035142941), COEF_CONST(1.039123167) }, |
207 { COEF_CONST(1.01546933), COEF_CONST(1.023293502), COEF_CONST(1.035142941), COEF_CONST(1.051155908), COEF_CONST(1.059252598) }, | 207 { COEF_CONST(1.01546933), COEF_CONST(1.023293502), COEF_CONST(1.035142941), COEF_CONST(1.051155908), COEF_CONST(1.059252598) }, |
208 { COEF_CONST(1.019373909), COEF_CONST(1.03117796), COEF_CONST(1.051155908), COEF_CONST(1.071518432), COEF_CONST(1.0839263) }, | 208 { COEF_CONST(1.019373909), COEF_CONST(1.03117796), COEF_CONST(1.051155908), COEF_CONST(1.071518432), COEF_CONST(1.0839263) }, |
209 { COEF_CONST(1.023293502), COEF_CONST(1.043118698), COEF_CONST(1.067414119), COEF_CONST(1.092277933), COEF_CONST(1.113439626) }, | 209 { COEF_CONST(1.023293502), COEF_CONST(1.043118698), COEF_CONST(1.067414119), COEF_CONST(1.092277933), COEF_CONST(1.113439626) }, |
210 { COEF_CONST(1.03117796), COEF_CONST(1.055195268), COEF_CONST(1.0839263), COEF_CONST(1.113439626), COEF_CONST(1.143756546) } | 210 { COEF_CONST(1.03117796), COEF_CONST(1.055195268), COEF_CONST(1.0839263), COEF_CONST(1.113439626), COEF_CONST(1.143756546) } |
211 }; | 211 }; |
212 | 212 |
213 /* 2^(-pan_quant[x][y]/30) */ | 213 /* 2^(-pan_quant[x][y]/30) */ |
214 static const real_t pan_pow_2_30_neg[8][5] = { | 214 static const real_t pan_pow_2_30_neg[8][5] = { |
215 { COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1) }, | 215 { COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1) }, |
216 { COEF_CONST(0.99616963), COEF_CONST(0.99616963), COEF_CONST(0.992353931), COEF_CONST(0.992353931), COEF_CONST(0.99235393) }, | 216 { COEF_CONST(0.99616963), COEF_CONST(0.99616963), COEF_CONST(0.992353931), COEF_CONST(0.992353931), COEF_CONST(0.99235393) }, |
217 { COEF_CONST(0.992353931), COEF_CONST(0.992353931), COEF_CONST(0.984766325), COEF_CONST(0.980994305), COEF_CONST(0.980994305) }, | 217 { COEF_CONST(0.992353931), COEF_CONST(0.992353931), COEF_CONST(0.984766325), COEF_CONST(0.980994305), COEF_CONST(0.980994305) }, |
218 { COEF_CONST(0.988552848), COEF_CONST(0.984766325), COEF_CONST(0.977236734), COEF_CONST(0.966050157), COEF_CONST(0.962349827) }, | 218 { COEF_CONST(0.988552848), COEF_CONST(0.984766325), COEF_CONST(0.977236734), COEF_CONST(0.966050157), COEF_CONST(0.962349827) }, |
219 { COEF_CONST(0.984766325), COEF_CONST(0.977236734), COEF_CONST(0.966050157), COEF_CONST(0.951333663), COEF_CONST(0.944061881) }, | 219 { COEF_CONST(0.984766325), COEF_CONST(0.977236734), COEF_CONST(0.966050157), COEF_CONST(0.951333663), COEF_CONST(0.944061881) }, |
220 { COEF_CONST(0.980994305), COEF_CONST(0.969764715), COEF_CONST(0.951333663), COEF_CONST(0.933255062), COEF_CONST(0.922571949) }, | 220 { COEF_CONST(0.980994305), COEF_CONST(0.969764715), COEF_CONST(0.951333663), COEF_CONST(0.933255062), COEF_CONST(0.922571949) }, |
221 { COEF_CONST(0.977236734), COEF_CONST(0.958663671), COEF_CONST(0.936843519), COEF_CONST(0.915517901), COEF_CONST(0.898117847) }, | 221 { COEF_CONST(0.977236734), COEF_CONST(0.958663671), COEF_CONST(0.936843519), COEF_CONST(0.915517901), COEF_CONST(0.898117847) }, |
222 { COEF_CONST(0.969764715), COEF_CONST(0.947691892), COEF_CONST(0.922571949), COEF_CONST(0.898117847), COEF_CONST(0.874311936) } | 222 { COEF_CONST(0.969764715), COEF_CONST(0.947691892), COEF_CONST(0.922571949), COEF_CONST(0.898117847), COEF_CONST(0.874311936) } |
223 }; | 223 }; |
224 | 224 |
225 static const real_t g_decayslope[MAX_SA_BAND] = { | 225 static const real_t g_decayslope[MAX_SA_BAND] = { |
226 FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.95),FRAC_CONST(0.9), FRAC_CONST(0.85), FRAC_CONST(0.8), | 226 FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.95),FRAC_CONST(0.9), FRAC_CONST(0.85), FRAC_CONST(0.8), |
227 FRAC_CONST(0.75),FRAC_CONST(0.7), FRAC_CONST(0.65),FRAC_CONST(0.6), FRAC_CONST(0.55),FRAC_CONST(0.5), FRAC_CONST(0.45), | 227 FRAC_CONST(0.75),FRAC_CONST(0.7), FRAC_CONST(0.65),FRAC_CONST(0.6), FRAC_CONST(0.55),FRAC_CONST(0.5), FRAC_CONST(0.45), |
228 FRAC_CONST(0.4), FRAC_CONST(0.35),FRAC_CONST(0.3), FRAC_CONST(0.25),FRAC_CONST(0.2), FRAC_CONST(0.15), FRAC_CONST(0.1), | 228 FRAC_CONST(0.4), FRAC_CONST(0.35),FRAC_CONST(0.3), FRAC_CONST(0.25),FRAC_CONST(0.2), FRAC_CONST(0.15), FRAC_CONST(0.1), |
229 FRAC_CONST(0.05),FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), | 229 FRAC_CONST(0.05),FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), |
230 FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), | 230 FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), |
231 FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), | 231 FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), |
232 FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0) | 232 FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0) |
233 }; | 233 }; |
234 | 234 |
235 static const real_t sa_sqrt_1_minus[8][2] = { | 235 static const real_t sa_sqrt_1_minus[8][2] = { |
236 { FRAC_CONST(1), FRAC_CONST(1) }, | 236 { FRAC_CONST(1), FRAC_CONST(1) }, |
241 { FRAC_CONST(0.980663811), FRAC_CONST(0.706312672) }, | 241 { FRAC_CONST(0.980663811), FRAC_CONST(0.706312672) }, |
242 { FRAC_CONST(0.962494836), FRAC_CONST(0.45341406) }, | 242 { FRAC_CONST(0.962494836), FRAC_CONST(0.45341406) }, |
243 { FRAC_CONST(0.929071574), FRAC_CONST(0) } | 243 { FRAC_CONST(0.929071574), FRAC_CONST(0) } |
244 }; | 244 }; |
245 | 245 |
246 static const uint8_t sa_freq_scale[9][2] = | 246 static const uint8_t sa_freq_scale[9][2] = |
247 { | 247 { |
248 { 0, 0}, | 248 { 0, 0}, |
249 { 1, 1}, | 249 { 1, 1}, |
250 { 2, 2}, | 250 { 2, 2}, |
251 { 3, 3}, | 251 { 3, 3}, |
252 { 5, 5}, | 252 { 5, 5}, |
253 { 7, 7}, | 253 { 7, 7}, |
254 {10,10}, | 254 {10,10}, |
255 {13,13}, | 255 {13,13}, |
256 {46,23} | 256 {46,23} |
257 }; | 257 }; |
258 | 258 |
259 static const uint8_t pan_freq_scale[21] = | 259 static const uint8_t pan_freq_scale[21] = |
260 { | 260 { |
261 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, | 261 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, |
262 11, 12, 13, 14, 15, 18, 22, 26, 32, 64 | 262 11, 12, 13, 14, 15, 18, 22, 26, 32, 64 |
263 }; | 263 }; |
264 | 264 |
265 static const uint8_t pan_quant_class[20] = | 265 static const uint8_t pan_quant_class[20] = |
266 { | 266 { |
267 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 267 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
268 2, 2, 2, 2, 3, 3, 3, 4, 4, 4 | 268 2, 2, 2, 2, 3, 3, 3, 4, 4, 4 |
269 }; | 269 }; |
270 | 270 |
271 /* Inverse mapping lookup */ | 271 /* Inverse mapping lookup */ |
272 static const uint8_t pan_inv_freq[64] = { | 272 static const uint8_t pan_inv_freq[64] = { |
273 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, | 273 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
274 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, | 274 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, |
275 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, | 275 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, |
276 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19 | 276 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19 |
277 }; | 277 }; |
278 | 278 |
279 static const uint8_t sa_inv_freq[MAX_SA_BAND] = { | 279 static const uint8_t sa_inv_freq[MAX_SA_BAND] = { |
280 0, 1, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, | 280 0, 1, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, |
281 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | 281 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
282 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | 282 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
283 7, 7, 7, 7, 7, 7, 7 | 283 7, 7, 7, 7, 7, 7, 7 |
284 }; | 284 }; |
285 | 285 |
286 static const real_t filter_coeff[] = | 286 static const real_t filter_coeff[] = |
287 { | 287 { |
288 FRAC_CONST(0.65143905754106), | 288 FRAC_CONST(0.65143905754106), |
289 FRAC_CONST(0.56471812200776), | 289 FRAC_CONST(0.56471812200776), |
290 FRAC_CONST(0.48954165955695) | 290 FRAC_CONST(0.48954165955695) |
291 }; | 291 }; |
292 | 292 |
293 static const uint8_t delay_length[][2] = | 293 static const uint8_t delay_length[][2] = |
294 { | 294 { |
295 { 1, 3 }, { 2, 4 }, { 3, 5 } | 295 { 1, 3 }, { 2, 4 }, { 3, 5 } |
296 }; | 296 }; |
297 | 297 |
298 static const real_t delay_fraction[] = | 298 static const real_t delay_fraction[] = |
299 { | 299 { |
300 FRAC_CONST(0.43), FRAC_CONST(0.75), FRAC_CONST(0.347) | 300 FRAC_CONST(0.43), FRAC_CONST(0.75), FRAC_CONST(0.347) |
301 }; | 301 }; |
302 | 302 |
303 static const real_t peak_decay[2] = | 303 static const real_t peak_decay[2] = |
304 { | 304 { |
305 FRAC_CONST(0.58664621951003), FRAC_CONST(0.76592833836465) | 305 FRAC_CONST(0.58664621951003), FRAC_CONST(0.76592833836465) |
306 }; | 306 }; |
307 | 307 |
308 static const real_t smooth_coeff[2] = | 308 static const real_t smooth_coeff[2] = |
309 { | 309 { |
310 FRAC_CONST(0.6), FRAC_CONST(0.25) | 310 FRAC_CONST(0.6), FRAC_CONST(0.25) |
311 }; | 311 }; |
312 | 312 |
313 /* Please note that these are the same tables as in plain PS */ | 313 /* Please note that these are the same tables as in plain PS */ |
543 } else | 543 } else |
544 return i; | 544 return i; |
545 } | 545 } |
546 | 546 |
547 static int8_t pan_delta_clip(drm_ps_info *ps, int8_t i) | 547 static int8_t pan_delta_clip(drm_ps_info *ps, int8_t i) |
548 { | 548 { |
549 if (i < -7) { | 549 if (i < -7) { |
550 /* printf(" PANminclip %d", i); */ | 550 /* printf(" PANminclip %d", i); */ |
551 ps->pan_decode_error = 1; | 551 ps->pan_decode_error = 1; |
552 return -7; | 552 return -7; |
553 } else if (i > 7) { | 553 } else if (i > 7) { |
556 return 7; | 556 return 7; |
557 } else | 557 } else |
558 return i; | 558 return i; |
559 } | 559 } |
560 | 560 |
561 static void drm_ps_delta_decode(drm_ps_info *ps) | 561 static void drm_ps_delta_decode(drm_ps_info *ps) |
562 { | 562 { |
563 uint8_t band; | 563 uint8_t band; |
564 | 564 |
565 if (ps->bs_enable_sa) | 565 if (ps->bs_enable_sa) |
566 { | 566 { |
567 if (ps->bs_sa_dt_flag && !ps->g_last_had_sa) | 567 if (ps->bs_sa_dt_flag && !ps->g_last_had_sa) |
568 { | 568 { |
569 for (band = 0; band < DRM_NUM_SA_BANDS; band++) | 569 for (band = 0; band < DRM_NUM_SA_BANDS; band++) |
570 { | 570 { |
571 ps->g_prev_sa_index[band] = 0; | 571 ps->g_prev_sa_index[band] = 0; |
572 } | 572 } |
573 } | 573 } |
574 if (ps->bs_sa_dt_flag) | 574 if (ps->bs_sa_dt_flag) |
575 { | 575 { |
576 ps->g_sa_index[0] = sa_delta_clip(ps, ps->g_prev_sa_index[0]+ps->bs_sa_data[0]); | 576 ps->g_sa_index[0] = sa_delta_clip(ps, ps->g_prev_sa_index[0]+ps->bs_sa_data[0]); |
577 | 577 |
578 } else { | 578 } else { |
579 ps->g_sa_index[0] = sa_delta_clip(ps,ps->bs_sa_data[0]); | 579 ps->g_sa_index[0] = sa_delta_clip(ps,ps->bs_sa_data[0]); |
580 } | 580 } |
581 | 581 |
582 for (band = 1; band < DRM_NUM_SA_BANDS; band++) | 582 for (band = 1; band < DRM_NUM_SA_BANDS; band++) |
583 { | 583 { |
584 if (ps->bs_sa_dt_flag) | 584 if (ps->bs_sa_dt_flag) |
585 { | 585 { |
586 ps->g_sa_index[band] = sa_delta_clip(ps, ps->g_prev_sa_index[band] + ps->bs_sa_data[band]); | 586 ps->g_sa_index[band] = sa_delta_clip(ps, ps->g_prev_sa_index[band] + ps->bs_sa_data[band]); |
587 } else { | 587 } else { |
588 ps->g_sa_index[band] = sa_delta_clip(ps, ps->g_sa_index[band-1] + ps->bs_sa_data[band]); | 588 ps->g_sa_index[band] = sa_delta_clip(ps, ps->g_sa_index[band-1] + ps->bs_sa_data[band]); |
589 } | 589 } |
590 } | 590 } |
591 } | 591 } |
592 | 592 |
593 /* An error during SA decoding implies PAN data will be undecodable, too */ | 593 /* An error during SA decoding implies PAN data will be undecodable, too */ |
595 if (ps->sa_decode_error) { | 595 if (ps->sa_decode_error) { |
596 ps->pan_decode_error = 1; | 596 ps->pan_decode_error = 1; |
597 ps->bs_enable_pan = ps->g_last_had_pan; | 597 ps->bs_enable_pan = ps->g_last_had_pan; |
598 ps->bs_enable_sa = ps->g_last_had_sa; | 598 ps->bs_enable_sa = ps->g_last_had_sa; |
599 } | 599 } |
600 | 600 |
601 | 601 |
602 if (ps->bs_enable_sa) | 602 if (ps->bs_enable_sa) |
603 { | 603 { |
604 if (ps->sa_decode_error) { | 604 if (ps->sa_decode_error) { |
605 for (band = 0; band < DRM_NUM_SA_BANDS; band++) | 605 for (band = 0; band < DRM_NUM_SA_BANDS; band++) |
606 { | 606 { |
607 ps->g_sa_index[band] = ps->g_last_good_sa_index[band]; | 607 ps->g_sa_index[band] = ps->g_last_good_sa_index[band]; |
608 } | 608 } |
609 } else { | 609 } else { |
610 for (band = 0; band < DRM_NUM_SA_BANDS; band++) | 610 for (band = 0; band < DRM_NUM_SA_BANDS; band++) |
611 { | 611 { |
612 ps->g_last_good_sa_index[band] = ps->g_sa_index[band]; | 612 ps->g_last_good_sa_index[band] = ps->g_sa_index[band]; |
613 } | 613 } |
614 } | 614 } |
615 } | 615 } |
616 | 616 |
617 if (ps->bs_enable_pan) | 617 if (ps->bs_enable_pan) |
618 { | 618 { |
619 if (ps->bs_pan_dt_flag && !ps->g_last_had_pan) | 619 if (ps->bs_pan_dt_flag && !ps->g_last_had_pan) |
620 { | 620 { |
621 /* The DRM PS spec doesn't say anything about this case. (deltacoded in time without a previous frame) | 621 /* The DRM PS spec doesn't say anything about this case. (deltacoded in time without a previous frame) |
622 AAC PS spec you must tread previous frame as 0, so that's what we try. | 622 AAC PS spec you must tread previous frame as 0, so that's what we try. |
623 */ | 623 */ |
624 for (band = 0; band < DRM_NUM_PAN_BANDS; band++) | 624 for (band = 0; band < DRM_NUM_PAN_BANDS; band++) |
625 { | 625 { |
626 ps->g_prev_pan_index[band] = 0; | 626 ps->g_prev_pan_index[band] = 0; |
627 } | 627 } |
628 } | 628 } |
629 | 629 |
630 if (ps->bs_pan_dt_flag) | 630 if (ps->bs_pan_dt_flag) |
631 { | 631 { |
632 ps->g_pan_index[0] = pan_delta_clip(ps, ps->g_prev_pan_index[0]+ps->bs_pan_data[0]); | 632 ps->g_pan_index[0] = pan_delta_clip(ps, ps->g_prev_pan_index[0]+ps->bs_pan_data[0]); |
633 } else { | 633 } else { |
634 ps->g_pan_index[0] = pan_delta_clip(ps, ps->bs_pan_data[0]); | 634 ps->g_pan_index[0] = pan_delta_clip(ps, ps->bs_pan_data[0]); |
635 } | 635 } |
636 | 636 |
637 for (band = 1; band < DRM_NUM_PAN_BANDS; band++) | 637 for (band = 1; band < DRM_NUM_PAN_BANDS; band++) |
638 { | 638 { |
639 if (ps->bs_pan_dt_flag) | 639 if (ps->bs_pan_dt_flag) |
640 { | 640 { |
641 ps->g_pan_index[band] = pan_delta_clip(ps, ps->g_prev_pan_index[band] + ps->bs_pan_data[band]); | 641 ps->g_pan_index[band] = pan_delta_clip(ps, ps->g_prev_pan_index[band] + ps->bs_pan_data[band]); |
642 } else { | 642 } else { |
643 ps->g_pan_index[band] = pan_delta_clip(ps, ps->g_pan_index[band-1] + ps->bs_pan_data[band]); | 643 ps->g_pan_index[band] = pan_delta_clip(ps, ps->g_pan_index[band-1] + ps->bs_pan_data[band]); |
644 } | 644 } |
645 } | 645 } |
646 | 646 |
647 if (ps->pan_decode_error) { | 647 if (ps->pan_decode_error) { |
648 for (band = 0; band < DRM_NUM_PAN_BANDS; band++) | 648 for (band = 0; band < DRM_NUM_PAN_BANDS; band++) |
649 { | 649 { |
650 ps->g_pan_index[band] = ps->g_last_good_pan_index[band]; | 650 ps->g_pan_index[band] = ps->g_last_good_pan_index[band]; |
651 } | 651 } |
652 } else { | 652 } else { |
653 for (band = 0; band < DRM_NUM_PAN_BANDS; band++) | 653 for (band = 0; band < DRM_NUM_PAN_BANDS; band++) |
654 { | 654 { |
655 ps->g_last_good_pan_index[band] = ps->g_pan_index[band]; | 655 ps->g_last_good_pan_index[band] = ps->g_pan_index[band]; |
656 } | 656 } |
657 } | 657 } |
658 } | 658 } |
659 } | 659 } |
660 | 660 |
661 static void drm_calc_sa_side_signal(drm_ps_info *ps, qmf_t X[38][64], uint8_t rateselect) | 661 static void drm_calc_sa_side_signal(drm_ps_info *ps, qmf_t X[38][64], uint8_t rateselect) |
662 { | 662 { |
663 uint8_t s, b, k; | 663 uint8_t s, b, k; |
664 complex_t qfrac, tmp0, tmp, in, R0; | 664 complex_t qfrac, tmp0, tmp, in, R0; |
665 real_t peakdiff; | 665 real_t peakdiff; |
666 real_t nrg; | 666 real_t nrg; |
667 real_t power; | 667 real_t power; |
673 uint32_t in_re, in_im; | 673 uint32_t in_re, in_im; |
674 #endif | 674 #endif |
675 | 675 |
676 for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b++) | 676 for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b++) |
677 { | 677 { |
678 /* set delay indices */ | 678 /* set delay indices */ |
679 for (k = 0; k < NUM_OF_LINKS; k++) | 679 for (k = 0; k < NUM_OF_LINKS; k++) |
680 temp_delay_ser[k] = ps->delay_buf_index_ser[k]; | 680 temp_delay_ser[k] = ps->delay_buf_index_ser[k]; |
681 | 681 |
682 RE(Phi_Fract) = RE(Phi_Fract_Qmf[b]); | 682 RE(Phi_Fract) = RE(Phi_Fract_Qmf[b]); |
683 IM(Phi_Fract) = IM(Phi_Fract_Qmf[b]); | 683 IM(Phi_Fract) = IM(Phi_Fract_Qmf[b]); |
684 | 684 |
685 for (s = 0; s < NUM_OF_SUBSAMPLES; s++) | 685 for (s = 0; s < NUM_OF_SUBSAMPLES; s++) |
686 { | 686 { |
687 const real_t gamma = REAL_CONST(1.5); | 687 const real_t gamma = REAL_CONST(1.5); |
688 const real_t sigma = REAL_CONST(1.5625); | 688 const real_t sigma = REAL_CONST(1.5625); |
689 | 689 |
690 RE(in) = QMF_RE(X[s][b]); | 690 RE(in) = QMF_RE(X[s][b]); |
691 IM(in) = QMF_IM(X[s][b]); | 691 IM(in) = QMF_IM(X[s][b]); |
716 if (MUL_R(peakdiff, gamma) <= nrg) { | 716 if (MUL_R(peakdiff, gamma) <= nrg) { |
717 transratio = sigma; | 717 transratio = sigma; |
718 } else { | 718 } else { |
719 transratio = MUL_R(DIV_R(nrg, MUL_R(peakdiff, gamma)), sigma); | 719 transratio = MUL_R(DIV_R(nrg, MUL_R(peakdiff, gamma)), sigma); |
720 } | 720 } |
721 | 721 |
722 for (k = 0; k < NUM_OF_LINKS; k++) | 722 for (k = 0; k < NUM_OF_LINKS; k++) |
723 { | 723 { |
724 new_delay_slopes[k] = MUL_F(g_decayslope[b], filter_coeff[k]); | 724 new_delay_slopes[k] = MUL_F(g_decayslope[b], filter_coeff[k]); |
725 } | 725 } |
726 | 726 |
727 RE(tmp0) = RE(ps->d_buff[0][b]); | 727 RE(tmp0) = RE(ps->d_buff[0][b]); |
729 | 729 |
730 RE(ps->d_buff[0][b]) = RE(ps->d_buff[1][b]); | 730 RE(ps->d_buff[0][b]) = RE(ps->d_buff[1][b]); |
731 IM(ps->d_buff[0][b]) = IM(ps->d_buff[1][b]); | 731 IM(ps->d_buff[0][b]) = IM(ps->d_buff[1][b]); |
732 | 732 |
733 RE(ps->d_buff[1][b]) = RE(in); | 733 RE(ps->d_buff[1][b]) = RE(in); |
734 IM(ps->d_buff[1][b]) = IM(in); | 734 IM(ps->d_buff[1][b]) = IM(in); |
735 | 735 |
736 ComplexMult(&RE(tmp), &IM(tmp), RE(tmp0), IM(tmp0), RE(Phi_Fract), IM(Phi_Fract)); | 736 ComplexMult(&RE(tmp), &IM(tmp), RE(tmp0), IM(tmp0), RE(Phi_Fract), IM(Phi_Fract)); |
737 | 737 |
738 RE(R0) = RE(tmp); | 738 RE(R0) = RE(tmp); |
739 IM(R0) = IM(tmp); | 739 IM(R0) = IM(tmp); |
740 | 740 |
741 for (k = 0; k < NUM_OF_LINKS; k++) | 741 for (k = 0; k < NUM_OF_LINKS; k++) |
742 { | 742 { |
743 RE(qfrac) = RE(Q_Fract_allpass_Qmf[b][k]); | 743 RE(qfrac) = RE(Q_Fract_allpass_Qmf[b][k]); |
744 IM(qfrac) = IM(Q_Fract_allpass_Qmf[b][k]); | 744 IM(qfrac) = IM(Q_Fract_allpass_Qmf[b][k]); |
745 | 745 |
746 RE(tmp0) = RE(ps->d2_buff[k][temp_delay_ser[k]][b]); | 746 RE(tmp0) = RE(ps->d2_buff[k][temp_delay_ser[k]][b]); |
764 for (k = 0; k < NUM_OF_LINKS; k++) | 764 for (k = 0; k < NUM_OF_LINKS; k++) |
765 { | 765 { |
766 if (++temp_delay_ser[k] >= delay_length[k][rateselect]) | 766 if (++temp_delay_ser[k] >= delay_length[k][rateselect]) |
767 temp_delay_ser[k] = 0; | 767 temp_delay_ser[k] = 0; |
768 } | 768 } |
769 } | 769 } |
770 } | 770 } |
771 | 771 |
772 for (k = 0; k < NUM_OF_LINKS; k++) | 772 for (k = 0; k < NUM_OF_LINKS; k++) |
773 ps->delay_buf_index_ser[k] = temp_delay_ser[k]; | 773 ps->delay_buf_index_ser[k] = temp_delay_ser[k]; |
774 } | 774 } |
775 | 775 |
776 static void drm_add_ambiance(drm_ps_info *ps, uint8_t rateselect, qmf_t X_left[38][64], qmf_t X_right[38][64]) | 776 static void drm_add_ambiance(drm_ps_info *ps, uint8_t rateselect, qmf_t X_left[38][64], qmf_t X_right[38][64]) |
777 { | 777 { |
778 uint8_t s, b, ifreq, qclass; | 778 uint8_t s, b, ifreq, qclass; |
779 real_t sa_map[MAX_SA_BAND], sa_dir_map[MAX_SA_BAND], k_sa_map[MAX_SA_BAND], k_sa_dir_map[MAX_SA_BAND]; | 779 real_t sa_map[MAX_SA_BAND], sa_dir_map[MAX_SA_BAND], k_sa_map[MAX_SA_BAND], k_sa_dir_map[MAX_SA_BAND]; |
780 real_t new_dir_map, new_sa_map; | 780 real_t new_dir_map, new_sa_map; |
781 | 781 |
782 if (ps->bs_enable_sa) | 782 if (ps->bs_enable_sa) |
783 { | 783 { |
784 /* Instead of dequantization and mapping, we use an inverse mapping | 784 /* Instead of dequantization and mapping, we use an inverse mapping |
785 to look up all the values we need */ | 785 to look up all the values we need */ |
786 for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b++) | 786 for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b++) |
791 qclass = (b != 0); | 791 qclass = (b != 0); |
792 | 792 |
793 sa_map[b] = sa_quant[ps->g_prev_sa_index[ifreq]][qclass]; | 793 sa_map[b] = sa_quant[ps->g_prev_sa_index[ifreq]][qclass]; |
794 new_sa_map = sa_quant[ps->g_sa_index[ifreq]][qclass]; | 794 new_sa_map = sa_quant[ps->g_sa_index[ifreq]][qclass]; |
795 | 795 |
796 k_sa_map[b] = MUL_F(inv_f_num_of_subsamples, (new_sa_map - sa_map[b])); | 796 k_sa_map[b] = MUL_F(inv_f_num_of_subsamples, (new_sa_map - sa_map[b])); |
797 | 797 |
798 sa_dir_map[b] = sa_sqrt_1_minus[ps->g_prev_sa_index[ifreq]][qclass]; | 798 sa_dir_map[b] = sa_sqrt_1_minus[ps->g_prev_sa_index[ifreq]][qclass]; |
799 new_dir_map = sa_sqrt_1_minus[ps->g_sa_index[ifreq]][qclass]; | 799 new_dir_map = sa_sqrt_1_minus[ps->g_sa_index[ifreq]][qclass]; |
800 | 800 |
801 k_sa_dir_map[b] = MUL_F(inv_f_num_of_subsamples, (new_dir_map - sa_dir_map[b])); | 801 k_sa_dir_map[b] = MUL_F(inv_f_num_of_subsamples, (new_dir_map - sa_dir_map[b])); |
802 | 802 |
803 } | 803 } |
804 | 804 |
805 for (s = 0; s < NUM_OF_SUBSAMPLES; s++) | 805 for (s = 0; s < NUM_OF_SUBSAMPLES; s++) |
806 { | 806 { |
807 for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b++) | 807 for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b++) |
808 { | 808 { |
809 QMF_RE(X_right[s][b]) = MUL_F(QMF_RE(X_left[s][b]), sa_dir_map[b]) - MUL_F(QMF_RE(ps->SA[s][b]), sa_map[b]); | 809 QMF_RE(X_right[s][b]) = MUL_F(QMF_RE(X_left[s][b]), sa_dir_map[b]) - MUL_F(QMF_RE(ps->SA[s][b]), sa_map[b]); |
810 QMF_IM(X_right[s][b]) = MUL_F(QMF_IM(X_left[s][b]), sa_dir_map[b]) - MUL_F(QMF_IM(ps->SA[s][b]), sa_map[b]); | 810 QMF_IM(X_right[s][b]) = MUL_F(QMF_IM(X_left[s][b]), sa_dir_map[b]) - MUL_F(QMF_IM(ps->SA[s][b]), sa_map[b]); |
811 QMF_RE(X_left[s][b]) = MUL_F(QMF_RE(X_left[s][b]), sa_dir_map[b]) + MUL_F(QMF_RE(ps->SA[s][b]), sa_map[b]); | 811 QMF_RE(X_left[s][b]) = MUL_F(QMF_RE(X_left[s][b]), sa_dir_map[b]) + MUL_F(QMF_RE(ps->SA[s][b]), sa_map[b]); |
812 QMF_IM(X_left[s][b]) = MUL_F(QMF_IM(X_left[s][b]), sa_dir_map[b]) + MUL_F(QMF_IM(ps->SA[s][b]), sa_map[b]); | 812 QMF_IM(X_left[s][b]) = MUL_F(QMF_IM(X_left[s][b]), sa_dir_map[b]) + MUL_F(QMF_IM(ps->SA[s][b]), sa_map[b]); |
813 | 813 |
814 sa_map[b] += k_sa_map[b]; | 814 sa_map[b] += k_sa_map[b]; |
815 sa_dir_map[b] += k_sa_dir_map[b]; | 815 sa_dir_map[b] += k_sa_dir_map[b]; |
816 } | 816 } |
817 for (b = sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b < NUM_OF_QMF_CHANNELS; b++) | 817 for (b = sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b < NUM_OF_QMF_CHANNELS; b++) |
818 { | 818 { |
819 QMF_RE(X_right[s][b]) = QMF_RE(X_left[s][b]); | 819 QMF_RE(X_right[s][b]) = QMF_RE(X_left[s][b]); |
820 QMF_IM(X_right[s][b]) = QMF_IM(X_left[s][b]); | 820 QMF_IM(X_right[s][b]) = QMF_IM(X_left[s][b]); |
821 } | 821 } |
822 } | 822 } |
823 } | 823 } |
824 else { | 824 else { |
825 for (s = 0; s < NUM_OF_SUBSAMPLES; s++) | 825 for (s = 0; s < NUM_OF_SUBSAMPLES; s++) |
826 { | 826 { |
827 for (b = 0; b < NUM_OF_QMF_CHANNELS; b++) | 827 for (b = 0; b < NUM_OF_QMF_CHANNELS; b++) |
828 { | 828 { |
829 QMF_RE(X_right[s][b]) = QMF_RE(X_left[s][b]); | 829 QMF_RE(X_right[s][b]) = QMF_RE(X_left[s][b]); |
830 QMF_IM(X_right[s][b]) = QMF_IM(X_left[s][b]); | 830 QMF_IM(X_right[s][b]) = QMF_IM(X_left[s][b]); |
831 } | 831 } |
832 } | 832 } |
833 } | 833 } |
834 } | 834 } |
835 | 835 |
836 static void drm_add_pan(drm_ps_info *ps, uint8_t rateselect, qmf_t X_left[38][64], qmf_t X_right[38][64]) | 836 static void drm_add_pan(drm_ps_info *ps, uint8_t rateselect, qmf_t X_left[38][64], qmf_t X_right[38][64]) |
837 { | 837 { |
838 uint8_t s, b, qclass, ifreq; | 838 uint8_t s, b, qclass, ifreq; |
839 real_t tmp, coeff1, coeff2; | 839 real_t tmp, coeff1, coeff2; |
840 real_t pan_base[MAX_PAN_BAND]; | 840 real_t pan_base[MAX_PAN_BAND]; |
841 real_t pan_delta[MAX_PAN_BAND]; | 841 real_t pan_delta[MAX_PAN_BAND]; |
842 qmf_t temp_l, temp_r; | 842 qmf_t temp_l, temp_r; |
843 | 843 |
844 if (ps->bs_enable_pan) | 844 if (ps->bs_enable_pan) |
845 { | 845 { |
846 for (b = 0; b < NUM_OF_QMF_CHANNELS; b++) | 846 for (b = 0; b < NUM_OF_QMF_CHANNELS; b++) |
847 { | 847 { |
848 /* Instead of dequantization, 20->64 mapping and 2^G(x,y) we do an | 848 /* Instead of dequantization, 20->64 mapping and 2^G(x,y) we do an |
849 inverse mapping 64->20 and look up the 2^G(x,y) values directly */ | 849 inverse mapping 64->20 and look up the 2^G(x,y) values directly */ |
850 ifreq = pan_inv_freq[b]; | 850 ifreq = pan_inv_freq[b]; |
851 qclass = pan_quant_class[ifreq]; | 851 qclass = pan_quant_class[ifreq]; |
852 | 852 |
853 if (ps->g_prev_pan_index[ifreq] >= 0) | 853 if (ps->g_prev_pan_index[ifreq] >= 0) |
854 { | 854 { |
855 pan_base[b] = pan_pow_2_pos[ps->g_prev_pan_index[ifreq]][qclass]; | 855 pan_base[b] = pan_pow_2_pos[ps->g_prev_pan_index[ifreq]][qclass]; |
856 } else { | 856 } else { |
857 pan_base[b] = pan_pow_2_neg[-ps->g_prev_pan_index[ifreq]][qclass]; | 857 pan_base[b] = pan_pow_2_neg[-ps->g_prev_pan_index[ifreq]][qclass]; |
858 } | 858 } |
859 | 859 |
860 /* 2^((a-b)/30) = 2^(a/30) * 1/(2^(b/30)) */ | 860 /* 2^((a-b)/30) = 2^(a/30) * 1/(2^(b/30)) */ |
861 /* a en b can be negative so we may need to inverse parts */ | 861 /* a en b can be negative so we may need to inverse parts */ |
862 if (ps->g_pan_index[ifreq] >= 0) | 862 if (ps->g_pan_index[ifreq] >= 0) |
863 { | 863 { |
864 if (ps->g_prev_pan_index[ifreq] >= 0) | 864 if (ps->g_prev_pan_index[ifreq] >= 0) |
865 { | 865 { |
866 pan_delta[b] = MUL_C(pan_pow_2_30_pos[ps->g_pan_index[ifreq]][qclass], | 866 pan_delta[b] = MUL_C(pan_pow_2_30_pos[ps->g_pan_index[ifreq]][qclass], |
867 pan_pow_2_30_neg[ps->g_prev_pan_index[ifreq]][qclass]); | 867 pan_pow_2_30_neg[ps->g_prev_pan_index[ifreq]][qclass]); |
868 } else { | 868 } else { |
869 pan_delta[b] = MUL_C(pan_pow_2_30_pos[ps->g_pan_index[ifreq]][qclass], | 869 pan_delta[b] = MUL_C(pan_pow_2_30_pos[ps->g_pan_index[ifreq]][qclass], |
870 pan_pow_2_30_pos[-ps->g_prev_pan_index[ifreq]][qclass]); | 870 pan_pow_2_30_pos[-ps->g_prev_pan_index[ifreq]][qclass]); |
871 } | 871 } |
872 } else { | 872 } else { |
873 if (ps->g_prev_pan_index[ifreq] >= 0) | 873 if (ps->g_prev_pan_index[ifreq] >= 0) |
874 { | 874 { |
875 pan_delta[b] = MUL_C(pan_pow_2_30_neg[-ps->g_pan_index[ifreq]][qclass], | 875 pan_delta[b] = MUL_C(pan_pow_2_30_neg[-ps->g_pan_index[ifreq]][qclass], |
876 pan_pow_2_30_neg[ps->g_prev_pan_index[ifreq]][qclass]); | 876 pan_pow_2_30_neg[ps->g_prev_pan_index[ifreq]][qclass]); |
877 } else { | 877 } else { |
878 pan_delta[b] = MUL_C(pan_pow_2_30_neg[-ps->g_pan_index[ifreq]][qclass], | 878 pan_delta[b] = MUL_C(pan_pow_2_30_neg[-ps->g_pan_index[ifreq]][qclass], |
887 for (b = 0; b < NUM_OF_QMF_CHANNELS; b++) | 887 for (b = 0; b < NUM_OF_QMF_CHANNELS; b++) |
888 { | 888 { |
889 tmp = pan_base[b]; | 889 tmp = pan_base[b]; |
890 | 890 |
891 coeff2 = DIV_R(REAL_CONST(2.0), (REAL_CONST(1.0) + tmp)); | 891 coeff2 = DIV_R(REAL_CONST(2.0), (REAL_CONST(1.0) + tmp)); |
892 coeff1 = MUL_R(coeff2, tmp); | 892 coeff1 = MUL_R(coeff2, tmp); |
893 | 893 |
894 QMF_RE(temp_l) = QMF_RE(X_left[s][b]); | 894 QMF_RE(temp_l) = QMF_RE(X_left[s][b]); |
895 QMF_IM(temp_l) = QMF_IM(X_left[s][b]); | 895 QMF_IM(temp_l) = QMF_IM(X_left[s][b]); |
896 QMF_RE(temp_r) = QMF_RE(X_right[s][b]); | 896 QMF_RE(temp_r) = QMF_RE(X_right[s][b]); |
897 QMF_IM(temp_r) = QMF_IM(X_right[s][b]); | 897 QMF_IM(temp_r) = QMF_IM(X_right[s][b]); |
898 | 898 |
899 QMF_RE(X_left[s][b]) = MUL_R(QMF_RE(temp_l), coeff1); | 899 QMF_RE(X_left[s][b]) = MUL_R(QMF_RE(temp_l), coeff1); |
900 QMF_IM(X_left[s][b]) = MUL_R(QMF_IM(temp_l), coeff1); | 900 QMF_IM(X_left[s][b]) = MUL_R(QMF_IM(temp_l), coeff1); |
901 QMF_RE(X_right[s][b]) = MUL_R(QMF_RE(temp_r), coeff2); | 901 QMF_RE(X_right[s][b]) = MUL_R(QMF_RE(temp_r), coeff2); |
902 QMF_IM(X_right[s][b]) = MUL_R(QMF_IM(temp_r), coeff2); | 902 QMF_IM(X_right[s][b]) = MUL_R(QMF_IM(temp_r), coeff2); |
903 | 903 |
904 /* 2^(a+k*b) = 2^a * 2^b * ... * 2^b */ | 904 /* 2^(a+k*b) = 2^a * 2^b * ... * 2^b */ |
905 /* ^^^^^^^^^^^^^^^ k times */ | 905 /* ^^^^^^^^^^^^^^^ k times */ |
906 pan_base[b] = MUL_C(pan_base[b], pan_delta[b]); | 906 pan_base[b] = MUL_C(pan_base[b], pan_delta[b]); |
907 } | 907 } |
908 } | 908 } |
909 } | 909 } |
910 } | 910 } |
911 | 911 |
912 drm_ps_info *drm_ps_init(void) | 912 drm_ps_info *drm_ps_init(void) |
913 { | 913 { |
914 drm_ps_info *ps = (drm_ps_info*)faad_malloc(sizeof(drm_ps_info)); | 914 drm_ps_info *ps = (drm_ps_info*)faad_malloc(sizeof(drm_ps_info)); |
915 | 915 |
916 memset(ps, 0, sizeof(drm_ps_info)); | 916 memset(ps, 0, sizeof(drm_ps_info)); |
917 | 917 |
918 return ps; | 918 return ps; |
919 } | 919 } |
920 | 920 |
921 void drm_ps_free(drm_ps_info *ps) | 921 void drm_ps_free(drm_ps_info *ps) |
925 | 925 |
926 /* main DRM PS decoding function */ | 926 /* main DRM PS decoding function */ |
927 uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate, qmf_t X_left[38][64], qmf_t X_right[38][64]) | 927 uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate, qmf_t X_left[38][64], qmf_t X_right[38][64]) |
928 { | 928 { |
929 uint8_t rateselect = (samplerate >= 24000); | 929 uint8_t rateselect = (samplerate >= 24000); |
930 | 930 |
931 if (ps == NULL) | 931 if (ps == NULL) |
932 { | 932 { |
933 memcpy(X_right, X_left, sizeof(qmf_t)*30*64); | 933 memcpy(X_right, X_left, sizeof(qmf_t)*30*64); |
934 return 0; | 934 return 0; |
935 } | 935 } |
936 | 936 |
937 if (!ps->drm_ps_data_available && !guess) | 937 if (!ps->drm_ps_data_available && !guess) |
938 { | 938 { |
939 memcpy(X_right, X_left, sizeof(qmf_t)*30*64); | 939 memcpy(X_right, X_left, sizeof(qmf_t)*30*64); |
940 memset(ps->g_prev_sa_index, 0, sizeof(ps->g_prev_sa_index)); | 940 memset(ps->g_prev_sa_index, 0, sizeof(ps->g_prev_sa_index)); |
941 memset(ps->g_prev_pan_index, 0, sizeof(ps->g_prev_pan_index)); | 941 memset(ps->g_prev_pan_index, 0, sizeof(ps->g_prev_pan_index)); |
942 return 0; | 942 return 0; |
947 if (!guess) | 947 if (!guess) |
948 { | 948 { |
949 ps->sa_decode_error = 0; | 949 ps->sa_decode_error = 0; |
950 ps->pan_decode_error = 0; | 950 ps->pan_decode_error = 0; |
951 drm_ps_delta_decode(ps); | 951 drm_ps_delta_decode(ps); |
952 } else | 952 } else |
953 { | 953 { |
954 ps->sa_decode_error = 1; | 954 ps->sa_decode_error = 1; |
955 ps->pan_decode_error = 1; | 955 ps->pan_decode_error = 1; |
956 /* don't even bother decoding */ | 956 /* don't even bother decoding */ |
957 } | 957 } |
958 | 958 |
959 ps->drm_ps_data_available = 0; | 959 ps->drm_ps_data_available = 0; |
960 | 960 |
961 drm_calc_sa_side_signal(ps, X_left, rateselect); | 961 drm_calc_sa_side_signal(ps, X_left, rateselect); |
962 drm_add_ambiance(ps, rateselect, X_left, X_right); | 962 drm_add_ambiance(ps, rateselect, X_left, X_right); |
963 | 963 |
964 if (ps->bs_enable_sa) | 964 if (ps->bs_enable_sa) |
965 { | 965 { |
966 ps->g_last_had_sa = 1; | 966 ps->g_last_had_sa = 1; |
967 | 967 |
968 memcpy(ps->g_prev_sa_index, ps->g_sa_index, sizeof(int8_t) * DRM_NUM_SA_BANDS); | 968 memcpy(ps->g_prev_sa_index, ps->g_sa_index, sizeof(int8_t) * DRM_NUM_SA_BANDS); |
969 | 969 |
970 } else { | 970 } else { |
971 ps->g_last_had_sa = 0; | 971 ps->g_last_had_sa = 0; |
972 } | 972 } |
973 | 973 |
974 if (ps->bs_enable_pan) | 974 if (ps->bs_enable_pan) |
975 { | 975 { |
976 drm_add_pan(ps, rateselect, X_left, X_right); | 976 drm_add_pan(ps, rateselect, X_left, X_right); |
977 | 977 |
978 ps->g_last_had_pan = 1; | 978 ps->g_last_had_pan = 1; |
979 | 979 |
980 memcpy(ps->g_prev_pan_index, ps->g_pan_index, sizeof(int8_t) * DRM_NUM_PAN_BANDS); | 980 memcpy(ps->g_prev_pan_index, ps->g_pan_index, sizeof(int8_t) * DRM_NUM_PAN_BANDS); |
981 | 981 |
982 } else { | 982 } else { |
983 ps->g_last_had_pan = 0; | 983 ps->g_last_had_pan = 0; |