Skip to content

Commit

Permalink
mini: remove start offset from bit reader
Browse files Browse the repository at this point in the history
  • Loading branch information
bradh committed Oct 18, 2024
1 parent 2fab233 commit 9d547af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
10 changes: 0 additions & 10 deletions libheif/bitstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,16 +422,6 @@ class BitReader
return ((int64_t) bytes_remaining) * 8 + nextbits_cnt;
}

void set_start_offset(uint64_t offset)
{
start_offset = offset;
}

uint64_t get_file_offset() const
{
return start_offset + (data_length - bytes_remaining - (nextbits_cnt / 8));
}

private:
const uint8_t* data;
int data_length;
Expand Down
11 changes: 5 additions & 6 deletions libheif/mini.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Error Box_mini::parse(BitstreamRange &range, const heif_security_limits *limits)
std::vector<uint8_t> mini_data(length);
range.read(mini_data.data(), mini_data.size());
BitReader bits(mini_data.data(), (int)(mini_data.size()));
bits.set_start_offset(start_offset);
m_version = bits.get_bits8(2);
m_explicit_codec_types_flag = bits.get_flag();
m_float_flag = bits.get_flag();
Expand Down Expand Up @@ -417,26 +416,26 @@ Error Box_mini::parse(BitstreamRange &range, const heif_security_limits *limits)

if (m_alpha_flag && (m_alpha_item_data_size > 0))
{
m_alpha_item_data_offset = bits.get_file_offset();
m_alpha_item_data_offset = bits.get_current_byte_index() + start_offset;
bits.skip_bytes(m_alpha_item_data_size);
}
if (m_alpha_flag && m_gainmap_flag && (m_gainmap_item_data_size > 0))
{
m_gainmap_item_data_offset = bits.get_file_offset();
m_gainmap_item_data_offset = bits.get_current_byte_index() + start_offset;
bits.skip_bits(m_gainmap_item_data_size);
}

m_main_item_data_offset = bits.get_file_offset();
m_main_item_data_offset = bits.get_current_byte_index() + start_offset;
bits.skip_bytes(m_main_item_data_size);

if (m_exif_flag)
{
m_exif_item_data_offset = bits.get_file_offset();
m_exif_item_data_offset = bits.get_current_byte_index() + start_offset;
bits.skip_bytes(m_exif_item_data_size);
}
if (m_xmp_flag)
{
m_xmp_item_data_offset = bits.get_file_offset();
m_xmp_item_data_offset = bits.get_current_byte_index() + start_offset;
bits.skip_bytes(m_xmp_item_data_size);
}
return range.get_error();
Expand Down

0 comments on commit 9d547af

Please sign in to comment.