comparison cook.c @ 5345:af1c85da8982 libavcodec

fixpoint: separate windowing arithmetic imlt_window_float
author mhoffman
date Mon, 16 Jul 2007 11:52:46 +0000
parents b0d49997bd92
children b41036edcf2e
comparison
equal deleted inserted replaced
5344:b0d49997bd92 5345:af1c85da8982
660 } 660 }
661 return; 661 return;
662 } 662 }
663 } 663 }
664 664
665 665 /**
666 /** 666 * Apply transform window, overlap buffers.
667 * The modulated lapped transform, this takes transform coefficients
668 * and transforms them into timedomain samples.
669 * Apply transform window, overlap buffers, apply gain profile
670 * and buffer management.
671 * 667 *
672 * @param q pointer to the COOKContext 668 * @param q pointer to the COOKContext
673 * @param inbuffer pointer to the mltcoefficients 669 * @param inbuffer pointer to the mltcoefficients
674 * @param gains_ptr current and previous gains 670 * @param gains_ptr current and previous gains
675 * @param previous_buffer pointer to the previous buffer to be used for overlapping 671 * @param previous_buffer pointer to the previous buffer to be used for overlapping
676 */ 672 */
677 673
678 static void imlt_gain(COOKContext *q, float *inbuffer, 674 static void imlt_window_float (COOKContext *q, float *buffer1,
679 cook_gains *gains_ptr, float* previous_buffer) 675 cook_gains *gains_ptr, float *previous_buffer)
680 { 676 {
681 const float fc = q->pow2tab[gains_ptr->previous[0] + 63]; 677 const float fc = q->pow2tab[gains_ptr->previous[0] + 63];
682 float *buffer0 = q->mono_mdct_output;
683 float *buffer1 = q->mono_mdct_output + q->samples_per_channel;
684 int i; 678 int i;
685
686 /* Inverse modified discrete cosine transform */
687 q->mdct_ctx.fft.imdct_calc(&q->mdct_ctx, q->mono_mdct_output,
688 inbuffer, q->mdct_tmp);
689
690 /* The weird thing here, is that the two halves of the time domain 679 /* The weird thing here, is that the two halves of the time domain
691 * buffer are swapped. Also, the newest data, that we save away for 680 * buffer are swapped. Also, the newest data, that we save away for
692 * next frame, has the wrong sign. Hence the subtraction below. 681 * next frame, has the wrong sign. Hence the subtraction below.
693 * Almost sounds like a complex conjugate/reverse data/FFT effect. 682 * Almost sounds like a complex conjugate/reverse data/FFT effect.
694 */ 683 */
696 /* Apply window and overlap */ 685 /* Apply window and overlap */
697 for(i = 0; i < q->samples_per_channel; i++){ 686 for(i = 0; i < q->samples_per_channel; i++){
698 buffer1[i] = buffer1[i] * fc * q->mlt_window[i] - 687 buffer1[i] = buffer1[i] * fc * q->mlt_window[i] -
699 previous_buffer[i] * q->mlt_window[q->samples_per_channel - 1 - i]; 688 previous_buffer[i] * q->mlt_window[q->samples_per_channel - 1 - i];
700 } 689 }
690 }
691
692 /**
693 * The modulated lapped transform, this takes transform coefficients
694 * and transforms them into timedomain samples.
695 * Apply transform window, overlap buffers, apply gain profile
696 * and buffer management.
697 *
698 * @param q pointer to the COOKContext
699 * @param inbuffer pointer to the mltcoefficients
700 * @param gains_ptr current and previous gains
701 * @param previous_buffer pointer to the previous buffer to be used for overlapping
702 */
703
704 static void imlt_gain(COOKContext *q, float *inbuffer,
705 cook_gains *gains_ptr, float* previous_buffer)
706 {
707 float *buffer0 = q->mono_mdct_output;
708 float *buffer1 = q->mono_mdct_output + q->samples_per_channel;
709 int i;
710
711 /* Inverse modified discrete cosine transform */
712 q->mdct_ctx.fft.imdct_calc(&q->mdct_ctx, q->mono_mdct_output,
713 inbuffer, q->mdct_tmp);
714
715 imlt_window_float (q, buffer1, gains_ptr, previous_buffer);
701 716
702 /* Apply gain profile */ 717 /* Apply gain profile */
703 for (i = 0; i < 8; i++) { 718 for (i = 0; i < 8; i++) {
704 if (gains_ptr->now[i] || gains_ptr->now[i + 1]) 719 if (gains_ptr->now[i] || gains_ptr->now[i + 1])
705 interpolate(q, &buffer1[q->gain_size_factor * i], 720 interpolate(q, &buffer1[q->gain_size_factor * i],