瀏覽代碼

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.
Nico Weber 1 年之前
父節點
當前提交
7e4fe8e610
共有 1 個文件被更改,包括 2 次插入9 次删除
  1. 2 9
      Userland/Libraries/LibPDF/Filter.cpp

+ 2 - 9
Userland/Libraries/LibPDF/Filter.cpp

@@ -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: