remove limit on n image in composite
composite was limited to a max of 64 images ... remove the limit see https://github.com/jcupitt/pyvips/issues/30
This commit is contained in:
parent
97a4ed2ca9
commit
5fd2ecf81d
@ -3,6 +3,7 @@
|
|||||||
- fix a minor accidental ABI break in 8.6.0 -> 8.6.1 [remicollet]
|
- fix a minor accidental ABI break in 8.6.0 -> 8.6.1 [remicollet]
|
||||||
- fix read of plane-separate TIFFs with large strips [remicollet]
|
- fix read of plane-separate TIFFs with large strips [remicollet]
|
||||||
- fix a C++ warning in composite.cpp [lovell]
|
- fix a C++ warning in composite.cpp [lovell]
|
||||||
|
- remove number of images limit in composite
|
||||||
|
|
||||||
10/12/17 started 8.6.1
|
10/12/17 started 8.6.1
|
||||||
- fix mmap window new/free cycling
|
- fix mmap window new/free cycling
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
* - from bandjoin.c
|
* - from bandjoin.c
|
||||||
* 30/11/17
|
* 30/11/17
|
||||||
* - add composite2 class, to make a nice CLI interface
|
* - add composite2 class, to make a nice CLI interface
|
||||||
|
* 30/1/18
|
||||||
|
* - remove number of images limit
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -53,10 +55,6 @@
|
|||||||
|
|
||||||
#include "pconversion.h"
|
#include "pconversion.h"
|
||||||
|
|
||||||
/* Maximum number of input images -- why not?
|
|
||||||
*/
|
|
||||||
#define MAX_INPUT_IMAGES (64)
|
|
||||||
|
|
||||||
/* Maximum number of image bands.
|
/* Maximum number of image bands.
|
||||||
*/
|
*/
|
||||||
#define MAX_BANDS (64)
|
#define MAX_BANDS (64)
|
||||||
@ -141,6 +139,88 @@ vips_composite_base_dispose( GObject *gobject )
|
|||||||
G_OBJECT_CLASS( vips_composite_base_parent_class )->dispose( gobject );
|
G_OBJECT_CLASS( vips_composite_base_parent_class )->dispose( gobject );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Our sequence value.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
VipsCompositeBase *composite;
|
||||||
|
|
||||||
|
/* Set of input regions.
|
||||||
|
*/
|
||||||
|
VipsRegion **ir;
|
||||||
|
|
||||||
|
/* For each input, an input pointer.
|
||||||
|
*/
|
||||||
|
VipsPel **p;
|
||||||
|
|
||||||
|
} VipsCompositeSequence;
|
||||||
|
|
||||||
|
static int
|
||||||
|
vips_composite_stop( void *vseq, void *a, void *b )
|
||||||
|
{
|
||||||
|
VipsCompositeSequence *seq = (VipsCompositeSequence *) vseq;
|
||||||
|
|
||||||
|
if( seq->ir ) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for( i = 0; seq->ir[i]; i++ )
|
||||||
|
VIPS_UNREF( seq->ir[i] );
|
||||||
|
VIPS_FREE( seq->ir );
|
||||||
|
}
|
||||||
|
|
||||||
|
VIPS_FREE( seq->p );
|
||||||
|
|
||||||
|
VIPS_FREE( seq );
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
vips_composite_start( VipsImage *out, void *a, void *b )
|
||||||
|
{
|
||||||
|
VipsImage **in = (VipsImage **) a;
|
||||||
|
VipsCompositeBase *composite = (VipsCompositeBase *) b;
|
||||||
|
|
||||||
|
VipsCompositeSequence *seq;
|
||||||
|
int i, n;
|
||||||
|
|
||||||
|
if( !(seq = VIPS_NEW( NULL, VipsCompositeSequence )) )
|
||||||
|
return( NULL );
|
||||||
|
|
||||||
|
seq->composite = composite;
|
||||||
|
seq->ir = NULL;
|
||||||
|
seq->p = NULL;
|
||||||
|
|
||||||
|
/* How many images?
|
||||||
|
*/
|
||||||
|
for( n = 0; in[n]; n++ )
|
||||||
|
;
|
||||||
|
|
||||||
|
/* Alocate space for region array.
|
||||||
|
*/
|
||||||
|
if( !(seq->ir = VIPS_ARRAY( NULL, n + 1, VipsRegion * )) ) {
|
||||||
|
vips_composite_stop( seq, NULL, NULL );
|
||||||
|
return( NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create a set of regions.
|
||||||
|
*/
|
||||||
|
for( i = 0; i < n; i++ )
|
||||||
|
if( !(seq->ir[i] = vips_region_new( in[i] )) ) {
|
||||||
|
vips_composite_stop( seq, NULL, NULL );
|
||||||
|
return( NULL );
|
||||||
|
}
|
||||||
|
seq->ir[n] = NULL;
|
||||||
|
|
||||||
|
/* Input pointers.
|
||||||
|
*/
|
||||||
|
if( !(seq->p = VIPS_ARRAY( NULL, n + 1, VipsPel * )) ) {
|
||||||
|
vips_composite_stop( seq, NULL, NULL );
|
||||||
|
return( NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
return( seq );
|
||||||
|
}
|
||||||
|
|
||||||
/* For each of the supported interpretations, the maximum value of each band.
|
/* For each of the supported interpretations, the maximum value of each band.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
@ -815,47 +895,46 @@ vips_combine_pixels3( VipsCompositeBase *composite, VipsPel *q, VipsPel **p )
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
vips_composite_base_gen( VipsRegion *output_region,
|
vips_composite_base_gen( VipsRegion *output_region,
|
||||||
void *seq, void *a, void *b, gboolean *stop )
|
void *vseq, void *a, void *b, gboolean *stop )
|
||||||
{
|
{
|
||||||
VipsRegion **input_regions = (VipsRegion **) seq;
|
VipsCompositeSequence *seq = (VipsCompositeSequence *) vseq;
|
||||||
VipsCompositeBase *composite = (VipsCompositeBase *) b;
|
VipsCompositeBase *composite = (VipsCompositeBase *) b;
|
||||||
VipsRect *r = &output_region->valid;
|
VipsRect *r = &output_region->valid;
|
||||||
int ps = VIPS_IMAGE_SIZEOF_PEL( output_region->im );
|
int ps = VIPS_IMAGE_SIZEOF_PEL( output_region->im );
|
||||||
|
|
||||||
if( vips_reorder_prepare_many( output_region->im, input_regions, r ) )
|
if( vips_reorder_prepare_many( output_region->im, seq->ir, r ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
VIPS_GATE_START( "vips_composite_base_gen: work" );
|
VIPS_GATE_START( "vips_composite_base_gen: work" );
|
||||||
|
|
||||||
for( int y = 0; y < r->height; y++ ) {
|
for( int y = 0; y < r->height; y++ ) {
|
||||||
VipsPel *p[MAX_INPUT_IMAGES];
|
|
||||||
VipsPel *q;
|
VipsPel *q;
|
||||||
|
|
||||||
for( int i = 0; i < composite->n; i++ )
|
for( int i = 0; i < composite->n; i++ )
|
||||||
p[i] = VIPS_REGION_ADDR( input_regions[i],
|
seq->p[i] = VIPS_REGION_ADDR( seq->ir[i],
|
||||||
r->left, r->top + y );
|
r->left, r->top + y );
|
||||||
p[composite->n] = NULL;
|
seq->p[composite->n] = NULL;
|
||||||
q = VIPS_REGION_ADDR( output_region, r->left, r->top + y );
|
q = VIPS_REGION_ADDR( output_region, r->left, r->top + y );
|
||||||
|
|
||||||
for( int x = 0; x < r->width; x++ ) {
|
for( int x = 0; x < r->width; x++ ) {
|
||||||
switch( input_regions[0]->im->BandFmt ) {
|
switch( seq->ir[0]->im->BandFmt ) {
|
||||||
case VIPS_FORMAT_UCHAR:
|
case VIPS_FORMAT_UCHAR:
|
||||||
#ifdef HAVE_VECTOR_ARITH
|
#ifdef HAVE_VECTOR_ARITH
|
||||||
if( composite->bands == 3 )
|
if( composite->bands == 3 )
|
||||||
vips_combine_pixels3
|
vips_combine_pixels3
|
||||||
<unsigned char, 0, UCHAR_MAX>
|
<unsigned char, 0, UCHAR_MAX>
|
||||||
( composite, q, p );
|
( composite, q, seq->p );
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
vips_combine_pixels
|
vips_combine_pixels
|
||||||
<unsigned char, 0, UCHAR_MAX>
|
<unsigned char, 0, UCHAR_MAX>
|
||||||
( composite, q, p );
|
( composite, q, seq->p );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIPS_FORMAT_CHAR:
|
case VIPS_FORMAT_CHAR:
|
||||||
vips_combine_pixels
|
vips_combine_pixels
|
||||||
<signed char, SCHAR_MIN, SCHAR_MAX>
|
<signed char, SCHAR_MIN, SCHAR_MAX>
|
||||||
( composite, q, p );
|
( composite, q, seq->p );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIPS_FORMAT_USHORT:
|
case VIPS_FORMAT_USHORT:
|
||||||
@ -863,30 +942,30 @@ vips_composite_base_gen( VipsRegion *output_region,
|
|||||||
if( composite->bands == 3 )
|
if( composite->bands == 3 )
|
||||||
vips_combine_pixels3
|
vips_combine_pixels3
|
||||||
<unsigned short, 0, USHRT_MAX>
|
<unsigned short, 0, USHRT_MAX>
|
||||||
( composite, q, p );
|
( composite, q, seq->p );
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
vips_combine_pixels
|
vips_combine_pixels
|
||||||
<unsigned short, 0, USHRT_MAX>
|
<unsigned short, 0, USHRT_MAX>
|
||||||
( composite, q, p );
|
( composite, q, seq->p );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIPS_FORMAT_SHORT:
|
case VIPS_FORMAT_SHORT:
|
||||||
vips_combine_pixels
|
vips_combine_pixels
|
||||||
<signed short, SHRT_MIN, SHRT_MAX>
|
<signed short, SHRT_MIN, SHRT_MAX>
|
||||||
( composite, q, p );
|
( composite, q, seq->p );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIPS_FORMAT_UINT:
|
case VIPS_FORMAT_UINT:
|
||||||
vips_combine_pixels
|
vips_combine_pixels
|
||||||
<unsigned int, 0, UINT_MAX>
|
<unsigned int, 0, UINT_MAX>
|
||||||
( composite, q, p );
|
( composite, q, seq->p );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIPS_FORMAT_INT:
|
case VIPS_FORMAT_INT:
|
||||||
vips_combine_pixels
|
vips_combine_pixels
|
||||||
<signed int, INT_MIN, INT_MAX>
|
<signed int, INT_MIN, INT_MAX>
|
||||||
( composite, q, p );
|
( composite, q, seq->p );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIPS_FORMAT_FLOAT:
|
case VIPS_FORMAT_FLOAT:
|
||||||
@ -894,18 +973,18 @@ vips_composite_base_gen( VipsRegion *output_region,
|
|||||||
if( composite->bands == 3 )
|
if( composite->bands == 3 )
|
||||||
vips_combine_pixels3
|
vips_combine_pixels3
|
||||||
<float, 0, USHRT_MAX>
|
<float, 0, USHRT_MAX>
|
||||||
( composite, q, p );
|
( composite, q, seq->p );
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
vips_combine_pixels
|
vips_combine_pixels
|
||||||
<float, 0, 0>
|
<float, 0, 0>
|
||||||
( composite, q, p );
|
( composite, q, seq->p );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIPS_FORMAT_DOUBLE:
|
case VIPS_FORMAT_DOUBLE:
|
||||||
vips_combine_pixels
|
vips_combine_pixels
|
||||||
<double, 0, 0>
|
<double, 0, 0>
|
||||||
( composite, q, p );
|
( composite, q, seq->p );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -914,7 +993,7 @@ vips_composite_base_gen( VipsRegion *output_region,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for( int i = 0; i < composite->n; i++ )
|
for( int i = 0; i < composite->n; i++ )
|
||||||
p[i] += ps;
|
seq->p[i] += ps;
|
||||||
q += ps;
|
q += ps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -991,12 +1070,6 @@ vips_composite_base_build( VipsObject *object )
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( composite->n > MAX_INPUT_IMAGES ) {
|
|
||||||
vips_error( klass->nickname,
|
|
||||||
"%s", _( "too many input images" ) );
|
|
||||||
return( -1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Transform to compositing space. It defaults to sRGB or B_W, usually
|
/* Transform to compositing space. It defaults to sRGB or B_W, usually
|
||||||
* 8 bit, but 16 bit if any inputs are 16 bit.
|
* 8 bit, but 16 bit if any inputs are 16 bit.
|
||||||
*/
|
*/
|
||||||
@ -1086,7 +1159,9 @@ vips_composite_base_build( VipsObject *object )
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips_image_generate( conversion->out,
|
if( vips_image_generate( conversion->out,
|
||||||
vips_start_many, vips_composite_base_gen, vips_stop_many,
|
vips_composite_start,
|
||||||
|
vips_composite_base_gen,
|
||||||
|
vips_composite_stop,
|
||||||
in, composite ) )
|
in, composite ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user