-
-
Notifications
You must be signed in to change notification settings - Fork 678
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
colour: use cmsFLAGS_NOOPTIMIZE
to keep all precision
#3368
Conversation
389fe7b
to
9f8dd36
Compare
9f8dd36
to
de57c3e
Compare
Using the images from libvips/php-vips#169 and libvips/php-vips#192, I see:
Details$ /usr/bin/time -f %M:%e vips icc_import php-vips-169.jpg t1.v --pcs xyz
55512:0.10
$ /usr/bin/time -f %M:%e vips icc_import php-vips-169.jpg t2.v --pcs lab
56604:0.12
$ /usr/bin/time -f %M:%e vips icc_export t1.v output-xyz.v
36312:0.06
$ /usr/bin/time -f %M:%e vips icc_export t2.v output-lab.v
37084:0.06
$ vips avg output-xyz.v
59.424550
$ vips avg output-lab.v
69.385891
$ /usr/bin/time -f %M:%e vips icc_import php-vips-192.jpg t1.v --pcs xyz
51372:0.10
$ /usr/bin/time -f %M:%e vips icc_import php-vips-192.jpg t2.v --pcs lab
50728:0.11
$ /usr/bin/time -f %M:%e vips icc_export t1.v output-xyz.v
34512:0.06
$ /usr/bin/time -f %M:%e vips icc_export t2.v output-lab.v
35140:0.06
$ vips avg output-xyz.v
60.507960
$ vips avg output-lab.v
67.984691 This PR: Details$ /usr/bin/time -f %M:%e vips icc_import php-vips-169.jpg t1.v --pcs xyz
54864:0.12
$ /usr/bin/time -f %M:%e vips icc_import php-vips-169.jpg t2.v --pcs lab
54844:0.16
$ /usr/bin/time -f %M:%e vips icc_export t1.v output-xyz.v
36072:0.08
$ /usr/bin/time -f %M:%e vips icc_export t2.v output-lab.v
39672:0.09
$ vips avg output-xyz.v
69.553215
$ vips avg output-lab.v
69.553283
$ /usr/bin/time -f %M:%e vips icc_import php-vips-192.jpg t1.v --pcs xyz
50316:0.10
$ /usr/bin/time -f %M:%e vips icc_import php-vips-192.jpg t2.v --pcs lab
49556:0.12
$ /usr/bin/time -f %M:%e vips icc_export t1.v output-xyz.v
34524:0.06
$ /usr/bin/time -f %M:%e vips icc_export t2.v output-lab.v
34572:0.07
$ vips avg output-xyz.v
67.716544
$ vips avg output-lab.v
67.715953 So, it produces similar images using a profile connection space with either LAB or XYZ. Previously, it produced a visible colour difference when using XYZ as PCS. I think the timings are reasonable for these particular images. Note that this flag also disables all optimizations of the fast-float plugin available in LCMS and released under the GPL (though, that also required an explicit opt-in, see e.g. commit kleisauke@a1a122e). This is ready for review now. |
Do we know which of the (4?) builtin lcms optimisations is causing this? Could it be something to do with Should we make the addition of this flag conditional on using XYZ as it suffers more greatly? |
Good points, I didn't investigate that. It looks like using the With that I see: $ vips icc_import php-vips-169.jpg t1.v --pcs xyz
$ vips icc_import php-vips-169.jpg t2.v --pcs lab
$ vips icc_export t1.v output-xyz.v
$ vips icc_export t2.v output-lab.v
$ vips avg output-xyz.v
69.553215
$ vips avg output-lab.v
69.553287 And: $ vips icc_import php-vips-192.jpg t1.v --pcs xyz
$ vips icc_import php-vips-192.jpg t2.v --pcs lab
$ vips icc_export t1.v output-xyz.v
$ vips icc_export t2.v output-lab.v
$ vips avg output-xyz.v
67.716544
$ vips avg output-lab.v
67.716544
$ sha256sum output-{xyz,lab}.v
1bf5a9392fe67f1948302c6d864f180a3d242391a665f829fb61f5af7dddb32b output-xyz.v
1bf5a9392fe67f1948302c6d864f180a3d242391a665f829fb61f5af7dddb32b output-lab.v Though, I had to raise a test threshold for that (see commit kleisauke@5608c82). |
Three builtin optimisations are skipped when using floats, so I guess it was one of these causing the difference. https://github.com/mm2/Little-CMS/blob/d0752309ff93f62be246ee9bf18338107f30d485/src/cmsopt.c#L661-L662 If the performance is similar then using floats would probably be simpler overall, plus not prevent optimisations that are possible. |
Avoids the need to pack the buffer of floats into lcms's fixed-point formats and ensures full precision internally in lcms. Resolves: libvips#3150. Supersedes: libvips#3368.
Closing in favor of #3373. I confirm the performance on that PR is similar to this PR. |
Resolves: #3150.