Skip to content

Commit

Permalink
implement Box_ster (stereo entity group)
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Jul 10, 2024
1 parent eb97cd6 commit 8a48bf8
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
35 changes: 34 additions & 1 deletion libheif/box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -548,10 +548,13 @@ Error Box::read(BitstreamRange& range, std::shared_ptr<Box>* result)
break;

case fourcc("altr"):
case fourcc("ster"):
box = std::make_shared<Box_EntityToGroup>();
break;

case fourcc("ster"):
box = std::make_shared<Box_ster>();
break;

case fourcc("dinf"):
box = std::make_shared<Box_dinf>();
break;
Expand Down Expand Up @@ -3259,6 +3262,36 @@ std::string Box_EntityToGroup::dump(Indent& indent) const
}


Error Box_ster::parse(BitstreamRange& range)
{
Error err = Box_EntityToGroup::parse(range);
if (err) {
return err;
}

if (entity_ids.size() != 2) {
return {heif_error_Invalid_input,
heif_suberror_Invalid_box_size,
"'ster' entity group does not exists of exactly two images"};
}

return Error::Ok;
}


std::string Box_ster::dump(Indent& indent) const
{
std::ostringstream sstr;
sstr << Box::dump(indent);

sstr << indent << "group id: " << group_id << "\n"
<< indent << "left image ID " << entity_ids[0] << "\n"
<< indent << "right image ID " << entity_ids[1] << "\n";

return sstr.str();
}



Error Box_pymd::parse(BitstreamRange& range)
{
Expand Down
14 changes: 14 additions & 0 deletions libheif/box.h
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,20 @@ class Box_EntityToGroup : public FullBox
};


class Box_ster : public Box_EntityToGroup
{
public:
std::string dump(Indent&) const override;

heif_item_id get_left_image() const { return entity_ids[0]; }
heif_item_id get_right_image() const { return entity_ids[1]; }

protected:

Error parse(BitstreamRange& range) override;
};


class Box_pymd : public Box_EntityToGroup
{
public:
Expand Down

0 comments on commit 8a48bf8

Please sign in to comment.