mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-07 20:31:04 +03:00
LibGfx/ISOBMFF: Add JPEG2000ColorSpecificationBox
This commit is contained in:
parent
59bd378db8
commit
214ff799ce
Notes:
sideshowbarker
2024-07-17 02:55:44 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/214ff799ce Pull-request: https://github.com/SerenityOS/serenity/pull/23682 Reviewed-by: https://github.com/LucasChollet Reviewed-by: https://github.com/Zaggy1024 Reviewed-by: https://github.com/timschumi ✅
@ -13,6 +13,8 @@ ErrorOr<void> JPEG2000HeaderBox::read_from_stream(BoxStream& stream)
|
|||||||
{
|
{
|
||||||
auto make_subbox = [](BoxType type, BoxStream& stream) -> ErrorOr<Optional<NonnullOwnPtr<Box>>> {
|
auto make_subbox = [](BoxType type, BoxStream& stream) -> ErrorOr<Optional<NonnullOwnPtr<Box>>> {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
case BoxType::JPEG2000ColorSpecificationBox:
|
||||||
|
return TRY(JPEG2000ColorSpecificationBox::create_from_stream(stream));
|
||||||
case BoxType::JPEG2000ImageHeaderBox:
|
case BoxType::JPEG2000ImageHeaderBox:
|
||||||
return TRY(JPEG2000ImageHeaderBox::create_from_stream(stream));
|
return TRY(JPEG2000ImageHeaderBox::create_from_stream(stream));
|
||||||
default:
|
default:
|
||||||
@ -58,6 +60,33 @@ void JPEG2000ImageHeaderBox::dump(String const& prepend) const
|
|||||||
outln("{}- contains_intellectual_property_rights = {}", prepend, contains_intellectual_property_rights);
|
outln("{}- contains_intellectual_property_rights = {}", prepend, contains_intellectual_property_rights);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<void> JPEG2000ColorSpecificationBox::read_from_stream(BoxStream& stream)
|
||||||
|
{
|
||||||
|
method = TRY(stream.read_value<u8>());
|
||||||
|
precedence = TRY(stream.read_value<i8>());
|
||||||
|
approximation = TRY(stream.read_value<u8>());
|
||||||
|
if (method == 1)
|
||||||
|
enumerated_color_space = TRY(stream.read_value<BigEndian<u32>>());
|
||||||
|
if (method == 2) {
|
||||||
|
ByteBuffer local_icc_data = TRY(ByteBuffer::create_uninitialized(stream.remaining()));
|
||||||
|
TRY(stream.read_until_filled(local_icc_data));
|
||||||
|
icc_data = move(local_icc_data);
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void JPEG2000ColorSpecificationBox::dump(String const& prepend) const
|
||||||
|
{
|
||||||
|
Box::dump(prepend);
|
||||||
|
outln("{}- method = {}", prepend, method);
|
||||||
|
outln("{}- precedence = {}", prepend, precedence);
|
||||||
|
outln("{}- approximation = {}", prepend, approximation);
|
||||||
|
if (method == 1)
|
||||||
|
outln("{}- enumerated_color_space = {}", prepend, enumerated_color_space);
|
||||||
|
if (method == 2)
|
||||||
|
outln("{}- icc_data = {} bytes", prepend, icc_data.size());
|
||||||
|
}
|
||||||
|
|
||||||
ErrorOr<void> JPEG2000SignatureBox::read_from_stream(BoxStream& stream)
|
ErrorOr<void> JPEG2000SignatureBox::read_from_stream(BoxStream& stream)
|
||||||
{
|
{
|
||||||
signature = TRY(stream.read_value<BigEndian<u32>>());
|
signature = TRY(stream.read_value<BigEndian<u32>>());
|
||||||
|
@ -27,6 +27,17 @@ struct JPEG2000ImageHeaderBox final : public Box {
|
|||||||
u8 contains_intellectual_property_rights { 0 };
|
u8 contains_intellectual_property_rights { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// I.5.3.3 Colour Specification box
|
||||||
|
struct JPEG2000ColorSpecificationBox final : public Box {
|
||||||
|
BOX_SUBTYPE(JPEG2000ColorSpecificationBox);
|
||||||
|
|
||||||
|
u8 method { 0 };
|
||||||
|
i8 precedence { 0 };
|
||||||
|
u8 approximation { 0 };
|
||||||
|
u32 enumerated_color_space { 0 }; // Only set if method == 1
|
||||||
|
ByteBuffer icc_data; // Only set if method == 2
|
||||||
|
};
|
||||||
|
|
||||||
struct JPEG2000SignatureBox final : public Box {
|
struct JPEG2000SignatureBox final : public Box {
|
||||||
BOX_SUBTYPE(JPEG2000SignatureBox);
|
BOX_SUBTYPE(JPEG2000SignatureBox);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user