diff options
author | Marti Maria <marti.maria@littlecms.com> | 2023-05-10 08:59:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-10 08:59:41 +0200 |
commit | cdf9635b69c3f270684b3e6a0cdeda9b03ce920c (patch) | |
tree | 6d0d549c5d3c37902349d6113de4f0814311c3c0 | |
parent | 5ac2593ca31ca78857e8e4bf0a2a097b654d7f98 (diff) | |
parent | 2479d91f31e1d4687ad45aadc7da93ed16959f19 (diff) | |
download | lcms2-cdf9635b69c3f270684b3e6a0cdeda9b03ce920c.tar.gz |
Merge pull request #379 from nico/patch-1
Simplify fixed-point to double conversion routines
Looks good, thank you!
-rw-r--r-- | src/cmsplugin.c | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/src/cmsplugin.c b/src/cmsplugin.c index 3876506..e278832 100644 --- a/src/cmsplugin.c +++ b/src/cmsplugin.c @@ -364,12 +364,7 @@ cmsBool CMSEXPORT _cmsWriteXYZNumber(cmsIOHANDLER* io, const cmsCIEXYZ* XYZ) // from Fixed point 8.8 to double cmsFloat64Number CMSEXPORT _cms8Fixed8toDouble(cmsUInt16Number fixed8) { - cmsUInt8Number msb, lsb; - - lsb = (cmsUInt8Number) (fixed8 & 0xff); - msb = (cmsUInt8Number) (((cmsUInt16Number) fixed8 >> 8) & 0xff); - - return (cmsFloat64Number) ((cmsFloat64Number) msb + ((cmsFloat64Number) lsb / 256.0)); + return fixed8 / 256.0; } cmsUInt16Number CMSEXPORT _cmsDoubleTo8Fixed8(cmsFloat64Number val) @@ -381,19 +376,7 @@ cmsUInt16Number CMSEXPORT _cmsDoubleTo8Fixed8(cmsFloat64Number val) // from Fixed point 15.16 to double cmsFloat64Number CMSEXPORT _cms15Fixed16toDouble(cmsS15Fixed16Number fix32) { - cmsFloat64Number floater, sign, mid; - int Whole, FracPart; - - sign = (fix32 < 0 ? -1 : 1); - fix32 = abs(fix32); - - Whole = (cmsUInt16Number)(fix32 >> 16) & 0xffff; - FracPart = (cmsUInt16Number)(fix32 & 0xffff); - - mid = (cmsFloat64Number) FracPart / 65536.0; - floater = (cmsFloat64Number) Whole + mid; - - return sign * floater; + return fix32 / 65536.0; } // from double to Fixed point 15.16 |