pub struct FrameHeader {
pub blocking_strategy: bool,
pub block_size: BlockSize<u16>,
pub sample_rate: SampleRate<u32>,
pub channel_assignment: ChannelAssignment,
pub bits_per_sample: BitsPerSample,
pub frame_number: FrameNumber,
}Expand description
A FLAC frame header
| Bits | Field |
|---|---|
| 15 | sync code (0b111111111111100) |
| 1 | blocking_strategy |
| 4 | block_size |
| 4 | sample_rate |
| 4 | channel_assignment |
| 3 | bits_per_sample |
| 1 | padding (0) |
| 8-56 | frame_number |
| (8 or 16) | uncommon block size |
| (8 or 16) | uncommon sample rate |
| 8 | CRC-8 of header data |
§Example
use flac_codec::stream::{
FrameHeader, BlockSize, SampleRate, ChannelAssignment,
Independent, BitsPerSample, FrameNumber,
};
let mut data: &[u8] = &[
0b11111111, 0b1111100_0, // sync code + blocking
0b0110_1001, // block size + sample rate
0b0000_100_0, // channels + bps + pad
0x00, // frame number
0x13, // uncommon block size (+1)
0x64, // CRC-8
];
assert_eq!(
FrameHeader::read_subset(&mut data).unwrap(),
FrameHeader {
blocking_strategy: false,
block_size: BlockSize::Uncommon8(20),
sample_rate: SampleRate::Hz44100,
channel_assignment: ChannelAssignment::Independent(
Independent::Mono
),
bits_per_sample: BitsPerSample::Bps16,
frame_number: FrameNumber(0),
},
);Fields§
§blocking_strategy: boolThe blocking strategy bit
block_size: BlockSize<u16>The block size, in samples
sample_rate: SampleRate<u32>The sample rate, in Hz
channel_assignment: ChannelAssignmentHow the channels are assigned
bits_per_sample: BitsPerSampleThe number if bits per output sample
frame_number: FrameNumberThe frame’s number in the stream
Implementations§
Source§impl FrameHeader
impl FrameHeader
Sourcepub fn read<R: Read>(
reader: &mut R,
streaminfo: &Streaminfo,
) -> Result<Self, Error>
pub fn read<R: Read>( reader: &mut R, streaminfo: &Streaminfo, ) -> Result<Self, Error>
Reads new header from the given reader
Sourcepub fn read_subset<R: Read>(reader: &mut R) -> Result<Self, Error>
pub fn read_subset<R: Read>(reader: &mut R) -> Result<Self, Error>
Reads new header from the given reader
Trait Implementations§
Source§impl Debug for FrameHeader
impl Debug for FrameHeader
Source§impl FromBitStream for FrameHeader
impl FromBitStream for FrameHeader
Source§impl FromBitStreamWith<'_> for FrameHeader
impl FromBitStreamWith<'_> for FrameHeader
Source§impl PartialEq for FrameHeader
impl PartialEq for FrameHeader
Source§impl ToBitStream for FrameHeader
impl ToBitStream for FrameHeader
Source§impl ToBitStreamWith<'_> for FrameHeader
impl ToBitStreamWith<'_> for FrameHeader
Source§type Context = Streaminfo
type Context = Streaminfo
Some context to use when writing
Source§fn to_writer<W: BitWrite + ?Sized>(
&self,
w: &mut W,
_streaminfo: &Streaminfo,
) -> Result<(), Self::Error>
fn to_writer<W: BitWrite + ?Sized>( &self, w: &mut W, _streaminfo: &Streaminfo, ) -> Result<(), Self::Error>
Generate self to writer
impl Eq for FrameHeader
impl StructuralPartialEq for FrameHeader
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
Mutably borrows from an owned value. Read more