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

Different results depending on endianess #395

Closed
sommerluk opened this issue Jul 31, 2023 · 5 comments
Closed

Different results depending on endianess #395

sommerluk opened this issue Jul 31, 2023 · 5 comments

Comments

@sommerluk
Copy link
Contributor

Setup

Consider the following code:

    cmsHPROFILE rgbProfileHandle = cmsCreate_sRGBProfile();
    cmsHPROFILE cielabD50ProfileHandle = cmsCreateLab4Profile(nullptr); // nullptr means: Default white point (D50)
    auto m_transformRgbToCielabD50Handle = cmsCreateTransform(
        rgbProfileHandle, // input profile handle
        TYPE_RGB_DBL, // input buffer format
        cielabD50ProfileHandle, // output profile handle
        TYPE_Lab_DBL, // output buffer format
        INTENT_ABSOLUTE_COLORIMETRIC,
        cmsFLAGS_NOCACHE);
    cmsCloseProfile(cielabD50ProfileHandle);
    cmsCloseProfile(rgbProfileHandle);

    cmsFloat64Number rgb[3] = {red, green, blue};
    cmsCIELab cielabD50;
    cmsDoTransform(m_transformRgbToCielabD50Handle, // handle to transform
                   &rgb, // input
                   &cielabD50, // output
                   1 // convert exactly 1 value
    );

Using LCMS 2.12.0 on Ubuntu Linux 22.04 LTS.

Actual result

For red, green and blue = 0, depending if you are on a big endian or a little endian machine, the value of cielabD50 lightness is different:

  • On little endian: 0.000000e+00 7.569790e-06 7.569790e-06
  • On big endian: -2.220446e-16 7.569790e-06 7.569790e-06

Expected results

  • The value of cielabD50 is identical on big endian and little endian machines.
  • The value of cielabD50 lightness is never negative.

Additional information

For red, green and blue = 0,001, this results in cielabD50 6.991457e-02 7.569790e-06 7.569790e-06 on both, little endian and big endian machines. Also, for all other higher values, the result on little endian and big endian seem to give identical results.

@mm2
Copy link
Owner

mm2 commented Jul 31, 2023

Hi. Thanks for reporting, unfortunately I have no way to access a big endian machine anymore. Have you tried with 2.15?
Could you run the testbed on the big endian machine? i.e "make check" Does it pass the tests?
Thanks!

@sommerluk
Copy link
Contributor Author

sommerluk commented Jul 31, 2023

Well, I have no direct access to a bigendian machine either. I use Docker + qemu to emulate one within the CI. This can be done also for LittleCMS: https://github.com/sommerluk/Little-CMS/blob/1ee56666795bf695c2e1b24c4a034343bfde0b44/.circleci/config.yml

Result for current lcms master:
log.txt

@mm2
Copy link
Owner

mm2 commented Aug 10, 2023

Finally I have been able to check the testbed on an very old PowerPC that is true big endian. There is no issue there.
Maybe is something on the emulation?
Keep in mind a very small negative number on L* can happen on profiles where the zero is calculated. Floating point zero is quite difficult to obtain when it comes from a complex calculation, and we are talking about 0.00000000000000022

@sommerluk
Copy link
Contributor Author

Indeed, the difference is very small. I only noticed it because I had a failing unit test that checked that the results of a function that relies on LittleCMS are within the given range.

Should we close this report as non-issue?

@mm2
Copy link
Owner

mm2 commented Aug 30, 2023

Should we close this report as non-issue?

Sure. Closed as I cannot reproduce it anyway.

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

2 participants