Skip to content

Commit

Permalink
mini: read signed integers
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Oct 19, 2024
1 parent c1cc7e0 commit 0853c8a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
7 changes: 7 additions & 0 deletions libheif/bitstream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,13 @@ uint32_t BitReader::get_bits32(int n)
return static_cast<uint32_t>(get_bits(n));
}

int32_t BitReader::get_bits32s()
{
uint32_t bits = get_bits(32);
return static_cast<int32_t>(bits);
}


bool BitReader::get_flag()
{
return (get_bits(1) == 0x01);
Expand Down
2 changes: 2 additions & 0 deletions libheif/bitstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ class BitReader

uint32_t get_bits32(int n);

int32_t get_bits32s();

/**
* Get a one-bit flag value.
*
Expand Down
14 changes: 7 additions & 7 deletions libheif/mini.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,20 +275,20 @@ Error Box_mini::parse(BitstreamRange &range, const heif_security_limits *limits)
if (m_tmap_cclv_flag)
{
m_tmap_cclv = std::make_shared<Box_cclv>();
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();
bool ccv_avg_luminance_value_present_flag = bits.get_flag();
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)
Expand Down

0 comments on commit 0853c8a

Please sign in to comment.