From ff9100eb4dff4b01fe9d702743f61021b24fa002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Wed, 9 Oct 2024 13:47:41 -0400 Subject: [PATCH] h265parser/bitwriter: add some comments for ceil_log2 use Validate that the length of field must be calculate with ceil_logs2 and not bit storage. Part-of: --- .../gst-libs/gst/codecparsers/gsth265bitwriter.c | 5 ++++- .../gst-libs/gst/codecparsers/gsth265parser.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265bitwriter.c b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265bitwriter.c index 8026c32a6d..786ceef67c 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265bitwriter.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265bitwriter.c @@ -1437,6 +1437,7 @@ _h265_slice_bit_writer_ref_pic_list_modification (const GstH265SliceHdr * if (rpl_mod->ref_pic_list_modification_flag_l0) { for (i = 0; i <= slice->num_ref_idx_l0_active_minus1; i++) { + /* 7.4.7.2 list_entry_l0 */ WRITE_BITS (bw, rpl_mod->list_entry_l0[i], n); } } @@ -1575,7 +1576,7 @@ _h265_bit_writer_slice_header (const GstH265SliceHdr * slice, if (slice->pps->dependent_slice_segments_enabled_flag) WRITE_BITS (bw, slice->dependent_slice_segment_flag, 1); - /* sice_segment_address parsing */ + /* 7.4.7.1 slice_segment_address parsing */ WRITE_BITS (bw, slice->segment_address, n); } @@ -1610,6 +1611,7 @@ _h265_bit_writer_slice_header (const GstH265SliceHdr * slice, sps->num_short_term_ref_pic_sets - 1) goto error; + /* 7.4.7.1 short_term_ref_pic_set_idx */ WRITE_BITS (bw, slice->short_term_ref_pic_set_idx, n); } @@ -1625,6 +1627,7 @@ _h265_bit_writer_slice_header (const GstH265SliceHdr * slice, for (i = 0; i < limit; i++) { if (i < slice->num_long_term_sps) { if (sps->num_long_term_ref_pics_sps > 1) { + /* 7.4.7.1 lt_idx_sps */ const guint n = gst_util_ceil_log2 (sps->num_long_term_ref_pics_sps); WRITE_BITS (bw, slice->lt_idx_sps[i], n); diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c index 5a79000e96..5d99c113bf 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c @@ -926,6 +926,7 @@ gst_h265_slice_parse_ref_pic_list_modification (GstH265SliceHdr * slice, if (rpl_mod->ref_pic_list_modification_flag_l0) { for (i = 0; i <= slice->num_ref_idx_l0_active_minus1; i++) { + /* 7.4.7.2 list_entry_l0 */ READ_UINT32 (nr, rpl_mod->list_entry_l0[i], n); CHECK_ALLOWED_MAX (rpl_mod->list_entry_l0[i], (NumPocTotalCurr - 1)); } @@ -2801,7 +2802,7 @@ gst_h265_parser_parse_slice_hdr (GstH265Parser * parser, if (pps->dependent_slice_segments_enabled_flag) READ_UINT8 (&nr, slice->dependent_slice_segment_flag, 1); - /* sice_segment_address parsing */ + /* 7.4.7.1 slice_segment_address parsing */ READ_UINT32 (&nr, slice->segment_address, n); } @@ -2835,6 +2836,7 @@ gst_h265_parser_parse_slice_hdr (GstH265Parser * parser, (nal_reader_get_pos (&nr) - pos) - (8 * (nal_reader_get_epb_count (&nr) - epb_pos)); } else if (sps->num_short_term_ref_pic_sets > 1) { + /* 7.4.7.1 short_term_ref_pic_set_idx */ const guint n = gst_util_ceil_log2 (sps->num_short_term_ref_pic_sets); READ_UINT8 (&nr, slice->short_term_ref_pic_set_idx, n); CHECK_ALLOWED_MAX (slice->short_term_ref_pic_set_idx, @@ -2855,6 +2857,7 @@ gst_h265_parser_parse_slice_hdr (GstH265Parser * parser, for (i = 0; i < limit; i++) { if (i < slice->num_long_term_sps) { if (sps->num_long_term_ref_pics_sps > 1) { + /* 7.4.7.1 lt_idx_sps */ const guint n = gst_util_ceil_log2 (sps->num_long_term_ref_pics_sps); READ_UINT8 (&nr, slice->lt_idx_sps[i], n);