RFR: 8295430: Use cmsDoTransformLineStride instead of cmsDoTransform in the loop
Sergey Bylokhov
serb at openjdk.org
Fri Oct 21 20:02:24 UTC 2022
On Wed, 19 Oct 2022 02:59:37 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:
> This is the request to improve the change made by the
> [8005530: [lcms] Improve performance of ColorConverOp for default destinations](http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/fd8810d50c99)
>
> Right now the LCMSTransform mantain the special "imageAtOnce" flags and call cmsDoTransform function in the loop per line to support the gaps betwen the lines in the images . This code can be improved by using one call to cmsDoTransformLineStride. Some discussion about this method can be found [here](https://github.com/mm2/Little-CMS/issues/314), the full [specification](https://github.com/mm2/Little-CMS/blob/master/doc/LittleCMS2.14%20API.pdf):
>
>
> void cmsDoTransformLineStride(cmsHTRANSFORM Transform,
> const void* InputBuffer,
> void* OutputBuffer,
> cmsUInt32Number PixelsPerLine,
> cmsUInt32Number LineCount,
> cmsUInt32Number BytesPerLineIn,
> cmsUInt32Number BytesPerLineOut,
> cmsUInt32Number BytesPerPlaneIn,
> cmsUInt32Number BytesPerPlaneOut);
>
> This function translates bitmaps with complex organization. Each bitmap may contain
> several lines, and every may have padding. The distance from one line to the next one is
> BytesPerLine{In/Out}. In planar formats, each line may hold several planes, each plane may
> have padding. Padding of lines and planes should be same across all bitmap. I.e. all lines
> in same bitmap have to be padded in same way. This function may be more efficient that
> repeated calls to cmsDoTransform(), especially when customized plug-ins are being used.
>
> Parameters:
>
> - hTransform: Handle to a color transform object.
> - InputBuffer: A pointer to the input bitmap
> - OutputBuffer: A pointer to the output bitmap.
> - PixelsPerLine: The number of pixels for line, which is same on input and in output.
> - LineCount: The number of lines, which is same on input and output
> - BytesPerLine{In,Out}: The distance in bytes from one line to the next one.
> - BytesPerPlaneIn{In,Out}: The distance in bytes from one plane to the next one inside a line. Only applies
> in planar formats.
>
>
> Notes:
> - This function is quite efficient, and is used by some plug-ins to give a big
> speedup. If you can load whole image to memory and then call this function
> over it, it will be much faster than any other approach.
> - BytesPerPlaneIn{In,Out} is ignored if the formats used are not planar. Please note
> 1-plane planar is indistinguishable from 1-component chunky, so BytesPerPlane is
> ignored as well in this case.
> - If the image does not have any gaps between the pixels and lines BytesPerLine{}
> are equal to the pixel's size * PixelsPerLine.
> - To specify padding between pixels, use T_EXTRA() and EXTRA_SH() to specify
> extra channels.
src/java.desktop/share/native/liblcms/LCMS.c line 554:
> 552:
> 553: cmsDoTransformLineStride(sTrans, input, output, width, height,
> 554: srcNextRowOffset, dstNextRowOffset, 0, 0);
We do not use "planar" types, so the last two parameters are ignored.
-------------
PR: https://git.openjdk.org/jdk/pull/10754
More information about the client-libs-dev
mailing list