Skip to main content

BitstreamWriter

Struct BitstreamWriter 

Source
pub struct BitstreamWriter {
    pub data: Box<[u8]>,
    pub data_size: i32,
    pub data_position: i32,
    pub cache: u32,
    pub cache_bits: i32,
}
Expand description

Bitstream writer structure (matches shine’s bitstream_t exactly) (ref/shine/src/lib/bitstream.h:4-10)

Fields§

§data: Box<[u8]>

Processed data

§data_size: i32

Total data size

§data_position: i32

Data position

§cache: u32

Bit stream cache

§cache_bits: i32

Free bits in cache

Implementations§

Source§

impl BitstreamWriter

Source

pub fn new(size: i32) -> Self

Open the bitstream for writing (matches shine_open_bit_stream) (ref/shine/src/lib/bitstream.c:15-22)

Source

pub fn put_bits(&mut self, val: u32, n: i32) -> EncodingResult<()>

Write N bits into the bit stream (matches shine_putbits exactly) (ref/shine/src/lib/bitstream.c:30-58)

§Arguments
  • val - value to write into the buffer
  • n - number of bits of val
Source

pub fn get_bits_count(&self) -> i32

Get the current bit count (matches shine_get_bits_count exactly) (ref/shine/src/lib/bitstream.c:60-62)

Source

pub fn get_data(&self) -> &[u8]

Get the output data

Source

pub fn flush(&mut self) -> EncodingResult<()>

Flush any remaining bits in the cache This matches shine’s behavior when there are remaining bits in cache

Source

pub fn byte_align(&mut self) -> EncodingResult<()>

Align to byte boundary by flushing partial bytes This matches shine’s byte alignment behavior

Trait Implementations§

Source§

impl Debug for BitstreamWriter

Source§

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

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

impl Default for BitstreamWriter

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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.