LibGfx/ISOBMFF: Add JPEG2000ContiguousCodestreamBox

This commit is contained in:
Nico Weber 2024-03-22 15:37:49 -04:00 committed by Tim Schumacher
parent f372a9b346
commit c58996f4fc
Notes: sideshowbarker 2024-07-17 02:35:27 +09:00
3 changed files with 25 additions and 0 deletions

View file

@ -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<void> 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<void> JPEG2000SignatureBox::read_from_stream(BoxStream& stream)
{
signature = TRY(stream.read_value<BigEndian<u32>>());

View file

@ -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);

View file

@ -27,6 +27,8 @@ ErrorOr<BoxList> 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: