pub enum BitsPerSample {
Streaminfo(SignedBitCount<32>),
Bps8,
Bps12,
Bps16,
Bps20,
Bps24,
Bps32,
}Expand description
The the possible bits-per-sample of a FLAC frame
Common bits-per-sample are stored as a 3-bit value, while uncommon bits-per-sample are stored in the STREAMINFO metadata block. Bits-per-sample defined in the STREAMINFO metadata block are only possible on a “non-subset” stream, which is not streamable.
| Bits | Bits-per-Sample |
|---|---|
000 | get from STREAMINFO |
001 | 8 |
010 | 12 |
011 | invalid |
100 | 16 |
101 | 20 |
110 | 24 |
111 | 32 |
§Example
use flac_codec::stream::BitsPerSample;
use bitstream_io::{BitReader, BitRead, BigEndian};
let data: &[u8] = &[
0b0000_100_0, // channels + bps + pad
];
let mut r = BitReader::endian(data, BigEndian);
r.skip(4).unwrap(); // skip channel assignment
assert_eq!(
r.parse::<BitsPerSample>().unwrap(),
BitsPerSample::Bps16,
);Variants§
Streaminfo(SignedBitCount<32>)
Gets bps from STREAMINFO metadata block
Bps8
8 bits-per-sample
Bps12
12 bits-per-sample
Bps16
16 bits-per-sample
Bps20
20 bits-per-sample
Bps24
24 bits-per-sample
Bps32
32 bits-per-sample
Implementations§
Source§impl BitsPerSample
impl BitsPerSample
Sourcepub fn checked_add(self, rhs: u32) -> Option<SignedBitCount<32>>
pub fn checked_add(self, rhs: u32) -> Option<SignedBitCount<32>>
Adds the given number of bits to this bit count, if possible.
If the number of bits would overflow the maximum count,
returns None.
Trait Implementations§
Source§impl Clone for BitsPerSample
impl Clone for BitsPerSample
Source§fn clone(&self) -> BitsPerSample
fn clone(&self) -> BitsPerSample
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BitsPerSample
impl Debug for BitsPerSample
Source§impl From<BitsPerSample> for SignedBitCount<32>
impl From<BitsPerSample> for SignedBitCount<32>
Source§fn from(bps: BitsPerSample) -> Self
fn from(bps: BitsPerSample) -> Self
Converts to this type from the input type.
Source§impl From<BitsPerSample> for u32
impl From<BitsPerSample> for u32
Source§fn from(bps: BitsPerSample) -> Self
fn from(bps: BitsPerSample) -> Self
Converts to this type from the input type.
Source§impl From<SignedBitCount<32>> for BitsPerSample
impl From<SignedBitCount<32>> for BitsPerSample
Source§fn from(bps: SignedBitCount<32>) -> Self
fn from(bps: SignedBitCount<32>) -> Self
Converts to this type from the input type.
Source§impl FromBitStream for BitsPerSample
impl FromBitStream for BitsPerSample
Source§impl FromBitStreamUsing for BitsPerSample
impl FromBitStreamUsing for BitsPerSample
Source§type Context = Option<SignedBitCount<32>>
type Context = Option<SignedBitCount<32>>
Some context to consume when parsing
Source§fn from_reader<R: BitRead + ?Sized>(
r: &mut R,
streaminfo_bps: Option<SignedBitCount<32>>,
) -> Result<Self, Error>
fn from_reader<R: BitRead + ?Sized>( r: &mut R, streaminfo_bps: Option<SignedBitCount<32>>, ) -> Result<Self, Error>
Parse Self from reader with the given context
Source§impl PartialEq<SignedBitCount<32>> for BitsPerSample
impl PartialEq<SignedBitCount<32>> for BitsPerSample
Source§impl PartialEq for BitsPerSample
impl PartialEq for BitsPerSample
Source§impl ToBitStream for BitsPerSample
impl ToBitStream for BitsPerSample
impl Copy for BitsPerSample
impl Eq for BitsPerSample
impl StructuralPartialEq for BitsPerSample
Auto Trait Implementations§
impl Freeze for BitsPerSample
impl RefUnwindSafe for BitsPerSample
impl Send for BitsPerSample
impl Sync for BitsPerSample
impl Unpin for BitsPerSample
impl UnwindSafe for BitsPerSample
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