diff --git a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.cpp b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.cpp index 2fac28b623e..d3c8ec4a510 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.cpp @@ -127,6 +127,22 @@ void JPEG2000CaptureResolutionBox::dump(String const& prepend) const outln("{}- horizontal_capture_grid_resolution = {}/{} * 10^{}", prepend, horizontal_capture_grid_resolution_numerator, horizontal_capture_grid_resolution_denominator, horizontal_capture_grid_resolution_exponent); } +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 + // or streaming it into the jpeg2000 decoder would be nicer. + ByteBuffer local_codestream = TRY(ByteBuffer::create_uninitialized(stream.remaining())); + TRY(stream.read_until_filled(local_codestream)); + codestream = move(local_codestream); + return {}; +} + +void JPEG2000ContiguousCodestreamBox::dump(String const& prepend) const +{ + Box::dump(prepend); + outln("{}- codestream = {} bytes", prepend, codestream.size()); +} + ErrorOr JPEG2000SignatureBox::read_from_stream(BoxStream& stream) { signature = TRY(stream.read_value>()); diff --git a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.h b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.h index b7fce691129..c91a798e946 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.h +++ b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.h @@ -55,6 +55,13 @@ struct JPEG2000CaptureResolutionBox final : public Box { i8 horizontal_capture_grid_resolution_exponent { 0 }; }; +// I.5.4 Contiguous Codestream box +struct JPEG2000ContiguousCodestreamBox final : public Box { + BOX_SUBTYPE(JPEG2000ContiguousCodestreamBox); + + ByteBuffer codestream; +}; + struct JPEG2000SignatureBox final : public Box { BOX_SUBTYPE(JPEG2000SignatureBox); diff --git a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Reader.cpp b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Reader.cpp index 8f5b513c7fb..e5466d45d6e 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Reader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Reader.cpp @@ -27,6 +27,8 @@ ErrorOr Reader::read_entire_file() switch (type) { case BoxType::FileTypeBox: return TRY(FileTypeBox::create_from_stream(stream)); + case BoxType::JPEG2000ContiguousCodestreamBox: + return TRY(JPEG2000ContiguousCodestreamBox::create_from_stream(stream)); case BoxType::JPEG2000HeaderBox: return TRY(JPEG2000HeaderBox::create_from_stream(stream)); case BoxType::JPEG2000SignatureBox: