LibGfx/ISOBMFF: Add JPEG2000CaptureResolutionBox

This commit is contained in:
Nico Weber 2024-03-22 15:21:51 -04:00 committed by Tim Schumacher
parent b386d5bb14
commit 4a95e55fb3
Notes: sideshowbarker 2024-07-17 03:03:15 +09:00
2 changed files with 33 additions and 1 deletions

View File

@ -91,8 +91,10 @@ void JPEG2000ColorSpecificationBox::dump(String const& prepend) const
ErrorOr<void> JPEG2000ResolutionBox::read_from_stream(BoxStream& stream)
{
auto make_subbox = [](BoxType type, BoxStream&) -> ErrorOr<Optional<NonnullOwnPtr<Box>>> {
auto make_subbox = [](BoxType type, BoxStream& stream) -> ErrorOr<Optional<NonnullOwnPtr<Box>>> {
switch (type) {
case BoxType::JPEG2000CaptureResolutionBox:
return TRY(JPEG2000CaptureResolutionBox::create_from_stream(stream));
default:
return OptionalNone {};
}
@ -107,6 +109,24 @@ void JPEG2000ResolutionBox::dump(String const& prepend) const
SuperBox::dump(prepend);
}
ErrorOr<void> JPEG2000CaptureResolutionBox::read_from_stream(BoxStream& stream)
{
vertical_capture_grid_resolution_numerator = TRY(stream.read_value<BigEndian<u16>>());
vertical_capture_grid_resolution_denominator = TRY(stream.read_value<BigEndian<u16>>());
horizontal_capture_grid_resolution_numerator = TRY(stream.read_value<BigEndian<u16>>());
horizontal_capture_grid_resolution_denominator = TRY(stream.read_value<BigEndian<u16>>());
vertical_capture_grid_resolution_exponent = TRY(stream.read_value<i8>());
horizontal_capture_grid_resolution_exponent = TRY(stream.read_value<i8>());
return {};
}
void JPEG2000CaptureResolutionBox::dump(String const& prepend) const
{
Box::dump(prepend);
outln("{}- vertical_capture_grid_resolution = {}/{} * 10^{}", prepend, vertical_capture_grid_resolution_numerator, vertical_capture_grid_resolution_denominator, vertical_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> JPEG2000SignatureBox::read_from_stream(BoxStream& stream)
{
signature = TRY(stream.read_value<BigEndian<u32>>());

View File

@ -43,6 +43,18 @@ struct JPEG2000ResolutionBox final : public SuperBox {
BOX_SUBTYPE(JPEG2000ResolutionBox);
};
// I.5.3.7.1 Capture Resolution box
struct JPEG2000CaptureResolutionBox final : public Box {
BOX_SUBTYPE(JPEG2000CaptureResolutionBox);
u16 vertical_capture_grid_resolution_numerator { 0 };
u16 vertical_capture_grid_resolution_denominator { 0 };
u16 horizontal_capture_grid_resolution_numerator { 0 };
u16 horizontal_capture_grid_resolution_denominator { 0 };
i8 vertical_capture_grid_resolution_exponent { 0 };
i8 horizontal_capture_grid_resolution_exponent { 0 };
};
struct JPEG2000SignatureBox final : public Box {
BOX_SUBTYPE(JPEG2000SignatureBox);