Merge branch 'master' of github.com:jcupitt/libvips

Conflicts:
	TODO
This commit is contained in:
John Cupitt 2014-09-24 12:24:57 +01:00
commit 6ad94da99c
11 changed files with 94 additions and 46 deletions

3
TODO
View File

@ -15,6 +15,9 @@
non-instantiatable type '(null)' non-instantiatable type '(null)'
Trace/breakpoint trap (core dumped) Trace/breakpoint trap (core dumped)
- colour difference does detach / reattach bands (badly), it should
use the thing in the base class instead
- dECMC result differs from Lindbloom's result: - dECMC result differs from Lindbloom's result:
http://www.brucelindbloom.com/index.html?Eqn_DeltaE_CIE2000.html http://www.brucelindbloom.com/index.html?Eqn_DeltaE_CIE2000.html

View File

@ -153,21 +153,12 @@ vips_sum_init( VipsSum *sum )
static int static int
vips_sumv( VipsImage **in, VipsImage **out, int n, va_list ap ) vips_sumv( VipsImage **in, VipsImage **out, int n, va_list ap )
{ {
VipsArea *area; VipsArrayImage *array;
VipsImage **array;
int i;
int result; int result;
area = vips_area_new_array_object( n ); array = vips_array_image_new( in, n );
array = (VipsImage **) area->data; result = vips_call_split( "sum", ap, array, out );
for( i = 0; i < n; i++ ) { vips_area_unref( VIPS_AREA( array ) );
array[i] = in[i];
g_object_ref( array[i] );
}
result = vips_call_split( "sum", ap, area, out );
vips_area_unref( area );
return( result ); return( result );
} }

View File

@ -444,7 +444,7 @@ vips_colour_space_build( VipsObject *object )
{ {
VipsColour *colour = VIPS_COLOUR( object ); VipsColour *colour = VIPS_COLOUR( object );
VipsColourSpace *space = VIPS_COLOUR_SPACE( object ); VipsColourSpace *space = VIPS_COLOUR_SPACE( object );
VipsImage **t = (VipsImage **) vips_object_local_array( object, 2 ); VipsImage **t = (VipsImage **) vips_object_local_array( object, 1 );
/* We only process float. /* We only process float.
*/ */

View File

@ -187,21 +187,12 @@ vips_bandjoin_init( VipsBandjoin *bandjoin )
static int static int
vips_bandjoinv( VipsImage **in, VipsImage **out, int n, va_list ap ) vips_bandjoinv( VipsImage **in, VipsImage **out, int n, va_list ap )
{ {
VipsArea *area; VipsArrayImage *array;
VipsImage **array;
int i;
int result; int result;
area = vips_area_new_array_object( n ); array = vips_array_image_new( in, n );
array = (VipsImage **) area->data; result = vips_call_split( "bandjoin", ap, array, out );
for( i = 0; i < n; i++ ) { vips_area_unref( VIPS_AREA( array ) );
array[i] = in[i];
g_object_ref( array[i] );
}
result = vips_call_split( "bandjoin", ap, area, out );
vips_area_unref( area );
return( result ); return( result );
} }

View File

@ -256,21 +256,12 @@ vips_bandrank_init( VipsBandrank *bandrank )
static int static int
vips_bandrankv( VipsImage **in, VipsImage **out, int n, va_list ap ) vips_bandrankv( VipsImage **in, VipsImage **out, int n, va_list ap )
{ {
VipsArea *area; VipsArrayImage *array;
VipsImage **array;
int i;
int result; int result;
area = vips_area_new_array_object( n ); array = vips_array_image_new( in, n );
array = (VipsImage **) area->data; result = vips_call_split( "bandrank", ap, array, out );
for( i = 0; i < n; i++ ) { vips_area_unref( VIPS_AREA( array ) );
array[i] = in[i];
g_object_ref( array[i] );
}
result = vips_call_split( "bandrank", ap, area, out );
vips_area_unref( area );
return( result ); return( result );
} }

View File

@ -465,7 +465,8 @@ int vips_system( const char *cmd_format, ... )
/* Defined in type.c, but declared here since they use VipsImage. /* Defined in type.c, but declared here since they use VipsImage.
*/ */
VipsArrayImage *vips_array_image_new( const VipsImage **array, int n ); VipsArrayImage *vips_array_image_new( VipsImage **array, int n );
VipsArrayImage *vips_array_image_newv( int n, ... );
VipsImage **vips_array_image_get( VipsArrayImage *array, int *n ); VipsImage **vips_array_image_get( VipsArrayImage *array, int *n );
VipsImage **vips_value_get_array_image( const GValue *value, int *n ); VipsImage **vips_value_get_array_image( const GValue *value, int *n );
int vips_value_set_array_image( GValue *value, VipsImage **array, int n ); int vips_value_set_array_image( GValue *value, VipsImage **array, int n );

View File

@ -196,6 +196,9 @@ typedef struct _VipsArrayImage {
VipsArea area; VipsArea area;
} VipsArrayImage; } VipsArrayImage;
/* See image.h for vips_array_image_new() etc., they need to be declared after
* VipsImage.
*/
GType vips_array_image_get_type( void ); GType vips_array_image_get_type( void );
void vips_value_set_area( GValue *value, VipsCallbackFn free_fn, void *data ); void vips_value_set_area( GValue *value, VipsCallbackFn free_fn, void *data );

View File

@ -389,8 +389,8 @@ vips_leak( void )
vips__type_leak(); vips__type_leak();
#ifdef DEBUG #ifdef DEBUG
#endif /*DEBUG*/
vips_buffer_dump_all(); vips_buffer_dump_all();
#endif /*DEBUG*/
} }
/** /**

View File

@ -999,6 +999,10 @@ transform_g_string_array_image( const GValue *src_value, GValue *dest_value )
* @n: number of images * @n: number of images
* *
* Allocate a new array of images and copy @array into it. Free with * Allocate a new array of images and copy @array into it. Free with
* vips_area_unref().
*
* The images will all be reffed by this function. They
* will be automatically unreffed for you by
* vips_area_unref(). * vips_area_unref().
* *
* See also: #VipsArea. * See also: #VipsArea.
@ -1006,14 +1010,58 @@ transform_g_string_array_image( const GValue *src_value, GValue *dest_value )
* Returns: (transfer full): A new #VipsArrayImage. * Returns: (transfer full): A new #VipsArrayImage.
*/ */
VipsArrayImage * VipsArrayImage *
vips_array_image_new( const VipsImage **array, int n ) vips_array_image_new( VipsImage **array, int n )
{ {
VipsArea *area; VipsArea *area;
VipsImage *array_copy; VipsImage **array_copy;
int i;
area = vips_area_new_array_object( n );
area->type = VIPS_TYPE_IMAGE;
area = vips_area_new_array( G_TYPE_DOUBLE, sizeof( double ), n );
array_copy = vips_area_get_data( area, NULL, NULL, NULL, NULL ); array_copy = vips_area_get_data( area, NULL, NULL, NULL, NULL );
memcpy( array_copy, array, n * sizeof( double ) ); for( i = 0; i < n; i++ ) {
array_copy[i] = (VipsImage *) array[i];
g_object_ref( array_copy[i] );
}
return( (VipsArrayImage *) area );
}
/**
* vips_array_image_newv:
* @n: number of images
* @...: list of #VipsImage arguments
*
* Allocate a new array of @n #VipsImage and copy @... into it. Free with
* vips_area_unref().
*
* The images will all be reffed by this function. They
* will be automatically unreffed for you by
* vips_area_unref().
*
* See also: vips_array_image_new()
*
* Returns: (transfer full): A new #VipsArrayImage.
*/
VipsArrayImage *
vips_array_image_newv( int n, ... )
{
va_list ap;
VipsArea *area;
VipsImage **array;
int i;
area = vips_area_new_array_object( n );
area->type = VIPS_TYPE_IMAGE;
array = vips_area_get_data( area, NULL, NULL, NULL, NULL );
va_start( ap, n );
for( i = 0; i < n; i++ ) {
array[i] = va_arg( ap, VipsImage * );
g_object_ref( array[i] );
}
va_end( ap );
return( (VipsArrayImage *) area ); return( (VipsArrayImage *) area );
} }

9
python/soak.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
export G_DEBUG=fatal-warnings
while true; do
if ! python test_colour.py TestColour.test_bug; then
exit
fi
done

View File

@ -107,6 +107,17 @@ class TestColour(unittest.TestCase):
self.mono = self.colour.extract_band(1) self.mono = self.colour.extract_band(1)
self.all_images = [self.mono, self.colour] self.all_images = [self.mono, self.colour]
def test_bug(self):
# mid-grey in Lab ... put 42 in the extra band, it should be copied
# unmodified
test = Vips.Image.black(100, 100) + [50, 0, 0, 42]
test = test.copy(interpretation = Vips.Interpretation.LAB)
# a long series should come in a circle
im = test
for col in [Vips.Interpretation.RGB16]:
im = im.colourspace(col)
def test_colourspace(self): def test_colourspace(self):
# mid-grey in Lab ... put 42 in the extra band, it should be copied # mid-grey in Lab ... put 42 in the extra band, it should be copied
# unmodified # unmodified