/// Decodes all intensity stereo coded bands within an entire long block for MPEG1, MPEG2, and
/// MPEG2.5 bitstreams, and returns the intensity bound.
Decodes all intensity stereo coded bands within an entire long block for MPEG1, MPEG2, and
MPEG2.5 bitstreams, and returns the intensity bound.
Decodes all intensity stereo coded bands within an entire long block for MPEG1 MPEG2 and MPEG2 . 5 bitstreams and returns the intensity bound .
fn process_intensity_long_block(
    header: &FrameHeader,
    granule: &Granule,
    mid_side: bool,
    ch0: &mut [f32; 576],
    ch1: &mut [f32; 576],
) -> usize {
    // As per ISO/IEC 11172-3 and ISO/IEC 13818-3, for long blocks that have intensity stereo
    // coding enabled, all bands starting after the last non-zero band in channel 1 may be
    // intensity stereo coded.
    //
    // The scale-factors in channel 1 for those respective bands determine the intensity position.
    // The rzero sample index is the index of last non-zero sample plus 1. If a band's start index
    // is >= the rzero sample index then that band could be intensity stereo coded.
    let rzero = granule.channels[1].rzero;
    let bands = &SFB_LONG_BANDS[header.sample_rate_idx];
    // Create an iterator that yields a band start-end pair, and scale-factor.
    let bands_iter = bands.iter()
                          .zip(&bands[1..])
                          .zip(granule.channels[1].scalefacs.iter());
    // Decode intensity stereo coded bands based on bitstream version.
    if header.is_mpeg1() {
        // Iterate over each band and decode the intensity stereo coding if the band is zero.
        for ((start, end), is_pos) in bands_iter {
            if *start >= rzero {
                process_intensity_mpeg1(
                    *is_pos as usize,
                    mid_side,
                    &mut ch0[*start..*end],
                    &mut ch1[*start..*end],
                );
            }
        }
    }
    else {
        // The process for decoding intensity stereo coded bands for MPEG2 bitstreams is the same as
        // MPEG1, except that the position ratio table changes based on the least-significant bit of
        // scalefac_compress.
        //
        // Select the ratio table, then process each band one-by-one just like MPEG1.
        let is_pos_table =
            &INTENSITY_STEREO_RATIOS_MPEG2[granule.channels[1].scalefac_compress as usize & 0x1];
        for ((start, end), is_pos) in bands_iter {
            if *start >= rzero {
                process_intensity_mpeg2(
                    is_pos_table,
                    *is_pos as usize,
                    mid_side,
                    &mut ch0[*start..*end],
                    &mut ch1[*start..*end],
                );
            }
        }
    }
    // The intensity bound (where intensity stereo coding begins) is rzero sample index. Note that
    // the actual bound should be rounded up to the next band, but the sample between rzero and the
    // next band are 0, therefore it's okay to ignore them.
    rzero
}
fn process_intensity_long_block ( header : & FrameHeader , granule : & Granule , mid_side : bool , ch0 : & mut [ f32 ; 576 ] , ch1 : & mut [ f32 ; 576 ] , ) -> usize { // As per ISO/IEC 11172-3 and ISO/IEC 13818-3, for long blocks that have intensity stereo // coding enabled, all bands starting after the last non-zero band in channel 1 may be // intensity stereo coded. // // The scale-factors in channel 1 for those respective bands determine the intensity position. // The rzero sample index is the index of last non-zero sample plus 1. If a band's start index // is >= the rzero sample index then that band could be intensity stereo coded. let rzero = granule . channels [ 1 ] . rzero ; let bands = & SFB_LONG_BANDS [ header . sample_rate_idx ] ; // Create an iterator that yields a band start-end pair, and scale-factor. let bands_iter = bands . iter ( ) . zip ( & bands [ 1 .. ] ) . zip ( granule . channels [ 1 ] . scalefacs . iter ( ) ) ; // Decode intensity stereo coded bands based on bitstream version. if header . is_mpeg1 ( ) { // Iterate over each band and decode the intensity stereo coding if the band is zero. for ( ( start , end ) , is_pos ) in bands_iter { if * start >= rzero { process_intensity_mpeg1 ( * is_pos as usize , mid_side , & mut ch0 [ * start .. * end ] , & mut ch1 [ * start .. * end ] , ) ; } } } else { // The process for decoding intensity stereo coded bands for MPEG2 bitstreams is the same as // MPEG1, except that the position ratio table changes based on the least-significant bit of // scalefac_compress. // // Select the ratio table, then process each band one-by-one just like MPEG1. let is_pos_table = & INTENSITY_STEREO_RATIOS_MPEG2 [ granule . channels [ 1 ] . scalefac_compress as usize & 0x1 ] ; for ( ( start , end ) , is_pos ) in bands_iter { if * start >= rzero { process_intensity_mpeg2 ( is_pos_table , * is_pos as usize , mid_side , & mut ch0 [ * start .. * end ] , & mut ch1 [ * start .. * end ] , ) ; } } } // The intensity bound (where intensity stereo coding begins) is rzero sample index. Note that // the actual bound should be rounded up to the next band, but the sample between rzero and the // next band are 0, therefore it's okay to ignore them. rzero }
Decodes all intensity stereo coded bands within an entire long block for MPEG1, MPEG2, and
MPEG2.5 bitstreams, and returns the intensity bound.
Decodes all intensity stereo coded bands within an entire long block for MPEG1 MPEG2 and MPEG2 . 5 bitstreams and returns the intensity bound .
header
&FrameHeader
granule
&Granule
mid_side
bool
ch0
&mut [f32; 576]
ch1
&mut [f32; 576]