move im_shift*( to a class, remove bool package

This commit is contained in:
John Cupitt 2011-11-12 17:18:13 +00:00
parent 2d30264840
commit 5b133145a7
17 changed files with 353 additions and 738 deletions

View File

@ -10,7 +10,7 @@
im_abs(), im_sign(), im_max(), im_maxpos(), im_deviate(), im_divide(),
im_multiply(), im_stats(), im_measure(), im_recomb(), im_floor(), im_ceil(),
im_rint(), im_equal*(), im_notequal*(), im_less*(), im_lesseq*(), im_more*(),
im_moreeq*(), im_remainder*(), im_and*(), im_or*(), im_eor*()
im_moreeq*(), im_remainder*(), im_and*(), im_or*(), im_eor*(), im_shift*()
redone as classes
- added argument priorites to help control arg ordering
- generate has a 'stop' param to signal successful early termination

6
TODO
View File

@ -2,11 +2,7 @@
- move power, boolean to unary const
- boolean.c
- move power to unary const

View File

@ -629,7 +629,6 @@ AC_OUTPUT([
libvips/include/vips/Makefile
libvips/Makefile
libvips/arithmetic/Makefile
libvips/boolean/Makefile
libvips/cimg/Makefile
libvips/colour/Makefile
libvips/conversion/Makefile

View File

@ -13,7 +13,6 @@ SUBDIRS = \
include \
arithmetic \
resample \
boolean \
colour \
conversion \
deprecated \
@ -48,7 +47,6 @@ endif
libvips_la_LIBADD = \
resample/libresample.la \
arithmetic/libarithmetic.la \
boolean/libboolean.la \
colour/libcolour.la \
conversion/libconversion.la \
convolution/libconvolution.la \

View File

@ -189,6 +189,14 @@ vips_boolean_buffer( VipsArithmetic *arithmetic,
SWITCH( LOOP, FLOOP, ^ );
break;
case VIPS_OPERATION_BOOLEAN_LSHIFT:
SWITCH( LOOP, FLOOP, << );
break;
case VIPS_OPERATION_BOOLEAN_RSHIFT:
SWITCH( LOOP, FLOOP, >> );
break;
default:
g_assert( 0 );
}
@ -358,6 +366,14 @@ vips_boolean_const_buffer( VipsArithmetic *arithmetic,
SWITCH( LOOPC, FLOOPC, ^ );
break;
case VIPS_OPERATION_BOOLEAN_LSHIFT:
SWITCH( LOOPC, FLOOPC, << );
break;
case VIPS_OPERATION_BOOLEAN_RSHIFT:
SWITCH( LOOPC, FLOOPC, >> );
break;
default:
g_assert( 0 );
}

View File

@ -1,7 +0,0 @@
noinst_LTLIBRARIES = libboolean.la
libboolean_la_SOURCES = \
bool_dispatch.c \
boolean.c
INCLUDES = -I${top_srcdir}/libvips/include @VIPS_CFLAGS@ @VIPS_INCLUDES@

View File

@ -1,390 +0,0 @@
/* VIPS function dispatch tables for conversion.
*
* J. Cupitt, 8/4/93.
*/
/*
This file is part of VIPS.
VIPS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
#include <vips/intl.h>
#include <stdio.h>
#include <vips/vips.h>
/**
* SECTION: boolean
* @short_description: boolean algebra on images, bitshifts
* @see_also: <link linkend="libvips-arithmetic">arithmetic</link>
* @stability: Stable
* @include: vips/vips.h
*
* These operations perform boolean operations, such as bitwise-and, on
* every pixel in an image or pair of images.
* They are useful for combining the results of
* the relational and morphological functions.
* All will work with
* images of any type or any mixture of types, of any size and of any number
* of bands.
*
* For binary operations, if the number of bands differs, one of the images
* must have one band. In this case, an n-band image is formed from the
* one-band image by joining n copies of the one-band image together and then
* the two n-band images are operated upon.
*
* In the same way, for operations that take an array constant, such as
* im_andimage_vec(), you can mix single-element arrays or single-band images
* freely.
*
* If the images differ in size, the smaller image is enlarged to match the
* larger by adding zero pixels along the bottom and right.
*
* The output type is the same as the input type for integer types. Float and
* complex types are cast to signed int.
*
* You might think im_andimage() would be called "im_and", but that causes
* problems when we try and make a C++ binding and drop the "im_" prefix.
*/
/* Two images in, one out.
*/
static im_arg_desc two_in_one_out[] = {
IM_INPUT_IMAGE( "in1" ),
IM_INPUT_IMAGE( "in2" ),
IM_OUTPUT_IMAGE( "out" )
};
/* One image plus one constant in, one image out.
*/
static im_arg_desc const_in_one_out[] = {
IM_INPUT_IMAGE( "in1" ),
IM_OUTPUT_IMAGE( "out" ),
IM_INPUT_INT( "c" )
};
/* One image plus doublevec in, one image out.
*/
static im_arg_desc vec_in_one_out[] = {
IM_INPUT_IMAGE( "in" ),
IM_OUTPUT_IMAGE( "out" ),
IM_INPUT_DOUBLEVEC( "vec" )
};
/* Call im_andimage via arg vector.
*/
static int
andimage_vec( im_object *argv )
{
return( im_andimage( argv[0], argv[1], argv[2] ) );
}
/* Description of im_andimage.
*/
static im_function andimage_desc = {
"im_andimage", /* Name */
"bitwise and of two images", /* Description */
IM_FN_PTOP | IM_FN_PIO, /* Flags */
andimage_vec, /* Dispatch function */
IM_NUMBER( two_in_one_out ), /* Size of arg list */
two_in_one_out /* Arg list */
};
/* Call im_andimageconst via arg vector.
*/
static int
andimageconst_vec( im_object *argv )
{
int c = *((int *) argv[2]);
return( im_andimageconst( argv[0], argv[1], c ) );
}
/* Description of im_andconst.
*/
static im_function andimageconst_desc = {
"im_andimageconst", /* Name */
"bitwise and of an image with a constant",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
andimageconst_vec, /* Dispatch function */
IM_NUMBER( const_in_one_out ), /* Size of arg list */
const_in_one_out /* Arg list */
};
/* Call im_andimage_vec via arg vector.
*/
static int
andimage_vec_vec( im_object *argv )
{
im_doublevec_object *rv = (im_doublevec_object *) argv[2];
return( im_andimage_vec( argv[0], argv[1], rv->n, rv->vec ) );
}
/* Description of im_andimageconst.
*/
static im_function andimage_vec_desc = {
"im_andimage_vec", /* Name */
"bitwise and of an image with a vector constant",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
andimage_vec_vec, /* Dispatch function */
IM_NUMBER( vec_in_one_out ), /* Size of arg list */
vec_in_one_out /* Arg list */
};
/* Call im_orimage via arg vector.
*/
static int
orimage_vec( im_object *argv )
{
return( im_orimage( argv[0], argv[1], argv[2] ) );
}
/* Description of im_orimage.
*/
static im_function orimage_desc = {
"im_orimage", /* Name */
"bitwise or of two images", /* Description */
IM_FN_PTOP | IM_FN_PIO, /* Flags */
orimage_vec, /* Dispatch function */
IM_NUMBER( two_in_one_out ), /* Size of arg list */
two_in_one_out /* Arg list */
};
/* Call im_orimageconst via arg vector.
*/
static int
orimageconst_vec( im_object *argv )
{
int c = *((int *) argv[2]);
return( im_orimageconst( argv[0], argv[1], c ) );
}
/* Description of im_orimageconst.
*/
static im_function orimageconst_desc = {
"im_orimageconst", /* Name */
"bitwise or of an image with a constant",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
orimageconst_vec, /* Dispatch function */
IM_NUMBER( const_in_one_out ), /* Size of arg list */
const_in_one_out /* Arg list */
};
/* Call im_orimage_vec via arg vector.
*/
static int
orimage_vec_vec( im_object *argv )
{
im_doublevec_object *rv = (im_doublevec_object *) argv[2];
return( im_orimage_vec( argv[0], argv[1], rv->n, rv->vec ) );
}
/* Description of im_orimage_vec.
*/
static im_function orimage_vec_desc = {
"im_orimage_vec", /* Name */
"bitwise or of an image with a vector constant",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
orimage_vec_vec, /* Dispatch function */
IM_NUMBER( vec_in_one_out ), /* Size of arg list */
vec_in_one_out /* Arg list */
};
/* Call im_eorimage via arg vector.
*/
static int
eorimage_vec( im_object *argv )
{
return( im_eorimage( argv[0], argv[1], argv[2] ) );
}
/* Description of im_eorimage.
*/
static im_function eorimage_desc = {
"im_eorimage", /* Name */
"bitwise eor of two images", /* Description */
IM_FN_PTOP | IM_FN_PIO, /* Flags */
eorimage_vec, /* Dispatch function */
IM_NUMBER( two_in_one_out ), /* Size of arg list */
two_in_one_out /* Arg list */
};
/* Call im_eorimageconst via arg vector.
*/
static int
eorimageconst_vec( im_object *argv )
{
int c = *((int *) argv[2]);
return( im_eorimageconst( argv[0], argv[1], c ) );
}
/* Description of im_eorimageconst.
*/
static im_function eorimageconst_desc = {
"im_eorimageconst", /* Name */
"bitwise eor of an image with a constant",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
eorimageconst_vec, /* Dispatch function */
IM_NUMBER( const_in_one_out ), /* Size of arg list */
const_in_one_out /* Arg list */
};
/* Call im_eorimage_vec via arg vector.
*/
static int
eorimage_vec_vec( im_object *argv )
{
im_doublevec_object *rv = (im_doublevec_object *) argv[2];
return( im_eorimage_vec( argv[0], argv[1], rv->n, rv->vec ) );
}
/* Description of im_eorimage_vec.
*/
static im_function eorimage_vec_desc = {
"im_eorimage_vec", /* Name */
"bitwise eor of an image with a vector constant",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
eorimage_vec_vec, /* Dispatch function */
IM_NUMBER( vec_in_one_out ), /* Size of arg list */
vec_in_one_out /* Arg list */
};
/* Call im_shiftleft via arg vector.
*/
static int
shiftleft_vec( im_object *argv )
{
int n = *((int *) argv[2]);
return( im_shiftleft( argv[0], argv[1], n ) );
}
/* Description of im_shiftleft.
*/
static im_function shiftleft_desc = {
"im_shiftleft", /* Name */
"shift image n bits to left",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
shiftleft_vec, /* Dispatch function */
IM_NUMBER( const_in_one_out ), /* Size of arg list */
const_in_one_out /* Arg list */
};
/* Call im_shiftleft_vec via arg vector.
*/
static int
shiftleft_vec_vec( im_object *argv )
{
im_doublevec_object *rv = (im_doublevec_object *) argv[2];
return( im_shiftleft_vec( argv[0], argv[1], rv->n, rv->vec ) );
}
/* Description of im_shiftleft_vec.
*/
static im_function shiftleft_vec_desc = {
"im_shiftleft_vec", /* Name */
"shift image array bits to left",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
shiftleft_vec_vec, /* Dispatch function */
IM_NUMBER( vec_in_one_out ), /* Size of arg list */
vec_in_one_out /* Arg list */
};
/* Call im_shiftright via arg vector.
*/
static int
shiftright_vec( im_object *argv )
{
int n = *((int *) argv[2]);
return( im_shiftright( argv[0], argv[1], n ) );
}
/* Description of im_shiftright.
*/
static im_function shiftright_desc = {
"im_shiftright", /* Name */
"shift integer image n bits to right",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
shiftright_vec, /* Dispatch function */
IM_NUMBER( const_in_one_out ), /* Size of arg list */
const_in_one_out /* Arg list */
};
/* Call im_shiftright_vec via arg vector.
*/
static int
shiftright_vec_vec( im_object *argv )
{
im_doublevec_object *rv = (im_doublevec_object *) argv[2];
return( im_shiftright_vec( argv[0], argv[1], rv->n, rv->vec ) );
}
/* Description of im_shiftright_vec.
*/
static im_function shiftright_vec_desc = {
"im_shiftright_vec", /* Name */
"shift image array bits to right",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
shiftright_vec_vec, /* Dispatch function */
IM_NUMBER( vec_in_one_out ), /* Size of arg list */
vec_in_one_out /* Arg list */
};
/* Package up all these functions.
*/
static im_function *bool_list[] = {
&andimage_desc,
&andimageconst_desc,
&andimage_vec_desc,
&orimage_desc,
&orimageconst_desc,
&orimage_vec_desc,
&eorimage_desc,
&eorimageconst_desc,
&eorimage_vec_desc,
&shiftleft_vec_desc,
&shiftleft_desc,
&shiftright_vec_desc,
&shiftright_desc
};
/* Package of functions.
*/
im_package im__boolean = {
"boolean",
IM_NUMBER( bool_list ),
bool_list
};

View File

@ -1,278 +0,0 @@
/* boolean.c --- various bit operations
*
* Modified:
* 15/12/94 JC
* - ANSIfied
* - adapted to partials with im_wrap...
* 25/1/95 JC
* - added check1ary(), check2ary()
* 8/2/95 JC
* - new im_wrapmany
* 19/7/95 JC
* - added im_shiftleft() and im_shiftright()
* 6/7/98 JC
* - added _vec forms
* - removed *p++ stuff
* 10/9/99 JC
* - and/or/eor now do all int types
* 10/10/02 JC
* - renamed im_and() etc. as im_andimage() to remove breakage in the C++
* layer if operator names are turned on
* 30/6/04
* - now cast float/complex args to int
* 11/9/09
* - use new im__cast_and__call()
* - therefore now supports 1-band $op n-band
* 17/9/09
* - moved to im__arith_binary*()
* - renamed im_eor_vec() as im_eorimage_vec() for C++ sanity
* 21/11/10
* - oop, constants are always (int) now, so (^-1) works for unsigned
* types
*/
/*
This file is part of VIPS.
VIPS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
#include <vips/intl.h>
#include <stdio.h>
#include <math.h>
#include <vips/vips.h>
#include <vips/internal.h>
/* Save a bit of typing.
*/
#define UC IM_BANDFMT_UCHAR
#define C IM_BANDFMT_CHAR
#define US IM_BANDFMT_USHORT
#define S IM_BANDFMT_SHORT
#define UI IM_BANDFMT_UINT
#define I IM_BANDFMT_INT
/* Type conversions for boolean.
*/
static int bandfmt_bool[10] = {
/* UC C US S UI I F X D DX */
UC, C, US, S, UI, I, I, I, I, I,
};
#define CONST1( IN, OUT, OP ) { \
OUT *tq = (OUT *) q; \
IN *tp = (IN *) p; \
int tc = *((int *) vector); \
\
for( i = 0; i < ne; i++ ) \
tq[i] = (OUT) tp[i] OP (OUT) tc; \
}
#define CONST1_BUFFER( NAME, OP ) \
static void \
NAME ## 1_buffer( PEL *p, PEL *q, int n, PEL *vector, IMAGE *im ) \
{ \
/* Complex just doubles the size. \
*/ \
const int ne = n * im->Bands * \
(vips_bandfmt_iscomplex( im->BandFmt ) ? 2 : 1); \
\
int i; \
\
switch( im->BandFmt ) { \
case IM_BANDFMT_CHAR: \
CONST1( signed char, signed char, OP ); break; \
case IM_BANDFMT_UCHAR: \
CONST1( unsigned char, unsigned char, OP ); break; \
case IM_BANDFMT_SHORT: \
CONST1( signed short, signed short, OP ); break; \
case IM_BANDFMT_USHORT: \
CONST1( unsigned short, unsigned short, OP ); break; \
case IM_BANDFMT_INT: \
CONST1( signed int, signed int, OP ); break; \
case IM_BANDFMT_UINT: \
CONST1( unsigned int, unsigned int, OP ); break; \
case IM_BANDFMT_FLOAT: \
CONST1( float, signed int, OP ); break; \
case IM_BANDFMT_COMPLEX: \
CONST1( float, signed int, OP ); break; \
case IM_BANDFMT_DOUBLE: \
CONST1( double, signed int, OP ); break; \
case IM_BANDFMT_DPCOMPLEX: \
CONST1( double, signed int, OP ); break; \
\
default: \
g_assert( 0 ); \
} \
}
#define CONSTN( IN, OUT, OP ) { \
OUT *tq = (OUT *) q; \
IN *tp = (IN *) p; \
int *tc = (int *) vector; \
\
for( i = 0, x = 0; x < n; x++ ) \
for( b = 0; b < bands; b++, i++ ) \
tq[i] = (OUT) tp[i] OP (OUT) tc[b]; \
}
#define CONSTN_BUFFER( NAME, OP ) \
static void \
NAME ## n_buffer( PEL *p, PEL *q, int n, PEL *vector, IMAGE *im ) \
{ \
const int bands = im->Bands; \
\
int i, x, b; \
\
switch( im->BandFmt ) { \
case IM_BANDFMT_CHAR: \
CONSTN( signed char, signed char, OP ); break; \
case IM_BANDFMT_UCHAR: \
CONSTN( unsigned char, unsigned char, OP ); break; \
case IM_BANDFMT_SHORT: \
CONSTN( signed short, signed short, OP ); break; \
case IM_BANDFMT_USHORT: \
CONSTN( unsigned short, unsigned short, OP ); break; \
case IM_BANDFMT_INT: \
CONSTN( signed int, signed int, OP ); break; \
case IM_BANDFMT_UINT: \
CONSTN( unsigned int, unsigned int, OP ); break; \
case IM_BANDFMT_FLOAT: \
CONSTN( float, signed int, OP ); break; \
case IM_BANDFMT_COMPLEX: \
CONSTN( float, signed int, OP ); break; \
case IM_BANDFMT_DOUBLE: \
CONSTN( double, signed int, OP ); break; \
case IM_BANDFMT_DPCOMPLEX: \
CONSTN( double, signed int, OP ); break; \
\
default: \
g_assert( 0 ); \
} \
}
CONST1_BUFFER( SHIFTL, << )
CONSTN_BUFFER( SHIFTL, << )
/**
* im_shiftleft_vec:
* @in: input #IMAGE
* @out: output #IMAGE
* @n: array length
* @c: array of constants
*
* This operation calculates @in << @c (left-shift by @c bits
* with array
* @c) and writes the result to @out.
*
* See also: im_andimage(), im_orimageconst().
*
* Returns: 0 on success, -1 on error
*/
int
im_shiftleft_vec( IMAGE *in, IMAGE *out, int n, double *c )
{
return( im__arith_binary_const( "im_shiftleft",
in, out, n, c, IM_BANDFMT_INT,
bandfmt_bool,
(im_wrapone_fn) SHIFTL1_buffer,
(im_wrapone_fn) SHIFTLn_buffer ) );
}
/**
* im_shiftleft:
* @in: input #IMAGE
* @out: output #IMAGE
* @n: constant
*
* This operation calculates @in << @n (left-shift by @n bits)
* and writes the result to @out.
*
* See also: im_andimage(), im_orimageconst().
*
* Returns: 0 on success, -1 on error
*/
int
im_shiftleft( IMAGE *in, IMAGE *out, int n )
{
double c = n;
return( im_shiftleft_vec( in, out, 1, &c ) );
}
CONST1_BUFFER( SHIFTR, >> )
CONSTN_BUFFER( SHIFTR, >> )
/**
* im_shiftright_vec:
* @in: input #IMAGE
* @out: output #IMAGE
* @n: array length
* @c: array of constants
*
* This operation calculates @in << @c (right-shift by @c bits
* with array
* @c) and writes the result to @out.
*
* See also: im_andimage(), im_orimageconst().
*
* Returns: 0 on success, -1 on error
*/
int
im_shiftright_vec( IMAGE *in, IMAGE *out, int n, double *c )
{
return( im__arith_binary_const( "im_shiftright",
in, out, n, c, IM_BANDFMT_INT,
bandfmt_bool,
(im_wrapone_fn) SHIFTR1_buffer,
(im_wrapone_fn) SHIFTRn_buffer ) );
}
/**
* im_shiftright:
* @in: input #IMAGE
* @out: output #IMAGE
* @n: constant
*
* This operation calculates @in >> @n (right-shift by @n bits)
* and writes the result to @out.
*
* See also: im_andimage(), im_orimageconst().
*
* Returns: 0 on success, -1 on error
*/
int
im_shiftright( IMAGE *in, IMAGE *out, int n )
{
double c = n;
return( im_shiftright_vec( in, out, 1, &c ) );
}

View File

@ -1484,6 +1484,289 @@ static im_function vips2mask_desc = {
vips2mask_args /* Arg list */
};
/* One image plus one constant in, one image out.
*/
static im_arg_desc const_in_one_out[] = {
IM_INPUT_IMAGE( "in1" ),
IM_OUTPUT_IMAGE( "out" ),
IM_INPUT_INT( "c" )
};
/* One image plus doublevec in, one image out.
*/
static im_arg_desc vec_in_one_out[] = {
IM_INPUT_IMAGE( "in" ),
IM_OUTPUT_IMAGE( "out" ),
IM_INPUT_DOUBLEVEC( "vec" )
};
/* Call im_andimage via arg vector.
*/
static int
andimage_vec( im_object *argv )
{
return( im_andimage( argv[0], argv[1], argv[2] ) );
}
/* Description of im_andimage.
*/
static im_function andimage_desc = {
"im_andimage", /* Name */
"bitwise and of two images", /* Description */
IM_FN_PTOP | IM_FN_PIO, /* Flags */
andimage_vec, /* Dispatch function */
IM_NUMBER( two_in_one_out ), /* Size of arg list */
two_in_one_out /* Arg list */
};
/* Call im_andimageconst via arg vector.
*/
static int
andimageconst_vec( im_object *argv )
{
int c = *((int *) argv[2]);
return( im_andimageconst( argv[0], argv[1], c ) );
}
/* Description of im_andconst.
*/
static im_function andimageconst_desc = {
"im_andimageconst", /* Name */
"bitwise and of an image with a constant",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
andimageconst_vec, /* Dispatch function */
IM_NUMBER( const_in_one_out ), /* Size of arg list */
const_in_one_out /* Arg list */
};
/* Call im_andimage_vec via arg vector.
*/
static int
andimage_vec_vec( im_object *argv )
{
im_doublevec_object *rv = (im_doublevec_object *) argv[2];
return( im_andimage_vec( argv[0], argv[1], rv->n, rv->vec ) );
}
/* Description of im_andimageconst.
*/
static im_function andimage_vec_desc = {
"im_andimage_vec", /* Name */
"bitwise and of an image with a vector constant",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
andimage_vec_vec, /* Dispatch function */
IM_NUMBER( vec_in_one_out ), /* Size of arg list */
vec_in_one_out /* Arg list */
};
/* Call im_orimage via arg vector.
*/
static int
orimage_vec( im_object *argv )
{
return( im_orimage( argv[0], argv[1], argv[2] ) );
}
/* Description of im_orimage.
*/
static im_function orimage_desc = {
"im_orimage", /* Name */
"bitwise or of two images", /* Description */
IM_FN_PTOP | IM_FN_PIO, /* Flags */
orimage_vec, /* Dispatch function */
IM_NUMBER( two_in_one_out ), /* Size of arg list */
two_in_one_out /* Arg list */
};
/* Call im_orimageconst via arg vector.
*/
static int
orimageconst_vec( im_object *argv )
{
int c = *((int *) argv[2]);
return( im_orimageconst( argv[0], argv[1], c ) );
}
/* Description of im_orimageconst.
*/
static im_function orimageconst_desc = {
"im_orimageconst", /* Name */
"bitwise or of an image with a constant",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
orimageconst_vec, /* Dispatch function */
IM_NUMBER( const_in_one_out ), /* Size of arg list */
const_in_one_out /* Arg list */
};
/* Call im_orimage_vec via arg vector.
*/
static int
orimage_vec_vec( im_object *argv )
{
im_doublevec_object *rv = (im_doublevec_object *) argv[2];
return( im_orimage_vec( argv[0], argv[1], rv->n, rv->vec ) );
}
/* Description of im_orimage_vec.
*/
static im_function orimage_vec_desc = {
"im_orimage_vec", /* Name */
"bitwise or of an image with a vector constant",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
orimage_vec_vec, /* Dispatch function */
IM_NUMBER( vec_in_one_out ), /* Size of arg list */
vec_in_one_out /* Arg list */
};
/* Call im_eorimage via arg vector.
*/
static int
eorimage_vec( im_object *argv )
{
return( im_eorimage( argv[0], argv[1], argv[2] ) );
}
/* Description of im_eorimage.
*/
static im_function eorimage_desc = {
"im_eorimage", /* Name */
"bitwise eor of two images", /* Description */
IM_FN_PTOP | IM_FN_PIO, /* Flags */
eorimage_vec, /* Dispatch function */
IM_NUMBER( two_in_one_out ), /* Size of arg list */
two_in_one_out /* Arg list */
};
/* Call im_eorimageconst via arg vector.
*/
static int
eorimageconst_vec( im_object *argv )
{
int c = *((int *) argv[2]);
return( im_eorimageconst( argv[0], argv[1], c ) );
}
/* Description of im_eorimageconst.
*/
static im_function eorimageconst_desc = {
"im_eorimageconst", /* Name */
"bitwise eor of an image with a constant",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
eorimageconst_vec, /* Dispatch function */
IM_NUMBER( const_in_one_out ), /* Size of arg list */
const_in_one_out /* Arg list */
};
/* Call im_eorimage_vec via arg vector.
*/
static int
eorimage_vec_vec( im_object *argv )
{
im_doublevec_object *rv = (im_doublevec_object *) argv[2];
return( im_eorimage_vec( argv[0], argv[1], rv->n, rv->vec ) );
}
/* Description of im_eorimage_vec.
*/
static im_function eorimage_vec_desc = {
"im_eorimage_vec", /* Name */
"bitwise eor of an image with a vector constant",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
eorimage_vec_vec, /* Dispatch function */
IM_NUMBER( vec_in_one_out ), /* Size of arg list */
vec_in_one_out /* Arg list */
};
/* Call im_shiftleft via arg vector.
*/
static int
shiftleft_vec( im_object *argv )
{
int n = *((int *) argv[2]);
return( im_shiftleft( argv[0], argv[1], n ) );
}
/* Description of im_shiftleft.
*/
static im_function shiftleft_desc = {
"im_shiftleft", /* Name */
"shift image n bits to left",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
shiftleft_vec, /* Dispatch function */
IM_NUMBER( const_in_one_out ), /* Size of arg list */
const_in_one_out /* Arg list */
};
/* Call im_shiftleft_vec via arg vector.
*/
static int
shiftleft_vec_vec( im_object *argv )
{
im_doublevec_object *rv = (im_doublevec_object *) argv[2];
return( im_shiftleft_vec( argv[0], argv[1], rv->n, rv->vec ) );
}
/* Description of im_shiftleft_vec.
*/
static im_function shiftleft_vec_desc = {
"im_shiftleft_vec", /* Name */
"shift image array bits to left",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
shiftleft_vec_vec, /* Dispatch function */
IM_NUMBER( vec_in_one_out ), /* Size of arg list */
vec_in_one_out /* Arg list */
};
/* Call im_shiftright via arg vector.
*/
static int
shiftright_vec( im_object *argv )
{
int n = *((int *) argv[2]);
return( im_shiftright( argv[0], argv[1], n ) );
}
/* Description of im_shiftright.
*/
static im_function shiftright_desc = {
"im_shiftright", /* Name */
"shift integer image n bits to right",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
shiftright_vec, /* Dispatch function */
IM_NUMBER( const_in_one_out ), /* Size of arg list */
const_in_one_out /* Arg list */
};
/* Call im_shiftright_vec via arg vector.
*/
static int
shiftright_vec_vec( im_object *argv )
{
im_doublevec_object *rv = (im_doublevec_object *) argv[2];
return( im_shiftright_vec( argv[0], argv[1], rv->n, rv->vec ) );
}
/* Description of im_shiftright_vec.
*/
static im_function shiftright_vec_desc = {
"im_shiftright_vec", /* Name */
"shift image array bits to right",
IM_FN_PTOP | IM_FN_PIO, /* Flags */
shiftright_vec_vec, /* Dispatch function */
IM_NUMBER( vec_in_one_out ), /* Size of arg list */
vec_in_one_out /* Arg list */
};
/* Package up all these functions.
*/
static im_function *deprecated_list[] = {
@ -1537,7 +1820,20 @@ static im_function *deprecated_list[] = {
&mask2vips_desc,
&vips2mask_desc,
&insertplace_desc,
&circle_desc
&circle_desc,
&andimage_desc,
&andimageconst_desc,
&andimage_vec_desc,
&orimage_desc,
&orimageconst_desc,
&orimage_vec_desc,
&eorimage_desc,
&eorimageconst_desc,
&eorimage_vec_desc,
&shiftleft_vec_desc,
&shiftleft_desc,
&shiftright_vec_desc,
&shiftright_desc
};
/* Package of functions.

View File

@ -60,7 +60,6 @@
*/
extern im_package im__arithmetic;
extern im_package im__cimg;
extern im_package im__boolean;
extern im_package im__colour;
extern im_package im__conversion;
extern im_package im__convolution;
@ -569,7 +568,6 @@ static im_package im__iofuncs = {
*/
static im_package *built_in[] = {
&im__arithmetic,
&im__boolean,
#ifdef ENABLE_CXX
&im__cimg,
#endif /*ENABLE_CXX*/

View File

@ -1952,6 +1952,20 @@ im_eorimage_vec( VipsImage *in, VipsImage *out, int n, double *c )
VIPS_OPERATION_BOOLEAN_EOR, c, n ) );
}
int
im_shiftleft_vec( IMAGE *in, IMAGE *out, int n, double *c )
{
return( vips__boolean_vec( in, out,
VIPS_OPERATION_BOOLEAN_LSHIFT, c, n ) );
}
int
im_shiftright_vec( IMAGE *in, IMAGE *out, int n, double *c )
{
return( vips__boolean_vec( in, out,
VIPS_OPERATION_BOOLEAN_RSHIFT, c, n ) );
}
int
im_andimageconst( IMAGE *in, IMAGE *out, double c )
{
@ -1970,3 +1984,18 @@ im_eorimageconst( IMAGE *in, IMAGE *out, double c )
return( im_eorimage_vec( in, out, 1, &c ) );
}
int
im_shiftleft( IMAGE *in, IMAGE *out, int n )
{
double c = n;
return( im_shiftleft_vec( in, out, 1, &c ) );
}
int
im_shiftright( IMAGE *in, IMAGE *out, int n )
{
double c = n;
return( im_shiftright_vec( in, out, 1, &c ) );
}

View File

@ -3,7 +3,6 @@ pkginclude_HEADERS = \
almostdeprecated.h \
deprecated.h \
arithmetic.h \
boolean.h \
buf.h \
colour.h \
conversion.h \

View File

@ -114,6 +114,8 @@ typedef enum {
VIPS_OPERATION_BOOLEAN_AND,
VIPS_OPERATION_BOOLEAN_OR,
VIPS_OPERATION_BOOLEAN_EOR,
VIPS_OPERATION_BOOLEAN_LSHIFT,
VIPS_OPERATION_BOOLEAN_RSHIFT,
VIPS_OPERATION_BOOLEAN_LAST
} VipsOperationBoolean;

View File

@ -1,49 +0,0 @@
/* boolean.h
*
* 20/9/09
* - from proto.h
*/
/*
This file is part of VIPS.
VIPS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
*/
#ifndef IM_BOOLEAN_H
#define IM_BOOLEAN_H
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
int im_shiftleft_vec( VipsImage *in, VipsImage *out, int n, double *c );
int im_shiftleft( VipsImage *in, VipsImage *out, int n );
int im_shiftright_vec( VipsImage *in, VipsImage *out, int n, double *c );
int im_shiftright( VipsImage *in, VipsImage *out, int n );
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /*IM_BOOLEAN_H*/

View File

@ -120,7 +120,6 @@ extern "C" {
#include <vips/enumtypes.h>
#include <vips/arithmetic.h>
#include <vips/boolean.h>
#include <vips/relational.h>
#include <vips/conversion.h>
#include <vips/convolution.h>

View File

@ -574,6 +574,11 @@ int im_andimageconst( VipsImage *in, VipsImage *out, double c );
int im_orimageconst( VipsImage *in, VipsImage *out, double c );
int im_eorimageconst( VipsImage *in, VipsImage *out, double c );
int im_shiftleft_vec( VipsImage *in, VipsImage *out, int n, double *c );
int im_shiftleft( VipsImage *in, VipsImage *out, int n );
int im_shiftright_vec( VipsImage *in, VipsImage *out, int n, double *c );
int im_shiftright( VipsImage *in, VipsImage *out, int n );
int im_remainder( VipsImage *in1, VipsImage *in2, VipsImage *out );
int im_remainder_vec( VipsImage *in, VipsImage *out, int n, double *c );
int im_remainderconst( VipsImage *in, VipsImage *out, double c );

View File

@ -161,6 +161,8 @@ vips_operation_boolean_get_type( void )
{VIPS_OPERATION_BOOLEAN_AND, "VIPS_OPERATION_BOOLEAN_AND", "and"},
{VIPS_OPERATION_BOOLEAN_OR, "VIPS_OPERATION_BOOLEAN_OR", "or"},
{VIPS_OPERATION_BOOLEAN_EOR, "VIPS_OPERATION_BOOLEAN_EOR", "eor"},
{VIPS_OPERATION_BOOLEAN_LSHIFT, "VIPS_OPERATION_BOOLEAN_LSHIFT", "lshift"},
{VIPS_OPERATION_BOOLEAN_RSHIFT, "VIPS_OPERATION_BOOLEAN_RSHIFT", "rshift"},
{VIPS_OPERATION_BOOLEAN_LAST, "VIPS_OPERATION_BOOLEAN_LAST", "last"},
{0, NULL, NULL}
};