LibGfx/ISOBMFF: Implement UserExtensionBox

.jpf (JPEG2000) files written by Photoshop contain a whole bunch of
these boxes.

fileformats.archiveteam.org/wiki/Boxes/atoms_format lists a few
UUID types. Of those 3, these are in Photoshop-written .jpf files:

* 0537cdab-9d0c-4431-a72a-fa561f2a113e Exif
* 2c4c0100-8504-40b9-a03e-562148d6dfeb Photoshop Image Resource
* be7acfcb-97a9-42e8-9c71-999491e3afac XMP
This commit is contained in:
Nico Weber 2024-03-25 20:33:29 -04:00 committed by Tim Flynn
parent 45fa6249df
commit a971625c49
Notes: sideshowbarker 2024-07-17 07:25:39 +09:00
3 changed files with 33 additions and 0 deletions

View File

@ -120,4 +120,28 @@ void SuperBox::dump(String const& prepend) const
child_box->dump(indented_prepend);
}
ErrorOr<void> UserExtensionBox::read_from_stream(BoxStream& stream)
{
// unsigned int(8)[16] uuid;
TRY(stream.read_until_filled(uuid));
// unsigned int(8) data[];
data = TRY(ByteBuffer::create_uninitialized(stream.remaining()));
TRY(stream.read_until_filled(data));
return {};
}
void UserExtensionBox::dump(String const& prepend) const
{
Box::dump(prepend);
auto indented_prepend = add_indent(prepend);
out("{}- uuid = ", prepend);
for (auto byte : uuid)
out("{:02x}"sv, byte);
outln();
outln("{}- data = [ {} bytes ]", prepend, data.size());
}
}

View File

@ -106,4 +106,11 @@ private:
BoxList m_child_boxes;
};
struct UserExtensionBox final : public Box {
BOX_SUBTYPE(UserExtensionBox);
Array<u8, 16> uuid;
ByteBuffer data;
};
}

View File

@ -35,6 +35,8 @@ ErrorOr<BoxList> Reader::read_entire_file()
return TRY(JPEG2000SignatureBox::create_from_stream(stream));
case BoxType::JPEG2000UUIDInfoBox:
return TRY(JPEG2000UUIDInfoBox::create_from_stream(stream));
case BoxType::UserExtensionBox:
return TRY(UserExtensionBox::create_from_stream(stream));
default:
return OptionalNone {};
}