Преглед изворни кода

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
Nico Weber пре 1 година
родитељ
комит
a971625c49

+ 24 - 0
Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Boxes.cpp

@@ -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());
+}
+
 }

+ 7 - 0
Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Boxes.h

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

+ 2 - 0
Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Reader.cpp

@@ -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 {};
         }