From 8f9ed667cdc9cc31a31d53d35cf24cc45acb892a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Wed, 9 Oct 2024 13:46:17 -0400 Subject: [PATCH] h264parse: use of ceil_log2 instead of bit_storage According to the specification: The length of the slice_group_id[ i ] syntax element is Ceil( Log2( num_slice_groups_minus1 + 1 ) ) bits Part-of: --- .../gst-libs/gst/codecparsers/gsth264parser.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth264parser.c b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth264parser.c index 58514b5a29..c379061a14 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth264parser.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth264parser.c @@ -2320,7 +2320,8 @@ gst_h264_parse_pps (GstH264NalParser * nalparser, GstH264NalUnit * nalu, gint i; READ_UE (&nr, pps->pic_size_in_map_units_minus1); - bits = g_bit_storage (pps->num_slice_groups_minus1); + /* 7.4.2.2 7-23 slice_group_id */ + bits = gst_util_ceil_log2 (pps->num_slice_groups_minus1 + 1); pps->slice_group_id = g_new (guint8, pps->pic_size_in_map_units_minus1 + 1); @@ -2600,11 +2601,12 @@ gst_h264_parser_parse_slice_hdr (GstH264NalParser * nalparser, if (pps->num_slice_groups_minus1 > 0 && pps->slice_group_map_type >= 3 && pps->slice_group_map_type <= 5) { - /* Ceil(Log2(PicSizeInMapUnits / SliceGroupChangeRate + 1)) [7-33] */ + guint32 PicWidthInMbs = sps->pic_width_in_mbs_minus1 + 1; guint32 PicHeightInMapUnits = sps->pic_height_in_map_units_minus1 + 1; guint32 PicSizeInMapUnits = PicWidthInMbs * PicHeightInMapUnits; guint32 SliceGroupChangeRate = pps->slice_group_change_rate_minus1 + 1; + /* Ceil(Log2(PicSizeInMapUnits / SliceGroupChangeRate + 1)) [7-35] */ const guint n = gst_util_ceil_log2 (PicSizeInMapUnits / SliceGroupChangeRate + 1); READ_UINT16 (&nr, slice->slice_group_change_cycle, n);