FrameHeader

Struct FrameHeader 

Source
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: bool

This 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 : reserved
  • 0001 : 192 samples
  • 0010-0101 : 576 * (2^(n-2)) samples, i.e. 576/1152/2304/4608
  • 0110 : get 8 bit (blocksize-1) from end of header
  • 0111 : get 16 bit (blocksize-1) from end of header
  • 1000-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 block
  • 0001 : 88.2kHz
  • 0010 : 176.4kHz
  • 0011 : 192kHz
  • 0100 : 8kHz
  • 0101 : 16kHz
  • 0110 : 22.05kHz
  • 0111 : 24kHz
  • 1000 : 32kHz
  • 1001 : 44.1kHz
  • 1010 : 48kHz
  • 1011 : 96kHz
  • 1100 : get 8 bit sample rate (in kHz) from end of header
  • 1101 : get 16 bit sample rate (in Hz) from end of header
  • 1110 : get 16 bit sample rate (in tens of Hz) from end of header
  • 1111 : 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) channel
  • 1001 : right/side stereo: channel 0 is the side(difference) channel, channel 1 is the right channel
  • 1010 : mid/side stereo: channel 0 is the mid(average) channel, channel 1 is the side(difference) channel
  • 1011-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§

Source§

impl Debug for FrameHeader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.