Skip to content

Commit

Permalink
make Box::operator== virtual so that we can implement efficient compa…
Browse files Browse the repository at this point in the history
…risons (see Box_ispe)
  • Loading branch information
farindk committed Jun 10, 2024
1 parent 1e75661 commit 47fcf6e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions libheif/box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2169,6 +2169,18 @@ Error Box_ispe::write(StreamWriter& writer) const
}


bool Box_ispe::operator==(const Box& other) const
{
const auto* other_ispe = dynamic_cast<const Box_ispe*>(&other);
if (other_ispe == nullptr) {
return false;
}

return (m_image_width == other_ispe->m_image_width &&
m_image_height == other_ispe->m_image_height);
}


Error Box_ipma::parse(BitstreamRange& range)
{
parse_full_box_header(range);
Expand Down
4 changes: 3 additions & 1 deletion libheif/box.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class Box : public BoxHeader

int find_or_append_child_box(const std::shared_ptr<Box>& box);

bool operator==(const Box& other) const;
virtual bool operator==(const Box& other) const;

static bool equal(const std::shared_ptr<Box>& box1, const std::shared_ptr<Box>& box2);

Expand Down Expand Up @@ -584,6 +584,8 @@ class Box_ispe : public FullBox

Error write(StreamWriter& writer) const override;

bool operator==(const Box& other) const override;

protected:
Error parse(BitstreamRange& range) override;

Expand Down

0 comments on commit 47fcf6e

Please sign in to comment.