pub struct BitReader<'a> { /* private fields */ }Expand description
A bit reader for codec bitstreams. It properly handles emulation-prevention bytes and stop bits for H264.
Implementations§
Source§impl<'a> BitReader<'a>
impl<'a> BitReader<'a>
pub fn new(data: &'a [u8], needs_epb: bool) -> Self
Sourcepub fn read_bits<U: TryFrom<u32>>(
&mut self,
num_bits: usize,
) -> Result<U, String>
pub fn read_bits<U: TryFrom<u32>>( &mut self, num_bits: usize, ) -> Result<U, String>
Read up to 31 bits from the stream. Note that we don’t want to read 32 bits even though we’re returning a u32 because that would break the read_bits_signed() function. 31 bits should be overkill for compressed header parsing anyway.
Sourcepub fn read_bits_signed<U: TryFrom<i32>>(
&mut self,
num_bits: usize,
) -> Result<U, String>
pub fn read_bits_signed<U: TryFrom<i32>>( &mut self, num_bits: usize, ) -> Result<U, String>
Reads a two’s complement signed integer of length |num_bits|.
Sourcepub fn read_bits_aligned<U: TryFrom<u32>>(
&mut self,
num_bits: usize,
) -> Result<U, String>
pub fn read_bits_aligned<U: TryFrom<u32>>( &mut self, num_bits: usize, ) -> Result<U, String>
Reads an unsigned integer from the stream and checks if the stream is byte aligned.
Sourcepub fn skip_bits(&mut self, num_bits: usize) -> Result<(), String>
pub fn skip_bits(&mut self, num_bits: usize) -> Result<(), String>
Skip num_bits bits from the stream.
Sourcepub fn num_bits_left(&mut self) -> usize
pub fn num_bits_left(&mut self) -> usize
Returns the amount of bits left in the stream
Sourcepub fn has_more_rsbp_data(&mut self) -> bool
pub fn has_more_rsbp_data(&mut self) -> bool
Whether the stream still has RBSP data. Implements more_rbsp_data(). See the spec for more details.
Sourcepub fn read_ue<U: TryFrom<u32>>(&mut self) -> Result<U, String>
pub fn read_ue<U: TryFrom<u32>>(&mut self) -> Result<U, String>
Reads an Unsigned Exponential golomb coding number from the next bytes in the bitstream. This may advance the state of position within the bitstream even if the read operation is unsuccessful. See H264 Annex B specification 9.1 for details.
pub fn read_ue_bounded<U: TryFrom<u32>>( &mut self, min: u32, max: u32, ) -> Result<U, String>
pub fn read_ue_max<U: TryFrom<u32>>(&mut self, max: u32) -> Result<U, String>
Sourcepub fn read_se<U: TryFrom<i32>>(&mut self) -> Result<U, String>
pub fn read_se<U: TryFrom<i32>>(&mut self) -> Result<U, String>
Reads a signed exponential golomb coding number. Instead of using two’s complement, this scheme maps even integers to positive numbers and odd integers to negative numbers. The least significant bit indicates the sign. See H264 Annex B specification 9.1.1 for details.
pub fn read_se_bounded<U: TryFrom<i32>>( &mut self, min: i32, max: i32, ) -> Result<U, String>
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for BitReader<'a>
impl<'a> RefUnwindSafe for BitReader<'a>
impl<'a> Send for BitReader<'a>
impl<'a> Sync for BitReader<'a>
impl<'a> Unpin for BitReader<'a>
impl<'a> UnsafeUnpin for BitReader<'a>
impl<'a> UnwindSafe for BitReader<'a>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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