1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:27:44 +00:00

LibGfx/JPEGXL: Fix property 8

The first implementation of this property was just plain wrong. Looks
like this property isn't used a lot as I found the issue by reviewing
the code and not because of a specific image.

The test image is a 32x32 mosaic of alternating black and yellow pixels,
it was generated using this code:

Bitdepth 8
RCT 1
Width 32
Height 32

if W-WW-NW+NWW > -300
 - Set -1000
 - Set 900
This commit is contained in:
Lucas CHOLLET 2023-07-31 16:56:12 -04:00 committed by Andreas Kling
parent 6b41fef2e4
commit 00240cb0b3
3 changed files with 29 additions and 6 deletions

View file

@ -1303,12 +1303,15 @@ static ErrorOr<Vector<i32>> get_properties(Vector<Channel> const& channels, u16
TRY(properties.try_append(W));
// x > 0 ? W - /* (the value of property 9 at position (x - 1, y)) */ : W
i32 x_1 = x - 1;
i32 const W_x_1 = x_1 > 0 ? channels[i].get(x_1 - 1, y) : (x_1 >= 0 && y > 0 ? channels[i].get(x_1, y - 1) : 0);
i32 const N_x_1 = x_1 >= 0 && y > 0 ? channels[i].get(x_1, y - 1) : W_x_1;
i32 const NW_x_1 = x_1 > 0 && y > 0 ? channels[i].get(x_1 - 1, y - 1) : W_x_1;
TRY(properties.try_append(W_x_1 + N_x_1 - NW_x_1));
if (x > 0) {
auto const x_1 = x - 1;
i32 const W_x_1 = x_1 > 0 ? channels[i].get(x_1 - 1, y) : (y > 0 ? channels[i].get(x_1, y - 1) : 0);
i32 const N_x_1 = y > 0 ? channels[i].get(x_1, y - 1) : W_x_1;
i32 const NW_x_1 = x_1 > 0 && y > 0 ? channels[i].get(x_1 - 1, y - 1) : W_x_1;
TRY(properties.try_append(W - (W_x_1 + N_x_1 - NW_x_1)));
} else {
TRY(properties.try_append(W));
}
TRY(properties.try_append(W + N - NW));
TRY(properties.try_append(W - NW));