diff --git a/TODO b/TODO index 41f71709..c50be981 100644 --- a/TODO +++ b/TODO @@ -5,19 +5,19 @@ im = Vips.Image.identity() self.assertTrue(im.hist_ismonotonic()) -john@mm-jcupitt5 ~/Desktop/pics $ more mono.mat -2 1 +$ more mono.mat +2 1 1 128 -1 1 -john@mm-jcupitt5 ~/Desktop/pics $ vips identity x.v -john@mm-jcupitt5 ~/Desktop/pics $ vips convi x.v x2.v mono.mat --vips-info ---vips-novector -info: convi: using C path -john@mm-jcupitt5 ~/Desktop/pics $ vips max x2.v -1.000000 -john@mm-jcupitt5 ~/Desktop/pics $ vips convi x.v x2.v mono.mat --vips-info -info: convi: using vector path -john@mm-jcupitt5 ~/Desktop/pics $ vips max x2.v -0.000000 + +vips identity x.v + +vips convi x.v x2.v mono.mat --vips-info --vips-novector +vips min x2.v +128.0 + +vips convi x.v x2.v mono.mat --vips-info +vips min x2.v +0.0 should be 1.0 (0 for first pixel, 1 thereafter), instead it's 0 everywhere diff --git a/libvips/convolution/convi.c b/libvips/convolution/convi.c index 18cac4ca..0d95e820 100644 --- a/libvips/convolution/convi.c +++ b/libvips/convolution/convi.c @@ -102,10 +102,10 @@ */ /* - */ -#define DEBUG_PIXELS #define DEBUG +#define DEBUG_PIXELS #define DEBUG_COMPILE + */ #ifdef HAVE_CONFIG_H #include @@ -422,7 +422,7 @@ vips_convi_compile_clip( VipsConvi *convi ) ASM3( "shrsw", "value", "value", c6 ); CONST( off, offset, 2 ); - ASM3( "subw", "value", "value", off ); + ASM3( "addw", "value", "value", off ); /* You'd think "convsuswb" (convert signed 16-bit to unsigned * 8-bit with saturation) would be quicker, but it's a lot @@ -515,6 +515,21 @@ vips_convi_generate_vector( VipsRegion *or, for( y = 0; y < r->height; y ++ ) { VipsPel *q = VIPS_REGION_ADDR( or, r->left, r->top + y ); + +#ifdef DEBUG_PIXELS +{ + int h, v; + + printf( "before convolve: x = %d, y = %d\n", + r->left, r->top + y ); + for( v = 0; v < M->Ysize; v++ ) { + for( h = 0; h < M->Xsize; h++ ) + printf( "%3d ", *VIPS_REGION_ADDR( ir, + r->left + h, r->top + y + v ) ); + printf( "\n" ); + } +} +#endif /*DEBUG_PIXELS*/ /* We run our n passes to generate this scanline. */ @@ -531,9 +546,18 @@ vips_convi_generate_vector( VipsRegion *or, VIPS_SWAP( signed short *, seq->t1, seq->t2 ); } +#ifdef DEBUG_PIXELS + printf( "before clip: %d\n", ((signed short *) seq->t1)[0] ); +#endif /*DEBUG_PIXELS*/ + vips_executor_set_array( &clip, convi->r, seq->t1 ); vips_executor_set_destination( &clip, q ); vips_executor_run( &clip ); + +#ifdef DEBUG_PIXELS + printf( "after clip: %d\n", + *VIPS_REGION_ADDR( or, r->left, r->top + y ) ); +#endif /*DEBUG_PIXELS*/ } VIPS_GATE_STOP( "vips_convi_generate_vector: work" );