-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Lossy WebP: Enable sharp RGB to YUV conversion #79257
Conversation
Remark from the linked blog:
Perhaps we should do an analysis of current import times compared to import times with this change? |
I did a test by importing 64 sample images from Kenney Game Assets 1 at once on two builds (because I don't trust cwebp), one of them with sharp_yuv enabled, and the other one disabled. To make import longer, I set WebP compression method to max (6). If there was a difference between import times, it was a matter of miliseconds (both did around 3 seconds). The similar times are likely due to compression method, not conversion. With this in mind, I would say the time increase is actually negligible. |
On the very same paragraph:
Lossy WebP encoding is already extremely fast compared to lossless (on the same test, lossless took 36 seconds to import). My above comment has some test details if anyone is interested. |
I tested this PR locally, rebased against BenchmarkOS: Fedora 38
Build type:
|
Before | After (this PR) |
---|---|
6 seconds | 13 seconds |
Build type: optimize=speed lto=full
This is what official builds use.
Before | After (this PR) |
---|---|
4 seconds | 7 seconds |
3,900 images with lossy compression is a lot more than what most projects will use, so I think it's fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the assessment that this improvement in quality is worthwhile given Calinou's times. Seems like a win to me.
The only possible downside I can think is someone perhaps compressing lossy webp at runtime, might want to have an option for fast low-quality compression, but I would rather wait for the usecase to present itself, since I can't think of a case where fast-but-low quality would be desirable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a great improvement.
In the future if performance is a problem we could try to make this multi-threaded.
Thanks! |
Thank you!
|
Drastically increases lossy WebP quality by performing a sharp RGB to YUV conversion. This has minimal impact on size and some additional time to encode.
This article explains well how this works.
Here's a preview linked from it:
I wanted to make a new check option on the import tab to enable/disable. There is a High Quality import option that could be used, but it's designed with changing VRAM compressed formats in mind and can't be passed to WebPCommon. Both alternatives can't be done without making major changes to the ResourceSaver that will only benefit lossy WebP.
In the end, I decided that leaving it enabled was better, as the size increase is minimal.