From f372a9b346ce478fb729f729553452f4d3a482f1 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 22 Mar 2024 15:30:49 -0400 Subject: [PATCH] LibGfx/ISOBMFF: Add JPEG2000UUIDListBox --- .../ImageFormats/ISOBMFF/JPEG2000Boxes.cpp | 26 ++++++++++++++++++- .../ImageFormats/ISOBMFF/JPEG2000Boxes.h | 8 ++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.cpp b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.cpp index 5bd95032726..2fac28b623e 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.cpp @@ -141,8 +141,10 @@ void JPEG2000SignatureBox::dump(String const& prepend) const ErrorOr JPEG2000UUIDInfoBox::read_from_stream(BoxStream& stream) { - auto make_subbox = [](BoxType type, BoxStream&) -> ErrorOr>> { + auto make_subbox = [](BoxType type, BoxStream& stream) -> ErrorOr>> { switch (type) { + case BoxType::JPEG2000UUIDListBox: + return TRY(JPEG2000UUIDListBox::create_from_stream(stream)); default: return OptionalNone {}; } @@ -157,5 +159,27 @@ void JPEG2000UUIDInfoBox::dump(String const& prepend) const SuperBox::dump(prepend); } +ErrorOr JPEG2000UUIDListBox::read_from_stream(BoxStream& stream) +{ + u16 count = TRY(stream.read_value>()); + for (u32 i = 0; i < count; ++i) { + Array uuid; + TRY(stream.read_until_filled(uuid)); + uuids.append(uuid); + } + return {}; +} + +void JPEG2000UUIDListBox::dump(String const& prepend) const +{ + Box::dump(prepend); + for (auto const& uuid : uuids) { + out("{}- ", prepend); + for (auto byte : uuid) { + out("{:02x}", byte); + } + outln(); + } +} } diff --git a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.h b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.h index 9b1a56de506..b7fce691129 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.h +++ b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.h @@ -61,8 +61,16 @@ struct JPEG2000SignatureBox final : public Box { u32 signature { 0 }; }; +// I.7.3 UUID Info boxes (superbox) struct JPEG2000UUIDInfoBox final : public SuperBox { BOX_SUBTYPE(JPEG2000UUIDInfoBox); }; +// I.7.3.1 UUID List box +struct JPEG2000UUIDListBox final : public Box { + BOX_SUBTYPE(JPEG2000UUIDListBox); + + Vector> uuids; +}; + }