mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-15 23:37:32 +03:00
LibGfx/ISOBMFF: Give JPEG2000HeaderBox its own type
...and make SuperBox a pure superclass that's not usable by itself.
This commit is contained in:
parent
65bd090815
commit
c84487ed2d
Notes:
sideshowbarker
2024-07-17 03:30:41 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/c84487ed2d Pull-request: https://github.com/SerenityOS/serenity/pull/23682 Reviewed-by: https://github.com/LucasChollet Reviewed-by: https://github.com/Zaggy1024 Reviewed-by: https://github.com/timschumi ✅
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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>>());
|
||||
|
@ -10,6 +10,10 @@
|
||||
|
||||
namespace Gfx::ISOBMFF {
|
||||
|
||||
struct JPEG2000HeaderBox final : public SuperBox {
|
||||
BOX_SUBTYPE(JPEG2000HeaderBox);
|
||||
};
|
||||
|
||||
struct JPEG2000SignatureBox final : public Box {
|
||||
BOX_SUBTYPE(JPEG2000SignatureBox);
|
||||
|
||||
|
@ -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))));
|
||||
|
Loading…
Reference in New Issue
Block a user