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:
Lucas CHOLLET 2023-07-22 13:02:50 -04:00 committed by Andreas Kling
parent ea411774f0
commit 33ca35f1c7
Notes: sideshowbarker 2024-07-17 22:09:47 +09:00

View File

@ -1447,8 +1447,7 @@ static void apply_transformation(Image& image, TransformInfo const& transformati
static ErrorOr<void> read_pass_group(LittleEndianInputBitStream& stream,
Image& image,
FrameHeader const& frame_header,
u32 group_dim,
Vector<TransformInfo> const& transform_infos)
u32 group_dim)
{
if (frame_header.encoding == FrameHeader::Encoding::kVarDCT) {
(void)stream;
@ -1469,9 +1468,6 @@ static ErrorOr<void> read_pass_group(LittleEndianInputBitStream& stream,
TODO();
}
for (auto const& transformation : transform_infos.in_reverse())
apply_transformation(image, transformation);
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& 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)
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;
}