This commit is contained in:
John Cupitt 2010-11-05 20:42:56 +00:00
parent a52d9736d2
commit 25267f26eb
3 changed files with 31 additions and 23 deletions

View File

@ -108,7 +108,7 @@ VipsVector *vips_vector_new( const char *name, int dsize );
void vips_vector_constant( VipsVector *vector, void vips_vector_constant( VipsVector *vector,
char *name, int value, int size ); char *name, int value, int size );
void vips_vector_source_name( VipsVector *vector, char *name, int size ); int vips_vector_source_name( VipsVector *vector, char *name, int size );
void vips_vector_source_scanline( VipsVector *vector, void vips_vector_source_scanline( VipsVector *vector,
char *name, int line, int size ); char *name, int line, int size );
void vips_vector_temporary( VipsVector *vector, char *name, int size ); void vips_vector_temporary( VipsVector *vector, char *name, int size );

View File

@ -208,16 +208,22 @@ vips_vector_constant( VipsVector *vector, char *name, int value, int size )
#endif /*HAVE_ORC*/ #endif /*HAVE_ORC*/
} }
void int
vips_vector_source_name( VipsVector *vector, char *name, int size ) vips_vector_source_name( VipsVector *vector, char *name, int size )
{ {
int var;
#ifdef HAVE_ORC #ifdef HAVE_ORC
g_assert( orc_program_find_var_by_name( vector->program, name ) == -1 ); g_assert( orc_program_find_var_by_name( vector->program, name ) == -1 );
vector->s[vector->n_source] = vector->s[vector->n_source] = var =
orc_program_add_source( vector->program, size, name ); orc_program_add_source( vector->program, size, name );
vector->n_source += 1; vector->n_source += 1;
#else /*!HAVE_ORC*/
var = -1;
#endif /*HAVE_ORC*/ #endif /*HAVE_ORC*/
return( var );
} }
void void

View File

@ -82,6 +82,8 @@ typedef struct {
int first; /* The index of the first mask coff we use */ int first; /* The index of the first mask coff we use */
int last; /* The index of the last mask coff we use */ int last; /* The index of the last mask coff we use */
int r; /* Set previous result in this var */
/* The code we generate for this section of this mask. /* The code we generate for this section of this mask.
*/ */
VipsVector *vector; VipsVector *vector;
@ -134,12 +136,11 @@ morph_close( Morph *morph )
* 0 for success, -1 on error. * 0 for success, -1 on error.
*/ */
static int static int
pass_compile_section( Morph *morph, int first, int *last ) pass_compile_section( Pass *pass, Morph *morph, gboolean first_pass )
{ {
INTMASK *mask = morph->mask; INTMASK *mask = morph->mask;
const int n_mask = mask->xsize * mask->ysize; const int n_mask = mask->xsize * mask->ysize;
Pass *pass;
VipsVector *v; VipsVector *v;
char offset[256]; char offset[256];
char source[256]; char source[256];
@ -147,14 +148,6 @@ pass_compile_section( Morph *morph, int first, int *last )
char one[256]; char one[256];
int i; int i;
/* Allocate space for another pass.
*/
if( morph->n_pass == MAX_PASSES )
return( -1 );
pass = &morph->pass[morph->n_pass];
morph->n_pass += 1;
pass->first = first;
pass->vector = v = vips_vector_new( "morph", 1 ); pass->vector = v = vips_vector_new( "morph", 1 );
/* The value we fetch from the image, the accumulated sum. /* The value we fetch from the image, the accumulated sum.
@ -169,20 +162,20 @@ pass_compile_section( Morph *morph, int first, int *last )
* is a later pass, we have to init the sum from the result * is a later pass, we have to init the sum from the result
* of the previous pass. * of the previous pass.
*/ */
if( morph->n_pass == 1 ) { if( first_pass ) {
if( morph->op == DILATE ) if( morph->op == DILATE )
ASM2( "copyb", "sum", zero ); ASM2( "copyb", "sum", zero );
else else
ASM2( "copyb", "sum", one ); ASM2( "copyb", "sum", one );
} }
else { else {
/* "r" is the result of the previous pass. var in s[1]. /* "r" is the result of the previous pass.
*/ */
vips_vector_source_name( v, "r", 1 ); pass->r = vips_vector_source_name( v, "r", 1 );
ASM2( "loadb", "sum", "r" ); ASM2( "loadb", "sum", "r" );
} }
for( i = first; i < n_mask; i++ ) { for( i = pass->first; i < n_mask; i++ ) {
int x = i % mask->xsize; int x = i % mask->xsize;
int y = i / mask->xsize; int y = i / mask->xsize;
@ -224,7 +217,6 @@ pass_compile_section( Morph *morph, int first, int *last )
} }
pass->last = i; pass->last = i;
*last = i;
ASM2( "copyb", "d1", "sum" ); ASM2( "copyb", "d1", "sum" );
@ -248,6 +240,7 @@ pass_compile( Morph *morph )
const int n_mask = mask->xsize * mask->ysize; const int n_mask = mask->xsize * mask->ysize;
int i; int i;
Pass *pass;
#ifdef DEBUG #ifdef DEBUG
printf( "morph: generating vector code\n" ); printf( "morph: generating vector code\n" );
@ -256,8 +249,6 @@ pass_compile( Morph *morph )
/* Generate passes until we've used up the whole mask. /* Generate passes until we've used up the whole mask.
*/ */
for( i = 0;;) { for( i = 0;;) {
int last;
/* Skip any don't-care coefficients at the start of the mask /* Skip any don't-care coefficients at the start of the mask
* region. * region.
*/ */
@ -266,9 +257,20 @@ pass_compile( Morph *morph )
if( i == n_mask ) if( i == n_mask )
break; break;
if( pass_compile_section( morph, i, &last ) ) /* Allocate space for another pass.
*/
if( morph->n_pass == MAX_PASSES )
return( -1 ); return( -1 );
i = last + 1; pass = &morph->pass[morph->n_pass];
morph->n_pass += 1;
pass->first = i;
pass->last = i;
pass->r = -1;
if( pass_compile_section( pass, morph, morph->n_pass == 1 ) )
return( -1 );
i = pass->last + 1;
if( i >= n_mask ) if( i >= n_mask )
break; break;
@ -673,7 +675,7 @@ morph_vector_gen( REGION *or, void *vseq, void *a, void *b )
vips_executor_set_scanline( &executor[j], vips_executor_set_scanline( &executor[j],
ir, r->left, r->top + y ); ir, r->left, r->top + y );
vips_executor_set_array( &executor[j], vips_executor_set_array( &executor[j],
morph->pass[j].vector->s[1], seq->t1 ); morph->pass[j].r, seq->t1 );
vips_executor_set_destination( &executor[j], d ); vips_executor_set_destination( &executor[j], d );
vips_executor_run( &executor[j] ); vips_executor_run( &executor[j] );