pub enum Residuals<I> {
Method0 {
partitions: Vec<ResidualPartition<0b1111, I>>,
},
Method1 {
partitions: Vec<ResidualPartition<0b11111, I>>,
},
}Expand description
Residual values for FIXED or LPC subframes
| Bits | Meaning |
|---|---|
| 2 | residual coding method |
| 4 | partition order |
| residual partition₀ | |
| (residual partition₁) | |
| ⋮ |
The residual coding method can be 0 or 1. A coding method of 0 means 4-bit Rice parameters in residual partitions. A coding method of 5 means 5-bit Rice parameters in residual partitions (method 0 is the common case).
The number of residual partitions equals 2ⁿ where n is the partition order.
§Example
use flac_codec::stream::{Residuals, ResidualPartition};
use bitstream_io::{BitReader, BitRead, BigEndian, BitCount};
let data: &[u8] = &[
0b00_0000_00, // coding method + partition order + partition
// residual partition
0b01010001,
0b00010001,
0b00010001,
0b00010001,
0b00010001,
0b00010001,
0b00010001,
0b00010001,
0b00010001,
0b00010000,
0b00000000,
];
let mut r = BitReader::endian(data, BigEndian);
assert_eq!(
r.parse_using::<Residuals<i32>>((20, 1)).unwrap(),
// coding method = 0b00
// partition order = 0b0000, or 1 partition
Residuals::Method0 {
partitions: vec![
ResidualPartition::Standard {
rice: BitCount::new::<1>(),
residuals: vec![
1, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2
],
}
],
},
);Variants§
Method0
Coding method 0
Fields
§
partitions: Vec<ResidualPartition<0b1111, I>>The residual partitions
Method1
Coding method 1
Fields
§
partitions: Vec<ResidualPartition<0b11111, I>>The residual partitions
Implementations§
Source§impl<I> Residuals<I>
impl<I> Residuals<I>
Sourcepub fn coding_method(&self) -> CodingMethod
pub fn coding_method(&self) -> CodingMethod
The type of coding method in use, either Rice or Rice2
Sourcepub fn partition_order(&self) -> u32
pub fn partition_order(&self) -> u32
The residual block’s partition order
Trait Implementations§
Source§impl<I: SignedInteger> FromBitStreamUsing for Residuals<I>
impl<I: SignedInteger> FromBitStreamUsing for Residuals<I>
Source§impl<I: SignedInteger> ToBitStream for Residuals<I>
impl<I: SignedInteger> ToBitStream for Residuals<I>
impl<I: Eq> Eq for Residuals<I>
impl<I> StructuralPartialEq for Residuals<I>
Auto Trait Implementations§
impl<I> Freeze for Residuals<I>
impl<I> RefUnwindSafe for Residuals<I>where
I: RefUnwindSafe,
impl<I> Send for Residuals<I>where
I: Send,
impl<I> Sync for Residuals<I>where
I: Sync,
impl<I> Unpin for Residuals<I>where
I: Unpin,
impl<I> UnwindSafe for Residuals<I>where
I: UnwindSafe,
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