-
-
Notifications
You must be signed in to change notification settings - Fork 702
Revise premultiply #2120
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
Revise premultiply #2120
Conversation
we actually test vipsthumbnail --linear on an RGBA image, which should catch everything, hopefully
for compat in thumbnail behaviour
Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>
…revise-premultiply
allow this case: vipsthumbnail k2.jpg --export-profile cmyk for an image with no embedded profile
…revise-premultiply
Profiling suggests the unpremultiply operation might be ~17% slower with this change. Using callgrind to unpremultiply a 6MP RGBA image with code compiled using gcc 9.3.0 and Before:
After:
Would the following diff be functionally equivalent? --- a/libvips/include/vips/util.h
+++ b/libvips/include/vips/util.h
@@ -91,11 +91,7 @@ vips_recip( double x )
{
static const double epsilon = 1e-10;
- int sign = x < 0.0 ? -1.0 : 1.0;
-
- return( sign * x >= epsilon ?
- 1.0 / x :
- sign / epsilon );
+ return 1 / VIPS_CLIP( -epsilon, x, epsilon );
} If so, that's only 8% slower:
|
it wasn't really necessary, and it was rather slow
I removed the recip thing -- it wasn't really necessary, and it was slower than I expected. Thanks for the speed check! |
\o/ good stuff, thanks! |
This PR revises unpremultiply (again), and tries to simplify thumbnail a bit. It fixes resizing RGBA images in scRGB space, and hopefully doesn't regress an earlier RGBA resize issue. There's a test as well, to try to stop this happening again.
Background: #1941
Related issue: #1675