fix a race in xyz to lab

the table build had a race condition
This commit is contained in:
John Cupitt 2011-08-03 10:12:45 +01:00
parent 1bded6682e
commit 8790e552b6
4 changed files with 15 additions and 12 deletions

1
.gitignore vendored
View File

@ -125,4 +125,5 @@ doc/reference/sgml.stamp
doc/reference/xml/
doc/html
doc/pdf
gtkdocerrors

View File

@ -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

View File

@ -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

View File

@ -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.