From a40397c43807f3ff958298dc01bfa9fc1f5be3f7 Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Wed, 9 Mar 2016 19:20:57 +0000 Subject: [PATCH 1/2] Build LAB to sRGB tables only when first needed Reduces libvips start-up time by ~20ms --- libvips/colour/LabQ2sRGB.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libvips/colour/LabQ2sRGB.c b/libvips/colour/LabQ2sRGB.c index 9113b9cc..97184762 100644 --- a/libvips/colour/LabQ2sRGB.c +++ b/libvips/colour/LabQ2sRGB.c @@ -468,6 +468,8 @@ vips_col_make_tables_LabQ2sRGB( void ) static void vips_LabQ2sRGB_line( VipsColour *colour, VipsPel *q, VipsPel **in, int width ) { + vips_col_make_tables_LabQ2sRGB(); + unsigned char *p = (unsigned char *) in[0]; int i, t; @@ -526,8 +528,6 @@ vips_LabQ2sRGB_class_init( VipsLabQ2sRGBClass *class ) object_class->description = _( "convert a LabQ image to sRGB" ); colour_class->process_line = vips_LabQ2sRGB_line; - - vips_col_make_tables_LabQ2sRGB(); } static void From 61d2aa658603f561b7ef1447d1dad35c55095dfd Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 10 Mar 2016 08:53:54 +0000 Subject: [PATCH 2/2] formatting --- libvips/colour/LabQ2sRGB.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libvips/colour/LabQ2sRGB.c b/libvips/colour/LabQ2sRGB.c index 97184762..06b6c285 100644 --- a/libvips/colour/LabQ2sRGB.c +++ b/libvips/colour/LabQ2sRGB.c @@ -22,6 +22,8 @@ * - spot NaN, Inf in XYZ2RGB, they break LUT indexing * - split sRGB <-> XYZ into sRGB <-> scRGB <-> XYZ so we can support * scRGB as a colourspace + * 10/3/16 Lovell Fuller + * - move vips_col_make_tables_LabQ2sRGB() to first pixel processing */ /* @@ -468,8 +470,6 @@ vips_col_make_tables_LabQ2sRGB( void ) static void vips_LabQ2sRGB_line( VipsColour *colour, VipsPel *q, VipsPel **in, int width ) { - vips_col_make_tables_LabQ2sRGB(); - unsigned char *p = (unsigned char *) in[0]; int i, t; @@ -480,6 +480,8 @@ vips_LabQ2sRGB_line( VipsColour *colour, VipsPel *q, VipsPel **in, int width ) int ae = 0; int be = 0; + vips_col_make_tables_LabQ2sRGB(); + for( i = 0; i < width; i++ ) { /* Get colour, add in error from previous pixel. */