From 7e4fe8e610e05e1c96c8778f41be69400e66669c Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 16 Nov 2023 19:28:16 -0500 Subject: [PATCH] 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. --- Userland/Libraries/LibPDF/Filter.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Userland/Libraries/LibPDF/Filter.cpp b/Userland/Libraries/LibPDF/Filter.cpp index 700c753e1f..e64ba5ad8b 100644 --- a/Userland/Libraries/LibPDF/Filter.cpp +++ b/Userland/Libraries/LibPDF/Filter.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -191,15 +192,7 @@ PDFErrorOr 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: