1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:17:35 +00:00

LibPDF: Use PNG::paeth_predictor() in png decoding path

No behavior change.

Ideally, the PDF code would just call a function PNGLoader to do the
PNG unfiltering, but let's first try to make the implementations look
more similar.
This commit is contained in:
Nico Weber 2023-11-16 19:28:16 -05:00 committed by Andreas Kling
parent 6b2c60404d
commit 7e4fe8e610

View file

@ -9,6 +9,7 @@
#include <LibCompress/Deflate.h>
#include <LibCompress/LZWDecoder.h>
#include <LibGfx/ImageFormats/JPEGLoader.h>
#include <LibGfx/ImageFormats/PNGShared.h>
#include <LibPDF/CommonNames.h>
#include <LibPDF/Filter.h>
#include <LibPDF/Reader.h>
@ -191,15 +192,7 @@ PDFErrorOr<ByteBuffer> Filter::decode_png_prediction(Bytes bytes, int bytes_per_
upper_left = previous_row[i - 1];
}
u8 above = previous_row[i];
u8 p = left + above - upper_left;
int left_distance = abs(p - left);
int above_distance = abs(p - above);
int upper_left_distance = abs(p - upper_left);
u8 paeth = min(left_distance, min(above_distance, upper_left_distance));
row[i] += paeth;
row[i] += Gfx::PNG::paeth_predictor(left, above, upper_left);
}
break;
default: