pub(super) fn read_side_info<B: ByteStream>(
    reader: &mut B,
    header: &FrameHeader,
    frame_data: &mut FrameData
) -> Result<usize> {

    let mut bs = BitStreamLtr::new(reader);

    // For MPEG version 1...
    let side_info_len = if header.is_mpeg1() {
        // First 9 bits is main_data_begin.
        frame_data.main_data_begin = bs.read_bits_leq32(9)? as u16;

        // Next 3 (>1 channel) or 5 (1 channel) bits are private and should be ignored.
        match header.channel_mode {
            ChannelMode::Mono => bs.ignore_bits(5)?,
            _                 => bs.ignore_bits(3)?,
        };

        // Next four (or 8, if more than one channel) are the SCFSI bits.
        for scfsi in &mut frame_data.scfsi[..header.n_channels()] {
            for band in scfsi.iter_mut() {
                *band = bs.read_bit()?;
            }
        }

        // The size of the side_info, fixed for layer 3.
        match header.channel_mode {
            ChannelMode::Mono => 17,
            _                 => 32,
        }
    }
    // For MPEG version 2...
    else {
        // First 8 bits is main_data_begin.
        frame_data.main_data_begin = bs.read_bits_leq32(8)? as u16;

        // Next 1 (1 channel) or 2 (>1 channel) bits are private and should be ignored.
        match header.channel_mode {
            ChannelMode::Mono => bs.ignore_bits(1)?,
            _                 => bs.ignore_bits(2)?,
        };

        // The size of the side_info, fixed for layer 3.
        match header.channel_mode {
            ChannelMode::Mono =>  9,
            _                 => 17,
        }
    };

    // Read the side_info for each granule.
    for granule in frame_data.granules_mut(header.version) {
        read_granule_side_info(&mut bs, granule, header)?;
    }

    Ok(side_info_len)
}
/// Reads the side_info of a MPEG audio frame from a `BitStream` into `FrameData`.
Reads the side_info of a MPEG audio frame from a `BitStream` into `FrameData`.
Reads the side_info of a MPEG audio frame from a ` BitStream ` into ` FrameData ` .
pub(super) fn read_side_info<B: ByteStream>(
    reader: &mut B,
    header: &FrameHeader,
    frame_data: &mut FrameData
) -> Result<usize> {
    let mut bs = BitStreamLtr::new(reader);
    // For MPEG version 1...
    let side_info_len = if header.is_mpeg1() {
        // First 9 bits is main_data_begin.
        frame_data.main_data_begin = bs.read_bits_leq32(9)? as u16;
        // Next 3 (>1 channel) or 5 (1 channel) bits are private and should be ignored.
        match header.channel_mode {
            ChannelMode::Mono => bs.ignore_bits(5)?,
            _                 => bs.ignore_bits(3)?,
        };
        // Next four (or 8, if more than one channel) are the SCFSI bits.
        for scfsi in &mut frame_data.scfsi[..header.n_channels()] {
            for band in scfsi.iter_mut() {
                *band = bs.read_bit()?;
            }
        }
        // The size of the side_info, fixed for layer 3.
        match header.channel_mode {
            ChannelMode::Mono => 17,
            _                 => 32,
        }
    }
    // For MPEG version 2...
    else {
        // First 8 bits is main_data_begin.
        frame_data.main_data_begin = bs.read_bits_leq32(8)? as u16;
        // Next 1 (1 channel) or 2 (>1 channel) bits are private and should be ignored.
        match header.channel_mode {
            ChannelMode::Mono => bs.ignore_bits(1)?,
            _                 => bs.ignore_bits(2)?,
        };
        // The size of the side_info, fixed for layer 3.
        match header.channel_mode {
            ChannelMode::Mono =>  9,
            _                 => 17,
        }
    };
    // Read the side_info for each granule.
    for granule in frame_data.granules_mut(header.version) {
        read_granule_side_info(&mut bs, granule, header)?;
    }
    Ok(side_info_len)
}
pub ( super ) fn read_side_info < B : ByteStream > ( reader : & mut B , header : & FrameHeader , frame_data : & mut FrameData ) -> Result < usize > { let mut bs = BitStreamLtr :: new ( reader ) ; // For MPEG version 1... let side_info_len = if header . is_mpeg1 ( ) { // First 9 bits is main_data_begin. frame_data . main_data_begin = bs . read_bits_leq32 ( 9 ) ? as u16 ; // Next 3 (>1 channel) or 5 (1 channel) bits are private and should be ignored. match header . channel_mode { ChannelMode :: Mono => bs . ignore_bits ( 5 ) ? , _ => bs . ignore_bits ( 3 ) ? , } ; // Next four (or 8, if more than one channel) are the SCFSI bits. for scfsi in & mut frame_data . scfsi [ .. header . n_channels ( ) ] { for band in scfsi . iter_mut ( ) { * band = bs . read_bit ( ) ? ; } } // The size of the side_info, fixed for layer 3. match header . channel_mode { ChannelMode :: Mono => 17 , _ => 32 , } } // For MPEG version 2... else { // First 8 bits is main_data_begin. frame_data . main_data_begin = bs . read_bits_leq32 ( 8 ) ? as u16 ; // Next 1 (1 channel) or 2 (>1 channel) bits are private and should be ignored. match header . channel_mode { ChannelMode :: Mono => bs . ignore_bits ( 1 ) ? , _ => bs . ignore_bits ( 2 ) ? , } ; // The size of the side_info, fixed for layer 3. match header . channel_mode { ChannelMode :: Mono => 9 , _ => 17 , } } ; // Read the side_info for each granule. for granule in frame_data . granules_mut ( header . version ) { read_granule_side_info ( & mut bs , granule , header ) ? ; } Ok ( side_info_len ) }
Reads the side_info of a MPEG audio frame from a `BitStream` into `FrameData`.
Reads the side_info of a MPEG audio frame from a ` BitStream ` into ` FrameData ` .
reader
&mut B
header
&FrameHeader
frame_data
&mut FrameData
reader
&mut B
header
&FrameHeader
frame_data
&mut FrameData