static int vips_unary_build( VipsObject *object ) { VipsArithmetic *arithmetic = VIPS_ARITHMETIC( object ); VipsUnary *unary = VIPS_UNARY( object ); arithmetic->n = 1; arithmetic->in = (VipsImage **) vips_object_local_array( object, 1 ); arithmetic->in[0] = unary->in; if( arithmetic->in[0] ) g_object_ref( arithmetic->in[0] ); if( VIPS_OBJECT_CLASS( vips_unary_parent_class )->build( object ) ) return( -1 ); return( 0 ); }
static int vips_unary_const_build( VipsObject *object ) { VipsArithmetic *arithmetic = VIPS_ARITHMETIC( object ); VipsUnary *unary = (VipsUnary *) object; VipsUnaryConst *uconst = (VipsUnaryConst *) object; /* If we have a three-element vector we need to bandup the image to * match. */ uconst->n = 1; if( uconst->c ) uconst->n = VIPS_MAX( uconst->n, uconst->c->n ); if( unary->in ) uconst->n = VIPS_MAX( uconst->n, unary->in->Bands ); arithmetic->base_bands = uconst->n; if( unary->in && uconst->c ) { if( vips_check_vector( "VipsRelationalConst", uconst->c->n, unary->in ) ) return( -1 ); } /* Some operations need the vector in the input type (eg. * im_equal_vec() where the output type is always uchar and is useless * for comparisons), some need it in the output type (eg. * im_andimage_vec() where we want to get the double to an int so we * can do bitwise-and without having to cast for each pixel), some * need a fixed type (eg. im_powtra_vec(), where we want to keep it as * double). * * Therefore pass in the desired vector type as a param. */ if( uconst->c ) uconst->c_ready = make_pixel( (VipsObject *) uconst, uconst->n, uconst->const_format, uconst->c->n, (double *) uconst->c->data ); if( VIPS_OBJECT_CLASS( vips_unary_const_parent_class )-> build( object ) ) return( -1 ); return( 0 ); }
static int vips_binary_build( VipsObject *object ) { VipsArithmetic *arithmetic = VIPS_ARITHMETIC( object ); VipsBinary *binary = VIPS_BINARY( object ); arithmetic->n = 2; arithmetic->in = (VipsImage **) vips_object_local_array( object, 2 ); arithmetic->in[0] = binary->left; arithmetic->in[1] = binary->right; if( arithmetic->in[0] ) g_object_ref( arithmetic->in[0] ); if( arithmetic->in[1] ) g_object_ref( arithmetic->in[1] ); if( VIPS_OBJECT_CLASS( vips_binary_parent_class )->build( object ) ) return( -1 ); return( 0 ); }
static int vips_arithmetic_gen( VipsRegion *or, void *seq, void *a, void *b, gboolean *stop ) { VipsRegion **ir = (VipsRegion **) seq; VipsArithmetic *arithmetic = VIPS_ARITHMETIC( b ); VipsArithmeticClass *class = VIPS_ARITHMETIC_GET_CLASS( arithmetic ); Rect *r = &or->valid; VipsPel *p[MAX_INPUT_IMAGES], *q; int i, y; /* Prepare all input regions and make buffer pointers. */ for( i = 0; ir[i]; i++ ) { if( vips_region_prepare( ir[i], r ) ) return( -1 ); p[i] = (VipsPel *) VIPS_REGION_ADDR( ir[i], r->left, r->top ); } p[i] = NULL; q = (VipsPel *) VIPS_REGION_ADDR( or, r->left, r->top ); VIPS_GATE_START( "vips_arithmetic_gen: work" ); for( y = 0; y < r->height; y++ ) { class->process_line( arithmetic, q, p, r->width ); for( i = 0; ir[i]; i++ ) p[i] += VIPS_REGION_LSKIP( ir[i] ); q += VIPS_REGION_LSKIP( or ); } VIPS_GATE_STOP( "vips_arithmetic_gen: work" ); return( 0 ); }
case VIPS_FORMAT_DPCOMPLEX: CASTC( double ); break; default: g_assert( 0 ); } return( q ); } static int vips_unary_const_build( VipsObject *object ) { VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object ); VipsArithmetic *arithmetic = VIPS_ARITHMETIC( object ); VipsUnary *unary = (VipsUnary *) object; VipsUnaryConst *uconst = (VipsUnaryConst *) object; /* If we have a three-element vector we need to bandup the image to * match. */ uconst->n = 1; if( uconst->c ) uconst->n = VIPS_MAX( uconst->n, uconst->c->n ); if( unary->in ) uconst->n = VIPS_MAX( uconst->n, unary->in->Bands ); arithmetic->base_bands = uconst->n; if( unary->in && uconst->c ) { if( vips_check_vector( class->nickname,