Skip to content

Conversation

@saucecontrol
Copy link
Contributor

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

Fixes a bug in the sums calculation for adaptive filtering:

I can only guess this adjustment was compensating for a bug that existed in an earlier version of the code where it counted the row filter byte in the sum. In any case, that is not happening now, so the adjustment at the end is taking away from a valid sum value. Although this is generally harmless, it does mean that in the event of a tie for sum values (e.g. 0 in a solid color image), Paeth will win by virtue of its larger row filter number (-4 adjustment), making the resulting image needlessly expensive to decode.

Also tidies up the code and codegen for PNG filters in a few ways:

  • Inlines the SIMD Paeth predictors for encoding, which were previously emitted as method calls for each input vector
  • Simplifies fallback code for SSE2-only configs
  • Eliminates some sign-extensions and extra arithmetic on row ref offsets
  • Uses FilterTypes enum values for row filter byte instead of magic numbers.

I will follow up another time with some improvements to the SIMD decode filter implementations. I have ideas 😉

Copy link
Member

@JimBobSquarePants JimBobSquarePants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool. Much improved readability also. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants