]>
Commit | Line | Data |
---|---|---|
10a0e290 BB |
1 | /* |
2 | ||
3 | SDL_imageFilter - bytes-image "filter" routines | |
4 | (uses inline x86 MMX optimizations if available) | |
5 | ||
6 | LGPL (c) A. Schiffler | |
7 | ||
8 | */ | |
9 | ||
10 | #ifndef _SDL_imageFilter_h | |
11 | #define _SDL_imageFilter_h | |
12 | ||
13 | /* Set up for C function definitions, even when using C++ */ | |
14 | #ifdef __cplusplus | |
15 | extern "C" { | |
16 | #endif | |
17 | ||
18 | /* ------ Function Prototypes ------ */ | |
19 | ||
20 | #ifdef WIN32 | |
21 | #ifdef BUILD_DLL | |
22 | #define DLLINTERFACE __declspec(dllexport) | |
23 | #else | |
24 | #define DLLINTERFACE __declspec(dllimport) | |
25 | #endif | |
26 | #else | |
27 | #define DLLINTERFACE | |
28 | #endif | |
29 | ||
30 | /* Comments: */ | |
31 | /* 1.) MMX functions work best if all data blocks are aligned on a 32 bytes boundary. */ | |
32 | /* 2.) Data that is not within an 8 byte boundary is processed using the C routine. */ | |
33 | /* 3.) Convolution routines do not have C routines at this time. */ | |
34 | ||
35 | // Detect MMX capability in CPU | |
36 | DLLINTERFACE int SDL_imageFilterMMXdetect(void); | |
37 | ||
38 | // Force use of MMX off (or turn possible use back on) | |
39 | DLLINTERFACE void SDL_imageFilterMMXoff(void); | |
40 | DLLINTERFACE void SDL_imageFilterMMXon(void); | |
41 | ||
42 | // | |
43 | // All routines return: | |
44 | // 0 OK | |
45 | // -1 Error (internal error, parameter error) | |
46 | // | |
47 | ||
48 | // SDL_imageFilterAdd: D = saturation255(S1 + S2) | |
49 | DLLINTERFACE int SDL_imageFilterAdd(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, int length); | |
50 | ||
51 | // SDL_imageFilterMean: D = S1/2 + S2/2 | |
52 | DLLINTERFACE int SDL_imageFilterMean(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, int length); | |
53 | ||
54 | // SDL_imageFilterSub: D = saturation0(S1 - S2) | |
55 | DLLINTERFACE int SDL_imageFilterSub(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, int length); | |
56 | ||
57 | // SDL_imageFilterAbsDiff: D = | S1 - S2 | | |
58 | DLLINTERFACE int SDL_imageFilterAbsDiff(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, int length); | |
59 | ||
60 | // SDL_imageFilterMult: D = saturation(S1 * S2) | |
61 | DLLINTERFACE int SDL_imageFilterMult(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, int length); | |
62 | ||
63 | // SDL_imageFilterMultNor: D = S1 * S2 (non-MMX) | |
64 | DLLINTERFACE int SDL_imageFilterMultNor(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, int length); | |
65 | ||
66 | // SDL_imageFilterMultDivby2: D = saturation255(S1/2 * S2) | |
67 | DLLINTERFACE int SDL_imageFilterMultDivby2(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, | |
68 | int length); | |
69 | ||
70 | // SDL_imageFilterMultDivby4: D = saturation255(S1/2 * S2/2) | |
71 | DLLINTERFACE int SDL_imageFilterMultDivby4(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, | |
72 | int length); | |
73 | ||
74 | // SDL_imageFilterBitAnd: D = S1 & S2 | |
75 | DLLINTERFACE int SDL_imageFilterBitAnd(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, int length); | |
76 | ||
77 | // SDL_imageFilterBitOr: D = S1 | S2 | |
78 | DLLINTERFACE int SDL_imageFilterBitOr(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, int length); | |
79 | ||
80 | // SDL_imageFilterDiv: D = S1 / S2 (non-MMX) | |
81 | DLLINTERFACE int SDL_imageFilterDiv(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, int length); | |
82 | ||
83 | // SDL_imageFilterBitNegation: D = !S | |
84 | DLLINTERFACE int SDL_imageFilterBitNegation(unsigned char *Src1, unsigned char *Dest, int length); | |
85 | ||
86 | // SDL_imageFilterAddByte: D = saturation255(S + C) | |
87 | DLLINTERFACE int SDL_imageFilterAddByte(unsigned char *Src1, unsigned char *Dest, int length, unsigned char C); | |
88 | ||
89 | // SDL_imageFilterAddUint: D = saturation255(S + (uint)C) | |
90 | DLLINTERFACE int SDL_imageFilterAddUint(unsigned char *Src1, unsigned char *Dest, int length, unsigned int C); | |
91 | ||
92 | // SDL_imageFilterAddByteToHalf: D = saturation255(S/2 + C) | |
93 | DLLINTERFACE int SDL_imageFilterAddByteToHalf(unsigned char *Src1, unsigned char *Dest, int length, | |
94 | unsigned char C); | |
95 | ||
96 | // SDL_imageFilterSubByte: D = saturation0(S - C) | |
97 | DLLINTERFACE int SDL_imageFilterSubByte(unsigned char *Src1, unsigned char *Dest, int length, unsigned char C); | |
98 | ||
99 | // SDL_imageFilterSubUint: D = saturation0(S - (uint)C) | |
100 | DLLINTERFACE int SDL_imageFilterSubUint(unsigned char *Src1, unsigned char *Dest, int length, unsigned int C); | |
101 | ||
102 | // SDL_imageFilterShiftRight: D = saturation0(S >> N) | |
103 | DLLINTERFACE int SDL_imageFilterShiftRight(unsigned char *Src1, unsigned char *Dest, int length, unsigned char N); | |
104 | ||
105 | // SDL_imageFilterShiftRightUint: D = saturation0((uint)S >> N) | |
106 | DLLINTERFACE int SDL_imageFilterShiftRightUint(unsigned char *Src1, unsigned char *Dest, int length, unsigned char N); | |
107 | ||
108 | // SDL_imageFilterMultByByte: D = saturation255(S * C) | |
109 | DLLINTERFACE int SDL_imageFilterMultByByte(unsigned char *Src1, unsigned char *Dest, int length, unsigned char C); | |
110 | ||
111 | // SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C) | |
112 | DLLINTERFACE int SDL_imageFilterShiftRightAndMultByByte(unsigned char *Src1, unsigned char *Dest, int length, | |
113 | unsigned char N, unsigned char C); | |
114 | ||
115 | // SDL_imageFilterShiftLeftByte: D = (S << N) | |
116 | DLLINTERFACE int SDL_imageFilterShiftLeftByte(unsigned char *Src1, unsigned char *Dest, int length, | |
117 | unsigned char N); | |
118 | ||
119 | // SDL_imageFilterShiftLeftUint: D = ((uint)S << N) | |
120 | DLLINTERFACE int SDL_imageFilterShiftLeftUint(unsigned char *Src1, unsigned char *Dest, int length, | |
121 | unsigned char N); | |
122 | ||
123 | // SDL_imageFilterShiftLeft: D = saturation255(S << N) | |
124 | DLLINTERFACE int SDL_imageFilterShiftLeft(unsigned char *Src1, unsigned char *Dest, int length, unsigned char N); | |
125 | ||
126 | // SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0 | |
127 | DLLINTERFACE int SDL_imageFilterBinarizeUsingThreshold(unsigned char *Src1, unsigned char *Dest, int length, | |
128 | unsigned char T); | |
129 | ||
130 | // SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0 | |
131 | DLLINTERFACE int SDL_imageFilterClipToRange(unsigned char *Src1, unsigned char *Dest, int length, | |
132 | unsigned char Tmin, unsigned char Tmax); | |
133 | ||
134 | // SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin) | |
135 | DLLINTERFACE int SDL_imageFilterNormalizeLinear(unsigned char *Src1, unsigned char *Dest, int length, int Cmin, | |
136 | int Cmax, int Nmin, int Nmax); | |
137 | ||
138 | /* !!! NO C-ROUTINE FOR THESE FUNCTIONS YET !!! */ | |
139 | ||
140 | // SDL_imageFilterConvolveKernel3x3Divide: Dij = saturation0and255( ... ) | |
141 | DLLINTERFACE int SDL_imageFilterConvolveKernel3x3Divide(unsigned char *Src, unsigned char *Dest, int rows, | |
142 | int columns, signed short *Kernel, unsigned char Divisor); | |
143 | ||
144 | // SDL_imageFilterConvolveKernel5x5Divide: Dij = saturation0and255( ... ) | |
145 | DLLINTERFACE int SDL_imageFilterConvolveKernel5x5Divide(unsigned char *Src, unsigned char *Dest, int rows, | |
146 | int columns, signed short *Kernel, unsigned char Divisor); | |
147 | ||
148 | // SDL_imageFilterConvolveKernel7x7Divide: Dij = saturation0and255( ... ) | |
149 | DLLINTERFACE int SDL_imageFilterConvolveKernel7x7Divide(unsigned char *Src, unsigned char *Dest, int rows, | |
150 | int columns, signed short *Kernel, unsigned char Divisor); | |
151 | ||
152 | // SDL_imageFilterConvolveKernel9x9Divide: Dij = saturation0and255( ... ) | |
153 | DLLINTERFACE int SDL_imageFilterConvolveKernel9x9Divide(unsigned char *Src, unsigned char *Dest, int rows, | |
154 | int columns, signed short *Kernel, unsigned char Divisor); | |
155 | ||
156 | // SDL_imageFilterConvolveKernel3x3ShiftRight: Dij = saturation0and255( ... ) | |
157 | DLLINTERFACE int SDL_imageFilterConvolveKernel3x3ShiftRight(unsigned char *Src, unsigned char *Dest, int rows, | |
158 | int columns, signed short *Kernel, | |
159 | unsigned char NRightShift); | |
160 | ||
161 | // SDL_imageFilterConvolveKernel5x5ShiftRight: Dij = saturation0and255( ... ) | |
162 | DLLINTERFACE int SDL_imageFilterConvolveKernel5x5ShiftRight(unsigned char *Src, unsigned char *Dest, int rows, | |
163 | int columns, signed short *Kernel, | |
164 | unsigned char NRightShift); | |
165 | ||
166 | // SDL_imageFilterConvolveKernel7x7ShiftRight: Dij = saturation0and255( ... ) | |
167 | DLLINTERFACE int SDL_imageFilterConvolveKernel7x7ShiftRight(unsigned char *Src, unsigned char *Dest, int rows, | |
168 | int columns, signed short *Kernel, | |
169 | unsigned char NRightShift); | |
170 | ||
171 | // SDL_imageFilterConvolveKernel9x9ShiftRight: Dij = saturation0and255( ... ) | |
172 | DLLINTERFACE int SDL_imageFilterConvolveKernel9x9ShiftRight(unsigned char *Src, unsigned char *Dest, int rows, | |
173 | int columns, signed short *Kernel, | |
174 | unsigned char NRightShift); | |
175 | ||
176 | // SDL_imageFilterSobelX: Dij = saturation255( ... ) | |
177 | DLLINTERFACE int SDL_imageFilterSobelX(unsigned char *Src, unsigned char *Dest, int rows, int columns); | |
178 | ||
179 | // SDL_imageFilterSobelXShiftRight: Dij = saturation255( ... ) | |
180 | DLLINTERFACE int SDL_imageFilterSobelXShiftRight(unsigned char *Src, unsigned char *Dest, int rows, int columns, | |
181 | unsigned char NRightShift); | |
182 | ||
183 | // Align/restore stack to 32 byte boundary -- Functionality untested! -- | |
184 | DLLINTERFACE void SDL_imageFilterAlignStack(void); | |
185 | DLLINTERFACE void SDL_imageFilterRestoreStack(void); | |
186 | ||
187 | /* Ends C function definitions when using C++ */ | |
188 | #ifdef __cplusplus | |
189 | } | |
190 | #endif | |
191 | ||
192 | #endif /* _SDL_imageFilter_h */ |