mm2 / Little-CMS

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

Pack/Unroll for the common formats are not implemented #356

Closed mrserb closed 1 year ago

mrserb commented 1 year ago

The LittleCMS library supports many variations of colorspaces, pixels layout, alpha, planar, etc/etc. To handle all that variations the library transforms the input/output data to/from the cmsFormatters16 or to/from the cmsFormattersFloat. To improve the performance of this operation the library selects some specific Input/output formatter based on input/output data.

For example, here is the list of input formatters for cmsFormatters16. Note that the Unroll1Byte formatter is small and fast, but a generic formatter which can handle all the formats is big and slow.

Unfortunately, the list for the cmsFormattersFloat type is small and has only some generic/slow formatters.

I am interested is it possible to implement the specific formatters for such common format as 3-components (ex RGB), and maybe 1-components (ex GRAY), 3-comps+1-extra (ex RGBA) or there are some limitations that I am missing? I assume the implementation of that formatters will be just copying the bytes from input to output similar to the implementation of Unroll1Byte/Unroll3Bytes/Unroll3BytesSkip1Swap?

Probably one N-components formatter will be good enough if that will use just one simple loop.

mm2 commented 1 year ago

This is on purpose and is a strategic decision. If you want to use lcms in your commercial products, that's ok but floating point is generic and slow. If you want fast floating point, then you could use the fast_float plugin, which is way faster than just changing the formatters. But this latter is under GPL3. I like to promote free projects under GPL3 so I give them this advantage.

mrserb commented 1 year ago

Unfortunately the OpenJDK is not commercial and its license GPL2+CP is not compatible to the GPL3.

mm2 commented 1 year ago

You could also create a plug-in for the extra formatters. This is really simple and could live in the OpenJDK layer.

mrserb commented 1 year ago

That would be great. Any examples of some simple plugins I cat learn on how to implement it? I cannot look to the standard lcms plugin to make sure I did not copy it.

mm2 commented 1 year ago

There is a full manual with examples. Take a look on doc folder of distribution