mux/hevc: measure coding type from slice_type; reuse shared BitReader
Honest PictureInfo population for HEVC, on the same principle as H.264. - Consolidate the bit reader: hevc.rs had its own BitReader (used by the SPS parser); h264 just gained one in startcode. Promote startcode's to the single shared pub(crate) reader (adds read_bits) and delete hevc's copy — one proven primitive, reused (SPS parse + both slice-type decoders). - hevc: decode slice_type from the first coded slice's slice_segment_header (H.265 §7.3.6.1) → I/P/B (§7.4.7.1). The offset to slice_type depends on num_extra_slice_header_bits, which lives in the PPS — so we parse it from the ACTIVE PPS (§7.3.2.3) and only measure slice_type when that PPS is known. With no active PPS we decline rather than guess: coding stays None, honestly absent. Set coding = coding_type_only(...) and source = pes.source; field order (pic_struct SEI) is not decoded, so field_order() is honestly None. - Tests: I/P/B from real slice headers, source carry, field-order absence, and the no-PPS honest-omission case.
This commit is contained in:
@@ -70,8 +70,17 @@ impl<'a> BitReader<'a> {
|
||||
Some(b as u32)
|
||||
}
|
||||
|
||||
/// Read `n` bits, MSB-first, into the low bits of a `u32`.
|
||||
pub fn read_bits(&mut self, n: u32) -> Option<u32> {
|
||||
let mut v = 0u32;
|
||||
for _ in 0..n {
|
||||
v = (v << 1) | self.read_bit()?;
|
||||
}
|
||||
Some(v)
|
||||
}
|
||||
|
||||
/// Skip `n` bits; `None` if that would run past the end.
|
||||
pub fn skip_bits(&mut self, n: usize) -> Option<()> {
|
||||
pub fn skip_bits(&mut self, n: u32) -> Option<()> {
|
||||
for _ in 0..n {
|
||||
self.read_bit()?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user