fix a race in im_maxpos_avg()

This commit is contained in:
John Cupitt 2014-07-25 13:52:36 +01:00
parent 79a144c3f0
commit a338a48c63
4 changed files with 13 additions and 29 deletions

View File

@ -1,3 +1,6 @@
25/7/14 started 7.40.5
- fix a race in im_maxpos_avg()
4/7/14 started 7.40.4
- fix vips_rawsave_fd(), thanks aferrero2707
- fix im_point()

26
TODO
View File

@ -1,30 +1,4 @@
- maxpos_avg seems to give variable results
irb(main):022:0> im.maxpos_avg
=> [141.0, 138.0, 248.0]
irb(main):023:0> im.maxpos_avg
=> [73.0, 95.0, 248.0]
[107.0, 116.5, 248.0] is correct, checked by hand
$ vips max --size 10 spec/samples/wagon.v --x-array --y-array --out-array
72 107 78 73 74 75 99 100 141 73
95 141 94 94 94 95 131 131 138 95
245 246 246 247 247 247 247 247 248 248
248.000000
so there are two maxes of 248, result should be average of the two
seems to be a race in maxpos_avg, it's still some Tom code, replace with a
wrapper over vips_max()
hard to do, since vips_max() needs to be told in advance the number of maxes
it should search for
- threadpool recyling might be useful for dzsave?

View File

@ -2,7 +2,7 @@
# also update the version number in the m4 macros below
AC_INIT([vips], [7.40.4], [vipsip@jiscmail.ac.uk])
AC_INIT([vips], [7.40.5], [vipsip@jiscmail.ac.uk])
# required for gobject-introspection
AC_PREREQ(2.62)
@ -18,7 +18,7 @@ AC_CONFIG_MACRO_DIR([m4])
# user-visible library versioning
m4_define([vips_major_version], [7])
m4_define([vips_minor_version], [40])
m4_define([vips_micro_version], [4])
m4_define([vips_micro_version], [5])
m4_define([vips_version],
[vips_major_version.vips_minor_version.vips_micro_version])
@ -38,7 +38,7 @@ VIPS_VERSION_STRING=$VIPS_VERSION-`date`
# binary interface changes not backwards compatible?: reset age to 0
LIBRARY_CURRENT=38
LIBRARY_REVISION=2
LIBRARY_REVISION=3
LIBRARY_AGE=0
# patched into include/vips/version.h

View File

@ -15,6 +15,8 @@
* 8/9/08
* - rewrite from im_maxpos()
* - now handles many bands, complex, faster
* 27/7/14
* - fix a race ... did not merge states if max was equal
*/
/*
@ -116,6 +118,11 @@ maxposavg_stop( void *seq, void *a, void *b )
*/
if( maxposavg->max > global_maxposavg->max )
*global_maxposavg = *maxposavg;
else if( maxposavg->max == global_maxposavg->max ) {
global_maxposavg->xpos += maxposavg->xpos;
global_maxposavg->ypos += maxposavg->ypos;
global_maxposavg->occurences += maxposavg->occurences;
}
im_free( seq );