Mercurial > libavcodec.hg
comparison ac3dec.c @ 5313:4bd60d3bab7e libavcodec
AC-3 decoder, soc revision 53, Aug 17 08:53:44 2006 UTC by cloud9
Converted the window from double to float.
Now sound produced is as good as sound produced by liba52.
author | jbr |
---|---|
date | Sat, 14 Jul 2007 16:00:05 +0000 |
parents | 2c875e6274d5 |
children | 7da10ff9dab1 |
comparison
equal
deleted
inserted
replaced
5312:2c875e6274d5 | 5313:4bd60d3bab7e |
---|---|
222 | 222 |
223 /** | 223 /** |
224 * Generate a Kaiser Window. | 224 * Generate a Kaiser Window. |
225 */ | 225 */ |
226 static void | 226 static void |
227 k_window_init(int alpha, double *window, int n, int iter) | 227 k_window_init(int alpha, float *window, int n, int iter) |
228 { | 228 { |
229 int j, k; | 229 int j, k; |
230 double a, x; | 230 float a, x; |
231 a = alpha * M_PI / n; | 231 a = alpha * M_PI / n; |
232 a = a*a; | 232 a = a*a; |
233 for(k=0; k<n; k++) { | 233 for(k=0; k<n; k++) { |
234 x = k * (n - k) * a; | 234 x = k * (n - k) * a; |
235 window[k] = 1.0; | 235 window[k] = 1.0; |
245 * @param window array to fill with window values | 245 * @param window array to fill with window values |
246 * @param n length of the window | 246 * @param n length of the window |
247 * @param iter number of iterations to use in BesselI0 | 247 * @param iter number of iterations to use in BesselI0 |
248 */ | 248 */ |
249 static void | 249 static void |
250 kbd_window_init(int alpha, double *window, int n, int iter) | 250 kbd_window_init(int alpha, float *window, int n, int iter) |
251 { | 251 { |
252 int k, n2; | 252 int k, n2; |
253 double *kwindow; | 253 float *kwindow; |
254 | 254 |
255 n2 = n >> 1; | 255 n2 = n >> 1; |
256 kwindow = &window[n2]; | 256 kwindow = &window[n2]; |
257 k_window_init(alpha, kwindow, n2, iter); | 257 k_window_init(alpha, kwindow, n2, iter); |
258 window[0] = kwindow[0]; | 258 window[0] = kwindow[0]; |
317 } | 317 } |
318 | 318 |
319 static void ac3_tables_init(void) | 319 static void ac3_tables_init(void) |
320 { | 320 { |
321 int i, j, k, l, v; | 321 int i, j, k, l, v; |
322 float alpha; | |
323 /* compute bndtab and masktab from bandsz */ | 322 /* compute bndtab and masktab from bandsz */ |
324 k = 0; | 323 k = 0; |
325 l = 0; | 324 l = 0; |
326 for(i=0;i<50;i++) { | 325 for(i=0;i<50;i++) { |
327 bndtab[i] = l; | 326 bndtab[i] = l; |
373 generate_quantizers_table_2(l11_quantizers_1, 11, 11, 11, 128); | 372 generate_quantizers_table_2(l11_quantizers_1, 11, 11, 11, 128); |
374 generate_quantizers_table_3(l11_quantizers_2, 11, 11, 11, 128); | 373 generate_quantizers_table_3(l11_quantizers_2, 11, 11, 11, 128); |
375 | 374 |
376 //for level-15 quantizers | 375 //for level-15 quantizers |
377 generate_quantizers_table(l15_quantizers, 15, 15); | 376 generate_quantizers_table(l15_quantizers, 15, 15); |
378 | |
379 /* Twiddle Factors for IMDCT. */ | |
380 for(i = 0; i < N / 4; i++) { | |
381 alpha = 2 * M_PI * (8 * i + 1) / (8 * N); | |
382 x_cos1[i] = -cos(alpha); | |
383 x_sin1[i] = -sin(alpha); | |
384 } | |
385 | |
386 for (i = 0; i < N / 8; i++) { | |
387 alpha = 2 * M_PI * (8 * i + 1) / (4 * N); | |
388 x_cos2[i] = -cos(alpha); | |
389 x_sin2[i] = -sin(alpha); | |
390 } | |
391 | 377 |
392 /* Kaiser-Bessel derived window. */ | 378 /* Kaiser-Bessel derived window. */ |
393 kbd_window_init(5, window, 256, 100); | 379 kbd_window_init(5, window, 256, 100); |
394 } | 380 } |
395 | 381 |
1915 static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, uint8_t *buf, int buf_size) | 1901 static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, uint8_t *buf, int buf_size) |
1916 { | 1902 { |
1917 AC3DecodeContext *ctx = (AC3DecodeContext *)avctx->priv_data; | 1903 AC3DecodeContext *ctx = (AC3DecodeContext *)avctx->priv_data; |
1918 int frame_start; | 1904 int frame_start; |
1919 int16_t *out_samples = (int16_t *)data; | 1905 int16_t *out_samples = (int16_t *)data; |
1920 int i, j, k, value, fs_58; | 1906 int i, j, k, value; |
1921 uint16_t crc1; | |
1922 | 1907 |
1923 av_log(NULL, AV_LOG_INFO, "decoding frame %d buf_size = %d\n", frame_count++, buf_size); | 1908 av_log(NULL, AV_LOG_INFO, "decoding frame %d buf_size = %d\n", frame_count++, buf_size); |
1924 | 1909 |
1925 //Synchronize the frame. | 1910 //Synchronize the frame. |
1926 frame_start = ac3_synchronize(buf, buf_size); | 1911 frame_start = ac3_synchronize(buf, buf_size); |