diff --git a/.gitignore b/.gitignore index c6433cc5..6e004421 100644 --- a/.gitignore +++ b/.gitignore @@ -125,4 +125,5 @@ doc/reference/sgml.stamp doc/reference/xml/ doc/html doc/pdf +gtkdocerrors diff --git a/ChangeLog b/ChangeLog index 233ccfff..720aec45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 26/7/11 started 7.26.1 - doc fixups - oops, ==0 missing from a strcmp() in vips7compat +- fixed a race in im_XYZ2Lab() table build 26/7/11 started 7.26.0 - version bunp for 7.26 diff --git a/libvips/colour/im_LabQ2disp.c b/libvips/colour/im_LabQ2disp.c index d5c0a8d0..88865f93 100644 --- a/libvips/colour/im_LabQ2disp.c +++ b/libvips/colour/im_LabQ2disp.c @@ -1,10 +1,6 @@ -/* @(#) Turn Lab 32bit packed format into displayable rgb. Fast, but very - * @(#) inaccurate: for display only! - * @(#) - * @(#) Usage: - * @(#) int im_LabQ2disp( IMAGE *in, IMAGE *out, struct im_col_display *d ) - * @(#) - * @(#) Returns: -1 on error, else 0 +/* Turn Lab 32bit packed format into displayable rgb. Fast, but very + * inaccurate: for display only! Note especially that this dithers and will + * give different results on different runs. * * 5/11/97 Steve Perry * - adapted from old ip code diff --git a/libvips/colour/im_XYZ2Lab.c b/libvips/colour/im_XYZ2Lab.c index 2c936ba7..7a5892f4 100644 --- a/libvips/colour/im_XYZ2Lab.c +++ b/libvips/colour/im_XYZ2Lab.c @@ -15,6 +15,8 @@ * - ahem, build the LUT outside the eval thread * 2/11/09 * - gtkdoc + * 3/8/11 + * - fix a race in the table build */ /* @@ -74,15 +76,14 @@ imb_XYZ2Lab_tables( void ) { static int built_tables = 0; - int was_built; int i; g_mutex_lock( im__global_lock ); - was_built = built_tables; - built_tables = 1; - g_mutex_unlock( im__global_lock ); - if( was_built ) + + if( built_tables ) { + g_mutex_unlock( im__global_lock ); return; + } for( i = 0; i < QUANT_ELEMENTS; i++ ) { float Y = (double) i / QUANT_ELEMENTS; @@ -92,6 +93,10 @@ imb_XYZ2Lab_tables( void ) else cbrt_table[i] = cbrt( Y ); } + + built_tables = 1; + + g_mutex_unlock( im__global_lock ); } /* Process a buffer of data.