diff options
author | Marti Maria <marti.maria@littlecms.com> | 2022-09-20 17:46:04 +0200 |
---|---|---|
committer | Marti Maria <marti.maria@littlecms.com> | 2022-09-20 17:46:04 +0200 |
commit | 7ec90142c2cf63e99fb6d9f0993ddf6a30addf12 (patch) | |
tree | b0d31fdcd5a692f218338cd867e52e483ca8143e /plugins/fast_float/src/fast_float_tethra.c | |
parent | be25a63be953dbfeef41cfec42550739ba74ea63 (diff) | |
download | lcms2-7ec90142c2cf63e99fb6d9f0993ddf6a30addf12.tar.gz |
Added a faster 32-bit float to 32-bit float RGB to Lab conversion
Another special case
Diffstat (limited to 'plugins/fast_float/src/fast_float_tethra.c')
-rw-r--r-- | plugins/fast_float/src/fast_float_tethra.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/plugins/fast_float/src/fast_float_tethra.c b/plugins/fast_float/src/fast_float_tethra.c index ef4fccf..64e011a 100644 --- a/plugins/fast_float/src/fast_float_tethra.c +++ b/plugins/fast_float/src/fast_float_tethra.c @@ -254,10 +254,9 @@ cmsBool OptimizeCLUTRGBTransform(_cmsTransform2Fn* TransformFn, if (T_BYTES(*InputFormat) != sizeof(cmsFloat32Number) || T_BYTES(*OutputFormat) != sizeof(cmsFloat32Number)) return FALSE; - // Input has to be RGB, Output may be any but Lab + // Input has to be RGB if (T_COLORSPACE(*InputFormat) != PT_RGB) return FALSE; - if (T_COLORSPACE(*OutputFormat) == PT_Lab) return FALSE; - + OriginalLut = *Lut; ContextID = cmsGetPipelineContextID(OriginalLut); @@ -286,6 +285,22 @@ cmsBool OptimizeCLUTRGBTransform(_cmsTransform2Fn* TransformFn, cmsPipelineInsertStage(OriginalLut, cmsAT_END, percent); } + else + // If output is Lab, add a conversion stage to get Lab values + if (T_COLORSPACE(*OutputFormat) == PT_Lab) { + + static const cmsFloat64Number mat[] = { 100.0, 0, 0, + 0, 255.0, 0, + 0, 0, 255.0 }; + + static const cmsFloat64Number off[] = { 0, -128.0, -128.0 }; + + cmsStage* lab_fix = cmsStageAllocMatrix(ContextID, 3, 3, mat, off); + if (lab_fix == NULL) goto Error; + + cmsPipelineInsertStage(OriginalLut, cmsAT_END, lab_fix); + } + // Resample the LUT if (!cmsStageSampleCLutFloat(OptimizedCLUTmpe, XFormSampler, (void*)OriginalLut, 0)) goto Error; |