mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-03 06:35:20 +00:00
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.
This commit is contained in:
parent
3d9ba87077
commit
841e359341
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue