Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Sub and Paeth filtering #363

Merged
merged 3 commits into from
Dec 23, 2022
Merged

Conversation

fintelia
Copy link
Contributor

@fintelia fintelia commented Nov 22, 2022

This PR changes the filter_internal method to make it more conducive to auto-vectorization. Using the benchmark infrastructure from #362, it increases overall encoding performance by ~30%:

before...

Directory                                     Ratio             Encode
---------                                    -------     --------------------
Total                                        28.472%      40 mps   0.14 GiB/s

after...

Directory                                     Ratio             Encode
---------                                    -------     --------------------
Total                                        28.472%      60 mps   0.20 GiB/s

Also fixes a bug I noticed while making this change: StreamWriter's prev_buf would contain filtered image data rather than unfiltered pixels (and adds a test to confirm).

Copy link
Member

@HeroicKatora HeroicKatora left a comment

Choose a reason for hiding this comment

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

Looks good to me in terms of implementation, just could use some more comments to capture some information on how it was derived.

src/encoder.rs Show resolved Hide resolved
src/filter.rs Show resolved Hide resolved
Also fixes a bug in StreamWriter where prev_buf would contain filtered
image data rather than unfiltered pixels.
@fintelia
Copy link
Contributor Author

@HeroicKatora I added an explanation of how the alternative Paeth filter implementation was derived.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants