Skip to content

Commit

Permalink
STY: Increase readability (py-pdf#2775)
Browse files Browse the repository at this point in the history
Add comments and remove noisy comments.
  • Loading branch information
j-t-1 authored Jul 26, 2024
1 parent a469e0f commit d40fcc1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pypdf/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,29 +190,29 @@ def _decode_png_prediction(data: bytes, columns: int, rowlength: int) -> bytes:
filter_byte = rowdata[0]

if filter_byte == 0:
# PNG None Predictor
pass
elif filter_byte == 1:
# PNG Sub Predictor
for i in range(bpp + 1, rowlength):
rowdata[i] = (rowdata[i] + rowdata[i - bpp]) % 256
elif filter_byte == 2:
# PNG Up Predictor
for i in range(1, rowlength):
rowdata[i] = (rowdata[i] + prev_rowdata[i]) % 256
elif filter_byte == 3:
# PNG Average Predictor
for i in range(1, bpp + 1):
# left = 0
floor = prev_rowdata[i] // 2
rowdata[i] = (rowdata[i] + floor) % 256
for i in range(bpp + 1, rowlength):
left = rowdata[i - bpp]
floor = (left + prev_rowdata[i]) // 2
rowdata[i] = (rowdata[i] + floor) % 256
elif filter_byte == 4:
# PNG Paeth Predictor
for i in range(1, bpp + 1):
# left = 0
up = prev_rowdata[i]
# up_left = 0
paeth = up
rowdata[i] = (rowdata[i] + paeth) % 256
rowdata[i] = (rowdata[i] + prev_rowdata[i]) % 256
for i in range(bpp + 1, rowlength):
left = rowdata[i - bpp]
up = prev_rowdata[i]
Expand Down

0 comments on commit d40fcc1

Please sign in to comment.