Skip to main content

BitReader

Struct BitReader 

Source
pub struct BitReader<'a> {
    data: &'a [u8],
    byte_pos: usize,
    bit_pos: u8,
}
Expand description

MSB-first のビットリーダ。H.264 の RBSP を読むための最小実装。

Fields§

§data: &'a [u8]§byte_pos: usize§bit_pos: u8

Implementations§

Source§

impl<'a> BitReader<'a>

Source

pub fn new(data: &'a [u8]) -> Self

Source

pub fn is_eof(&self) -> bool

残ビットが無い場合に true。

Source

pub fn more_rbsp_data(&self) -> bool

more_rbsp_data()(7.2): 末尾の rbsp_stop_one_bit より前に未読のビットが残っているか。 停止ビットは「最後の 0 でないバイトの最下位の 1」(後ろの 0 バイトは cabac_zero_word 等)。 複数スライスのフレームで、スライスの終わりを知るのに使う(2026-10-17)。

Source

pub fn read_bit(&mut self) -> u32

1 ビット読む。EOF 後は 0 を返す(呼び出し側で長さ管理する前提)。

Source

pub fn bit_position(&self) -> usize

先頭からのビット位置(CABAC の slice_data の開始位置を渡すのに使う)。

Source

pub fn byte_align(&mut self)

バイト境界まで進める(I_PCM の pcm_alignment_zero_bits 用)。

Source

pub fn read_bits(&mut self, n: u32) -> u32

n ビット読み(n <= 32)、無符号整数として返す。

Source

pub fn read_ue(&mut self) -> u32

符号なし Exp-Golomb ue(v)。 仕様: 先行ゼロ数 leadingZeroBits を数え、2^lzb - 1 + read_bits(lzb)。

Source

pub fn read_se(&mut self) -> i32

符号付き Exp-Golomb se(v)。ue を ±へマップ: 0->0, 1->1, 2->-1, 3->2, 4->-2 …

Trait Implementations§

Source§

impl MbSyntax for BitReader<'_>

Source§

fn residual8x8( &mut self, st: &DecState, bx4: usize, by4: usize, ) -> Result<([i32; 64], [u8; 4]), &'static str>

CAVLC の 8x8 は 4x4 の residual_block を 4 回読み、係数を交互に並べる(7.3.5.3.2: level8x8[4 * k + i] = level4x4_i[k])。nC は 4x4 ごとで、同じ 8x8 の先に読んだ 4x4 の total_coeff も使う。

Source§

fn mb_type( &mut self, _st: &DecState, _mb_x: u32, _mb_y: u32, _kind: SliceKind, ) -> Result<u32, &'static str>

Source§

fn sub_mb_type(&mut self, _kind: SliceKind) -> Result<u32, &'static str>

Source§

fn intra4x4_rem(&mut self) -> Option<i32>

prev_intra4x4_pred_mode_flag が 1 なら None、0 なら rem_intra4x4_pred_mode。
Source§

fn intra_chroma_mode( &mut self, _st: &DecState, _mb_x: u32, _mb_y: u32, ) -> Result<u8, &'static str>

Source§

fn cbp( &mut self, _st: &DecState, _mb_x: u32, _mb_y: u32, intra: bool, ) -> Result<u32, &'static str>

Source§

fn qp_delta(&mut self) -> Result<i32, &'static str>

Source§

fn ref_idx( &mut self, _st: &DecState, _list: usize, _px: usize, _py: usize, _pw: usize, _ph: usize, num_ref: u32, ) -> Result<i8, &'static str>

パーティション (px, py, pw, ph) の ref_idx_lX。
Source§

fn mvd( &mut self, _st: &DecState, _list: usize, _px: usize, _py: usize, _pw: usize, _ph: usize, ) -> Result<[i16; 2], &'static str>

パーティション (px, py, pw, ph) の mvd_lX。
Source§

fn residual( &mut self, st: &DecState, blk: ResBlock, ) -> Result<([i32; 16], u8), &'static str>

残差 1 ブロック(走査順の係数, 非ゼロ係数の数)。
Source§

fn pcm(&mut self, out: &mut [u8; 384])

I_PCM の 384 バイト(Y 256・Cb 64・Cr 64)。
Source§

fn transform_8x8(&mut self, _st: &DecState, _mb_x: u32, _mb_y: u32) -> bool

transform_size_8x8_flag。
Source§

fn mark_direct(&mut self, _px: usize, _py: usize, _pw: usize, _ph: usize)

B_Skip / B_Direct の領域を記録する(CABAC の ref_idx の文脈用)。

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<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> Same for T

Source§

type Output = T

Should always be Self
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.