Mercurial > libavcodec.hg
comparison ac3dec.c @ 7549:60b5c1e5a7ee libavcodec
use imdct_half in ac3
author | lorenm |
---|---|
date | Tue, 12 Aug 2008 01:30:24 +0000 |
parents | 8226017a65ae |
children | f9e4afa46993 |
comparison
equal
deleted
inserted
replaced
7548:3d1b177a1b8c | 7549:60b5c1e5a7ee |
---|---|
587 } | 587 } |
588 } | 588 } |
589 } | 589 } |
590 | 590 |
591 /** | 591 /** |
592 * Perform the 256-point IMDCT | |
593 */ | |
594 static void do_imdct_256(AC3DecodeContext *s, int chindex) | |
595 { | |
596 int i, k; | |
597 DECLARE_ALIGNED_16(float, x[128]); | |
598 FFTComplex z[2][64]; | |
599 float *o_ptr = s->tmp_output; | |
600 | |
601 for(i=0; i<2; i++) { | |
602 /* de-interleave coefficients */ | |
603 for(k=0; k<128; k++) { | |
604 x[k] = s->transform_coeffs[chindex][2*k+i]; | |
605 } | |
606 | |
607 /* run standard IMDCT */ | |
608 ff_imdct_calc(&s->imdct_256, o_ptr, x); | |
609 | |
610 /* reverse the post-rotation & reordering from standard IMDCT */ | |
611 for(k=0; k<32; k++) { | |
612 z[i][32+k].re = -o_ptr[128+2*k]; | |
613 z[i][32+k].im = -o_ptr[2*k]; | |
614 z[i][31-k].re = o_ptr[2*k+1]; | |
615 z[i][31-k].im = o_ptr[128+2*k+1]; | |
616 } | |
617 } | |
618 | |
619 /* apply AC-3 post-rotation & reordering */ | |
620 for(k=0; k<64; k++) { | |
621 o_ptr[ 2*k ] = -z[0][ k].im; | |
622 o_ptr[ 2*k+1] = z[0][63-k].re; | |
623 o_ptr[128+2*k ] = -z[0][ k].re; | |
624 o_ptr[128+2*k+1] = z[0][63-k].im; | |
625 o_ptr[256+2*k ] = -z[1][ k].re; | |
626 o_ptr[256+2*k+1] = z[1][63-k].im; | |
627 o_ptr[384+2*k ] = z[1][ k].im; | |
628 o_ptr[384+2*k+1] = -z[1][63-k].re; | |
629 } | |
630 } | |
631 | |
632 /** | |
633 * Inverse MDCT Transform. | 592 * Inverse MDCT Transform. |
634 * Convert frequency domain coefficients to time-domain audio samples. | 593 * Convert frequency domain coefficients to time-domain audio samples. |
635 * reference: Section 7.9.4 Transformation Equations | 594 * reference: Section 7.9.4 Transformation Equations |
636 */ | 595 */ |
637 static inline void do_imdct(AC3DecodeContext *s, int channels) | 596 static inline void do_imdct(AC3DecodeContext *s, int channels) |
638 { | 597 { |
639 int ch; | 598 int ch; |
640 | 599 |
641 for (ch=1; ch<=channels; ch++) { | 600 for (ch=1; ch<=channels; ch++) { |
642 if (s->block_switch[ch]) { | 601 if (s->block_switch[ch]) { |
643 do_imdct_256(s, ch); | 602 int i; |
603 float *x = s->tmp_output+128; | |
604 for(i=0; i<128; i++) | |
605 x[i] = s->transform_coeffs[ch][2*i]; | |
606 ff_imdct_half(&s->imdct_256, s->tmp_output, x); | |
607 s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, 0, 128); | |
608 for(i=0; i<128; i++) | |
609 x[i] = s->transform_coeffs[ch][2*i+1]; | |
610 ff_imdct_half(&s->imdct_256, s->delay[ch-1], x); | |
644 } else { | 611 } else { |
645 ff_imdct_calc(&s->imdct_512, s->tmp_output, s->transform_coeffs[ch]); | 612 ff_imdct_half(&s->imdct_512, s->tmp_output, s->transform_coeffs[ch]); |
646 } | 613 s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, 0, 128); |
647 /* For the first half of the block, apply the window, add the delay | 614 memcpy(s->delay[ch-1], s->tmp_output+128, 128*sizeof(float)); |
648 from the previous block, and send to output */ | 615 } |
649 s->dsp.vector_fmul_add_add(s->output[ch-1], s->tmp_output, | |
650 s->window, s->delay[ch-1], 0, 256, 1); | |
651 /* For the second half of the block, apply the window and store the | |
652 samples to delay, to be combined with the next block */ | |
653 s->dsp.vector_fmul_reverse(s->delay[ch-1], s->tmp_output+256, | |
654 s->window, 256); | |
655 } | 616 } |
656 } | 617 } |
657 | 618 |
658 /** | 619 /** |
659 * Downmix the output to mono or stereo. | 620 * Downmix the output to mono or stereo. |
684 /** | 645 /** |
685 * Upmix delay samples from stereo to original channel layout. | 646 * Upmix delay samples from stereo to original channel layout. |
686 */ | 647 */ |
687 static void ac3_upmix_delay(AC3DecodeContext *s) | 648 static void ac3_upmix_delay(AC3DecodeContext *s) |
688 { | 649 { |
689 int channel_data_size = sizeof(s->delay[0]); | 650 int channel_data_size = 128*sizeof(float); |
690 switch(s->channel_mode) { | 651 switch(s->channel_mode) { |
691 case AC3_CHMODE_DUALMONO: | 652 case AC3_CHMODE_DUALMONO: |
692 case AC3_CHMODE_STEREO: | 653 case AC3_CHMODE_STEREO: |
693 /* upmix mono to stereo */ | 654 /* upmix mono to stereo */ |
694 memcpy(s->delay[1], s->delay[0], channel_data_size); | 655 memcpy(s->delay[1], s->delay[0], channel_data_size); |
1048 ac3_downmix(s, s->transform_coeffs, 1); | 1009 ac3_downmix(s, s->transform_coeffs, 1); |
1049 } | 1010 } |
1050 | 1011 |
1051 if(!s->downmixed) { | 1012 if(!s->downmixed) { |
1052 s->downmixed = 1; | 1013 s->downmixed = 1; |
1014 // FIXME delay[] is half the size of the other downmixes | |
1053 ac3_downmix(s, s->delay, 0); | 1015 ac3_downmix(s, s->delay, 0); |
1054 } | 1016 } |
1055 | 1017 |
1056 do_imdct(s, s->out_channels); | 1018 do_imdct(s, s->out_channels); |
1057 } | 1019 } |