Skip to content

Commit

Permalink
Merge pull request #248 from wader/avc_pps-correct-more-rbsp-data
Browse files Browse the repository at this point in the history
avc_pps: Correct check if there is more rbsp data
  • Loading branch information
wader authored May 4, 2022
2 parents d1ca8ff + b0096bc commit 6013588
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
8 changes: 3 additions & 5 deletions format/mpeg/avc_pps.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ func init() {
})
}

// TODO:
// ffmpeg does: get_bits_left(gb) > 0 && show_bits(gb, 8) != 0x80
// we do: there is more than trailing rbsp left
func moreRBSPData(d *decode.D) bool {
l := d.BitsLeft()
return l > 8 //|| (l == 8 && d.PeekBits(8) != 1)
return l >= 8 && d.PeekBits(8) != 0b1000_0000
}

func avcPPSDecode(d *decode.D, in interface{}) interface{} {
Expand Down Expand Up @@ -77,7 +74,6 @@ func avcPPSDecode(d *decode.D, in interface{}) interface{} {
d.FieldBool("constrained_intra_pred_flag")
d.FieldBool("redundant_pic_cnt_present_flag")

// TODO: more_data() is there non-zero bits left?
if moreRBSPData(d) {
d.FieldBool("transform_8x8_mode_flag")
picScalingMatrixPresentFlag := d.FieldBool("pic_scaling_matrix_present_flag")
Expand All @@ -89,6 +85,8 @@ func avcPPSDecode(d *decode.D, in interface{}) interface{} {
})
}
d.FieldSFn("second_chroma_qp_index_offset", sEV)
} else {
d.FieldBool("rbsp_stop_one_bit")
}

d.FieldRawLen("rbsp_trailing_bits", d.BitsLeft())
Expand Down
Binary file added format/mpeg/testdata/avc_pps_stop_more_8bit
Binary file not shown.
19 changes: 19 additions & 0 deletions format/mpeg/testdata/avc_pps_stop_more_8bit.fqtest
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$ fq -d avc_pps ddv avc_pps_stop_more_8bit
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: avc_pps_stop_more_8bit (avc_pps) 0x0-0x3.7 (4)
0x0|ce |. | pic_parameter_set_id: 0 0x0-0x0 (0.1)
0x0|ce |. | seq_parameter_set_id: 0 0x0.1-0x0.1 (0.1)
0x0|ce |. | entropy_coding_mode_flag: false 0x0.2-0x0.2 (0.1)
0x0|ce |. | bottom_field_pic_order_in_frame_present_flag: false 0x0.3-0x0.3 (0.1)
0x0|ce |. | num_slice_groups: 1 0x0.4-0x0.4 (0.1)
0x0|ce |. | num_ref_idx_l0_default_active: 1 0x0.5-0x0.5 (0.1)
0x0|ce |. | num_ref_idx_l1_default_active: 1 0x0.6-0x0.6 (0.1)
0x0|ce |. | weighted_pred_flag: false 0x0.7-0x0.7 (0.1)
0x0| 1f | . | weighted_bipred_idc: 0 0x1-0x1.1 (0.2)
0x0| 1f | . | pic_init_qp: 25 0x1.2-0x1.4 (0.3)
0x0| 1f | . | pic_init_qs: 26 0x1.5-0x1.5 (0.1)
0x0| 1f | . | chroma_qp_index_offset: 0 0x1.6-0x1.6 (0.1)
0x0| 1f | . | deblocking_filter_control_present_flag: true 0x1.7-0x1.7 (0.1)
0x0| 20 | | constrained_intra_pred_flag: false 0x2-0x2 (0.1)
0x0| 20 | | redundant_pic_cnt_present_flag: false 0x2.1-0x2.1 (0.1)
0x0| 20 | | rbsp_stop_one_bit: true 0x2.2-0x2.2 (0.1)
0x0| 20 00| | .| | rbsp_trailing_bits: raw bits 0x2.3-0x3.7 (1.5)

0 comments on commit 6013588

Please sign in to comment.