diff --git a/format/mpeg/avc_pps.go b/format/mpeg/avc_pps.go index 668337e3..bf28eb79 100644 --- a/format/mpeg/avc_pps.go +++ b/format/mpeg/avc_pps.go @@ -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{} { @@ -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") @@ -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()) diff --git a/format/mpeg/testdata/avc_pps_stop_more_8bit b/format/mpeg/testdata/avc_pps_stop_more_8bit new file mode 100644 index 00000000..f914683c Binary files /dev/null and b/format/mpeg/testdata/avc_pps_stop_more_8bit differ diff --git a/format/mpeg/testdata/avc_pps_stop_more_8bit.fqtest b/format/mpeg/testdata/avc_pps_stop_more_8bit.fqtest new file mode 100644 index 00000000..f0095ff8 --- /dev/null +++ b/format/mpeg/testdata/avc_pps_stop_more_8bit.fqtest @@ -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)