Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/codec/h264/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ pub struct SliceHeader {
/// the bottom field of a coded frame specified in clause 8.2.1.
pub delta_pic_order_cnt: [i32; 2],

/// This value is required by V4L2 stateless decode params so it is calculated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't matter which backend requires this - the parser should be backend-agnostic, so no need to mention V4L2 here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. If it is only needed for V4L2 purpose, it might not be a right place to calculate here in the first place. My todo to check and move this if relevant.

/// by parser while processing slice header.
pub pic_order_cnt_bit_size: usize,

/// Shall be equal to 0 for slices and slice data partitions belonging to
/// the primary coded picture. The value of `redundant_pic_cnt shall` be
/// greater than 0 for coded slices or coded slice data partitions of a
Expand Down Expand Up @@ -315,6 +319,10 @@ pub struct SliceHeader {
/// Decoded reference picture marking parsed using 7.3.3.3
pub dec_ref_pic_marking: RefPicMarking,

/// This value is required by V4L2 stateless decode params so it is calculated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

/// by parser while processing slice header.
pub dec_ref_pic_marking_bit_size: usize,

/// Specifies the index for determining the initialization table used in the
/// initialization process for context variables.
pub cabac_init_idc: u8,
Expand Down Expand Up @@ -2334,6 +2342,7 @@ impl Parser {
) -> anyhow::Result<()> {
let rpm = &mut header.dec_ref_pic_marking;

let num_bits_left = r.num_bits_left();
if nalu.header.idr_pic_flag {
rpm.no_output_of_prior_pics_flag = r.read_bit()?;
rpm.long_term_reference_flag = r.read_bit()?;
Expand Down Expand Up @@ -2372,6 +2381,7 @@ impl Parser {
}
}
}
header.dec_ref_pic_marking_bit_size = num_bits_left - r.num_bits_left();

Ok(())
}
Expand Down Expand Up @@ -2436,6 +2446,7 @@ impl Parser {
header.idr_pic_id = r.read_ue_max(0xffff)?;
}

let num_bits_left = r.num_bits_left();
if sps.pic_order_cnt_type == 0 {
header.pic_order_cnt_lsb =
r.read_bits(usize::from(sps.log2_max_pic_order_cnt_lsb_minus4) + 4)?;
Expand All @@ -2451,6 +2462,7 @@ impl Parser {
header.delta_pic_order_cnt[1] = r.read_se()?;
}
}
header.pic_order_cnt_bit_size = num_bits_left - r.num_bits_left();

if pps.redundant_pic_cnt_present_flag {
header.redundant_pic_cnt = r.read_ue_max(127)?;
Expand Down