1 /* base class for all arithmetic operations 2 */ 3 4 /* 5 6 Copyright (C) 1991-2005 The National Gallery 7 8 This library is free software; you can redistribute it and/or 9 modify it under the terms of the GNU Lesser General Public 10 License as published by the Free Software Foundation; either 11 version 2.1 of the License, or (at your option) any later version. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with this library; if not, write to the Free Software 20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21 02110-1301 USA 22 23 */ 24 25 /* 26 27 These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk 28 29 */ 30 31 #ifndef VIPS_PARITHMETIC_H 32 #define VIPS_PARITHMETIC_H 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif /*__cplusplus*/ 37 38 #include <vips/vips.h> 39 #include <vips/vector.h> 40 41 #define VIPS_TYPE_ARITHMETIC (vips_arithmetic_get_type()) 42 #define VIPS_ARITHMETIC( obj ) \ 43 (G_TYPE_CHECK_INSTANCE_CAST( (obj), \ 44 VIPS_TYPE_ARITHMETIC, VipsArithmetic )) 45 #define VIPS_ARITHMETIC_CLASS( klass ) \ 46 (G_TYPE_CHECK_CLASS_CAST( (klass), \ 47 VIPS_TYPE_ARITHMETIC, VipsArithmeticClass)) 48 #define VIPS_IS_ARITHMETIC( obj ) \ 49 (G_TYPE_CHECK_INSTANCE_TYPE( (obj), VIPS_TYPE_ARITHMETIC )) 50 #define VIPS_IS_ARITHMETIC_CLASS( klass ) \ 51 (G_TYPE_CHECK_CLASS_TYPE( (klass), VIPS_TYPE_ARITHMETIC )) 52 #define VIPS_ARITHMETIC_GET_CLASS( obj ) \ 53 (G_TYPE_INSTANCE_GET_CLASS( (obj), \ 54 VIPS_TYPE_ARITHMETIC, VipsArithmeticClass )) 55 56 struct _VipsArithmetic; 57 typedef void (*VipsArithmeticProcessFn)( struct _VipsArithmetic *arithmetic, 58 VipsPel *out, VipsPel **in, int width ); 59 60 typedef struct _VipsArithmetic { 61 VipsOperation parent_instance; 62 63 /* All have an output image. 64 */ 65 VipsImage *out; 66 67 /* Array of input arguments, set these from a subclass. 68 */ 69 VipsImage **in; 70 int n; 71 72 /* The minimum number of output bands. For example, VipsLinear with a 73 * three element constant must make at least a three-band output. 74 */ 75 int base_bands; 76 77 /* The input images, ready for the operation. 78 */ 79 VipsImage **ready; 80 81 /* Set this to override class->format_table. 82 */ 83 VipsBandFormat format; 84 } VipsArithmetic; 85 86 typedef struct _VipsArithmeticClass { 87 VipsOperationClass parent_class; 88 89 /* For each input format, what output format. Used for arithmetic 90 * too, since we cast inputs to match. 91 */ 92 const VipsBandFormat *format_table; 93 94 /* A vector program for each input type. 95 */ 96 VipsVector *vectors[VIPS_FORMAT_LAST]; 97 98 /* ... and if we've set a program for this format. 99 */ 100 gboolean vector_program[VIPS_FORMAT_LAST]; 101 102 /* The buffer processor. 103 */ 104 VipsArithmeticProcessFn process_line; 105 } VipsArithmeticClass; 106 107 GType vips_arithmetic_get_type( void ); 108 109 void vips_arithmetic_set_format_table( VipsArithmeticClass *klass, 110 const VipsBandFormat *format_table ); 111 void vips_arithmetic_set_vector( VipsArithmeticClass *klass ); 112 VipsVector *vips_arithmetic_get_vector( VipsArithmeticClass *klass, 113 VipsBandFormat fmt ); 114 void vips_arithmetic_compile( VipsArithmeticClass *klass ); 115 VipsVector *vips_arithmetic_get_program( VipsArithmeticClass *klass, 116 VipsBandFormat fmt ); 117 118 #ifdef __cplusplus 119 } 120 #endif /*__cplusplus*/ 121 122 #endif /*VIPS_PARITHMETIC_H*/ 123 124 125