Ver código fonte

LibGfx/ISOBMFF: Give JPEG2000HeaderBox its own type

...and make SuperBox a pure superclass that's not usable by itself.
Nico Weber 1 ano atrás
pai
commit
c84487ed2d

+ 1 - 12
Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Boxes.h

@@ -95,22 +95,11 @@ struct FileTypeBox final : public Box {
 
 // A box that contains other boxes.
 struct SuperBox : public Box {
-    static ErrorOr<NonnullOwnPtr<SuperBox>> create_from_stream(BoxType type, BoxStream& stream)
-    {
-        auto box = TRY(try_make<SuperBox>(type));
-        TRY(box->read_from_stream(stream));
-        return box;
-    }
-    SuperBox(BoxType type)
-        : m_box_type(type)
-    {
-    }
+    SuperBox() = default;
     virtual ErrorOr<void> read_from_stream(BoxStream&) override;
-    virtual BoxType box_type() const override { return m_box_type; }
     virtual void dump(String const& prepend = {}) const override;
 
 private:
-    BoxType m_box_type { BoxType::None };
     BoxList m_child_boxes;
 };
 

+ 11 - 0
Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.cpp

@@ -8,6 +8,17 @@
 
 namespace Gfx::ISOBMFF {
 
+ErrorOr<void> JPEG2000HeaderBox::read_from_stream(BoxStream& stream)
+{
+    TRY(SuperBox::read_from_stream(stream));
+    return {};
+}
+
+void JPEG2000HeaderBox::dump(String const& prepend) const
+{
+    SuperBox::dump(prepend);
+}
+
 ErrorOr<void> JPEG2000SignatureBox::read_from_stream(BoxStream& stream)
 {
     signature = TRY(stream.read_value<BigEndian<u32>>());

+ 4 - 0
Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.h

@@ -10,6 +10,10 @@
 
 namespace Gfx::ISOBMFF {
 
+struct JPEG2000HeaderBox final : public SuperBox {
+    BOX_SUBTYPE(JPEG2000HeaderBox);
+};
+
 struct JPEG2000SignatureBox final : public Box {
     BOX_SUBTYPE(JPEG2000SignatureBox);
 

+ 1 - 1
Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Reader.cpp

@@ -34,7 +34,7 @@ ErrorOr<BoxList> Reader::read_entire_file()
             TRY(top_level_boxes.try_append(TRY(FileTypeBox::create_from_stream(box_stream))));
             break;
         case BoxType::JPEG2000HeaderBox:
-            TRY(top_level_boxes.try_append(TRY(SuperBox::create_from_stream(box_header.type, box_stream))));
+            TRY(top_level_boxes.try_append(TRY(JPEG2000HeaderBox::create_from_stream(box_stream))));
             break;
         case BoxType::JPEG2000SignatureBox:
             TRY(top_level_boxes.try_append(TRY(JPEG2000SignatureBox::create_from_stream(box_stream))));