LibGfx/ISOBMFF: Start creating JPEG2000 box types

`isobmff` can now dump the id in a JPEG2000SignatureBox.
Creates JPEG2000Boxes.{h,cpp} to house JPEG2000 box types.
This commit is contained in:
Nico Weber 2024-03-22 13:50:02 -04:00 committed by Tim Schumacher
parent a073b2d047
commit 65bd090815
Notes: sideshowbarker 2024-07-17 05:58:46 +09:00
5 changed files with 49 additions and 0 deletions

View File

@ -72,6 +72,7 @@ shared_library("LibGfx") {
"ImageFormats/ICOLoader.cpp",
"ImageFormats/ILBMLoader.cpp",
"ImageFormats/ISOBMFF/Boxes.cpp",
"ImageFormats/ISOBMFF/JPEG2000Boxes.cpp",
"ImageFormats/ISOBMFF/Reader.cpp",
"ImageFormats/ImageDecoder.cpp",
"ImageFormats/JBIG2Loader.cpp",

View File

@ -46,6 +46,7 @@ set(SOURCES
ImageFormats/ILBMLoader.cpp
ImageFormats/ImageDecoder.cpp
ImageFormats/ISOBMFF/Boxes.cpp
ImageFormats/ISOBMFF/JPEG2000Boxes.cpp
ImageFormats/ISOBMFF/Reader.cpp
ImageFormats/JBIG2Loader.cpp
ImageFormats/JPEGLoader.cpp

View File

@ -0,0 +1,23 @@
/*
* Copyright (c) 2024, Nico Weber <thakis@chromium.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "JPEG2000Boxes.h"
namespace Gfx::ISOBMFF {
ErrorOr<void> JPEG2000SignatureBox::read_from_stream(BoxStream& stream)
{
signature = TRY(stream.read_value<BigEndian<u32>>());
return {};
}
void JPEG2000SignatureBox::dump(String const& prepend) const
{
Box::dump(prepend);
outln("{}- signature = {:#08x}", prepend, signature);
}
}

View File

@ -0,0 +1,19 @@
/*
* Copyright (c) 2024, Nico Weber <thakis@chromium.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "Boxes.h"
namespace Gfx::ISOBMFF {
struct JPEG2000SignatureBox final : public Box {
BOX_SUBTYPE(JPEG2000SignatureBox);
u32 signature { 0 };
};
}

View File

@ -5,6 +5,8 @@
*/
#include "Reader.h"
#include "JPEG2000Boxes.h"
#include <AK/Function.h>
namespace Gfx::ISOBMFF {
@ -34,6 +36,9 @@ ErrorOr<BoxList> Reader::read_entire_file()
case BoxType::JPEG2000HeaderBox:
TRY(top_level_boxes.try_append(TRY(SuperBox::create_from_stream(box_header.type, box_stream))));
break;
case BoxType::JPEG2000SignatureBox:
TRY(top_level_boxes.try_append(TRY(JPEG2000SignatureBox::create_from_stream(box_stream))));
break;
default:
TRY(top_level_boxes.try_append(TRY(UnknownBox::create_from_stream(box_header.type, box_stream))));
break;