This commit is contained in:
John Cupitt 2010-11-04 14:54:23 +00:00
parent f930fe061b
commit 5bedec65da
5 changed files with 49 additions and 48 deletions

28
TODO
View File

@ -1,22 +1,16 @@
- nip2-7.22.3 on Windows is not adding the path you load from to the set opf
- we need to have separate sources for scanlines and for other sources
name scanlines sources as "sl0" onwards
name regular sources as "s1" onwards
- nip2-7.22.3 on Windows is not adding the path you load from to the set of
paths to search, breaking demo2 for Hamish
- custom morph, erode, apply 3 times, lock up!
4way3.mor
7 7 1 0
128 128 128 255 128 128 128
128 128 255 255 255 128 128
128 255 255 255 255 255 128
255 255 255 255 255 255 255
128 255 255 255 255 255 128
128 128 255 255 255 128 128
128 128 128 255 128 128 128
$ vips im_erode wtc1bit.v t2.v 4way3.mor
lock up
- lab [100,0,0] -> srgb [255, 255, 254]? how odd

View File

@ -98,11 +98,13 @@ add_buffer( PEL **in, PEL *out, int width, IMAGE *im )
if( vips_vector_get_enabled() &&
add_vectors[im->BandFmt] ) {
VipsVector *vector = add_vectors[im->BandFmt];
VipsExecutor ex;
vips_executor_set_program( &ex, add_vectors[im->BandFmt], sz );
vips_executor_set_array( &ex, "s1", in[0] );
vips_executor_set_array( &ex, "s2", in[1] );
vips_executor_set_program( &ex, vector, sz );
vips_executor_set_array( &ex, vector->s[0], in[0] );
vips_executor_set_array( &ex, vector->s[1], in[1] );
vips_executor_set_destination( &ex, out );
vips_executor_run( &ex );

View File

@ -57,11 +57,15 @@ typedef struct {
int n_parameter;
int n_instruction;
/* The scanlines this pass needs, and the variables each needs to be
* put into.
/* The sources this program needs. "s1"'s var is always in s[0],
* others may skip lines.
*/
int s[10];
int line[10];
int var[10];
/* The destination var.
*/
int d1;
#ifdef HAVE_ORC
/* The code we have generated.
@ -97,7 +101,7 @@ VipsVector *vips_vector_new_ds( const char *name, int size1, int size2 );
void vips_vector_constant( VipsVector *vector,
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( VipsVector *vector, char *name, int number, int size );
void vips_vector_temporary( VipsVector *vector, char *name, int size );
void vips_vector_asm2( VipsVector *vector,
@ -115,7 +119,7 @@ void vips_executor_set_program( VipsExecutor *executor,
void vips_executor_set_source( VipsExecutor *executor,
REGION *ir, int x, int y );
void vips_executor_set_destination( VipsExecutor *executor, void *value );
void vips_executor_set_array( VipsExecutor *executor, char *name, void *value );
void vips_executor_set_array( VipsExecutor *executor, int var, void *value );
void vips_executor_run( VipsExecutor *executor );

View File

@ -125,11 +125,12 @@ vips_vector_new_ds( const char *name, int size1, int size2 )
{
int var;
/* We always make s1.
/* We always make s1 / d1
*/
var = orc_program_find_var_by_name( vector->program, "s1" );
vector->var[0] = var;
vector->line[0] = 0;
vector->d1 = orc_program_find_var_by_name( vector->program, "d1" );
}
#endif /*HAVE_ORC*/
vector->n_source += 1;
@ -206,9 +207,10 @@ vips_vector_source_name( VipsVector *vector, char *name, int size )
#ifdef HAVE_ORC
g_assert( orc_program_find_var_by_name( vector->program, name ) == -1 );
orc_program_add_source( vector->program, size, name );
var = orc_program_add_source( vector->program, size, name );
vector->var[vector->n_source] = var;
vector->n_source += 1;
#endif /*HAVE_ORC*/
#else /*!HAVE_ORC*/
}
void
@ -218,15 +220,8 @@ vips_vector_source( VipsVector *vector, char *name, int line, int size )
im_snprintf( name, 256, "s%d", line );
if( orc_program_find_var_by_name( vector->program, name ) == -1 ) {
int var;
int i;
vips_vector_source_name( vector, name, size );
i = vector->n_source - 1;
var = orc_program_find_var_by_name( vector->program, name );
vector->var[i] = var;
vector->line[i] = line - 1;
vector->line[n_source - 1] = line - 1;
}
#endif /*HAVE_ORC*/
}
@ -330,19 +325,21 @@ void
vips_executor_set_destination( VipsExecutor *executor, void *value )
{
#ifdef HAVE_ORC
orc_executor_set_array_str( &executor->executor, "d1", value );
VipsVector *vector = executor->vector;
orc_executor_set_array( &executor->executor, vector->d1, value );
#endif /*HAVE_ORC*/
}
void
vips_executor_set_array( VipsExecutor *executor, char *name, void *value )
vips_executor_set_array( VipsExecutor *executor, int var, void *value )
{
#ifdef HAVE_ORC
VipsVector *vector = executor->vector;
OrcProgram *program = vector->program;
if( orc_program_find_var_by_name( program, name ) != -1 )
orc_executor_set_array_str( &executor->executor, name, value );
if( var != -1 )
orc_executor_set_array( &executor->executor, var, value );
#endif /*HAVE_ORC*/
}

View File

@ -86,6 +86,9 @@ typedef struct {
*/
VipsVector *vector;
/* The variable number for r, if we set it (or -1).
*/
int r;
} Pass;
/* Our parameters.
@ -155,13 +158,13 @@ pass_compile_section( Morph *morph, int first, int *last )
pass = &morph->pass[morph->n_pass];
morph->n_pass += 1;
pass->first = first;
pass->r = -1;
/* Start with a single source scanline, we add more as we need them.
*/
pass->vector = v = vips_vector_new_ds( "morph", 1, 1 );
/* The value we fetch from the image,
* the accumulated sum.
/* The value we fetch from the image, the accumulated sum.
*/
TEMP( "value", 1 );
TEMP( "sum", 1 );
@ -182,7 +185,7 @@ pass_compile_section( Morph *morph, int first, int *last )
else {
/* "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" );
}
@ -197,7 +200,7 @@ pass_compile_section( Morph *morph, int first, int *last )
/* The source. s1 is the first scanline in the mask.
*/
vips_vector_source( v, source, y + 1, 1 );
SRC( source, y + 1, 1 );
/* The offset, only for non-first-columns though.
*/
@ -674,11 +677,12 @@ morph_vector_gen( REGION *or, void *vseq, void *a, void *b )
else
d = seq->t2;
vips_executor_set_source( executor,
vips_executor_set_source( &executor[j],
ir, r->left, r->top + y );
vips_executor_set_array( executor, "r", seq->t1 );
vips_executor_set_array( executor, "d1", d );
vips_executor_run( executor );
vips_executor_set_array( &executor[j].executor,
morph->pass[j].r, seq->t1 );
vips_executor_set_destination( &executor[j], d );
vips_executor_run( &executor[j] );
IM_SWAP( void *, seq->t1, seq->t2 );
}