pub struct FrameHeader {
pub reserved: bool,
pub block_strategy: BlockStrategy,
pub block_size: u16,
pub sample_rate: SampleRate,
pub channel_assignment: ChannelAssignment,
pub sample_size: Option<u8>,
pub crc: u8,
}Fields§
§reserved: boolThis bit must remain reserved for 0 in order for a FLAC frame’s initial 15 bits to be distinguishable from the start of an MPEG audio frame (see also).
block_strategy: BlockStrategy<1> Blocking strategy:
- 0 : fixed-blocksize stream; frame header encodes the frame number
- 1 : variable-blocksize stream; frame header encodes the sample number
The “blocking strategy” bit must be the same throughout the entire stream. The “blocking strategy” bit determines how to calculate the sample number of the first sample in the frame. If the bit is 0 (fixed-blocksize), the frame header encodes the frame number as above, and the frame’s starting sample number will be the frame number times the blocksize. If it is 1 (variable-blocksize), the frame header encodes the frame’s starting sample number itself. (In the case of a fixed-blocksize stream, only the last block may be shorter than the stream blocksize; its starting sample number will be calculated as the frame number times the previous frame’s blocksize, or zero if it is the first frame).
block_size: u16<4> Block size in inter-channel samples:
0000: reserved0001: 192 samples0010-0101: 576 * (2^(n-2)) samples, i.e. 576/1152/2304/46080110: get 8 bit (blocksize-1) from end of header0111: get 16 bit (blocksize-1) from end of header1000-1111: 256 * (2^(n-8)) samples, i.e. 256/512/1024/2048/4096/8192/16384/32768
sample_rate: SampleRate<4> Sample rate:
0000: get from STREAMINFO metadata block0001: 88.2kHz0010: 176.4kHz0011: 192kHz0100: 8kHz0101: 16kHz0110: 22.05kHz0111: 24kHz1000: 32kHz1001: 44.1kHz1010: 48kHz1011: 96kHz1100: get 8 bit sample rate (in kHz) from end of header1101: get 16 bit sample rate (in Hz) from end of header1110: get 16 bit sample rate (in tens of Hz) from end of header1111: invalid, to prevent sync-fooling string of 1s
channel_assignment: ChannelAssignment<4> Channel assignment
0000-0111: (number of independent channels)-1. Where defined, the channel order follows SMPTE/ITU-R recommendations. The assignments are as follows:- 1 channel: mono
- 2 channels: left, right
- 3 channels: left, right, center
- 4 channels: front left, front right, back left, back right
- 5 channels: front left, front right, front center, back/surround left, back/surround right
- 6 channels: front left, front right, front center, LFE, back/surround left, back/surround right
- 7 channels: front left, front right, front center, LFE, back center, side left, side right
- 8 channels: front left, front right, front center, LFE, back left, back right, side left, side right
1000: left/side stereo: channel 0 is the left channel, channel 1 is the side(difference) channel1001: right/side stereo: channel 0 is the side(difference) channel, channel 1 is the right channel1010: mid/side stereo: channel 0 is the mid(average) channel, channel 1 is the side(difference) channel1011-1111: reserved
sample_size: Option<u8><3> Sample size in bits:
000 : get from STREAMINFO metadata block
001 : 8 bits per sample
010 : 12 bits per sample
011 : reserved
100 : 16 bits per sample
101 : 20 bits per sample
110 : 24 bits per sample
111 : reserved
crc: u8<8> CRC-8 (polynomial = x^8 + x^2 + x^1 + x^0, initialized with 0) of everything before the crc, including the sync code
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FrameHeader
impl RefUnwindSafe for FrameHeader
impl Send for FrameHeader
impl Sync for FrameHeader
impl Unpin for FrameHeader
impl UnwindSafe for FrameHeader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more