diff options
author | Nico Weber <thakis@chromium.org> | 2023-05-31 09:08:26 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-31 16:22:49 +0200 |
commit | 830a3a25dc6d1422caf31aa88b381ce2e63471ef (patch) | |
tree | 34572959eba9cb461fd41971328d6cd4186e3854 /Userland | |
parent | 40e1ec6cf9b27644456963f3a549d07c8ec29b85 (diff) | |
download | serenity-830a3a25dc6d1422caf31aa88b381ce2e63471ef.zip |
WebP/Lossy: Add a missing clamp() in `TM_PRED` prediction
The spec has that clamp at the end of
https://datatracker.ietf.org/doc/html/rfc6386#section-12.2:
The exact algorithm is as follows:
[...]
b[r][c] = clamp255(L[r]+ A[c] - P);
For the test images I'm looking at, it doesn't seem to make a
dramatic difference, but omitting it in `B_TM_PRED` did make
a dramatic difference, so add it. (Also, the spec demands it.)
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGfx/ImageFormats/WebPLoaderLossy.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGfx/ImageFormats/WebPLoaderLossy.cpp b/Userland/Libraries/LibGfx/ImageFormats/WebPLoaderLossy.cpp index dbb124d481..499a546ecf 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/WebPLoaderLossy.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/WebPLoaderLossy.cpp @@ -924,7 +924,7 @@ void predict_macroblock(Span<i16> prediction, IntraMacroblockMode mode, int mb_x VERIFY(mode == TM_PRED); for (int y = 0; y < N; ++y) for (int x = 0; x < N; ++x) - prediction[y * N + x] = left[y] + above[mb_x * N + x] - truemotion_corner; + prediction[y * N + x] = clamp(left[y] + above[mb_x * N + x] - truemotion_corner, 0, 255); } } |