mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-07 10:06:03 +00:00
LibGfx/ISOBMFF: Add JPEG2000ContiguousCodestreamBox
This commit is contained in:
parent
f372a9b346
commit
c58996f4fc
Notes:
sideshowbarker
2024-07-17 02:35:27 +09:00
Author: https://github.com/nico
Commit: c58996f4fc
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 ✅
3 changed files with 25 additions and 0 deletions
|
@ -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);
|
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)
|
ErrorOr<void> JPEG2000SignatureBox::read_from_stream(BoxStream& stream)
|
||||||
{
|
{
|
||||||
signature = TRY(stream.read_value<BigEndian<u32>>());
|
signature = TRY(stream.read_value<BigEndian<u32>>());
|
||||||
|
|
|
@ -55,6 +55,13 @@ struct JPEG2000CaptureResolutionBox final : public Box {
|
||||||
i8 horizontal_capture_grid_resolution_exponent { 0 };
|
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 {
|
struct JPEG2000SignatureBox final : public Box {
|
||||||
BOX_SUBTYPE(JPEG2000SignatureBox);
|
BOX_SUBTYPE(JPEG2000SignatureBox);
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,8 @@ ErrorOr<BoxList> Reader::read_entire_file()
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case BoxType::FileTypeBox:
|
case BoxType::FileTypeBox:
|
||||||
return TRY(FileTypeBox::create_from_stream(stream));
|
return TRY(FileTypeBox::create_from_stream(stream));
|
||||||
|
case BoxType::JPEG2000ContiguousCodestreamBox:
|
||||||
|
return TRY(JPEG2000ContiguousCodestreamBox::create_from_stream(stream));
|
||||||
case BoxType::JPEG2000HeaderBox:
|
case BoxType::JPEG2000HeaderBox:
|
||||||
return TRY(JPEG2000HeaderBox::create_from_stream(stream));
|
return TRY(JPEG2000HeaderBox::create_from_stream(stream));
|
||||||
case BoxType::JPEG2000SignatureBox:
|
case BoxType::JPEG2000SignatureBox:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue