Skip to content

Commit

Permalink
move expansion of mini boxes into the Box_mini class (#1351)
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Nov 4, 2024
1 parent 91bb186 commit 6ef2c54
Show file tree
Hide file tree
Showing 8 changed files with 389 additions and 285 deletions.
13 changes: 13 additions & 0 deletions libheif/box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,19 @@ bool Box::operator==(const Box& other) const
}


bool Box::remove_child_box(const std::shared_ptr<const Box>& box)
{
for (int i=0; i<(int)m_children.size(); i++) {
if (m_children[i].get() == box.get()) {
m_children.erase(m_children.begin() + i);
return true;
}
}

return false;
}


bool Box::equal(const std::shared_ptr<Box>& box1, const std::shared_ptr<Box>& box2)
{
if (!box1 || !box2) {
Expand Down
13 changes: 13 additions & 0 deletions libheif/box.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,18 @@ class Box : public BoxHeader
return nullptr;
}

template<typename T> bool replace_child_box(const std::shared_ptr<T>& box)
{
for (auto & b : m_children) {
if (std::dynamic_pointer_cast<T>(b) != nullptr) {
b = box;
return true;
}
}

append_child_box(box);
return false;
}

template<typename T>
std::vector<std::shared_ptr<T>> get_child_boxes() const
Expand All @@ -233,6 +244,8 @@ class Box : public BoxHeader

bool has_child_boxes() const { return !m_children.empty(); }

bool remove_child_box(const std::shared_ptr<const Box>& box);

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

static bool equal(const std::shared_ptr<Box>& box1, const std::shared_ptr<Box>& box2);
Expand Down
2 changes: 1 addition & 1 deletion libheif/codecs/avif_boxes.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Box_av1C : public Box
{

// allow access to protected parse() method
friend class HeifFile;
friend class Box_mini;

public:
Box_av1C()
Expand Down
2 changes: 1 addition & 1 deletion libheif/codecs/hevc_boxes.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Box_hvcC : public Box
{

// allow access to protected parse() method
friend class HeifFile;
friend class Box_mini;

public:
Box_hvcC()
Expand Down
Loading

0 comments on commit 6ef2c54

Please sign in to comment.