mm2 / Little-CMS

A free, open source, CMM engine. It provides fast transforms between ICC profiles.
https://www.littlecms.com
MIT License
549 stars 174 forks source link

cmsDoTransform for 64 bit image size #453

Closed boxerab closed 2 months ago

boxerab commented 2 months ago

First of all, thank you so much for this wonderful library.

Secondly, have you considered supporting images greater than 2^32 pixels in size ? This situation can arise for JPEG 2000 codec where images can be up to 2^64 pixels. Thanks!

mm2 commented 2 months ago

Thanks for your suggestion! In fact it is already done by this commit c429e374fbc1a0769af6d6516726242a7a0abfe5 Will be in the next release, if you need it now just use the unstable GIT sources.

boxerab commented 2 months ago

Great, thanks!

boxerab commented 2 months ago

Thanks, I checked the header in latest master and I still see

CMSAPI void             CMSEXPORT cmsDoTransform(cmsHTRANSFORM Transform,
                                                 const void * InputBuffer,
                                                 void * OutputBuffer,
                                                 cmsUInt32Number Size);

So, Size is still limited to 32 bit.

mm2 commented 2 months ago

Please use cmsDoTransformLineStride instead. Lines and pixels per line must be 32 bits but the product can reach 64 bits. This is the only way I have to allow big blocks keeping strict ABI compatibility.

boxerab commented 2 months ago

Thanks, that is much better. There is still a chance of overflow when image is RGB and/or 16 bit depth, and width is close to 2^32, but much less likely. Will you be able to change the signature to size_t in the future ?