/// Performs the the N-point Inverse Modified Discrete Cosine Transform.
///
/// The number of input samples in `src`, N, must equal the value `Imdct` was instantiated with.
/// The length of the output slice, `dst`, must equal 2N. Failing to meet these requirements
/// will throw an assertion.
///
/// This function performs no windowing, but each sample will be multiplied by `scale`. Typically,
/// scale will equal `sqrt(1.0 / N)` where N is the number of input samples, though each
/// application will vary.
Performs the the N-point Inverse Modified Discrete Cosine Transform.
The number of input samples in `src`, N, must equal the value `Imdct` was instantiated with.
The length of the output slice, `dst`, must equal 2N. Failing to meet these requirements
will throw an assertion.

This function performs no windowing, but each sample will be multiplied by `scale`. Typically,
scale will equal `sqrt(1.0 / N)` where N is the number of input samples, though each
application will vary.
Performs the the N - point Inverse Modified Discrete Cosine Transform . The number of input samples in ` src ` N must equal the value ` Imdct ` was instantiated with . The length of the output slice ` dst ` must equal 2N . Failing to meet these requirements will throw an assertion . This function performs no windowing but each sample will be multiplied by ` scale ` . Typically scale will equal ` sqrt ( 1 . 0 / N ) ` where N is the number of input samples though each application will vary .
pub fn imdct(&mut self, src: &[f32], dst: &mut [f32], scale: f32) {
        // The IMDCT produces 2N samples for N inputs. This algorithm defines the ouput length as
        // N.
        let n2 = self.n as usize;
        let n  = n2 << 1;
        let n4 = n2 >> 1;
        assert_eq!(dst.len(), n);
        assert_eq!(src.len(), n2);
        // Pre-process the input and place it in the second-half of dst.
        for ((ds, &src), &cos) in dst[n2..].iter_mut().zip(src).zip(&self.table) {
            *ds = src * cos;
        }
        // Compute the DCT-II in-place using the pre-processed samples that reside in the second-
        // half of dst.
        self.dct.dct_ii_inplace(&mut dst[n2..]);
        // DCT-II to DCT-IV
        //
        // Split dst into 4 evenly sized N/4 regions: [ a, b, c, d ]. Regions c & d contain the
        // DCT-II transformed samples from the previous step. After this step, regions b & c will
        // contain the DCT-II transformed samples.
        let (a, b) = dst.split_at_mut(n4);
        let (b, c) = b.split_at_mut(n4);
        let (c, d) = c.split_at_mut(n4);
        // Map c to b.
        b[0] = -0.5 * c[0];
        for i in 1..n4 {
            b[i] = -1.0 * (c[i] + b[i - 1]);
        }
        // Map d to c.
        c[0] = d[0] + b[n4 - 1];
        for i in 1..n4 {
            c[i] = d[i] - c[i - 1];
        }
        // DCT-IV to IMDCT
        //
        // Using symmetry, expand the DCT-IV to IMDCT. Multiply by the scale factor as this
        // is done.
        for (sa, &sc) in a.iter_mut().zip(c.iter()) {
            // Region a is a scaled copy of region c.
            *sa = scale * sc;
        }
        for ((sd, sc), &sb) in d.iter_mut().zip(c.iter_mut().rev()).zip(b.iter()) {
            // Region d is a scaled copy of region b.
            // Region c is a reversed and scaled copy of region b.
            let s = scale * sb;
            *sd = s;
            *sc = s;
        }
        for (sb, &sa) in b.iter_mut().zip(a.iter().rev()) {
            // Region b is an inverted copy of region c. Region c was overwrittern above,
            // but region a is a copy of the original region c.
            *sb = -1.0 * sa;
        }
    }
pub fn imdct ( & mut self , src : & [ f32 ] , dst : & mut [ f32 ] , scale : f32 ) { // The IMDCT produces 2N samples for N inputs. This algorithm defines the ouput length as // N. let n2 = self . n as usize ; let n = n2 << 1 ; let n4 = n2 >> 1 ; assert_eq ! ( dst len ( ) n ) ; assert_eq ! ( src len ( ) n2 ) ; // Pre-process the input and place it in the second-half of dst. for ( ( ds , & src ) , & cos ) in dst [ n2 .. ] . iter_mut ( ) . zip ( src ) . zip ( & self . table ) { * ds = src * cos ; } // Compute the DCT-II in-place using the pre-processed samples that reside in the second- // half of dst. self . dct . dct_ii_inplace ( & mut dst [ n2 .. ] ) ; // DCT-II to DCT-IV // // Split dst into 4 evenly sized N/4 regions: [ a, b, c, d ]. Regions c & d contain the // DCT-II transformed samples from the previous step. After this step, regions b & c will // contain the DCT-II transformed samples. let ( a , b ) = dst . split_at_mut ( n4 ) ; let ( b , c ) = b . split_at_mut ( n4 ) ; let ( c , d ) = c . split_at_mut ( n4 ) ; // Map c to b. b [ 0 ] = - 0.5 * c [ 0 ] ; for i in 1 .. n4 { b [ i ] = - 1.0 * ( c [ i ] + b [ i - 1 ] ) ; } // Map d to c. c [ 0 ] = d [ 0 ] + b [ n4 - 1 ] ; for i in 1 .. n4 { c [ i ] = d [ i ] - c [ i - 1 ] ; } // DCT-IV to IMDCT // // Using symmetry, expand the DCT-IV to IMDCT. Multiply by the scale factor as this // is done. for ( sa , & sc ) in a . iter_mut ( ) . zip ( c . iter ( ) ) { // Region a is a scaled copy of region c. * sa = scale * sc ; } for ( ( sd , sc ) , & sb ) in d . iter_mut ( ) . zip ( c . iter_mut ( ) . rev ( ) ) . zip ( b . iter ( ) ) { // Region d is a scaled copy of region b. // Region c is a reversed and scaled copy of region b. let s = scale * sb ; * sd = s ; * sc = s ; } for ( sb , & sa ) in b . iter_mut ( ) . zip ( a . iter ( ) . rev ( ) ) { // Region b is an inverted copy of region c. Region c was overwrittern above, // but region a is a copy of the original region c. * sb = - 1.0 * sa ; } }
Performs the the N-point Inverse Modified Discrete Cosine Transform.
Performs the the N - point Inverse Modified Discrete Cosine Transform .
&mut self
src
&[f32]
dst
&mut [f32]
scale
f32