diff options
author | Lucas CHOLLET <lucas.chollet@free.fr> | 2023-02-18 14:02:20 -0500 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2023-02-19 07:59:58 +0000 |
commit | 841e359341ceced7870d66c12586e434b48fee58 (patch) | |
tree | 3ef74c364bc34f205280676859db2630b3c375ff | |
parent | 3d9ba870772fcaba9ec5772b267f0f2a60133316 (diff) | |
download | serenity-841e359341ceced7870d66c12586e434b48fee58.zip |
LibGfx: Correctly handle JPEG image with restart markers
Restart markers are supposed to be applied every restart interval.
However, in these loops macroblocks are counted taking the luma sampling
factor into consideration. Meaning that we need to correct this factor
when testing if we should reset the DC.
Also, the decoder was discarding the first byte of every scan with a set
restart interval, as `0 % n == 0` is always true.
-rw-r--r-- | Userland/Libraries/LibGfx/JPEGLoader.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGfx/JPEGLoader.cpp b/Userland/Libraries/LibGfx/JPEGLoader.cpp index 31536717ea..3e914805fa 100644 --- a/Userland/Libraries/LibGfx/JPEGLoader.cpp +++ b/Userland/Libraries/LibGfx/JPEGLoader.cpp @@ -383,7 +383,7 @@ static ErrorOr<Vector<Macroblock>> decode_huffman_stream(JPEGLoadingContext& con for (u32 hcursor = 0; hcursor < context.mblock_meta.hcount; hcursor += context.hsample_factor) { u32 i = vcursor * context.mblock_meta.hpadded_count + hcursor; if (context.dc_reset_interval > 0) { - if (i % context.dc_reset_interval == 0) { + if (i != 0 && i % (context.dc_reset_interval * context.vsample_factor * context.hsample_factor) == 0) { context.previous_dc_values[0] = 0; context.previous_dc_values[1] = 0; context.previous_dc_values[2] = 0; |