Skip to content

Commit

Permalink
[WiP] Use lcms2 fast-float plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
kleisauke committed Feb 7, 2021
1 parent 4605ad6 commit a1a122e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
12 changes: 12 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,18 @@ if test x"$with_lcms" != x"no"; then
)
fi

# fast-float plugin (GPL3) added in 2.10.
if test x"$with_lcms" != x"no"; then
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $LCMS_CFLAGS"
AC_CHECK_DECL(LCMS2_FAST_FLOAT_VERSION,[
AC_DEFINE(HAVE_LCMS2_FAST_FLOAT_PLUGIN,1,
[define if the fast-float plugin of lcms2 is available.])
],[],
[#include <lcms2_fast_float.h>])
CFLAGS="$save_CFLAGS"
fi

# we need a conditional for this to only compile in fallback profiles if lcms
# is detected
AM_CONDITIONAL(ENABLE_LCMS, [test x"$with_lcms" != x"no"])
Expand Down
22 changes: 22 additions & 0 deletions libvips/colour/icc_transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@
*/
#include <lcms2.h>

#ifdef HAVE_LCMS2_FAST_FLOAT_PLUGIN
#include <lcms2_fast_float.h>
#endif

#include <vips/vips.h>

#include "pcolour.h"
Expand Down Expand Up @@ -207,14 +211,32 @@ is_pcs( cmsHPROFILE profile )
cmsGetColorSpace( profile ) == cmsSigXYZData );
}

#ifdef HAVE_LCMS2_FAST_FLOAT_PLUGIN
static void *
vips_icc_fast_float_init_cb( void *a )
{
cmsPlugin( cmsFastFloatExtensions() );

return( NULL );
}
#endif

static int
vips_icc_build( VipsObject *object )
{
#ifdef HAVE_LCMS2_FAST_FLOAT_PLUGIN
static GOnce once = G_ONCE_INIT;
#endif

VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object );
VipsColour *colour = (VipsColour *) object;
VipsColourCode *code = (VipsColourCode *) object;
VipsIcc *icc = (VipsIcc *) object;

#ifdef HAVE_LCMS2_FAST_FLOAT_PLUGIN
VIPS_ONCE( &once, vips_icc_fast_float_init_cb, NULL );
#endif

if( icc->depth != 8 &&
icc->depth != 16 ) {
vips_error( class->nickname,
Expand Down

0 comments on commit a1a122e

Please sign in to comment.