From b3c423e4ca952c0b6fcdff0116e1a3745f32fc05 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Mon, 25 Mar 2024 21:31:31 -0400 Subject: [PATCH] LibGfx/ISOBMFF: Implement JPEG2000DefaultDisplayResolutionBox Found e.g. in http://opf-labs.org/format-corpus/jp2k-formats/balloon.jpf --- .../LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.cpp | 12 ++++++++++++ .../LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.h | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.cpp b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.cpp index a6ab46a1cf8..2fa8760b7b5 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.cpp @@ -130,6 +130,8 @@ ErrorOr JPEG2000ResolutionBox::read_from_stream(BoxStream& stream) switch (type) { case BoxType::JPEG2000CaptureResolutionBox: return TRY(JPEG2000CaptureResolutionBox::create_from_stream(stream)); + case BoxType::JPEG2000DefaultDisplayResolutionBox: + return TRY(JPEG2000DefaultDisplayResolutionBox::create_from_stream(stream)); default: return OptionalNone {}; } @@ -172,6 +174,16 @@ void JPEG2000CaptureResolutionBox::dump(String const& prepend) const JPEG2000ResolutionSubboxBase::dump(prepend); } +ErrorOr JPEG2000DefaultDisplayResolutionBox::read_from_stream(BoxStream& stream) +{ + return JPEG2000ResolutionSubboxBase::read_from_stream(stream); +} + +void JPEG2000DefaultDisplayResolutionBox::dump(String const& prepend) const +{ + JPEG2000ResolutionSubboxBase::dump(prepend); +} + ErrorOr JPEG2000ContiguousCodestreamBox::read_from_stream(BoxStream& stream) { // FIXME: It's wasteful to make a copy of all the image data here. Having just a ReadonlyBytes diff --git a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.h b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.h index cb1a2c8e6bc..c66f523ea79 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.h +++ b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.h @@ -72,6 +72,11 @@ struct JPEG2000CaptureResolutionBox final : public JPEG2000ResolutionSubboxBase BOX_SUBTYPE(JPEG2000CaptureResolutionBox); }; +// I.5.3.7.2 Default Display Resolution box +struct JPEG2000DefaultDisplayResolutionBox final : public JPEG2000ResolutionSubboxBase { + BOX_SUBTYPE(JPEG2000DefaultDisplayResolutionBox); +}; + // I.5.4 Contiguous Codestream box struct JPEG2000ContiguousCodestreamBox final : public Box { BOX_SUBTYPE(JPEG2000ContiguousCodestreamBox);