diff --git a/libheif/bitstream.cc b/libheif/bitstream.cc index 127f236326..d0962750ec 100644 --- a/libheif/bitstream.cc +++ b/libheif/bitstream.cc @@ -532,6 +532,13 @@ uint32_t BitReader::get_bits32(int n) return static_cast(get_bits(n)); } +int32_t BitReader::get_bits32s() +{ + uint32_t bits = get_bits(32); + return static_cast(bits); +} + + bool BitReader::get_flag() { return (get_bits(1) == 0x01); diff --git a/libheif/bitstream.h b/libheif/bitstream.h index be73eb64fe..84db7a7b93 100644 --- a/libheif/bitstream.h +++ b/libheif/bitstream.h @@ -387,6 +387,8 @@ class BitReader uint32_t get_bits32(int n); + int32_t get_bits32s(); + /** * Get a one-bit flag value. * diff --git a/libheif/mini.cc b/libheif/mini.cc index 468025a441..8ab2f6aa59 100644 --- a/libheif/mini.cc +++ b/libheif/mini.cc @@ -275,7 +275,7 @@ Error Box_mini::parse(BitstreamRange &range, const heif_security_limits *limits) if (m_tmap_cclv_flag) { m_tmap_cclv = std::make_shared(); - bits.skip_bits(2); + bits.skip_bits(2); // skip ccv_cancel_flag and ccv_persistence_flag bool ccv_primaries_present_flag = bits.get_flag(); bool ccv_min_luminance_value_present_flag = bits.get_flag(); bool ccv_max_luminance_value_present_flag = bits.get_flag(); @@ -283,12 +283,12 @@ Error Box_mini::parse(BitstreamRange &range, const heif_security_limits *limits) bits.skip_bits(2); if (ccv_primaries_present_flag) { - int32_t x0 = bits.get_bits32(32); - int32_t y0 = bits.get_bits32(32); - int32_t x1 = bits.get_bits32(32); - int32_t y1 = bits.get_bits32(32); - int32_t x2 = bits.get_bits32(32); - int32_t y2 = bits.get_bits32(32); + int32_t x0 = bits.get_bits32s(); + int32_t y0 = bits.get_bits32s(); + int32_t x1 = bits.get_bits32s(); + int32_t y1 = bits.get_bits32s(); + int32_t x2 = bits.get_bits32s(); + int32_t y2 = bits.get_bits32s(); m_tmap_cclv->set_primaries(x0, y0, x1, y1, x2, y2); } if (ccv_min_luminance_value_present_flag)