mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +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
Notes:
sideshowbarker
2024-07-17 22:09:47 +09:00
Author: https://github.com/LucasChollet Commit: https://github.com/SerenityOS/serenity/commit/33ca35f1c7 Pull-request: https://github.com/SerenityOS/serenity/pull/20151
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,
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue