SubframeHeaderType

Enum SubframeHeaderType 

Source
pub enum SubframeHeaderType {
    Constant,
    Verbatim,
    Fixed {
        order: u8,
    },
    Lpc {
        order: NonZero<u8>,
    },
}
Expand description

A subframe header’s type and order

This is always a 6-bit field.

BitsTypeOrder
000000CONSTANTN/A
000001VERBATIMN/A
000010 to 000111reservedN/A
001000 to 001100FIXEDv - 8
001101 to 011111reservedN/A
100000 to 111111LPCv - 31

Variants§

§

Constant

All samples are the same

§Example

use flac_codec::stream::SubframeHeaderType;
use bitstream_io::{BitReader, BitRead, BigEndian};

let data: &[u8] = &[0b0_000000_0];
let mut r = BitReader::endian(data, BigEndian);
r.skip(1).unwrap();  // pad bit
assert_eq!(
    r.parse::<SubframeHeaderType>().unwrap(),
    SubframeHeaderType::Constant,
);
§

Verbatim

All samples as stored verbatim, without compression

§Example

use flac_codec::stream::SubframeHeaderType;
use bitstream_io::{BitReader, BitRead, BigEndian};

let data: &[u8] = &[0b0_000001_0];
let mut r = BitReader::endian(data, BigEndian);
r.skip(1).unwrap();  // pad bit
assert_eq!(
    r.parse::<SubframeHeaderType>().unwrap(),
    SubframeHeaderType::Verbatim,
);
§

Fixed

Samples are stored with one of a set of fixed LPC parameters

§Example

use flac_codec::stream::SubframeHeaderType;
use bitstream_io::{BitReader, BitRead, BigEndian};

let data: &[u8] = &[0b0_001100_0];
let mut r = BitReader::endian(data, BigEndian);
r.skip(1).unwrap();  // pad bit
assert_eq!(
    r.parse::<SubframeHeaderType>().unwrap(),
    SubframeHeaderType::Fixed { order: 0b001100 - 8 },  // order = 4
);

Fields

§order: u8

The predictor order, from 0..5

§

Lpc

Samples are stored with dynamic LPC parameters

§Example

use flac_codec::stream::SubframeHeaderType;
use bitstream_io::{BitReader, BitRead, BigEndian};
use std::num::NonZero;

let data: &[u8] = &[0b0_100000_0];
let mut r = BitReader::endian(data, BigEndian);
r.skip(1).unwrap();  // pad bit
assert_eq!(
    r.parse::<SubframeHeaderType>().unwrap(),
    SubframeHeaderType::Lpc {
        order: NonZero::new(0b100000 - 31).unwrap(),  // order = 1
    },
);

Fields

§order: NonZero<u8>

The predictor order, from 1..33

Implementations§

Source§

impl SubframeHeaderType

Source

pub const FIXED_COEFFS: [&[i64]; 5]

A set of FIXED subframe coefficients

Note that these are in the reverse order from how they’re usually presented, simply because we’ll be predicting samples in reverse order.

Trait Implementations§

Source§

impl Debug for SubframeHeaderType

Source§

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

Formats the value using the given formatter. Read more
Source§

impl FromBitStream for SubframeHeaderType

Source§

type Error = Error

Error generated during parsing, such as io::Error
Source§

fn from_reader<R: BitRead + ?Sized>(r: &mut R) -> Result<Self, Error>

Parse Self from reader
Source§

impl PartialEq for SubframeHeaderType

Source§

fn eq(&self, other: &SubframeHeaderType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToBitStream for SubframeHeaderType

Source§

type Error = Error

Error generated during building, such as io::Error
Source§

fn to_writer<W: BitWrite + ?Sized>(&self, w: &mut W) -> Result<(), Error>

Generate self to writer
Source§

fn bits<C>(&self) -> Result<C, Self::Error>
where C: Counter, Self: Sized,

Returns length of self in bits, if possible
Source§

fn bits_len<C, E>(&self) -> Result<C, Self::Error>
where C: Counter, E: Endianness, Self: Sized,

👎Deprecated since 4.0.0: use of bits() is preferred
Returns total length of self, if possible
Source§

impl Eq for SubframeHeaderType

Source§

impl StructuralPartialEq for SubframeHeaderType

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, 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.