mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 12:38:38 -10:00
LibGfx/ISOBMFF: Add support for some of the JPEG XL boxes
This commit is contained in:
1 parent
ec37a3daf5
commit
00e3f4b5f0
5 files changed
+95
No files matched your search
@@ -51,6 +51,7 @@ set(SOURCES
|
||||
ImageFormats/ImageDecoder.cpp
|
||||
ImageFormats/ISOBMFF/Boxes.cpp
|
||||
ImageFormats/ISOBMFF/JPEG2000Boxes.cpp
|
||||
ImageFormats/ISOBMFF/JPEGXLBoxes.cpp
|
||||
ImageFormats/ISOBMFF/Reader.cpp
|
||||
ImageFormats/JBIG2Loader.cpp
|
||||
ImageFormats/JPEG2000Loader.cpp
|
||||
|
||||
@@ -20,6 +20,9 @@ namespace Gfx::ISOBMFF {
|
||||
ENUMERATE_ONE(JPEG2000ChannelDefinitionBox, "cdef") \
|
||||
ENUMERATE_ONE(JPEG2000ComponentMappingBox, "cmap") \
|
||||
ENUMERATE_ONE(JPEG2000ColorSpecificationBox, "colr") \
|
||||
ENUMERATE_ONE(JPEGXLCodestreamBox, "jxlc") \
|
||||
ENUMERATE_ONE(JPEGXLLevelBox, "jxll") \
|
||||
ENUMERATE_ONE(JPEGXLSignatureBox, "JXL ") \
|
||||
ENUMERATE_ONE(FreeBox, "free") \
|
||||
ENUMERATE_ONE(FileTypeBox, "ftyp") \
|
||||
ENUMERATE_ONE(JPEG2000ImageHeaderBox, "ihdr") \
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2025, Lucas Chollet <[email protected]>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "JPEGXLBoxes.h"
|
||||
|
||||
namespace Gfx::ISOBMFF {
|
||||
|
||||
ErrorOr<void> JPEGXLSignatureBox::read_from_stream(ConstrainedStream& stream)
|
||||
{
|
||||
// FIXME: Make the decoder check the signature.
|
||||
TRY(stream.discard(4));
|
||||
return {};
|
||||
}
|
||||
|
||||
void JPEGXLSignatureBox::dump(String const& prepend) const
|
||||
{
|
||||
Box::dump(prepend);
|
||||
}
|
||||
|
||||
ErrorOr<void> JPEGXLLevelBox::read_from_stream(ConstrainedStream& stream)
|
||||
{
|
||||
level = TRY(stream.read_value<u8>());
|
||||
return {};
|
||||
}
|
||||
|
||||
void JPEGXLLevelBox::dump(String const& prepend) const
|
||||
{
|
||||
Box::dump(prepend);
|
||||
outln("{}- level = {}", prepend, level);
|
||||
}
|
||||
|
||||
ErrorOr<void> JPEGXLCodestreamBox::read_from_stream(ConstrainedStream& stream)
|
||||
{
|
||||
// FIXME: Prevent the copy.
|
||||
TRY(codestream.try_resize(stream.remaining()));
|
||||
TRY(stream.read_until_filled(codestream.span()));
|
||||
return {};
|
||||
}
|
||||
|
||||
void JPEGXLCodestreamBox::dump(String const& prepend) const
|
||||
{
|
||||
Box::dump(prepend);
|
||||
outln("{}- size = {}", prepend, codestream.size());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2025, Lucas Chollet <[email protected]>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Boxes.h"
|
||||
|
||||
namespace Gfx::ISOBMFF {
|
||||
|
||||
// 18181-2 Information technology — JPEG XL image coding system
|
||||
// Part 2: File format
|
||||
|
||||
// 9.1 JPEG XL Signature box (JXL␣)
|
||||
struct JPEGXLSignatureBox final : public Box {
|
||||
BOX_SUBTYPE(JPEGXLSignatureBox);
|
||||
};
|
||||
|
||||
// 9.3 Level box (jxll)
|
||||
struct JPEGXLLevelBox final : public Box {
|
||||
BOX_SUBTYPE(JPEGXLLevelBox);
|
||||
|
||||
u8 level { 0 };
|
||||
};
|
||||
|
||||
// 9.9 JPEG XL Codestream box (jxlc)
|
||||
struct JPEGXLCodestreamBox final : public Box {
|
||||
BOX_SUBTYPE(JPEGXLCodestreamBox);
|
||||
|
||||
Vector<u8> codestream;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "Reader.h"
|
||||
#include "JPEG2000Boxes.h"
|
||||
#include "JPEGXLBoxes.h"
|
||||
#include <AK/Function.h>
|
||||
|
||||
namespace Gfx::ISOBMFF {
|
||||
@@ -35,6 +36,12 @@ ErrorOr<BoxList> Reader::read_entire_file()
|
||||
return TRY(JPEG2000SignatureBox::create_from_stream(stream));
|
||||
case BoxType::JPEG2000UUIDInfoBox:
|
||||
return TRY(JPEG2000UUIDInfoBox::create_from_stream(stream));
|
||||
case BoxType::JPEGXLCodestreamBox:
|
||||
return TRY(JPEGXLCodestreamBox::create_from_stream(stream));
|
||||
case BoxType::JPEGXLLevelBox:
|
||||
return TRY(JPEGXLLevelBox::create_from_stream(stream));
|
||||
case BoxType::JPEGXLSignatureBox:
|
||||
return TRY(JPEGXLSignatureBox::create_from_stream(stream));
|
||||
case BoxType::UserExtensionBox:
|
||||
return TRY(UserExtensionBox::create_from_stream(stream));
|
||||
default:
|
||||
|
||||
Reference in new issue
Block a user