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

SIMD Encoder : an AVX2 implementation #143

Closed
wants to merge 18 commits into from

Conversation

MKCG
Copy link

@MKCG MKCG commented Dec 28, 2021

Hello,
this pull request implements an AVX2 based encoder.

It also introduces a new structure named qoi_encoder_t that could be use to implement a streaming encoder.

When encoding the images provided on the official website, I get those results :

branch type encode ms encode mpps branches branches misses
master any 14.4 157.28 28 137 276 765 1 492 397 899
this pull request any 7.9 284.32 11 348 182 313 714 559 161
master RGB 40.0 132.31 21 054 094 125 1 322 613 445
this pull request RGB 23.0 229.90 9 418 298 665 633 968 387
master RGBA 3.4 281.22 7 080 735 865 172 313 079
this pull request before 2672a47 RGBA 1.8 524.59 1 834 707 343 79 617 576
this pull request after 2672a47 RGBA 1.5 648.99 1 880 977 270 79 359 904

Note: 2672a47 avoids performing cpu intensive operations when the next 8 pixels belong to the same run. Only images with flat surfaces like screenshots will benefit from it.

Note: RGB images are a bit tricky to encode using AVX2 instructions, and this implementation can still be improved.

@MKCG MKCG marked this pull request as draft December 28, 2021 22:26
@MKCG MKCG changed the title WIP: RGBA Encoder : an almost branchless AVX2 implementation RGBA Encoder : an almost branchless AVX2 implementation Dec 28, 2021
@MKCG MKCG changed the title RGBA Encoder : an almost branchless AVX2 implementation RGBA Encoder : an AVX2 implementation Dec 29, 2021
@MKCG MKCG marked this pull request as ready for review December 29, 2021 02:38
@MKCG MKCG changed the title RGBA Encoder : an AVX2 implementation SIMD Encoder : an AVX2 implementation Dec 30, 2021
@MKCG
Copy link
Author

MKCG commented Jan 2, 2022

My PHP library use a C library defining a chunk based encoder to lower the memory footprint : https://github.com/MKCG/php-qoi/blob/main/src/FFI/lib/qoi.c#L112

I will probably open a pull request here to implement a streaming encoder.

@phoboslab
Copy link
Owner

This is very cool, but I'm sorry to say that I will not merge it. I want this "reference" encoder here to stay as simple as possible. Also, I neither have the expertise nor the desire to maintain this SIMD implementation.

If you publish your encoder under a different name (fastqoi? rapidqoi? simdqoi?) I will happily mention it in the readme here!

@phoboslab phoboslab closed this Jan 3, 2022
@MKCG
Copy link
Author

MKCG commented Jan 3, 2022

Actually I add little hope that it would be accepted since I already knew you weren't very familiar with AVX2 instructions from a previous comment on the final specification thread.

"simdqoi" would work for me, that would be a nice tribute to the amazing work of Daniel Lemire, Geoff Langdale and so many others. I guess that now I also have to make an AVX2 based decoder before publishing it.

Thanks for your time.

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.

None yet

2 participants