fn process_intensity_mpeg2(
    is_pos_table: &[(f32, f32); 32],
    is_pos: usize,
    mid_side: bool,
    ch0: &mut [f32],
    ch1: &mut [f32],
) {
    // For MPEG2 bitstreams, a scalefac can only be upto 5-bits long, so it's not possible for a
    // bitstream to specify an is_pos > 31. However, assert here to protect against logic errors in
    // the decoder.
    debug_assert!(is_pos <= 31);

    // A position of 7 is considered invalid and should be decoded as mid-side stereo if enabled.
    if is_pos != 7 {
        let (ratio_l, ratio_r) = is_pos_table[is_pos];

        for (l, r) in ch0.iter_mut().zip(ch1) {
            let is = *l;
            *l = ratio_l * is;
            *r = ratio_r * is;
        }
    }
    else if mid_side {
        process_mid_side(ch0, ch1);
    }
}
/// Decodes channel 0 of the intensity stereo coded signal into left and right channels for MPEG2
/// and MPEG2.5 bitstreams.
///
/// The intensity position for the scale factor band covering the samples in ch0 and ch1 slices is
/// required. Additionally, the appropriate intensity stereo ratios table is required, selected
/// based on the least-significant bit of scalefac_compress of channel 1.
///
/// As per ISO/IEC 13818-3, the following calculation may be performed to decode the intensity
/// stereo coded signal into left and right channels.
///
/// ```text
///      l[i] = ch0[i] * k_l
///      r[i] = ch0[i] * l_r
/// ```
///
/// where:
///      l[i], and r[i] are the left and right channels, respectively.
///      ch0[i] is the intensity stereo coded signal found in channel 0.
///      k_l, and k_r are the left and right channel ratios, respectively.
Decodes channel 0 of the intensity stereo coded signal into left and right channels for MPEG2
and MPEG2.5 bitstreams.

The intensity position for the scale factor band covering the samples in ch0 and ch1 slices is
required. Additionally, the appropriate intensity stereo ratios table is required, selected
based on the least-significant bit of scalefac_compress of channel 1.

As per ISO/IEC 13818-3, the following calculation may be performed to decode the intensity
stereo coded signal into left and right channels.



l[i], and r[i] are the left and right channels, respectively.
ch0[i] is the intensity stereo coded signal found in channel 0.
k_l, and k_r are the left and right channel ratios, respectively.
Decodes channel 0 of the intensity stereo coded signal into left and right channels for MPEG2 and MPEG2 . 5 bitstreams . The intensity position for the scale factor band covering the samples in ch0 and ch1 slices is required . Additionally the appropriate intensity stereo ratios table is required selected based on the least - significant bit of scalefac_compress of channel 1 . As per ISO / IEC 13818 - 3 the following calculation may be performed to decode the intensity stereo coded signal into left and right channels . l [ i ] and r [ i ] are the left and right channels respectively . ch0 [ i ] is the intensity stereo coded signal found in channel 0 . k_l and k_r are the left and right channel ratios respectively .
fn process_intensity_mpeg2(
    is_pos_table: &[(f32, f32); 32],
    is_pos: usize,
    mid_side: bool,
    ch0: &mut [f32],
    ch1: &mut [f32],
) {
    // For MPEG2 bitstreams, a scalefac can only be upto 5-bits long, so it's not possible for a
    // bitstream to specify an is_pos > 31. However, assert here to protect against logic errors in
    // the decoder.
    debug_assert!(is_pos <= 31);
    // A position of 7 is considered invalid and should be decoded as mid-side stereo if enabled.
    if is_pos != 7 {
        let (ratio_l, ratio_r) = is_pos_table[is_pos];
        for (l, r) in ch0.iter_mut().zip(ch1) {
            let is = *l;
            *l = ratio_l * is;
            *r = ratio_r * is;
        }
    }
    else if mid_side {
        process_mid_side(ch0, ch1);
    }
}
fn process_intensity_mpeg2 ( is_pos_table : & [ ( f32 , f32 ) ; 32 ] , is_pos : usize , mid_side : bool , ch0 : & mut [ f32 ] , ch1 : & mut [ f32 ] , ) { // For MPEG2 bitstreams, a scalefac can only be upto 5-bits long, so it's not possible for a // bitstream to specify an is_pos > 31. However, assert here to protect against logic errors in // the decoder. debug_assert ! ( is_pos 31 ) ; // A position of 7 is considered invalid and should be decoded as mid-side stereo if enabled. if is_pos != 7 { let ( ratio_l , ratio_r ) = is_pos_table [ is_pos ] ; for ( l , r ) in ch0 . iter_mut ( ) . zip ( ch1 ) { let is = * l ; * l = ratio_l * is ; * r = ratio_r * is ; } } else if mid_side { process_mid_side ( ch0 , ch1 ) ; } }
Decodes channel 0 of the intensity stereo coded signal into left and right channels for MPEG2
and MPEG2.5 bitstreams.
Decodes channel 0 of the intensity stereo coded signal into left and right channels for MPEG2 and MPEG2 . 5 bitstreams .
is_pos_table
&[(f32, f32); 32]
is_pos
usize
mid_side
bool
ch0
&mut [f32]
ch1
&mut [f32]
is_pos_table
&[(f32, f32); 32]
is_pos
usize
mid_side
bool
ch0
&mut [f32]
ch1
&mut [f32]