mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 13:47:35 +00:00
LibGfx/JPEGXL: Apply transformations after all PassGroups
The original image this decoder was written for has a single PassGroup, so applying transformations after each PassGroup or after all of them was equivalent. This patch fix the behavior for images with 0 or more than one PassGroup.
This commit is contained in:
parent
ea411774f0
commit
33ca35f1c7
1 changed files with 9 additions and 7 deletions
|
@ -1447,8 +1447,7 @@ static void apply_transformation(Image& image, TransformInfo const& transformati
|
||||||
static ErrorOr<void> read_pass_group(LittleEndianInputBitStream& stream,
|
static ErrorOr<void> read_pass_group(LittleEndianInputBitStream& stream,
|
||||||
Image& image,
|
Image& image,
|
||||||
FrameHeader const& frame_header,
|
FrameHeader const& frame_header,
|
||||||
u32 group_dim,
|
u32 group_dim)
|
||||||
Vector<TransformInfo> const& transform_infos)
|
|
||||||
{
|
{
|
||||||
if (frame_header.encoding == FrameHeader::Encoding::kVarDCT) {
|
if (frame_header.encoding == FrameHeader::Encoding::kVarDCT) {
|
||||||
(void)stream;
|
(void)stream;
|
||||||
|
@ -1469,9 +1468,6 @@ static ErrorOr<void> read_pass_group(LittleEndianInputBitStream& stream,
|
||||||
TODO();
|
TODO();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const& transformation : transform_infos.in_reverse())
|
|
||||||
apply_transformation(image, transformation);
|
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
|
@ -1538,9 +1534,15 @@ static ErrorOr<Frame> read_frame(LittleEndianInputBitStream& stream,
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const num_pass_group = frame.num_groups * frame.frame_header.passes.num_passes;
|
auto const num_pass_group = frame.num_groups * frame.frame_header.passes.num_passes;
|
||||||
auto const& transform_info = frame.lf_global.gmodular.modular_header.transform;
|
auto const& transform_infos = frame.lf_global.gmodular.modular_header.transform;
|
||||||
for (u64 i {}; i < num_pass_group; ++i)
|
for (u64 i {}; i < num_pass_group; ++i)
|
||||||
TRY(read_pass_group(stream, image, frame.frame_header, group_dim, transform_info));
|
TRY(read_pass_group(stream, image, frame.frame_header, group_dim));
|
||||||
|
|
||||||
|
// G.4.2 - Modular group data
|
||||||
|
// When all modular groups are decoded, the inverse transforms are applied to
|
||||||
|
// the at that point fully decoded GlobalModular image, as specified in H.6.
|
||||||
|
for (auto const& transformation : transform_infos.in_reverse())
|
||||||
|
apply_transformation(image, transformation);
|
||||||
|
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue