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 786ceef67c..6350f38a96 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265bitwriter.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265bitwriter.c @@ -25,7 +25,6 @@ #include "gsth265bitwriter.h" #include "nalutils.h" #include -#include #ifndef GST_DISABLE_GST_DEBUG #define GST_CAT_DEFAULT gst_h265_debug_category_get() @@ -1566,10 +1565,8 @@ _h265_bit_writer_slice_header (const GstH265SliceHdr * slice, CtbLog2SizeY = MinCbLog2SizeY + sps->log2_diff_max_min_luma_coding_block_size; CtbSizeY = 1 << CtbLog2SizeY; - PicHeightInCtbsY = - ceil ((gdouble) sps->pic_height_in_luma_samples / (gdouble) CtbSizeY); - PicWidthInCtbsY = - ceil ((gdouble) sps->pic_width_in_luma_samples / (gdouble) CtbSizeY); + PicHeightInCtbsY = div_ceil (sps->pic_height_in_luma_samples, CtbSizeY); + PicWidthInCtbsY = div_ceil (sps->pic_width_in_luma_samples, CtbSizeY); PicSizeInCtbsY = PicWidthInCtbsY * PicHeightInCtbsY; n = gst_util_ceil_log2 (PicSizeInCtbsY); 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 5d99c113bf..751b5638ac 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c @@ -70,7 +70,6 @@ #include #include #include -#include #ifndef GST_DISABLE_GST_DEBUG #define GST_CAT_DEFAULT gst_h265_debug_category_get() @@ -1180,7 +1179,7 @@ gst_h265_parser_parse_recovery_point (GstH265Parser * parser, goto error; } - max_pic_order_cnt_lsb = pow (2, (sps->log2_max_pic_order_cnt_lsb_minus4 + 4)); + max_pic_order_cnt_lsb = 1 << (sps->log2_max_pic_order_cnt_lsb_minus4 + 4); READ_SE_ALLOWED (nr, rp->recovery_poc_cnt, -max_pic_order_cnt_lsb / 2, max_pic_order_cnt_lsb - 1); READ_UINT8 (nr, rp->exact_match_flag, 1); @@ -2375,9 +2374,8 @@ gst_h265_parse_pps (GstH265Parser * parser, GstH265NalUnit * nalu, MinCbLog2SizeY + sps->log2_diff_max_min_luma_coding_block_size; CtbSizeY = 1 << CtbLog2SizeY; pps->PicHeightInCtbsY = - ceil ((gdouble) sps->pic_height_in_luma_samples / (gdouble) CtbSizeY); - pps->PicWidthInCtbsY = - ceil ((gdouble) sps->pic_width_in_luma_samples / (gdouble) CtbSizeY); + div_ceil (sps->pic_height_in_luma_samples, CtbSizeY); + pps->PicWidthInCtbsY = div_ceil (sps->pic_width_in_luma_samples, CtbSizeY); READ_UE_ALLOWED (&nr, pps->num_tile_columns_minus1, 0, pps->PicWidthInCtbsY - 1); @@ -2698,10 +2696,8 @@ gst_h265_parser_fill_pps (GstH265Parser * parser, GstH265PPS * pps) MinCbLog2SizeY = sps->log2_min_luma_coding_block_size_minus3 + 3; CtbLog2SizeY = MinCbLog2SizeY + sps->log2_diff_max_min_luma_coding_block_size; CtbSizeY = 1 << CtbLog2SizeY; - pps->PicHeightInCtbsY = - ceil ((gdouble) sps->pic_height_in_luma_samples / (gdouble) CtbSizeY); - pps->PicWidthInCtbsY = - ceil ((gdouble) sps->pic_width_in_luma_samples / (gdouble) CtbSizeY); + pps->PicHeightInCtbsY = div_ceil (sps->pic_height_in_luma_samples, CtbSizeY); + pps->PicWidthInCtbsY = div_ceil (sps->pic_width_in_luma_samples, CtbSizeY); if (pps->init_qp_minus26 < -(26 + qp_bd_offset)) return GST_H265_PARSER_BROKEN_LINK; diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/meson.build b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/meson.build index 82e9855a50..9c56f770a5 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/meson.build +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/meson.build @@ -58,7 +58,7 @@ gstcodecparsers = library('gstcodecparsers-' + api_version, soversion : soversion, darwin_versions : osxversion, install : true, - dependencies : [gstbase_dep, libm], + dependencies : [gstbase_dep], ) pkg_name = 'gstreamer-codecparsers-1.0' diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/nalutils.h b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/nalutils.h index 8e293ed934..f587fe0966 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/nalutils.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/nalutils.h @@ -261,3 +261,10 @@ gboolean count_exp_golomb_bits (guint32 value, guint * leading_zeros, guint * re goto error; \ } \ } + +static inline guint32 div_ceil (guint32 a, guint32 b) +{ + /* http://blog.pkh.me/p/36-figuring-out-round%2C-floor-and-ceil-with-integer-division.html */ + g_assert (b > 0); + return a / b + (a % b > 0); +}