scuffle_h265/rbsp_trailing_bits.rs
1use std::io;
2
3use scuffle_bytes_util::BitReader;
4
5/// Described by ISO/IEC 23008-2 - 7.4.2.1
6pub(crate) fn rbsp_trailing_bits<R: io::Read>(bit_reader: &mut BitReader<R>) -> io::Result<()> {
7 let rbsp_stop_one_bit = bit_reader.read_bit()?;
8 if !rbsp_stop_one_bit {
9 return Err(io::Error::new(io::ErrorKind::InvalidData, "rbsp_stop_one_bit must be 1"));
10 }
11
12 // Skip to the end of the current byte (all rbsp_alignment_zero_bits)
13 bit_reader.align()?;
14
15 Ok(())
16}