pub struct Frame {
pub header: FrameHeader,
pub subframes: Vec<SubframeWidth>,
}Expand description
A whole FLAC frame
A FLAC frame consists of a header, one or more subframes (each corresponding to a different channel), and concludes with a CRC-16 checksum over all the data in the frame.
┌──────────┬────────┬┄┄┄┄┄┄┄┄┬┄┄┄┬────────┬┄┄┄┄┄┄┄┄┬┄┄┄╮
│ FLAC Tag │ Block₀ │ Block₁ ┆ … ┆ Frame₀ │ Frame₁ ┆ … ┆ FLAC File
└──────────┴────────┴┄┄┄┄┄┄┄┄┴┄┄┄┼────────┼┄┄┄┄┄┄┄┄┴┄┄┄╯
╭────────────────────────────────╯ ╰─────────╮
├──────────────┬───────────┬┄┄┄┄┄┄┄┄┄┄┄┬┄┄┄┬────────┤
│ Frame Header │ Subframe₀ │ Subframe₁ ┆ … ┆ CRC-16 │ FLAC Frame
└──────────────┴───────────┴┄┄┄┄┄┄┄┄┄┄┄┴┄┄┄┴────────┘§Example
use flac_codec::stream::{
Frame, FrameHeader, BlockSize, SampleRate, ChannelAssignment,
Independent, BitsPerSample, FrameNumber, SubframeWidth, Subframe,
};
let mut data: &[u8] = &[
// frame header
0xff, 0xf8, 0x69, 0x08, 0x00, 0x13, 0x64,
// subframe
0x00, 0x00, 0x00,
// CRC-16
0xd3, 0x3b,
];
assert_eq!(
Frame::read_subset(&mut data).unwrap(),
Frame {
header: 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),
},
subframes: vec![
SubframeWidth::Common(
Subframe::Constant {
block_size: 20,
sample: 0x00_00,
wasted_bps: 0,
},
)
],
},
);Fields§
§header: FrameHeaderThe FLAC frame’s header
subframes: Vec<SubframeWidth>A FLAC frame’s sub-frames
Implementations§
Source§impl Frame
impl Frame
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 frame 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 frame from the given reader
Subset files are streamable FLAC files whose decoding parameters are fully contained within each frame header.
Trait Implementations§
impl Eq for Frame
impl StructuralPartialEq for Frame
Auto Trait Implementations§
impl Freeze for Frame
impl RefUnwindSafe for Frame
impl Send for Frame
impl Sync for Frame
impl Unpin for Frame
impl UnwindSafe for Frame
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