Struct symphonia_core::io::vlc::CodebookBuilder
source · pub struct CodebookBuilder { /* private fields */ }
Expand description
CodebookBuilder
generates a Codebook
using a provided codebook specification and
description.
Implementations§
source§impl CodebookBuilder
impl CodebookBuilder
sourcepub fn new(bit_order: BitOrder) -> Self
pub fn new(bit_order: BitOrder) -> Self
Instantiates a new CodebookBuilder
.
The bit_order
parameter specifies if the codeword bits should be reversed when
constructing the codebook. If the BitReader
or BitStream
reading the constructed
codebook reads bits in an order different from the order of the provided codewords,
then this option can be used to make them compatible.
sourcepub fn new_sparse(bit_order: BitOrder) -> Self
pub fn new_sparse(bit_order: BitOrder) -> Self
Instantiates a new CodebookBuilder
for sparse codebooks.
A sparse codebook is one in which not all codewords are valid. These invalid codewords are effectively “unused” and have no value. Therefore, it is illegal for a bitstream to contain the codeword bit pattern.
Unused codewords are marked by having a length of 0.
sourcepub fn bits_per_read(&mut self, max_bits_per_read: u8) -> &mut Self
pub fn bits_per_read(&mut self, max_bits_per_read: u8) -> &mut Self
Specify the maximum number of bits that should be consumed from the source at a time.
This value must be within the range 1 <= max_bits_per_read
<= 16. Values outside of
this range will cause this function to panic. If not provided, a value will be
automatically chosen.
sourcepub fn make<E: CodebookEntry>(
&mut self,
code_words: &[u32],
code_lens: &[u8],
values: &[E::ValueType]
) -> Result<Codebook<E>>
pub fn make<E: CodebookEntry>( &mut self, code_words: &[u32], code_lens: &[u8], values: &[E::ValueType] ) -> Result<Codebook<E>>
Construct a Codebook
using the given codewords, their respective lengths, and values.
This function may fail if the provided codewords do not form a complete VLC tree, or if
the CodebookEntry
is undersized.
This function will panic if the number of code words, code lengths, and values differ.