fix a race in xyz to lab
the table build had a race condition
This commit is contained in:
parent
1bded6682e
commit
8790e552b6
1
.gitignore
vendored
1
.gitignore
vendored
@ -125,4 +125,5 @@ doc/reference/sgml.stamp
|
|||||||
doc/reference/xml/
|
doc/reference/xml/
|
||||||
doc/html
|
doc/html
|
||||||
doc/pdf
|
doc/pdf
|
||||||
|
gtkdocerrors
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
26/7/11 started 7.26.1
|
26/7/11 started 7.26.1
|
||||||
- doc fixups
|
- doc fixups
|
||||||
- oops, ==0 missing from a strcmp() in vips7compat
|
- oops, ==0 missing from a strcmp() in vips7compat
|
||||||
|
- fixed a race in im_XYZ2Lab() table build
|
||||||
|
|
||||||
26/7/11 started 7.26.0
|
26/7/11 started 7.26.0
|
||||||
- version bunp for 7.26
|
- version bunp for 7.26
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
/* @(#) Turn Lab 32bit packed format into displayable rgb. Fast, but very
|
/* Turn Lab 32bit packed format into displayable rgb. Fast, but very
|
||||||
* @(#) inaccurate: for display only!
|
* inaccurate: for display only! Note especially that this dithers and will
|
||||||
* @(#)
|
* give different results on different runs.
|
||||||
* @(#) Usage:
|
|
||||||
* @(#) int im_LabQ2disp( IMAGE *in, IMAGE *out, struct im_col_display *d )
|
|
||||||
* @(#)
|
|
||||||
* @(#) Returns: -1 on error, else 0
|
|
||||||
*
|
*
|
||||||
* 5/11/97 Steve Perry
|
* 5/11/97 Steve Perry
|
||||||
* - adapted from old ip code
|
* - adapted from old ip code
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
* - ahem, build the LUT outside the eval thread
|
* - ahem, build the LUT outside the eval thread
|
||||||
* 2/11/09
|
* 2/11/09
|
||||||
* - gtkdoc
|
* - gtkdoc
|
||||||
|
* 3/8/11
|
||||||
|
* - fix a race in the table build
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -74,15 +76,14 @@ imb_XYZ2Lab_tables( void )
|
|||||||
{
|
{
|
||||||
static int built_tables = 0;
|
static int built_tables = 0;
|
||||||
|
|
||||||
int was_built;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
g_mutex_lock( im__global_lock );
|
g_mutex_lock( im__global_lock );
|
||||||
was_built = built_tables;
|
|
||||||
built_tables = 1;
|
if( built_tables ) {
|
||||||
g_mutex_unlock( im__global_lock );
|
g_mutex_unlock( im__global_lock );
|
||||||
if( was_built )
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for( i = 0; i < QUANT_ELEMENTS; i++ ) {
|
for( i = 0; i < QUANT_ELEMENTS; i++ ) {
|
||||||
float Y = (double) i / QUANT_ELEMENTS;
|
float Y = (double) i / QUANT_ELEMENTS;
|
||||||
@ -92,6 +93,10 @@ imb_XYZ2Lab_tables( void )
|
|||||||
else
|
else
|
||||||
cbrt_table[i] = cbrt( Y );
|
cbrt_table[i] = cbrt( Y );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
built_tables = 1;
|
||||||
|
|
||||||
|
g_mutex_unlock( im__global_lock );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process a buffer of data.
|
/* Process a buffer of data.
|
||||||
|
Loading…
Reference in New Issue
Block a user