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

Switch to zlib-ng for performance & newer libpng compatibility #2496

Open
gitoss opened this issue Oct 30, 2024 · 6 comments
Open

Switch to zlib-ng for performance & newer libpng compatibility #2496

gitoss opened this issue Oct 30, 2024 · 6 comments

Comments

@gitoss
Copy link

gitoss commented Oct 30, 2024

Since I seem to depend on the built-in libs with Visual Studio (I cannot get previously build libs to link with libavif due to some obscure "linking module flags: IDs have conflicting values" error:

A switch from old school zlib to zlib ng would enhance png performance, plus (probably) allow for libpng versions >1.6.40 (1.7 is is beta...). It's supposed a drop-in replacement with -DZLIB_COMPAT=ON

https://github.com/zlib-ng/zlib-ng
https://github.com/AOMediaCodec/libavif/blob/main/cmake/Modules/LocalZlibpng.cmake

@wantehchang
Copy link
Collaborator

I also considered zlib alternatives before because zlib's CMakeLists.txt did not support Windows well and the patch I sent to the zlib maintainer (both by email and as a pull request) was not reviewed. Another zlib fork worth considering is Chrome's zlib fork: https://chromium.googlesource.com/chromium/src/third_party/zlib

@gitoss
Copy link
Author

gitoss commented Oct 30, 2024

Another zlib fork worth considering is Chrome's zlib fork: https://chromium.googlesource.com/chromium/src/third_party/zlib

Interesting, I didn't know that.

zlib-ng looks appealing because of the SIMD code, but it might still be more hassle to configure even with the documentation provided. The chrome zlib looks simple, because there is no documenation (on the git site) at all :->

It probably doesn't matter that much unless encoding or decoding very big png files with high compression ... but it might still happen, I'm exporting Lightroom => PNG => avif/heic because PNG "just works".

Alas, being stuck with the old libpng doesn't look appealing at all... madler/zlib#1019

@wantehchang
Copy link
Collaborator

@gitoss I'd like to know why you are interested in zlib alternatives. From your earlier comment, I think the reasons are:

  1. Better performance
  2. Upgrade to libpng > v1.6.40

Is this correct?

Regarding the second reason, I am wondering how libpng 1.6.41-1.6.44 could be released without a zlib release containing madler/zlib@f1f503d.

The only reason I considered zlib alternatives was to fix a Windows build issue (madler/zlib#818). We are working around that Windows build issue in our LocalZlibpng.cmake file. Note: I think that issue has been fixed on the zlib main branch in another way, based on the two target_include_directories() calls shown in madler/zlib@f1f503d. It seems that I can abandon madler/zlib#818 and write a new pull request to remove the two include_directories() calls.

@gitoss
Copy link
Author

gitoss commented Nov 2, 2024

  1. Better performance
  2. Upgrade to libpng > v1.6.40

Yes, that is correct. The libpng issue probably will get solved sooner or later, but with bulk image encoding every bit of more performance helps - so why not use what's for 'free' by switching libs or optimizing compiler flags.

I've even compiled pgo-optimized versions of svt-av1, plus using faster maths functions - which makes a great difference in libavif, very like much more than a faster libpng.

@Neustradamus
Copy link

@gitoss, @wantehchang: About CMake and Zlib, please do PR or comment pulls/tickets...

I have done a ticket which is not complete:

@gitoss
Copy link
Author

gitoss commented Nov 11, 2024

@gitoss, @wantehchang: About CMake and Zlib, please do PR or comment pulls/tickets...
I have done a ticket which is not complete:

Looking at the ticket, changing the lib from zlib to zlib-ng or something else is probably better than trying to cmake-fix zlib.

Even the zlib maintainer stats that zlib forks have improved cmake support - which he would like to have backported with pull requests from the forks - which probably won't happen anytime soon or at all.

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

No branches or pull requests

3 participants