1 /* Integer Multi-Dimensional Interpolation */
2 /* Interpolation Kernel Code */
3 /* Generated by cgen */
4 /* Copyright 2000 - 2002 Graeme W. Gill */
5 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
6 
7 /* see the Licence.txt file for licencing details.*/
8 
9 
10 /*
11    Interpolation kernel specs:
12 
13    Input channels per pixel = 1
14    Input channel 0 bits = 8
15    Input channel 0 increment = 1
16    Input is channel interleaved
17    Input channels are separate words
18    Input value extraction is done in input table lookup
19 
20    Output channels per pixel = 1
21    Output channel 0 bits = 8
22    Output channel 0 increment = 1
23    Output is channel interleaved
24 
25    Output channels are separate words
26    Simplex table index bits       = 0
27    Interpolation table index bits = 8
28    Simplex table max resolution = 1
29    Interpolation table max resolution = 255
30  */
31 
32 /*
33    Machine architecture specs:
34 
35    Little endian
36    Reading and writing pixel values separately
37    Pointer size = 32 bits
38 
39    Ordinal size  8 bits is known as 'unsigned char'
40    Ordinal size 16 bits is known as 'unsigned short'
41    Ordinal size 32 bits is known as 'unsigned int'
42    Natural ordinal is 'unsigned int'
43 
44    Integer size  8 bits is known as 'signed char'
45    Integer size 16 bits is known as 'short'
46    Integer size 32 bits is known as 'int'
47    Natural integer is 'int'
48 
49  */
50 
51 #ifndef  IMDI_INCLUDED
52 #include <memory.h>
53 #include "imdi_imp.h"
54 #define  IMDI_INCLUDED
55 #endif  /* IMDI_INCLUDED */
56 
57 #ifndef DEFINED_pointer
58 #define DEFINED_pointer
59 typedef unsigned char * pointer;
60 #endif
61 
62 /* Input table inter & simplex indexes */
63 #define IT_IT(p, off) *((unsigned char *)((p) + 0 + (off) * 1))
64 
65 /* Simplex weighting table access */
66 #define SW_O(off) ((off) * 4)
67 
68 /* Simplex table - get weighting/offset value */
69 #define SX_WO(p, v) *((unsigned short *)((p) + (v) * 2))
70 
71 /* Interpolation multi-dim. table access */
72 #define IM_O(off) ((off) * 4)
73 
74 /* Interpolation table - get vertex values */
75 #define IM_PE(p, v) *((unsigned int *)((p) + 0 + (v) * 4))
76 
77 /* Output table indexes */
78 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
79 
80 void
imdi_k1(imdi * s,void ** outp,void ** inp,unsigned int npix)81 imdi_k1(
82 imdi *s,			/* imdi context */
83 void **outp,		/* pointer to output pointers */
84 void **inp,		/* pointer to input pointers */
85 unsigned int npix	/* Number of pixels to process */
86 ) {
87 	imdi_imp *p = (imdi_imp *)(s->impl);
88 	unsigned char *ip0 = (unsigned char *)inp[0];
89 	unsigned char *op0 = (unsigned char *)outp[0];
90 	unsigned char *ep = ip0 + npix * 1 ;
91 	pointer it0 = (pointer)p->in_tables[0];
92 	pointer ot0 = (pointer)p->out_tables[0];
93 	pointer sw_base = (pointer)p->sw_table;
94 	pointer im_base = (pointer)p->im_table;
95 
96 	for(;ip0 < ep; ip0 += 1, op0 += 1) {
97 		unsigned int ova0;	/* Output value partial accumulator */
98 		{
99 			pointer swp;
100 			pointer imp;
101 			{
102 				unsigned int ti;	/* Simplex+Interpolation index variable */
103 
104 				ti  = IT_IT(it0, ip0[0]);
105 
106 				imp = im_base + IM_O(ti >> 0);		/* Extract interp. index and comp. entry */
107 				swp = sw_base + SW_O(ti & 0x0);	/* Extract simplex index and comp. entry */
108 			}
109 			{
110 				unsigned int vowr;	/* Vertex offset/weight value */
111 				unsigned int vof;	/* Vertex offset value */
112 				unsigned int vwe;	/* Vertex weighting */
113 
114 				vowr = SX_WO(swp, 0);	/* Read vertex offset+weighting values */
115 				vof = (vowr & 0x7f);	/* Extract offset value */
116 				vwe = (vowr >> 7);	/* Extract weighting value */
117 				ova0  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
118 				vowr = SX_WO(swp, 1);	/* Read vertex offset+weighting values */
119 				vof = (vowr & 0x7f);	/* Extract offset value */
120 				vwe = (vowr >> 7);	/* Extract weighting value */
121 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
122 			}
123 		}
124 		{
125 			unsigned int oti;	/* Vertex offset value */
126 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
127 			op0[0] = OT_E(ot0, oti);	/* Write result */
128 		}
129 	}
130 }
131 #undef IT_IT
132 #undef SW_O
133 #undef SX_WO
134 #undef IM_O
135 #undef IM_PE
136 #undef OT_E
137 
138 void
imdi_k1_gen(genspec * g)139 imdi_k1_gen(
140 genspec *g			/* structure to be initialised */
141 ) {
142 	static unsigned char data[] = {
143 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
144 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
145 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
146 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
147 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
148 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
149 		0x00, 0x00, 0x00, 0x00, 0x80, 0xdb, 0x83, 0xbf,
150 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
151 		0x06, 0x00, 0x00, 0x00, 0xc0, 0xa6, 0xdc, 0xb7,
152 		0xff, 0xff, 0x0f, 0x00, 0x51, 0x00, 0x00, 0x00,
153 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
154 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
155 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
156 		0x8d, 0xb7, 0xf3, 0xb7, 0xc3, 0xd1, 0xf2, 0xb7,
157 		0x38, 0x18, 0xf4, 0xb7, 0xc4, 0x1f, 0xf4, 0xb7,
158 		0xa0, 0xdc, 0x83, 0xbf, 0x08, 0x00, 0x00, 0x00,
159 		0x4b, 0xa5, 0xf3, 0xb7, 0x34, 0x80, 0x04, 0x08,
160 		0x07, 0x00, 0x00, 0x00, 0x28, 0xd9, 0x83, 0xbf,
161 		0x03, 0x00, 0x00, 0x00, 0xae, 0xd9, 0x83, 0xbf,
162 		0x00, 0xe4, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
163 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
164 		0x07, 0x00, 0x00, 0x00, 0x34, 0x80, 0x04, 0x08,
165 		0xd0, 0x85, 0x04, 0x08, 0x4c, 0x69, 0x6e, 0x75,
166 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
167 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
168 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
169 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
170 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
171 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
172 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
173 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
174 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
175 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
176 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
177 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
178 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
179 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
180 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
181 		0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
182 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
183 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
184 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
185 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
186 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
187 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
188 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
189 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
190 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
191 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
192 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
193 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
194 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x31, 0x5f,
195 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
196 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
197 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
198 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
199 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
200 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
201 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
202 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
203 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
204 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
205 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
206 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
207 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x00,
208 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
209 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
210 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
211 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
212 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
213 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
214 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
215 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
216 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
217 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
218 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
219 		0x00, 0xf0, 0x04, 0x08
220 	};	/* Structure image */
221 
222 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
223 }
224 
225 void
imdi_k1_tab(tabspec * t)226 imdi_k1_tab(
227 tabspec *t			/* structure to be initialised */
228 ) {
229 	static unsigned char data[] = {
230 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
231 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
232 		0x00, 0x00, 0x00, 0x00, 0x2c, 0xf3, 0xdc, 0xb7,
233 		0x08, 0xad, 0xf2, 0xb7, 0xf8, 0xac, 0xf2, 0xb7,
234 		0x46, 0x83, 0x04, 0x08, 0x50, 0xd5, 0x83, 0xbf,
235 		0x60, 0x80, 0xf3, 0xb7, 0x46, 0x83, 0x04, 0x08,
236 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
237 		0x08, 0x00, 0x00, 0x00, 0xac, 0x53, 0xdd, 0xb7,
238 		0xa4, 0xd5, 0x83, 0xbf, 0x00, 0x00, 0x00, 0x00,
239 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
240 		0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
241 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
242 		0x09, 0x00, 0x00, 0x00, 0x08, 0x06, 0x00, 0x00,
243 		0x4e, 0xcb, 0xdd, 0xb7, 0x07, 0x00, 0x00, 0x00,
244 		0x2c, 0xf3, 0xdc, 0xb7, 0x04, 0x00, 0x00, 0x00,
245 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
246 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
247 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
248 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
249 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
250 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
251 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
252 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
253 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
254 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
255 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
256 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
257 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
258 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
259 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
260 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
261 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
262 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
263 	};	/* Structure image */
264 
265 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
266 }
267 
268 
269 
270 
271 
272 
273 /* Integer Multi-Dimensional Interpolation */
274 /* Interpolation Kernel Code */
275 /* Generated by cgen */
276 /* Copyright 2000 - 2002 Graeme W. Gill */
277 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
278 
279 /* see the Licence.txt file for licencing details.*/
280 
281 
282 /*
283    Interpolation kernel specs:
284 
285    Input channels per pixel = 3
286    Input channel 0 bits = 8
287    Input channel 0 increment = 3
288    Input channel 1 bits = 8
289    Input channel 1 increment = 3
290    Input channel 2 bits = 8
291    Input channel 2 increment = 3
292    Input is channel interleaved
293    Input channels are separate words
294    Input value extraction is done in input table lookup
295 
296    Output channels per pixel = 1
297    Output channel 0 bits = 8
298    Output channel 0 increment = 1
299    Output is channel interleaved
300 
301    Output channels are separate words
302    Simplex table index bits       = 12
303    Interpolation table index bits = 20
304    Simplex table max resolution = 16
305    Interpolation table max resolution = 101
306  */
307 
308 /*
309    Machine architecture specs:
310 
311    Little endian
312    Reading and writing pixel values separately
313    Pointer size = 32 bits
314 
315    Ordinal size  8 bits is known as 'unsigned char'
316    Ordinal size 16 bits is known as 'unsigned short'
317    Ordinal size 32 bits is known as 'unsigned int'
318    Natural ordinal is 'unsigned int'
319 
320    Integer size  8 bits is known as 'signed char'
321    Integer size 16 bits is known as 'short'
322    Integer size 32 bits is known as 'int'
323    Natural integer is 'int'
324 
325  */
326 
327 #ifndef  IMDI_INCLUDED
328 #include <memory.h>
329 #include "imdi_imp.h"
330 #define  IMDI_INCLUDED
331 #endif  /* IMDI_INCLUDED */
332 
333 #ifndef DEFINED_pointer
334 #define DEFINED_pointer
335 typedef unsigned char * pointer;
336 #endif
337 
338 /* Input table inter & simplex indexes */
339 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
340 
341 /* Simplex weighting table access */
342 #define SW_O(off) ((off) * 16)
343 
344 /* Simplex table - get weighting value */
345 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
346 
347 /* Simplex table - get offset value */
348 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
349 
350 /* Interpolation multi-dim. table access */
351 #define IM_O(off) ((off) * 4)
352 
353 /* Interpolation table - get vertex values */
354 #define IM_PE(p, v) *((unsigned int *)((p) + 0 + (v) * 4))
355 
356 /* Output table indexes */
357 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
358 
359 void
imdi_k2(imdi * s,void ** outp,void ** inp,unsigned int npix)360 imdi_k2(
361 imdi *s,			/* imdi context */
362 void **outp,		/* pointer to output pointers */
363 void **inp,		/* pointer to input pointers */
364 unsigned int npix	/* Number of pixels to process */
365 ) {
366 	imdi_imp *p = (imdi_imp *)(s->impl);
367 	unsigned char *ip0 = (unsigned char *)inp[0];
368 	unsigned char *op0 = (unsigned char *)outp[0];
369 	unsigned char *ep = ip0 + npix * 3 ;
370 	pointer it0 = (pointer)p->in_tables[0];
371 	pointer it1 = (pointer)p->in_tables[1];
372 	pointer it2 = (pointer)p->in_tables[2];
373 	pointer ot0 = (pointer)p->out_tables[0];
374 	pointer sw_base = (pointer)p->sw_table;
375 	pointer im_base = (pointer)p->im_table;
376 
377 	for(;ip0 < ep; ip0 += 3, op0 += 1) {
378 		unsigned int ova0;	/* Output value partial accumulator */
379 		{
380 			pointer swp;
381 			pointer imp;
382 			{
383 				unsigned int ti;	/* Simplex+Interpolation index variable */
384 
385 				ti  = IT_IT(it0, ip0[0]);
386 				ti += IT_IT(it1, ip0[1]);
387 				ti += IT_IT(it2, ip0[2]);
388 
389 				imp = im_base + IM_O(ti >> 12);		/* Extract interp. index and comp. entry */
390 				swp = sw_base + SW_O(ti & 0xfff);	/* Extract simplex index and comp. entry */
391 			}
392 			{
393 				unsigned int vof;	/* Vertex offset value */
394 				unsigned int vwe;	/* Vertex weighting */
395 
396 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
397 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
398 				ova0  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
399 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
400 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
401 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
402 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
403 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
404 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
405 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
406 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
407 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
408 			}
409 		}
410 		{
411 			unsigned int oti;	/* Vertex offset value */
412 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
413 			op0[0] = OT_E(ot0, oti);	/* Write result */
414 		}
415 	}
416 }
417 #undef IT_IT
418 #undef SW_O
419 #undef SX_WE
420 #undef SX_VO
421 #undef IM_O
422 #undef IM_PE
423 #undef OT_E
424 
425 void
imdi_k2_gen(genspec * g)426 imdi_k2_gen(
427 genspec *g			/* structure to be initialised */
428 ) {
429 	static unsigned char data[] = {
430 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
431 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
432 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
433 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
434 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
435 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
436 		0x00, 0x00, 0x00, 0x00, 0x80, 0xdb, 0x83, 0xbf,
437 		0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
438 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
439 		0xff, 0xff, 0x0f, 0x00, 0x51, 0x00, 0x00, 0x00,
440 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
441 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
442 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
443 		0x8d, 0xb7, 0xf3, 0xb7, 0xc3, 0xd1, 0xf2, 0xb7,
444 		0x38, 0x18, 0xf4, 0xb7, 0xc4, 0x1f, 0xf4, 0xb7,
445 		0xa0, 0xdc, 0x83, 0xbf, 0x08, 0x00, 0x00, 0x00,
446 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
447 		0x07, 0x00, 0x00, 0x00, 0x28, 0xd9, 0x83, 0xbf,
448 		0x03, 0x00, 0x00, 0x00, 0xae, 0xd9, 0x83, 0xbf,
449 		0x00, 0xe4, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
450 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
451 		0x07, 0x00, 0x00, 0x00, 0x34, 0x80, 0x04, 0x08,
452 		0xd0, 0x85, 0x04, 0x08, 0x4c, 0x69, 0x6e, 0x75,
453 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
454 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
455 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
456 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
457 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
458 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
459 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
460 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
461 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
462 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
463 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
464 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
465 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
466 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
467 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
468 		0x65, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
469 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
470 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
471 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
472 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
473 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
474 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
475 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
476 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
477 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
478 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
479 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
480 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
481 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x31, 0x5f,
482 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
483 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
484 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
485 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
486 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
487 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
488 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
489 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
490 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
491 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
492 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
493 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
494 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x32, 0x00,
495 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
496 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
497 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
498 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
499 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
500 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
501 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
502 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
503 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
504 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
505 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
506 		0x00, 0xf0, 0x04, 0x08
507 	};	/* Structure image */
508 
509 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
510 }
511 
512 void
imdi_k2_tab(tabspec * t)513 imdi_k2_tab(
514 tabspec *t			/* structure to be initialised */
515 ) {
516 	static unsigned char data[] = {
517 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
518 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
519 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
520 		0x02, 0x00, 0x00, 0x00, 0xf8, 0xac, 0xf2, 0xb7,
521 		0x46, 0x83, 0x04, 0x08, 0x50, 0xd5, 0x83, 0xbf,
522 		0x60, 0x80, 0xf3, 0xb7, 0x46, 0x83, 0x04, 0x08,
523 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
524 		0x14, 0x00, 0x00, 0x00, 0xac, 0x53, 0xdd, 0xb7,
525 		0xa4, 0xd5, 0x83, 0xbf, 0x0c, 0x00, 0x00, 0x00,
526 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
527 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
528 		0x04, 0x00, 0x00, 0x00, 0xf8, 0xac, 0xf2, 0xb7,
529 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
530 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
531 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
532 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
533 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
534 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
535 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
536 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
537 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
538 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
539 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
540 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
541 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
542 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
543 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
544 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
545 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
546 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
547 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
548 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
549 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
550 	};	/* Structure image */
551 
552 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
553 }
554 
555 
556 
557 
558 
559 
560 /* Integer Multi-Dimensional Interpolation */
561 /* Interpolation Kernel Code */
562 /* Generated by cgen */
563 /* Copyright 2000 - 2002 Graeme W. Gill */
564 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
565 
566 /* see the Licence.txt file for licencing details.*/
567 
568 
569 /*
570    Interpolation kernel specs:
571 
572    Input channels per pixel = 4
573    Input channel 0 bits = 8
574    Input channel 0 increment = 4
575    Input channel 1 bits = 8
576    Input channel 1 increment = 4
577    Input channel 2 bits = 8
578    Input channel 2 increment = 4
579    Input channel 3 bits = 8
580    Input channel 3 increment = 4
581    Input is channel interleaved
582    Input channels are separate words
583    Input value extraction is done in input table lookup
584 
585    Output channels per pixel = 1
586    Output channel 0 bits = 8
587    Output channel 0 increment = 1
588    Output is channel interleaved
589 
590    Output channels are separate words
591    Simplex table index bits       = 32
592    Interpolation table index bits = 32
593    Simplex table max resolution = 255
594    Interpolation table max resolution = 39
595  */
596 
597 /*
598    Machine architecture specs:
599 
600    Little endian
601    Reading and writing pixel values separately
602    Pointer size = 32 bits
603 
604    Ordinal size  8 bits is known as 'unsigned char'
605    Ordinal size 16 bits is known as 'unsigned short'
606    Ordinal size 32 bits is known as 'unsigned int'
607    Natural ordinal is 'unsigned int'
608 
609    Integer size  8 bits is known as 'signed char'
610    Integer size 16 bits is known as 'short'
611    Integer size 32 bits is known as 'int'
612    Natural integer is 'int'
613 
614  */
615 
616 #ifndef  IMDI_INCLUDED
617 #include <memory.h>
618 #include "imdi_imp.h"
619 #define  IMDI_INCLUDED
620 #endif  /* IMDI_INCLUDED */
621 
622 #ifndef DEFINED_pointer
623 #define DEFINED_pointer
624 typedef unsigned char * pointer;
625 #endif
626 
627 /* Input table interp. index */
628 #define IT_IX(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
629 
630 /* Input table simplex index enty */
631 #define IT_SX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
632 
633 /* Simplex weighting table access */
634 #define SW_O(off) ((off) * 20)
635 
636 /* Simplex table - get weighting value */
637 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
638 
639 /* Simplex table - get offset value */
640 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
641 
642 /* Interpolation multi-dim. table access */
643 #define IM_O(off) ((off) * 4)
644 
645 /* Interpolation table - get vertex values */
646 #define IM_PE(p, v) *((unsigned int *)((p) + 0 + (v) * 4))
647 
648 /* Output table indexes */
649 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
650 
651 void
imdi_k3(imdi * s,void ** outp,void ** inp,unsigned int npix)652 imdi_k3(
653 imdi *s,			/* imdi context */
654 void **outp,		/* pointer to output pointers */
655 void **inp,		/* pointer to input pointers */
656 unsigned int npix	/* Number of pixels to process */
657 ) {
658 	imdi_imp *p = (imdi_imp *)(s->impl);
659 	unsigned char *ip0 = (unsigned char *)inp[0];
660 	unsigned char *op0 = (unsigned char *)outp[0];
661 	unsigned char *ep = ip0 + npix * 4 ;
662 	pointer it0 = (pointer)p->in_tables[0];
663 	pointer it1 = (pointer)p->in_tables[1];
664 	pointer it2 = (pointer)p->in_tables[2];
665 	pointer it3 = (pointer)p->in_tables[3];
666 	pointer ot0 = (pointer)p->out_tables[0];
667 	pointer sw_base = (pointer)p->sw_table;
668 	pointer im_base = (pointer)p->im_table;
669 
670 	for(;ip0 < ep; ip0 += 4, op0 += 1) {
671 		unsigned int ova0;	/* Output value partial accumulator */
672 		{
673 			pointer swp;
674 			pointer imp;
675 			{
676 				unsigned int ti_s;	/* Simplex index variable */
677 				unsigned int ti_i;	/* Interpolation index variable */
678 
679 				ti_i  = IT_IX(it0, ip0[0]);
680 				ti_s  = IT_SX(it0, ip0[0]);
681 				ti_i += IT_IX(it1, ip0[1]);
682 				ti_s += IT_SX(it1, ip0[1]);
683 				ti_i += IT_IX(it2, ip0[2]);
684 				ti_s += IT_SX(it2, ip0[2]);
685 				ti_i += IT_IX(it3, ip0[3]);
686 				ti_s += IT_SX(it3, ip0[3]);
687 
688 				swp = sw_base + SW_O(ti_s);		/* Compute simplex table entry pointer */
689 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
690 			}
691 			{
692 				unsigned int vof;	/* Vertex offset value */
693 				unsigned int vwe;	/* Vertex weighting */
694 
695 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
696 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
697 				ova0  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
698 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
699 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
700 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
701 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
702 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
703 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
704 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
705 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
706 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
707 				vof = SX_VO(swp, 4);	/* Read vertex offset value */
708 				vwe = SX_WE(swp, 4);	/* Read vertex weighting value */
709 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
710 			}
711 		}
712 		{
713 			unsigned int oti;	/* Vertex offset value */
714 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
715 			op0[0] = OT_E(ot0, oti);	/* Write result */
716 		}
717 	}
718 }
719 #undef IT_IX
720 #undef IT_SX
721 #undef SW_O
722 #undef SX_WE
723 #undef SX_VO
724 #undef IM_O
725 #undef IM_PE
726 #undef OT_E
727 
728 void
imdi_k3_gen(genspec * g)729 imdi_k3_gen(
730 genspec *g			/* structure to be initialised */
731 ) {
732 	static unsigned char data[] = {
733 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
734 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
735 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
736 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
737 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
738 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
739 		0x00, 0x00, 0x00, 0x00, 0x80, 0xdb, 0x83, 0xbf,
740 		0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
741 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
742 		0x04, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00,
743 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
744 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
745 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
746 		0x00, 0x00, 0x00, 0x00, 0xc3, 0xd1, 0xf2, 0xb7,
747 		0x38, 0x18, 0xf4, 0xb7, 0xc4, 0x1f, 0xf4, 0xb7,
748 		0xa0, 0xdc, 0x83, 0xbf, 0x08, 0x00, 0x00, 0x00,
749 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
750 		0x08, 0x00, 0x00, 0x00, 0x28, 0xd9, 0x83, 0xbf,
751 		0x03, 0x00, 0x00, 0x00, 0xae, 0xd9, 0x83, 0xbf,
752 		0x00, 0xe4, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
753 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
754 		0x07, 0x00, 0x00, 0x00, 0x34, 0x80, 0x04, 0x08,
755 		0xd0, 0x85, 0x04, 0x08, 0x4c, 0x69, 0x6e, 0x75,
756 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
757 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
758 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
759 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
760 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
761 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
762 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
763 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
764 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
765 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
766 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
767 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
768 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
769 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
770 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
771 		0x27, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
772 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
773 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
774 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
775 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
776 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
777 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
778 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
779 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
780 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
781 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
782 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
783 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
784 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x31, 0x5f,
785 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
786 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
787 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
788 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
789 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
790 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
791 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
792 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
793 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
794 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
795 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
796 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
797 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x33, 0x00,
798 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
799 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
800 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
801 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
802 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
803 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
804 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
805 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
806 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
807 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
808 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
809 		0x00, 0xf0, 0x04, 0x08
810 	};	/* Structure image */
811 
812 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
813 }
814 
815 void
imdi_k3_tab(tabspec * t)816 imdi_k3_tab(
817 tabspec *t			/* structure to be initialised */
818 ) {
819 	static unsigned char data[] = {
820 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
821 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
822 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
823 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
824 		0x46, 0x83, 0x04, 0x08, 0x50, 0xd5, 0x83, 0xbf,
825 		0x60, 0x80, 0xf3, 0xb7, 0x46, 0x83, 0x04, 0x08,
826 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
827 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
828 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
829 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
830 		0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
831 		0x04, 0x00, 0x00, 0x00, 0xf8, 0xac, 0xf2, 0xb7,
832 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
833 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
834 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
835 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
836 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
837 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
838 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
839 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
840 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
841 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
842 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
843 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
844 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
845 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
846 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
847 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
848 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
849 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
850 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
851 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
852 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
853 	};	/* Structure image */
854 
855 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
856 }
857 
858 
859 
860 
861 
862 
863 /* Integer Multi-Dimensional Interpolation */
864 /* Interpolation Kernel Code */
865 /* Generated by cgen */
866 /* Copyright 2000 - 2002 Graeme W. Gill */
867 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
868 
869 /* see the Licence.txt file for licencing details.*/
870 
871 
872 /*
873    Interpolation kernel specs:
874 
875    Input channels per pixel = 5
876    Input channel 0 bits = 8
877    Input channel 0 increment = 5
878    Input channel 1 bits = 8
879    Input channel 1 increment = 5
880    Input channel 2 bits = 8
881    Input channel 2 increment = 5
882    Input channel 3 bits = 8
883    Input channel 3 increment = 5
884    Input channel 4 bits = 8
885    Input channel 4 increment = 5
886    Input is channel interleaved
887    Input channels are separate words
888    Input value extraction is done in input table lookup
889 
890    Output channels per pixel = 1
891    Output channel 0 bits = 8
892    Output channel 0 increment = 1
893    Output is channel interleaved
894 
895    Output channels are separate words
896    Weight+voffset bits       = 32
897    Interpolation table index bits = 32
898    Interpolation table max resolution = 53
899  */
900 
901 /*
902    Machine architecture specs:
903 
904    Little endian
905    Reading and writing pixel values separately
906    Pointer size = 32 bits
907 
908    Ordinal size  8 bits is known as 'unsigned char'
909    Ordinal size 16 bits is known as 'unsigned short'
910    Ordinal size 32 bits is known as 'unsigned int'
911    Natural ordinal is 'unsigned int'
912 
913    Integer size  8 bits is known as 'signed char'
914    Integer size 16 bits is known as 'short'
915    Integer size 32 bits is known as 'int'
916    Natural integer is 'int'
917 
918  */
919 
920 #ifndef  IMDI_INCLUDED
921 #include <memory.h>
922 #include "imdi_imp.h"
923 #define  IMDI_INCLUDED
924 #endif  /* IMDI_INCLUDED */
925 
926 #ifndef DEFINED_pointer
927 #define DEFINED_pointer
928 typedef unsigned char * pointer;
929 #endif
930 
931 /* Input table interp. index */
932 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
933 
934 /* Input table input weighting/offset value enty */
935 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
936 
937 /* Conditional exchange for sorting */
938 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
939 
940 /* Interpolation multi-dim. table access */
941 #define IM_O(off) ((off) * 4)
942 
943 /* Interpolation table - get vertex values */
944 #define IM_PE(p, v) *((unsigned int *)((p) + 0 + (v) * 4))
945 
946 /* Output table indexes */
947 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
948 
949 void
imdi_k4(imdi * s,void ** outp,void ** inp,unsigned int npix)950 imdi_k4(
951 imdi *s,			/* imdi context */
952 void **outp,		/* pointer to output pointers */
953 void **inp,		/* pointer to input pointers */
954 unsigned int npix	/* Number of pixels to process */
955 ) {
956 	imdi_imp *p = (imdi_imp *)(s->impl);
957 	unsigned char *ip0 = (unsigned char *)inp[0];
958 	unsigned char *op0 = (unsigned char *)outp[0];
959 	unsigned char *ep = ip0 + npix * 5 ;
960 	pointer it0 = (pointer)p->in_tables[0];
961 	pointer it1 = (pointer)p->in_tables[1];
962 	pointer it2 = (pointer)p->in_tables[2];
963 	pointer it3 = (pointer)p->in_tables[3];
964 	pointer it4 = (pointer)p->in_tables[4];
965 	pointer ot0 = (pointer)p->out_tables[0];
966 	pointer im_base = (pointer)p->im_table;
967 
968 	for(;ip0 < ep; ip0 += 5, op0 += 1) {
969 		unsigned int ova0;	/* Output value partial accumulator */
970 		{
971 			pointer imp;
972 			unsigned int wo0;	/* Weighting value and vertex offset variable */
973 			unsigned int wo1;	/* Weighting value and vertex offset variable */
974 			unsigned int wo2;	/* Weighting value and vertex offset variable */
975 			unsigned int wo3;	/* Weighting value and vertex offset variable */
976 			unsigned int wo4;	/* Weighting value and vertex offset variable */
977 			{
978 				unsigned int ti_i;	/* Interpolation index variable */
979 
980 				ti_i  = IT_IX(it0, ip0[0]);
981 				wo0   = IT_WO(it0, ip0[0]);
982 				ti_i += IT_IX(it1, ip0[1]);
983 				wo1   = IT_WO(it1, ip0[1]);
984 				ti_i += IT_IX(it2, ip0[2]);
985 				wo2   = IT_WO(it2, ip0[2]);
986 				ti_i += IT_IX(it3, ip0[3]);
987 				wo3   = IT_WO(it3, ip0[3]);
988 				ti_i += IT_IX(it4, ip0[4]);
989 				wo4   = IT_WO(it4, ip0[4]);
990 
991 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
992 
993 				/* Sort weighting values and vertex offset values */
994 				CEX(wo0, wo1);
995 				CEX(wo0, wo2);
996 				CEX(wo0, wo3);
997 				CEX(wo0, wo4);
998 				CEX(wo1, wo2);
999 				CEX(wo1, wo3);
1000 				CEX(wo1, wo4);
1001 				CEX(wo2, wo3);
1002 				CEX(wo2, wo4);
1003 				CEX(wo3, wo4);
1004 			}
1005 			{
1006 				unsigned int nvof;	/* Next vertex offset value */
1007 				unsigned int vof;	/* Vertex offset value */
1008 				unsigned int vwe;	/* Vertex weighting */
1009 
1010 				vof = 0;				/* First vertex offset is 0 */
1011 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
1012 				wo0 = (wo0 >> 23);		/* Extract weighting value */
1013 				vwe = 256 - wo0;		/* Baricentric weighting */
1014 				ova0  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1015 				vof += nvof;			/* Move to next vertex */
1016 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
1017 				wo1 = (wo1 >> 23);		/* Extract weighting value */
1018 				vwe = wo0 - wo1;		/* Baricentric weighting */
1019 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1020 				vof += nvof;			/* Move to next vertex */
1021 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
1022 				wo2 = (wo2 >> 23);		/* Extract weighting value */
1023 				vwe = wo1 - wo2;		/* Baricentric weighting */
1024 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1025 				vof += nvof;			/* Move to next vertex */
1026 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
1027 				wo3 = (wo3 >> 23);		/* Extract weighting value */
1028 				vwe = wo2 - wo3;		/* Baricentric weighting */
1029 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1030 				vof += nvof;			/* Move to next vertex */
1031 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
1032 				wo4 = (wo4 >> 23);		/* Extract weighting value */
1033 				vwe = wo3 - wo4;		/* Baricentric weighting */
1034 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1035 				vof += nvof;			/* Move to next vertex */
1036 				vwe = wo4;				/* Baricentric weighting */
1037 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1038 			}
1039 		}
1040 		{
1041 			unsigned int oti;	/* Vertex offset value */
1042 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
1043 			op0[0] = OT_E(ot0, oti);	/* Write result */
1044 		}
1045 	}
1046 }
1047 #undef IT_WO
1048 #undef IT_IX
1049 #undef CEX
1050 #undef IM_O
1051 #undef IM_PE
1052 #undef OT_E
1053 
1054 void
imdi_k4_gen(genspec * g)1055 imdi_k4_gen(
1056 genspec *g			/* structure to be initialised */
1057 ) {
1058 	static unsigned char data[] = {
1059 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
1060 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1061 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1062 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1063 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1064 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1065 		0x00, 0x00, 0x00, 0x00, 0x80, 0xdb, 0x83, 0xbf,
1066 		0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
1067 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
1068 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
1069 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1070 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1071 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1072 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1073 		0x38, 0x18, 0xf4, 0xb7, 0xc4, 0x1f, 0xf4, 0xb7,
1074 		0xa0, 0xdc, 0x83, 0xbf, 0x08, 0x00, 0x00, 0x00,
1075 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1076 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1077 		0x03, 0x00, 0x00, 0x00, 0xae, 0xd9, 0x83, 0xbf,
1078 		0x00, 0xe4, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
1079 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1080 		0x07, 0x00, 0x00, 0x00, 0x34, 0x80, 0x04, 0x08,
1081 		0xd0, 0x85, 0x04, 0x08, 0x4c, 0x69, 0x6e, 0x75,
1082 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1083 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1084 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1085 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1086 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1087 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1088 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1089 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
1090 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
1091 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1092 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1093 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1094 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1095 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1096 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1097 		0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1098 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
1099 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
1100 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
1101 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
1102 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
1103 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
1104 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
1105 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
1106 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
1107 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1108 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
1109 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
1110 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x31, 0x5f,
1111 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
1112 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
1113 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
1114 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
1115 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
1116 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
1117 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
1118 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1119 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1120 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1121 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1122 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
1123 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x34, 0x00,
1124 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1125 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1126 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
1127 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
1128 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
1129 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
1130 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
1131 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
1132 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
1133 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
1134 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
1135 		0x00, 0xf0, 0x04, 0x08
1136 	};	/* Structure image */
1137 
1138 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
1139 }
1140 
1141 void
imdi_k4_tab(tabspec * t)1142 imdi_k4_tab(
1143 tabspec *t			/* structure to be initialised */
1144 ) {
1145 	static unsigned char data[] = {
1146 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1147 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1148 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1149 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
1150 		0x04, 0x00, 0x00, 0x00, 0x50, 0xd5, 0x83, 0xbf,
1151 		0x60, 0x80, 0xf3, 0xb7, 0x46, 0x83, 0x04, 0x08,
1152 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1153 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
1154 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
1155 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1156 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
1157 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
1158 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
1159 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
1160 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
1161 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1162 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
1163 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1164 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
1165 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1166 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
1167 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
1168 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
1169 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
1170 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1171 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
1172 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
1173 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
1174 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1175 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
1176 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
1177 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
1178 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
1179 	};	/* Structure image */
1180 
1181 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
1182 }
1183 
1184 
1185 
1186 
1187 
1188 
1189 /* Integer Multi-Dimensional Interpolation */
1190 /* Interpolation Kernel Code */
1191 /* Generated by cgen */
1192 /* Copyright 2000 - 2002 Graeme W. Gill */
1193 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
1194 
1195 /* see the Licence.txt file for licencing details.*/
1196 
1197 
1198 /*
1199    Interpolation kernel specs:
1200 
1201    Input channels per pixel = 6
1202    Input channel 0 bits = 8
1203    Input channel 0 increment = 6
1204    Input channel 1 bits = 8
1205    Input channel 1 increment = 6
1206    Input channel 2 bits = 8
1207    Input channel 2 increment = 6
1208    Input channel 3 bits = 8
1209    Input channel 3 increment = 6
1210    Input channel 4 bits = 8
1211    Input channel 4 increment = 6
1212    Input channel 5 bits = 8
1213    Input channel 5 increment = 6
1214    Input is channel interleaved
1215    Input channels are separate words
1216    Input value extraction is done in input table lookup
1217 
1218    Output channels per pixel = 1
1219    Output channel 0 bits = 8
1220    Output channel 0 increment = 1
1221    Output is channel interleaved
1222 
1223    Output channels are separate words
1224    Weight+voffset bits       = 32
1225    Interpolation table index bits = 32
1226    Interpolation table max resolution = 24
1227  */
1228 
1229 /*
1230    Machine architecture specs:
1231 
1232    Little endian
1233    Reading and writing pixel values separately
1234    Pointer size = 32 bits
1235 
1236    Ordinal size  8 bits is known as 'unsigned char'
1237    Ordinal size 16 bits is known as 'unsigned short'
1238    Ordinal size 32 bits is known as 'unsigned int'
1239    Natural ordinal is 'unsigned int'
1240 
1241    Integer size  8 bits is known as 'signed char'
1242    Integer size 16 bits is known as 'short'
1243    Integer size 32 bits is known as 'int'
1244    Natural integer is 'int'
1245 
1246  */
1247 
1248 #ifndef  IMDI_INCLUDED
1249 #include <memory.h>
1250 #include "imdi_imp.h"
1251 #define  IMDI_INCLUDED
1252 #endif  /* IMDI_INCLUDED */
1253 
1254 #ifndef DEFINED_pointer
1255 #define DEFINED_pointer
1256 typedef unsigned char * pointer;
1257 #endif
1258 
1259 /* Input table interp. index */
1260 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
1261 
1262 /* Input table input weighting/offset value enty */
1263 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
1264 
1265 /* Conditional exchange for sorting */
1266 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
1267 
1268 /* Interpolation multi-dim. table access */
1269 #define IM_O(off) ((off) * 4)
1270 
1271 /* Interpolation table - get vertex values */
1272 #define IM_PE(p, v) *((unsigned int *)((p) + 0 + (v) * 4))
1273 
1274 /* Output table indexes */
1275 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
1276 
1277 void
imdi_k5(imdi * s,void ** outp,void ** inp,unsigned int npix)1278 imdi_k5(
1279 imdi *s,			/* imdi context */
1280 void **outp,		/* pointer to output pointers */
1281 void **inp,		/* pointer to input pointers */
1282 unsigned int npix	/* Number of pixels to process */
1283 ) {
1284 	imdi_imp *p = (imdi_imp *)(s->impl);
1285 	unsigned char *ip0 = (unsigned char *)inp[0];
1286 	unsigned char *op0 = (unsigned char *)outp[0];
1287 	unsigned char *ep = ip0 + npix * 6 ;
1288 	pointer it0 = (pointer)p->in_tables[0];
1289 	pointer it1 = (pointer)p->in_tables[1];
1290 	pointer it2 = (pointer)p->in_tables[2];
1291 	pointer it3 = (pointer)p->in_tables[3];
1292 	pointer it4 = (pointer)p->in_tables[4];
1293 	pointer it5 = (pointer)p->in_tables[5];
1294 	pointer ot0 = (pointer)p->out_tables[0];
1295 	pointer im_base = (pointer)p->im_table;
1296 
1297 	for(;ip0 < ep; ip0 += 6, op0 += 1) {
1298 		unsigned int ova0;	/* Output value partial accumulator */
1299 		{
1300 			pointer imp;
1301 			unsigned int wo0;	/* Weighting value and vertex offset variable */
1302 			unsigned int wo1;	/* Weighting value and vertex offset variable */
1303 			unsigned int wo2;	/* Weighting value and vertex offset variable */
1304 			unsigned int wo3;	/* Weighting value and vertex offset variable */
1305 			unsigned int wo4;	/* Weighting value and vertex offset variable */
1306 			unsigned int wo5;	/* Weighting value and vertex offset variable */
1307 			{
1308 				unsigned int ti_i;	/* Interpolation index variable */
1309 
1310 				ti_i  = IT_IX(it0, ip0[0]);
1311 				wo0   = IT_WO(it0, ip0[0]);
1312 				ti_i += IT_IX(it1, ip0[1]);
1313 				wo1   = IT_WO(it1, ip0[1]);
1314 				ti_i += IT_IX(it2, ip0[2]);
1315 				wo2   = IT_WO(it2, ip0[2]);
1316 				ti_i += IT_IX(it3, ip0[3]);
1317 				wo3   = IT_WO(it3, ip0[3]);
1318 				ti_i += IT_IX(it4, ip0[4]);
1319 				wo4   = IT_WO(it4, ip0[4]);
1320 				ti_i += IT_IX(it5, ip0[5]);
1321 				wo5   = IT_WO(it5, ip0[5]);
1322 
1323 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
1324 
1325 				/* Sort weighting values and vertex offset values */
1326 				CEX(wo0, wo1);
1327 				CEX(wo0, wo2);
1328 				CEX(wo0, wo3);
1329 				CEX(wo0, wo4);
1330 				CEX(wo0, wo5);
1331 				CEX(wo1, wo2);
1332 				CEX(wo1, wo3);
1333 				CEX(wo1, wo4);
1334 				CEX(wo1, wo5);
1335 				CEX(wo2, wo3);
1336 				CEX(wo2, wo4);
1337 				CEX(wo2, wo5);
1338 				CEX(wo3, wo4);
1339 				CEX(wo3, wo5);
1340 				CEX(wo4, wo5);
1341 			}
1342 			{
1343 				unsigned int nvof;	/* Next vertex offset value */
1344 				unsigned int vof;	/* Vertex offset value */
1345 				unsigned int vwe;	/* Vertex weighting */
1346 
1347 				vof = 0;				/* First vertex offset is 0 */
1348 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
1349 				wo0 = (wo0 >> 23);		/* Extract weighting value */
1350 				vwe = 256 - wo0;		/* Baricentric weighting */
1351 				ova0  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1352 				vof += nvof;			/* Move to next vertex */
1353 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
1354 				wo1 = (wo1 >> 23);		/* Extract weighting value */
1355 				vwe = wo0 - wo1;		/* Baricentric weighting */
1356 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1357 				vof += nvof;			/* Move to next vertex */
1358 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
1359 				wo2 = (wo2 >> 23);		/* Extract weighting value */
1360 				vwe = wo1 - wo2;		/* Baricentric weighting */
1361 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1362 				vof += nvof;			/* Move to next vertex */
1363 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
1364 				wo3 = (wo3 >> 23);		/* Extract weighting value */
1365 				vwe = wo2 - wo3;		/* Baricentric weighting */
1366 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1367 				vof += nvof;			/* Move to next vertex */
1368 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
1369 				wo4 = (wo4 >> 23);		/* Extract weighting value */
1370 				vwe = wo3 - wo4;		/* Baricentric weighting */
1371 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1372 				vof += nvof;			/* Move to next vertex */
1373 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
1374 				wo5 = (wo5 >> 23);		/* Extract weighting value */
1375 				vwe = wo4 - wo5;		/* Baricentric weighting */
1376 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1377 				vof += nvof;			/* Move to next vertex */
1378 				vwe = wo5;				/* Baricentric weighting */
1379 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1380 			}
1381 		}
1382 		{
1383 			unsigned int oti;	/* Vertex offset value */
1384 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
1385 			op0[0] = OT_E(ot0, oti);	/* Write result */
1386 		}
1387 	}
1388 }
1389 #undef IT_WO
1390 #undef IT_IX
1391 #undef CEX
1392 #undef IM_O
1393 #undef IM_PE
1394 #undef OT_E
1395 
1396 void
imdi_k5_gen(genspec * g)1397 imdi_k5_gen(
1398 genspec *g			/* structure to be initialised */
1399 ) {
1400 	static unsigned char data[] = {
1401 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
1402 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1403 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1404 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1405 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1406 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1407 		0x08, 0x00, 0x00, 0x00, 0x80, 0xdb, 0x83, 0xbf,
1408 		0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
1409 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
1410 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
1411 		0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1412 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1413 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1414 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1415 		0x00, 0x00, 0x00, 0x00, 0xc4, 0x1f, 0xf4, 0xb7,
1416 		0xa0, 0xdc, 0x83, 0xbf, 0x08, 0x00, 0x00, 0x00,
1417 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1418 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1419 		0x08, 0x00, 0x00, 0x00, 0xae, 0xd9, 0x83, 0xbf,
1420 		0x00, 0xe4, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
1421 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1422 		0x07, 0x00, 0x00, 0x00, 0x34, 0x80, 0x04, 0x08,
1423 		0xd0, 0x85, 0x04, 0x08, 0x4c, 0x69, 0x6e, 0x75,
1424 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1425 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1426 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1427 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1428 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1429 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1430 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1431 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
1432 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
1433 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1434 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1435 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1436 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1437 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1438 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1439 		0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1440 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
1441 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
1442 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
1443 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
1444 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
1445 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
1446 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
1447 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
1448 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
1449 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1450 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
1451 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
1452 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x31, 0x5f,
1453 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
1454 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
1455 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
1456 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
1457 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
1458 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
1459 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
1460 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1461 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1462 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1463 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1464 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
1465 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x35, 0x00,
1466 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1467 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1468 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
1469 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
1470 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
1471 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
1472 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
1473 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
1474 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
1475 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
1476 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
1477 		0x00, 0xf0, 0x04, 0x08
1478 	};	/* Structure image */
1479 
1480 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
1481 }
1482 
1483 void
imdi_k5_tab(tabspec * t)1484 imdi_k5_tab(
1485 tabspec *t			/* structure to be initialised */
1486 ) {
1487 	static unsigned char data[] = {
1488 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1489 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1490 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1491 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
1492 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
1493 		0x60, 0x80, 0xf3, 0xb7, 0x46, 0x83, 0x04, 0x08,
1494 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1495 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
1496 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
1497 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1498 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
1499 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
1500 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
1501 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
1502 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
1503 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1504 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
1505 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1506 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
1507 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1508 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
1509 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
1510 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
1511 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
1512 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1513 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
1514 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
1515 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
1516 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1517 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
1518 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
1519 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
1520 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
1521 	};	/* Structure image */
1522 
1523 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
1524 }
1525 
1526 
1527 
1528 
1529 
1530 
1531 /* Integer Multi-Dimensional Interpolation */
1532 /* Interpolation Kernel Code */
1533 /* Generated by cgen */
1534 /* Copyright 2000 - 2002 Graeme W. Gill */
1535 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
1536 
1537 /* see the Licence.txt file for licencing details.*/
1538 
1539 
1540 /*
1541    Interpolation kernel specs:
1542 
1543    Input channels per pixel = 7
1544    Input channel 0 bits = 8
1545    Input channel 0 increment = 7
1546    Input channel 1 bits = 8
1547    Input channel 1 increment = 7
1548    Input channel 2 bits = 8
1549    Input channel 2 increment = 7
1550    Input channel 3 bits = 8
1551    Input channel 3 increment = 7
1552    Input channel 4 bits = 8
1553    Input channel 4 increment = 7
1554    Input channel 5 bits = 8
1555    Input channel 5 increment = 7
1556    Input channel 6 bits = 8
1557    Input channel 6 increment = 7
1558    Input is channel interleaved
1559    Input channels are separate words
1560    Input value extraction is done in input table lookup
1561 
1562    Output channels per pixel = 1
1563    Output channel 0 bits = 8
1564    Output channel 0 increment = 1
1565    Output is channel interleaved
1566 
1567    Output channels are separate words
1568    Weight+voffset bits       = 32
1569    Interpolation table index bits = 32
1570    Interpolation table max resolution = 14
1571  */
1572 
1573 /*
1574    Machine architecture specs:
1575 
1576    Little endian
1577    Reading and writing pixel values separately
1578    Pointer size = 32 bits
1579 
1580    Ordinal size  8 bits is known as 'unsigned char'
1581    Ordinal size 16 bits is known as 'unsigned short'
1582    Ordinal size 32 bits is known as 'unsigned int'
1583    Natural ordinal is 'unsigned int'
1584 
1585    Integer size  8 bits is known as 'signed char'
1586    Integer size 16 bits is known as 'short'
1587    Integer size 32 bits is known as 'int'
1588    Natural integer is 'int'
1589 
1590  */
1591 
1592 #ifndef  IMDI_INCLUDED
1593 #include <memory.h>
1594 #include "imdi_imp.h"
1595 #define  IMDI_INCLUDED
1596 #endif  /* IMDI_INCLUDED */
1597 
1598 #ifndef DEFINED_pointer
1599 #define DEFINED_pointer
1600 typedef unsigned char * pointer;
1601 #endif
1602 
1603 /* Input table interp. index */
1604 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
1605 
1606 /* Input table input weighting/offset value enty */
1607 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
1608 
1609 /* Conditional exchange for sorting */
1610 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
1611 
1612 /* Interpolation multi-dim. table access */
1613 #define IM_O(off) ((off) * 4)
1614 
1615 /* Interpolation table - get vertex values */
1616 #define IM_PE(p, v) *((unsigned int *)((p) + 0 + (v) * 4))
1617 
1618 /* Output table indexes */
1619 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
1620 
1621 void
imdi_k6(imdi * s,void ** outp,void ** inp,unsigned int npix)1622 imdi_k6(
1623 imdi *s,			/* imdi context */
1624 void **outp,		/* pointer to output pointers */
1625 void **inp,		/* pointer to input pointers */
1626 unsigned int npix	/* Number of pixels to process */
1627 ) {
1628 	imdi_imp *p = (imdi_imp *)(s->impl);
1629 	unsigned char *ip0 = (unsigned char *)inp[0];
1630 	unsigned char *op0 = (unsigned char *)outp[0];
1631 	unsigned char *ep = ip0 + npix * 7 ;
1632 	pointer it0 = (pointer)p->in_tables[0];
1633 	pointer it1 = (pointer)p->in_tables[1];
1634 	pointer it2 = (pointer)p->in_tables[2];
1635 	pointer it3 = (pointer)p->in_tables[3];
1636 	pointer it4 = (pointer)p->in_tables[4];
1637 	pointer it5 = (pointer)p->in_tables[5];
1638 	pointer it6 = (pointer)p->in_tables[6];
1639 	pointer ot0 = (pointer)p->out_tables[0];
1640 	pointer im_base = (pointer)p->im_table;
1641 
1642 	for(;ip0 < ep; ip0 += 7, op0 += 1) {
1643 		unsigned int ova0;	/* Output value partial accumulator */
1644 		{
1645 			pointer imp;
1646 			unsigned int wo0;	/* Weighting value and vertex offset variable */
1647 			unsigned int wo1;	/* Weighting value and vertex offset variable */
1648 			unsigned int wo2;	/* Weighting value and vertex offset variable */
1649 			unsigned int wo3;	/* Weighting value and vertex offset variable */
1650 			unsigned int wo4;	/* Weighting value and vertex offset variable */
1651 			unsigned int wo5;	/* Weighting value and vertex offset variable */
1652 			unsigned int wo6;	/* Weighting value and vertex offset variable */
1653 			{
1654 				unsigned int ti_i;	/* Interpolation index variable */
1655 
1656 				ti_i  = IT_IX(it0, ip0[0]);
1657 				wo0   = IT_WO(it0, ip0[0]);
1658 				ti_i += IT_IX(it1, ip0[1]);
1659 				wo1   = IT_WO(it1, ip0[1]);
1660 				ti_i += IT_IX(it2, ip0[2]);
1661 				wo2   = IT_WO(it2, ip0[2]);
1662 				ti_i += IT_IX(it3, ip0[3]);
1663 				wo3   = IT_WO(it3, ip0[3]);
1664 				ti_i += IT_IX(it4, ip0[4]);
1665 				wo4   = IT_WO(it4, ip0[4]);
1666 				ti_i += IT_IX(it5, ip0[5]);
1667 				wo5   = IT_WO(it5, ip0[5]);
1668 				ti_i += IT_IX(it6, ip0[6]);
1669 				wo6   = IT_WO(it6, ip0[6]);
1670 
1671 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
1672 
1673 				/* Sort weighting values and vertex offset values */
1674 				CEX(wo0, wo1);
1675 				CEX(wo0, wo2);
1676 				CEX(wo0, wo3);
1677 				CEX(wo0, wo4);
1678 				CEX(wo0, wo5);
1679 				CEX(wo0, wo6);
1680 				CEX(wo1, wo2);
1681 				CEX(wo1, wo3);
1682 				CEX(wo1, wo4);
1683 				CEX(wo1, wo5);
1684 				CEX(wo1, wo6);
1685 				CEX(wo2, wo3);
1686 				CEX(wo2, wo4);
1687 				CEX(wo2, wo5);
1688 				CEX(wo2, wo6);
1689 				CEX(wo3, wo4);
1690 				CEX(wo3, wo5);
1691 				CEX(wo3, wo6);
1692 				CEX(wo4, wo5);
1693 				CEX(wo4, wo6);
1694 				CEX(wo5, wo6);
1695 			}
1696 			{
1697 				unsigned int nvof;	/* Next vertex offset value */
1698 				unsigned int vof;	/* Vertex offset value */
1699 				unsigned int vwe;	/* Vertex weighting */
1700 
1701 				vof = 0;				/* First vertex offset is 0 */
1702 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
1703 				wo0 = (wo0 >> 23);		/* Extract weighting value */
1704 				vwe = 256 - wo0;		/* Baricentric weighting */
1705 				ova0  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1706 				vof += nvof;			/* Move to next vertex */
1707 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
1708 				wo1 = (wo1 >> 23);		/* Extract weighting value */
1709 				vwe = wo0 - wo1;		/* Baricentric weighting */
1710 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1711 				vof += nvof;			/* Move to next vertex */
1712 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
1713 				wo2 = (wo2 >> 23);		/* Extract weighting value */
1714 				vwe = wo1 - wo2;		/* Baricentric weighting */
1715 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1716 				vof += nvof;			/* Move to next vertex */
1717 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
1718 				wo3 = (wo3 >> 23);		/* Extract weighting value */
1719 				vwe = wo2 - wo3;		/* Baricentric weighting */
1720 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1721 				vof += nvof;			/* Move to next vertex */
1722 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
1723 				wo4 = (wo4 >> 23);		/* Extract weighting value */
1724 				vwe = wo3 - wo4;		/* Baricentric weighting */
1725 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1726 				vof += nvof;			/* Move to next vertex */
1727 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
1728 				wo5 = (wo5 >> 23);		/* Extract weighting value */
1729 				vwe = wo4 - wo5;		/* Baricentric weighting */
1730 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1731 				vof += nvof;			/* Move to next vertex */
1732 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
1733 				wo6 = (wo6 >> 23);		/* Extract weighting value */
1734 				vwe = wo5 - wo6;		/* Baricentric weighting */
1735 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1736 				vof += nvof;			/* Move to next vertex */
1737 				vwe = wo6;				/* Baricentric weighting */
1738 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
1739 			}
1740 		}
1741 		{
1742 			unsigned int oti;	/* Vertex offset value */
1743 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
1744 			op0[0] = OT_E(ot0, oti);	/* Write result */
1745 		}
1746 	}
1747 }
1748 #undef IT_WO
1749 #undef IT_IX
1750 #undef CEX
1751 #undef IM_O
1752 #undef IM_PE
1753 #undef OT_E
1754 
1755 void
imdi_k6_gen(genspec * g)1756 imdi_k6_gen(
1757 genspec *g			/* structure to be initialised */
1758 ) {
1759 	static unsigned char data[] = {
1760 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
1761 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1762 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1763 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1764 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1765 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1766 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1767 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
1768 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
1769 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
1770 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
1771 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1772 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1773 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1774 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1775 		0xa0, 0xdc, 0x83, 0xbf, 0x08, 0x00, 0x00, 0x00,
1776 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1777 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1778 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1779 		0x00, 0xe4, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
1780 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1781 		0x07, 0x00, 0x00, 0x00, 0x34, 0x80, 0x04, 0x08,
1782 		0xd0, 0x85, 0x04, 0x08, 0x4c, 0x69, 0x6e, 0x75,
1783 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1784 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1785 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1786 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1787 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1788 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1789 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1790 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
1791 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
1792 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1793 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1794 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1795 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1796 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1797 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1798 		0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1799 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
1800 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
1801 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
1802 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
1803 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
1804 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
1805 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
1806 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
1807 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
1808 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1809 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
1810 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
1811 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x31, 0x5f,
1812 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
1813 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
1814 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
1815 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
1816 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
1817 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
1818 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
1819 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1820 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1821 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1822 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1823 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
1824 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x36, 0x00,
1825 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1826 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1827 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
1828 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
1829 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
1830 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
1831 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
1832 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
1833 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
1834 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
1835 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
1836 		0x00, 0xf0, 0x04, 0x08
1837 	};	/* Structure image */
1838 
1839 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
1840 }
1841 
1842 void
imdi_k6_tab(tabspec * t)1843 imdi_k6_tab(
1844 tabspec *t			/* structure to be initialised */
1845 ) {
1846 	static unsigned char data[] = {
1847 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1848 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1849 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1850 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
1851 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
1852 		0x06, 0x00, 0x00, 0x00, 0x46, 0x83, 0x04, 0x08,
1853 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1854 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
1855 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
1856 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1857 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
1858 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
1859 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
1860 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
1861 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
1862 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1863 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
1864 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1865 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
1866 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1867 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
1868 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
1869 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
1870 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
1871 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1872 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
1873 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
1874 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
1875 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1876 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
1877 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
1878 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
1879 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
1880 	};	/* Structure image */
1881 
1882 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
1883 }
1884 
1885 
1886 
1887 
1888 
1889 
1890 /* Integer Multi-Dimensional Interpolation */
1891 /* Interpolation Kernel Code */
1892 /* Generated by cgen */
1893 /* Copyright 2000 - 2002 Graeme W. Gill */
1894 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
1895 
1896 /* see the Licence.txt file for licencing details.*/
1897 
1898 
1899 /*
1900    Interpolation kernel specs:
1901 
1902    Input channels per pixel = 8
1903    Input channel 0 bits = 8
1904    Input channel 0 increment = 8
1905    Input channel 1 bits = 8
1906    Input channel 1 increment = 8
1907    Input channel 2 bits = 8
1908    Input channel 2 increment = 8
1909    Input channel 3 bits = 8
1910    Input channel 3 increment = 8
1911    Input channel 4 bits = 8
1912    Input channel 4 increment = 8
1913    Input channel 5 bits = 8
1914    Input channel 5 increment = 8
1915    Input channel 6 bits = 8
1916    Input channel 6 increment = 8
1917    Input channel 7 bits = 8
1918    Input channel 7 increment = 8
1919    Input is channel interleaved
1920    Input channels are separate words
1921    Input value extraction is done in input table lookup
1922 
1923    Output channels per pixel = 1
1924    Output channel 0 bits = 8
1925    Output channel 0 increment = 1
1926    Output is channel interleaved
1927 
1928    Output channels are separate words
1929    Weight+voffset bits       = 32
1930    Interpolation table index bits = 32
1931    Interpolation table max resolution = 9
1932  */
1933 
1934 /*
1935    Machine architecture specs:
1936 
1937    Little endian
1938    Reading and writing pixel values separately
1939    Pointer size = 32 bits
1940 
1941    Ordinal size  8 bits is known as 'unsigned char'
1942    Ordinal size 16 bits is known as 'unsigned short'
1943    Ordinal size 32 bits is known as 'unsigned int'
1944    Natural ordinal is 'unsigned int'
1945 
1946    Integer size  8 bits is known as 'signed char'
1947    Integer size 16 bits is known as 'short'
1948    Integer size 32 bits is known as 'int'
1949    Natural integer is 'int'
1950 
1951  */
1952 
1953 #ifndef  IMDI_INCLUDED
1954 #include <memory.h>
1955 #include "imdi_imp.h"
1956 #define  IMDI_INCLUDED
1957 #endif  /* IMDI_INCLUDED */
1958 
1959 #ifndef DEFINED_pointer
1960 #define DEFINED_pointer
1961 typedef unsigned char * pointer;
1962 #endif
1963 
1964 /* Input table interp. index */
1965 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
1966 
1967 /* Input table input weighting/offset value enty */
1968 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
1969 
1970 /* Conditional exchange for sorting */
1971 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
1972 
1973 /* Interpolation multi-dim. table access */
1974 #define IM_O(off) ((off) * 4)
1975 
1976 /* Interpolation table - get vertex values */
1977 #define IM_PE(p, v) *((unsigned int *)((p) + 0 + (v) * 4))
1978 
1979 /* Output table indexes */
1980 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
1981 
1982 void
imdi_k7(imdi * s,void ** outp,void ** inp,unsigned int npix)1983 imdi_k7(
1984 imdi *s,			/* imdi context */
1985 void **outp,		/* pointer to output pointers */
1986 void **inp,		/* pointer to input pointers */
1987 unsigned int npix	/* Number of pixels to process */
1988 ) {
1989 	imdi_imp *p = (imdi_imp *)(s->impl);
1990 	unsigned char *ip0 = (unsigned char *)inp[0];
1991 	unsigned char *op0 = (unsigned char *)outp[0];
1992 	unsigned char *ep = ip0 + npix * 8 ;
1993 	pointer it0 = (pointer)p->in_tables[0];
1994 	pointer it1 = (pointer)p->in_tables[1];
1995 	pointer it2 = (pointer)p->in_tables[2];
1996 	pointer it3 = (pointer)p->in_tables[3];
1997 	pointer it4 = (pointer)p->in_tables[4];
1998 	pointer it5 = (pointer)p->in_tables[5];
1999 	pointer it6 = (pointer)p->in_tables[6];
2000 	pointer it7 = (pointer)p->in_tables[7];
2001 	pointer ot0 = (pointer)p->out_tables[0];
2002 	pointer im_base = (pointer)p->im_table;
2003 
2004 	for(;ip0 < ep; ip0 += 8, op0 += 1) {
2005 		unsigned int ova0;	/* Output value partial accumulator */
2006 		{
2007 			pointer imp;
2008 			unsigned int wo0;	/* Weighting value and vertex offset variable */
2009 			unsigned int wo1;	/* Weighting value and vertex offset variable */
2010 			unsigned int wo2;	/* Weighting value and vertex offset variable */
2011 			unsigned int wo3;	/* Weighting value and vertex offset variable */
2012 			unsigned int wo4;	/* Weighting value and vertex offset variable */
2013 			unsigned int wo5;	/* Weighting value and vertex offset variable */
2014 			unsigned int wo6;	/* Weighting value and vertex offset variable */
2015 			unsigned int wo7;	/* Weighting value and vertex offset variable */
2016 			{
2017 				unsigned int ti_i;	/* Interpolation index variable */
2018 
2019 				ti_i  = IT_IX(it0, ip0[0]);
2020 				wo0   = IT_WO(it0, ip0[0]);
2021 				ti_i += IT_IX(it1, ip0[1]);
2022 				wo1   = IT_WO(it1, ip0[1]);
2023 				ti_i += IT_IX(it2, ip0[2]);
2024 				wo2   = IT_WO(it2, ip0[2]);
2025 				ti_i += IT_IX(it3, ip0[3]);
2026 				wo3   = IT_WO(it3, ip0[3]);
2027 				ti_i += IT_IX(it4, ip0[4]);
2028 				wo4   = IT_WO(it4, ip0[4]);
2029 				ti_i += IT_IX(it5, ip0[5]);
2030 				wo5   = IT_WO(it5, ip0[5]);
2031 				ti_i += IT_IX(it6, ip0[6]);
2032 				wo6   = IT_WO(it6, ip0[6]);
2033 				ti_i += IT_IX(it7, ip0[7]);
2034 				wo7   = IT_WO(it7, ip0[7]);
2035 
2036 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
2037 
2038 				/* Sort weighting values and vertex offset values */
2039 				CEX(wo0, wo1);
2040 				CEX(wo0, wo2);
2041 				CEX(wo0, wo3);
2042 				CEX(wo0, wo4);
2043 				CEX(wo0, wo5);
2044 				CEX(wo0, wo6);
2045 				CEX(wo0, wo7);
2046 				CEX(wo1, wo2);
2047 				CEX(wo1, wo3);
2048 				CEX(wo1, wo4);
2049 				CEX(wo1, wo5);
2050 				CEX(wo1, wo6);
2051 				CEX(wo1, wo7);
2052 				CEX(wo2, wo3);
2053 				CEX(wo2, wo4);
2054 				CEX(wo2, wo5);
2055 				CEX(wo2, wo6);
2056 				CEX(wo2, wo7);
2057 				CEX(wo3, wo4);
2058 				CEX(wo3, wo5);
2059 				CEX(wo3, wo6);
2060 				CEX(wo3, wo7);
2061 				CEX(wo4, wo5);
2062 				CEX(wo4, wo6);
2063 				CEX(wo4, wo7);
2064 				CEX(wo5, wo6);
2065 				CEX(wo5, wo7);
2066 				CEX(wo6, wo7);
2067 			}
2068 			{
2069 				unsigned int nvof;	/* Next vertex offset value */
2070 				unsigned int vof;	/* Vertex offset value */
2071 				unsigned int vwe;	/* Vertex weighting */
2072 
2073 				vof = 0;				/* First vertex offset is 0 */
2074 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
2075 				wo0 = (wo0 >> 23);		/* Extract weighting value */
2076 				vwe = 256 - wo0;		/* Baricentric weighting */
2077 				ova0  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
2078 				vof += nvof;			/* Move to next vertex */
2079 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
2080 				wo1 = (wo1 >> 23);		/* Extract weighting value */
2081 				vwe = wo0 - wo1;		/* Baricentric weighting */
2082 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
2083 				vof += nvof;			/* Move to next vertex */
2084 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
2085 				wo2 = (wo2 >> 23);		/* Extract weighting value */
2086 				vwe = wo1 - wo2;		/* Baricentric weighting */
2087 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
2088 				vof += nvof;			/* Move to next vertex */
2089 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
2090 				wo3 = (wo3 >> 23);		/* Extract weighting value */
2091 				vwe = wo2 - wo3;		/* Baricentric weighting */
2092 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
2093 				vof += nvof;			/* Move to next vertex */
2094 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
2095 				wo4 = (wo4 >> 23);		/* Extract weighting value */
2096 				vwe = wo3 - wo4;		/* Baricentric weighting */
2097 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
2098 				vof += nvof;			/* Move to next vertex */
2099 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
2100 				wo5 = (wo5 >> 23);		/* Extract weighting value */
2101 				vwe = wo4 - wo5;		/* Baricentric weighting */
2102 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
2103 				vof += nvof;			/* Move to next vertex */
2104 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
2105 				wo6 = (wo6 >> 23);		/* Extract weighting value */
2106 				vwe = wo5 - wo6;		/* Baricentric weighting */
2107 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
2108 				vof += nvof;			/* Move to next vertex */
2109 				nvof = (wo7 & 0x7fffff);	/* Extract offset value */
2110 				wo7 = (wo7 >> 23);		/* Extract weighting value */
2111 				vwe = wo6 - wo7;		/* Baricentric weighting */
2112 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
2113 				vof += nvof;			/* Move to next vertex */
2114 				vwe = wo7;				/* Baricentric weighting */
2115 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
2116 			}
2117 		}
2118 		{
2119 			unsigned int oti;	/* Vertex offset value */
2120 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
2121 			op0[0] = OT_E(ot0, oti);	/* Write result */
2122 		}
2123 	}
2124 }
2125 #undef IT_WO
2126 #undef IT_IX
2127 #undef CEX
2128 #undef IM_O
2129 #undef IM_PE
2130 #undef OT_E
2131 
2132 void
imdi_k7_gen(genspec * g)2133 imdi_k7_gen(
2134 genspec *g			/* structure to be initialised */
2135 ) {
2136 	static unsigned char data[] = {
2137 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2138 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2139 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2140 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2141 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2142 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2143 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2144 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2145 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2146 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2147 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2148 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2149 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2150 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2151 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2152 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2153 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2154 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2155 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2156 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2157 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2158 		0x07, 0x00, 0x00, 0x00, 0x34, 0x80, 0x04, 0x08,
2159 		0xd0, 0x85, 0x04, 0x08, 0x4c, 0x69, 0x6e, 0x75,
2160 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2161 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2162 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2163 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2164 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2165 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2166 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2167 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
2168 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
2169 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2170 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2171 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2172 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2173 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2174 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2175 		0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2176 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
2177 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
2178 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
2179 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
2180 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
2181 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
2182 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
2183 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
2184 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
2185 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2186 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
2187 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
2188 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x31, 0x5f,
2189 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
2190 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
2191 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
2192 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
2193 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
2194 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
2195 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
2196 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2197 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2198 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2199 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2200 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
2201 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x37, 0x00,
2202 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2203 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2204 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
2205 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
2206 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
2207 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
2208 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
2209 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
2210 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
2211 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
2212 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
2213 		0x00, 0xf0, 0x04, 0x08
2214 	};	/* Structure image */
2215 
2216 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
2217 }
2218 
2219 void
imdi_k7_tab(tabspec * t)2220 imdi_k7_tab(
2221 tabspec *t			/* structure to be initialised */
2222 ) {
2223 	static unsigned char data[] = {
2224 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2225 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2226 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2227 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
2228 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
2229 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
2230 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2231 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
2232 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
2233 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2234 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
2235 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
2236 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
2237 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
2238 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
2239 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2240 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
2241 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2242 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
2243 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2244 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
2245 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
2246 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
2247 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
2248 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2249 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
2250 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
2251 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
2252 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2253 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
2254 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
2255 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
2256 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
2257 	};	/* Structure image */
2258 
2259 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
2260 }
2261 
2262 
2263 
2264 
2265 
2266 
2267 /* Integer Multi-Dimensional Interpolation */
2268 /* Interpolation Kernel Code */
2269 /* Generated by cgen */
2270 /* Copyright 2000 - 2002 Graeme W. Gill */
2271 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
2272 
2273 /* see the Licence.txt file for licencing details.*/
2274 
2275 
2276 /*
2277    Interpolation kernel specs:
2278 
2279    Input channels per pixel = 1
2280    Input channel 0 bits = 8
2281    Input channel 0 increment = 1
2282    Input is channel interleaved
2283    Input channels are separate words
2284    Input value extraction is done in input table lookup
2285 
2286    Output channels per pixel = 3
2287    Output channel 0 bits = 8
2288    Output channel 0 increment = 3
2289    Output channel 1 bits = 8
2290    Output channel 1 increment = 3
2291    Output channel 2 bits = 8
2292    Output channel 2 increment = 3
2293    Output is channel interleaved
2294 
2295    Output channels are separate words
2296    Simplex table index bits       = 0
2297    Interpolation table index bits = 8
2298    Simplex table max resolution = 1
2299    Interpolation table max resolution = 255
2300  */
2301 
2302 /*
2303    Machine architecture specs:
2304 
2305    Little endian
2306    Reading and writing pixel values separately
2307    Pointer size = 32 bits
2308 
2309    Ordinal size  8 bits is known as 'unsigned char'
2310    Ordinal size 16 bits is known as 'unsigned short'
2311    Ordinal size 32 bits is known as 'unsigned int'
2312    Natural ordinal is 'unsigned int'
2313 
2314    Integer size  8 bits is known as 'signed char'
2315    Integer size 16 bits is known as 'short'
2316    Integer size 32 bits is known as 'int'
2317    Natural integer is 'int'
2318 
2319  */
2320 
2321 #ifndef  IMDI_INCLUDED
2322 #include <memory.h>
2323 #include "imdi_imp.h"
2324 #define  IMDI_INCLUDED
2325 #endif  /* IMDI_INCLUDED */
2326 
2327 #ifndef DEFINED_pointer
2328 #define DEFINED_pointer
2329 typedef unsigned char * pointer;
2330 #endif
2331 
2332 /* Input table inter & simplex indexes */
2333 #define IT_IT(p, off) *((unsigned char *)((p) + 0 + (off) * 1))
2334 
2335 /* Simplex weighting table access */
2336 #define SW_O(off) ((off) * 4)
2337 
2338 /* Simplex table - get weighting/offset value */
2339 #define SX_WO(p, v) *((unsigned short *)((p) + (v) * 2))
2340 
2341 /* Interpolation multi-dim. table access */
2342 #define IM_O(off) ((off) * 8)
2343 
2344 /* Interpolation table - get vertex values */
2345 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
2346 #define IM_PE(p, v) *((unsigned int *)((p) + 4 + (v) * 8))
2347 
2348 /* Output table indexes */
2349 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
2350 
2351 void
imdi_k8(imdi * s,void ** outp,void ** inp,unsigned int npix)2352 imdi_k8(
2353 imdi *s,			/* imdi context */
2354 void **outp,		/* pointer to output pointers */
2355 void **inp,		/* pointer to input pointers */
2356 unsigned int npix	/* Number of pixels to process */
2357 ) {
2358 	imdi_imp *p = (imdi_imp *)(s->impl);
2359 	unsigned char *ip0 = (unsigned char *)inp[0];
2360 	unsigned char *op0 = (unsigned char *)outp[0];
2361 	unsigned char *ep = ip0 + npix * 1 ;
2362 	pointer it0 = (pointer)p->in_tables[0];
2363 	pointer ot0 = (pointer)p->out_tables[0];
2364 	pointer ot1 = (pointer)p->out_tables[1];
2365 	pointer ot2 = (pointer)p->out_tables[2];
2366 	pointer sw_base = (pointer)p->sw_table;
2367 	pointer im_base = (pointer)p->im_table;
2368 
2369 	for(;ip0 < ep; ip0 += 1, op0 += 3) {
2370 		unsigned int ova0;	/* Output value accumulator */
2371 		unsigned int ova1;	/* Output value partial accumulator */
2372 		{
2373 			pointer swp;
2374 			pointer imp;
2375 			{
2376 				unsigned int ti;	/* Simplex+Interpolation index variable */
2377 
2378 				ti  = IT_IT(it0, ip0[0]);
2379 
2380 				imp = im_base + IM_O(ti >> 0);		/* Extract interp. index and comp. entry */
2381 				swp = sw_base + SW_O(ti & 0x0);	/* Extract simplex index and comp. entry */
2382 			}
2383 			{
2384 				unsigned int vowr;	/* Vertex offset/weight value */
2385 				unsigned int vof;	/* Vertex offset value */
2386 				unsigned int vwe;	/* Vertex weighting */
2387 
2388 				vowr = SX_WO(swp, 0);	/* Read vertex offset+weighting values */
2389 				vof = (vowr & 0x7f);	/* Extract offset value */
2390 				vwe = (vowr >> 7);	/* Extract weighting value */
2391 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
2392 				ova1  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
2393 				vowr = SX_WO(swp, 1);	/* Read vertex offset+weighting values */
2394 				vof = (vowr & 0x7f);	/* Extract offset value */
2395 				vwe = (vowr >> 7);	/* Extract weighting value */
2396 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
2397 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
2398 			}
2399 		}
2400 		{
2401 			unsigned int oti;	/* Vertex offset value */
2402 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
2403 			op0[0] = OT_E(ot0, oti);	/* Write result */
2404 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
2405 			op0[1] = OT_E(ot1, oti);	/* Write result */
2406 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
2407 			op0[2] = OT_E(ot2, oti);	/* Write result */
2408 		}
2409 	}
2410 }
2411 #undef IT_IT
2412 #undef SW_O
2413 #undef SX_WO
2414 #undef IM_O
2415 #undef IM_FE
2416 #undef IM_PE
2417 #undef OT_E
2418 
2419 void
imdi_k8_gen(genspec * g)2420 imdi_k8_gen(
2421 genspec *g			/* structure to be initialised */
2422 ) {
2423 	static unsigned char data[] = {
2424 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2425 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2426 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2427 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2428 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2429 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2430 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2431 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2432 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2433 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2434 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2435 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2436 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2437 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2438 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2439 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2440 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2441 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2442 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2443 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2444 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2445 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2446 		0xd0, 0x85, 0x04, 0x08, 0x4c, 0x69, 0x6e, 0x75,
2447 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2448 		0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
2449 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
2450 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2451 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2452 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2453 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2454 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
2455 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
2456 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2457 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2458 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2459 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2460 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2461 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2462 		0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2463 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
2464 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
2465 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
2466 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
2467 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
2468 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
2469 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
2470 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
2471 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
2472 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2473 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
2474 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
2475 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x33, 0x5f,
2476 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
2477 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
2478 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
2479 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
2480 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
2481 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
2482 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
2483 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2484 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2485 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2486 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2487 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
2488 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x38, 0x00,
2489 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2490 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2491 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
2492 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
2493 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
2494 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
2495 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
2496 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
2497 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
2498 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
2499 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
2500 		0x00, 0xf0, 0x04, 0x08
2501 	};	/* Structure image */
2502 
2503 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
2504 }
2505 
2506 void
imdi_k8_tab(tabspec * t)2507 imdi_k8_tab(
2508 tabspec *t			/* structure to be initialised */
2509 ) {
2510 	static unsigned char data[] = {
2511 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2512 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2513 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2514 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
2515 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
2516 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
2517 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2518 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
2519 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2520 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2521 		0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
2522 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2523 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
2524 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
2525 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
2526 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2527 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2528 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2529 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
2530 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2531 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2532 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
2533 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
2534 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
2535 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2536 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2537 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
2538 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
2539 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2540 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2541 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
2542 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
2543 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
2544 	};	/* Structure image */
2545 
2546 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
2547 }
2548 
2549 
2550 
2551 
2552 
2553 
2554 /* Integer Multi-Dimensional Interpolation */
2555 /* Interpolation Kernel Code */
2556 /* Generated by cgen */
2557 /* Copyright 2000 - 2002 Graeme W. Gill */
2558 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
2559 
2560 /* see the Licence.txt file for licencing details.*/
2561 
2562 
2563 /*
2564    Interpolation kernel specs:
2565 
2566    Input channels per pixel = 3
2567    Input channel 0 bits = 8
2568    Input channel 0 increment = 3
2569    Input channel 1 bits = 8
2570    Input channel 1 increment = 3
2571    Input channel 2 bits = 8
2572    Input channel 2 increment = 3
2573    Input is channel interleaved
2574    Input channels are separate words
2575    Input value extraction is done in input table lookup
2576 
2577    Output channels per pixel = 3
2578    Output channel 0 bits = 8
2579    Output channel 0 increment = 3
2580    Output channel 1 bits = 8
2581    Output channel 1 increment = 3
2582    Output channel 2 bits = 8
2583    Output channel 2 increment = 3
2584    Output is channel interleaved
2585 
2586    Output channels are separate words
2587    Simplex table index bits       = 12
2588    Interpolation table index bits = 20
2589    Simplex table max resolution = 16
2590    Interpolation table max resolution = 101
2591  */
2592 
2593 /*
2594    Machine architecture specs:
2595 
2596    Little endian
2597    Reading and writing pixel values separately
2598    Pointer size = 32 bits
2599 
2600    Ordinal size  8 bits is known as 'unsigned char'
2601    Ordinal size 16 bits is known as 'unsigned short'
2602    Ordinal size 32 bits is known as 'unsigned int'
2603    Natural ordinal is 'unsigned int'
2604 
2605    Integer size  8 bits is known as 'signed char'
2606    Integer size 16 bits is known as 'short'
2607    Integer size 32 bits is known as 'int'
2608    Natural integer is 'int'
2609 
2610  */
2611 
2612 #ifndef  IMDI_INCLUDED
2613 #include <memory.h>
2614 #include "imdi_imp.h"
2615 #define  IMDI_INCLUDED
2616 #endif  /* IMDI_INCLUDED */
2617 
2618 #ifndef DEFINED_pointer
2619 #define DEFINED_pointer
2620 typedef unsigned char * pointer;
2621 #endif
2622 
2623 /* Input table inter & simplex indexes */
2624 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
2625 
2626 /* Simplex weighting table access */
2627 #define SW_O(off) ((off) * 16)
2628 
2629 /* Simplex table - get weighting value */
2630 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
2631 
2632 /* Simplex table - get offset value */
2633 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
2634 
2635 /* Interpolation multi-dim. table access */
2636 #define IM_O(off) ((off) * 8)
2637 
2638 /* Interpolation table - get vertex values */
2639 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
2640 #define IM_PE(p, v) *((unsigned int *)((p) + 4 + (v) * 8))
2641 
2642 /* Output table indexes */
2643 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
2644 
2645 void
imdi_k9(imdi * s,void ** outp,void ** inp,unsigned int npix)2646 imdi_k9(
2647 imdi *s,			/* imdi context */
2648 void **outp,		/* pointer to output pointers */
2649 void **inp,		/* pointer to input pointers */
2650 unsigned int npix	/* Number of pixels to process */
2651 ) {
2652 	imdi_imp *p = (imdi_imp *)(s->impl);
2653 	unsigned char *ip0 = (unsigned char *)inp[0];
2654 	unsigned char *op0 = (unsigned char *)outp[0];
2655 	unsigned char *ep = ip0 + npix * 3 ;
2656 	pointer it0 = (pointer)p->in_tables[0];
2657 	pointer it1 = (pointer)p->in_tables[1];
2658 	pointer it2 = (pointer)p->in_tables[2];
2659 	pointer ot0 = (pointer)p->out_tables[0];
2660 	pointer ot1 = (pointer)p->out_tables[1];
2661 	pointer ot2 = (pointer)p->out_tables[2];
2662 	pointer sw_base = (pointer)p->sw_table;
2663 	pointer im_base = (pointer)p->im_table;
2664 
2665 	for(;ip0 < ep; ip0 += 3, op0 += 3) {
2666 		unsigned int ova0;	/* Output value accumulator */
2667 		unsigned int ova1;	/* Output value partial accumulator */
2668 		{
2669 			pointer swp;
2670 			pointer imp;
2671 			{
2672 				unsigned int ti;	/* Simplex+Interpolation index variable */
2673 
2674 				ti  = IT_IT(it0, ip0[0]);
2675 				ti += IT_IT(it1, ip0[1]);
2676 				ti += IT_IT(it2, ip0[2]);
2677 
2678 				imp = im_base + IM_O(ti >> 12);		/* Extract interp. index and comp. entry */
2679 				swp = sw_base + SW_O(ti & 0xfff);	/* Extract simplex index and comp. entry */
2680 			}
2681 			{
2682 				unsigned int vof;	/* Vertex offset value */
2683 				unsigned int vwe;	/* Vertex weighting */
2684 
2685 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
2686 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
2687 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
2688 				ova1  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
2689 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
2690 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
2691 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
2692 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
2693 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
2694 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
2695 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
2696 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
2697 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
2698 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
2699 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
2700 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
2701 			}
2702 		}
2703 		{
2704 			unsigned int oti;	/* Vertex offset value */
2705 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
2706 			op0[0] = OT_E(ot0, oti);	/* Write result */
2707 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
2708 			op0[1] = OT_E(ot1, oti);	/* Write result */
2709 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
2710 			op0[2] = OT_E(ot2, oti);	/* Write result */
2711 		}
2712 	}
2713 }
2714 #undef IT_IT
2715 #undef SW_O
2716 #undef SX_WE
2717 #undef SX_VO
2718 #undef IM_O
2719 #undef IM_FE
2720 #undef IM_PE
2721 #undef OT_E
2722 
2723 void
imdi_k9_gen(genspec * g)2724 imdi_k9_gen(
2725 genspec *g			/* structure to be initialised */
2726 ) {
2727 	static unsigned char data[] = {
2728 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
2729 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2730 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2731 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2732 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2733 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2734 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2735 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
2736 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
2737 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2738 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2739 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2740 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2741 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2742 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2743 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2744 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2745 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2746 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2747 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2748 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2749 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2750 		0xd0, 0x85, 0x04, 0x08, 0x4c, 0x69, 0x6e, 0x75,
2751 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2752 		0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
2753 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
2754 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2755 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2756 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2757 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2758 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
2759 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
2760 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2761 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2762 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2763 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2764 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2765 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2766 		0x65, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
2767 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
2768 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
2769 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
2770 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
2771 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
2772 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
2773 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
2774 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
2775 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
2776 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2777 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
2778 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
2779 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x33, 0x5f,
2780 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
2781 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
2782 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
2783 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
2784 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
2785 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
2786 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
2787 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2788 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2789 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2790 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2791 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
2792 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x39, 0x00,
2793 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2794 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2795 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
2796 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
2797 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
2798 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
2799 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
2800 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
2801 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
2802 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
2803 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
2804 		0x00, 0xf0, 0x04, 0x08
2805 	};	/* Structure image */
2806 
2807 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
2808 }
2809 
2810 void
imdi_k9_tab(tabspec * t)2811 imdi_k9_tab(
2812 tabspec *t			/* structure to be initialised */
2813 ) {
2814 	static unsigned char data[] = {
2815 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2816 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2817 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2818 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
2819 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
2820 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
2821 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
2822 		0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
2823 		0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
2824 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2825 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
2826 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2827 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
2828 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
2829 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
2830 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2831 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2832 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2833 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
2834 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2835 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2836 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
2837 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
2838 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
2839 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2840 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2841 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
2842 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
2843 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2844 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
2845 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
2846 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
2847 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
2848 	};	/* Structure image */
2849 
2850 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
2851 }
2852 
2853 
2854 
2855 
2856 
2857 
2858 /* Integer Multi-Dimensional Interpolation */
2859 /* Interpolation Kernel Code */
2860 /* Generated by cgen */
2861 /* Copyright 2000 - 2002 Graeme W. Gill */
2862 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
2863 
2864 /* see the Licence.txt file for licencing details.*/
2865 
2866 
2867 /*
2868    Interpolation kernel specs:
2869 
2870    Input channels per pixel = 4
2871    Input channel 0 bits = 8
2872    Input channel 0 increment = 4
2873    Input channel 1 bits = 8
2874    Input channel 1 increment = 4
2875    Input channel 2 bits = 8
2876    Input channel 2 increment = 4
2877    Input channel 3 bits = 8
2878    Input channel 3 increment = 4
2879    Input is channel interleaved
2880    Input channels are separate words
2881    Input value extraction is done in input table lookup
2882 
2883    Output channels per pixel = 3
2884    Output channel 0 bits = 8
2885    Output channel 0 increment = 3
2886    Output channel 1 bits = 8
2887    Output channel 1 increment = 3
2888    Output channel 2 bits = 8
2889    Output channel 2 increment = 3
2890    Output is channel interleaved
2891 
2892    Output channels are separate words
2893    Simplex table index bits       = 32
2894    Interpolation table index bits = 32
2895    Simplex table max resolution = 255
2896    Interpolation table max resolution = 39
2897  */
2898 
2899 /*
2900    Machine architecture specs:
2901 
2902    Little endian
2903    Reading and writing pixel values separately
2904    Pointer size = 32 bits
2905 
2906    Ordinal size  8 bits is known as 'unsigned char'
2907    Ordinal size 16 bits is known as 'unsigned short'
2908    Ordinal size 32 bits is known as 'unsigned int'
2909    Natural ordinal is 'unsigned int'
2910 
2911    Integer size  8 bits is known as 'signed char'
2912    Integer size 16 bits is known as 'short'
2913    Integer size 32 bits is known as 'int'
2914    Natural integer is 'int'
2915 
2916  */
2917 
2918 #ifndef  IMDI_INCLUDED
2919 #include <memory.h>
2920 #include "imdi_imp.h"
2921 #define  IMDI_INCLUDED
2922 #endif  /* IMDI_INCLUDED */
2923 
2924 #ifndef DEFINED_pointer
2925 #define DEFINED_pointer
2926 typedef unsigned char * pointer;
2927 #endif
2928 
2929 /* Input table interp. index */
2930 #define IT_IX(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
2931 
2932 /* Input table simplex index enty */
2933 #define IT_SX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
2934 
2935 /* Simplex weighting table access */
2936 #define SW_O(off) ((off) * 20)
2937 
2938 /* Simplex table - get weighting value */
2939 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
2940 
2941 /* Simplex table - get offset value */
2942 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
2943 
2944 /* Interpolation multi-dim. table access */
2945 #define IM_O(off) ((off) * 8)
2946 
2947 /* Interpolation table - get vertex values */
2948 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
2949 #define IM_PE(p, v) *((unsigned int *)((p) + 4 + (v) * 8))
2950 
2951 /* Output table indexes */
2952 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
2953 
2954 void
imdi_k10(imdi * s,void ** outp,void ** inp,unsigned int npix)2955 imdi_k10(
2956 imdi *s,			/* imdi context */
2957 void **outp,		/* pointer to output pointers */
2958 void **inp,		/* pointer to input pointers */
2959 unsigned int npix	/* Number of pixels to process */
2960 ) {
2961 	imdi_imp *p = (imdi_imp *)(s->impl);
2962 	unsigned char *ip0 = (unsigned char *)inp[0];
2963 	unsigned char *op0 = (unsigned char *)outp[0];
2964 	unsigned char *ep = ip0 + npix * 4 ;
2965 	pointer it0 = (pointer)p->in_tables[0];
2966 	pointer it1 = (pointer)p->in_tables[1];
2967 	pointer it2 = (pointer)p->in_tables[2];
2968 	pointer it3 = (pointer)p->in_tables[3];
2969 	pointer ot0 = (pointer)p->out_tables[0];
2970 	pointer ot1 = (pointer)p->out_tables[1];
2971 	pointer ot2 = (pointer)p->out_tables[2];
2972 	pointer sw_base = (pointer)p->sw_table;
2973 	pointer im_base = (pointer)p->im_table;
2974 
2975 	for(;ip0 < ep; ip0 += 4, op0 += 3) {
2976 		unsigned int ova0;	/* Output value accumulator */
2977 		unsigned int ova1;	/* Output value partial accumulator */
2978 		{
2979 			pointer swp;
2980 			pointer imp;
2981 			{
2982 				unsigned int ti_s;	/* Simplex index variable */
2983 				unsigned int ti_i;	/* Interpolation index variable */
2984 
2985 				ti_i  = IT_IX(it0, ip0[0]);
2986 				ti_s  = IT_SX(it0, ip0[0]);
2987 				ti_i += IT_IX(it1, ip0[1]);
2988 				ti_s += IT_SX(it1, ip0[1]);
2989 				ti_i += IT_IX(it2, ip0[2]);
2990 				ti_s += IT_SX(it2, ip0[2]);
2991 				ti_i += IT_IX(it3, ip0[3]);
2992 				ti_s += IT_SX(it3, ip0[3]);
2993 
2994 				swp = sw_base + SW_O(ti_s);		/* Compute simplex table entry pointer */
2995 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
2996 			}
2997 			{
2998 				unsigned int vof;	/* Vertex offset value */
2999 				unsigned int vwe;	/* Vertex weighting */
3000 
3001 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
3002 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
3003 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
3004 				ova1  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
3005 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
3006 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
3007 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
3008 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
3009 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
3010 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
3011 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
3012 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
3013 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
3014 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
3015 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
3016 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
3017 				vof = SX_VO(swp, 4);	/* Read vertex offset value */
3018 				vwe = SX_WE(swp, 4);	/* Read vertex weighting value */
3019 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
3020 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
3021 			}
3022 		}
3023 		{
3024 			unsigned int oti;	/* Vertex offset value */
3025 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
3026 			op0[0] = OT_E(ot0, oti);	/* Write result */
3027 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
3028 			op0[1] = OT_E(ot1, oti);	/* Write result */
3029 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
3030 			op0[2] = OT_E(ot2, oti);	/* Write result */
3031 		}
3032 	}
3033 }
3034 #undef IT_IX
3035 #undef IT_SX
3036 #undef SW_O
3037 #undef SX_WE
3038 #undef SX_VO
3039 #undef IM_O
3040 #undef IM_FE
3041 #undef IM_PE
3042 #undef OT_E
3043 
3044 void
imdi_k10_gen(genspec * g)3045 imdi_k10_gen(
3046 genspec *g			/* structure to be initialised */
3047 ) {
3048 	static unsigned char data[] = {
3049 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
3050 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3051 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3052 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3053 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3054 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3055 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3056 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
3057 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
3058 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3059 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3060 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3061 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3062 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3063 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3064 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3065 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3066 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3067 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3068 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3069 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3070 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3071 		0xd0, 0x85, 0x04, 0x08, 0x4c, 0x69, 0x6e, 0x75,
3072 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3073 		0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
3074 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
3075 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3076 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3077 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3078 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3079 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
3080 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
3081 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3082 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3083 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3084 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3085 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3086 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3087 		0x27, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
3088 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
3089 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
3090 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
3091 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
3092 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
3093 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
3094 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
3095 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
3096 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
3097 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3098 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
3099 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
3100 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x33, 0x5f,
3101 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
3102 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
3103 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
3104 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
3105 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
3106 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
3107 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
3108 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3109 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3110 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3111 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3112 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
3113 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x30,
3114 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3115 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3116 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
3117 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
3118 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
3119 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
3120 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
3121 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
3122 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
3123 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
3124 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
3125 		0x00, 0xf0, 0x04, 0x08
3126 	};	/* Structure image */
3127 
3128 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
3129 }
3130 
3131 void
imdi_k10_tab(tabspec * t)3132 imdi_k10_tab(
3133 tabspec *t			/* structure to be initialised */
3134 ) {
3135 	static unsigned char data[] = {
3136 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3137 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3138 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3139 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
3140 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
3141 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
3142 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3143 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
3144 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
3145 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3146 		0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
3147 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3148 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
3149 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
3150 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
3151 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3152 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3153 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3154 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
3155 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3156 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3157 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
3158 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
3159 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
3160 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3161 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3162 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
3163 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
3164 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3165 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3166 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
3167 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
3168 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
3169 	};	/* Structure image */
3170 
3171 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
3172 }
3173 
3174 
3175 
3176 
3177 
3178 
3179 /* Integer Multi-Dimensional Interpolation */
3180 /* Interpolation Kernel Code */
3181 /* Generated by cgen */
3182 /* Copyright 2000 - 2002 Graeme W. Gill */
3183 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
3184 
3185 /* see the Licence.txt file for licencing details.*/
3186 
3187 
3188 /*
3189    Interpolation kernel specs:
3190 
3191    Input channels per pixel = 5
3192    Input channel 0 bits = 8
3193    Input channel 0 increment = 5
3194    Input channel 1 bits = 8
3195    Input channel 1 increment = 5
3196    Input channel 2 bits = 8
3197    Input channel 2 increment = 5
3198    Input channel 3 bits = 8
3199    Input channel 3 increment = 5
3200    Input channel 4 bits = 8
3201    Input channel 4 increment = 5
3202    Input is channel interleaved
3203    Input channels are separate words
3204    Input value extraction is done in input table lookup
3205 
3206    Output channels per pixel = 3
3207    Output channel 0 bits = 8
3208    Output channel 0 increment = 3
3209    Output channel 1 bits = 8
3210    Output channel 1 increment = 3
3211    Output channel 2 bits = 8
3212    Output channel 2 increment = 3
3213    Output is channel interleaved
3214 
3215    Output channels are separate words
3216    Weight+voffset bits       = 32
3217    Interpolation table index bits = 32
3218    Interpolation table max resolution = 53
3219  */
3220 
3221 /*
3222    Machine architecture specs:
3223 
3224    Little endian
3225    Reading and writing pixel values separately
3226    Pointer size = 32 bits
3227 
3228    Ordinal size  8 bits is known as 'unsigned char'
3229    Ordinal size 16 bits is known as 'unsigned short'
3230    Ordinal size 32 bits is known as 'unsigned int'
3231    Natural ordinal is 'unsigned int'
3232 
3233    Integer size  8 bits is known as 'signed char'
3234    Integer size 16 bits is known as 'short'
3235    Integer size 32 bits is known as 'int'
3236    Natural integer is 'int'
3237 
3238  */
3239 
3240 #ifndef  IMDI_INCLUDED
3241 #include <memory.h>
3242 #include "imdi_imp.h"
3243 #define  IMDI_INCLUDED
3244 #endif  /* IMDI_INCLUDED */
3245 
3246 #ifndef DEFINED_pointer
3247 #define DEFINED_pointer
3248 typedef unsigned char * pointer;
3249 #endif
3250 
3251 /* Input table interp. index */
3252 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
3253 
3254 /* Input table input weighting/offset value enty */
3255 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
3256 
3257 /* Conditional exchange for sorting */
3258 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
3259 
3260 /* Interpolation multi-dim. table access */
3261 #define IM_O(off) ((off) * 8)
3262 
3263 /* Interpolation table - get vertex values */
3264 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
3265 #define IM_PE(p, v) *((unsigned int *)((p) + 4 + (v) * 8))
3266 
3267 /* Output table indexes */
3268 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
3269 
3270 void
imdi_k11(imdi * s,void ** outp,void ** inp,unsigned int npix)3271 imdi_k11(
3272 imdi *s,			/* imdi context */
3273 void **outp,		/* pointer to output pointers */
3274 void **inp,		/* pointer to input pointers */
3275 unsigned int npix	/* Number of pixels to process */
3276 ) {
3277 	imdi_imp *p = (imdi_imp *)(s->impl);
3278 	unsigned char *ip0 = (unsigned char *)inp[0];
3279 	unsigned char *op0 = (unsigned char *)outp[0];
3280 	unsigned char *ep = ip0 + npix * 5 ;
3281 	pointer it0 = (pointer)p->in_tables[0];
3282 	pointer it1 = (pointer)p->in_tables[1];
3283 	pointer it2 = (pointer)p->in_tables[2];
3284 	pointer it3 = (pointer)p->in_tables[3];
3285 	pointer it4 = (pointer)p->in_tables[4];
3286 	pointer ot0 = (pointer)p->out_tables[0];
3287 	pointer ot1 = (pointer)p->out_tables[1];
3288 	pointer ot2 = (pointer)p->out_tables[2];
3289 	pointer im_base = (pointer)p->im_table;
3290 
3291 	for(;ip0 < ep; ip0 += 5, op0 += 3) {
3292 		unsigned int ova0;	/* Output value accumulator */
3293 		unsigned int ova1;	/* Output value partial accumulator */
3294 		{
3295 			pointer imp;
3296 			unsigned int wo0;	/* Weighting value and vertex offset variable */
3297 			unsigned int wo1;	/* Weighting value and vertex offset variable */
3298 			unsigned int wo2;	/* Weighting value and vertex offset variable */
3299 			unsigned int wo3;	/* Weighting value and vertex offset variable */
3300 			unsigned int wo4;	/* Weighting value and vertex offset variable */
3301 			{
3302 				unsigned int ti_i;	/* Interpolation index variable */
3303 
3304 				ti_i  = IT_IX(it0, ip0[0]);
3305 				wo0   = IT_WO(it0, ip0[0]);
3306 				ti_i += IT_IX(it1, ip0[1]);
3307 				wo1   = IT_WO(it1, ip0[1]);
3308 				ti_i += IT_IX(it2, ip0[2]);
3309 				wo2   = IT_WO(it2, ip0[2]);
3310 				ti_i += IT_IX(it3, ip0[3]);
3311 				wo3   = IT_WO(it3, ip0[3]);
3312 				ti_i += IT_IX(it4, ip0[4]);
3313 				wo4   = IT_WO(it4, ip0[4]);
3314 
3315 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
3316 
3317 				/* Sort weighting values and vertex offset values */
3318 				CEX(wo0, wo1);
3319 				CEX(wo0, wo2);
3320 				CEX(wo0, wo3);
3321 				CEX(wo0, wo4);
3322 				CEX(wo1, wo2);
3323 				CEX(wo1, wo3);
3324 				CEX(wo1, wo4);
3325 				CEX(wo2, wo3);
3326 				CEX(wo2, wo4);
3327 				CEX(wo3, wo4);
3328 			}
3329 			{
3330 				unsigned int nvof;	/* Next vertex offset value */
3331 				unsigned int vof;	/* Vertex offset value */
3332 				unsigned int vwe;	/* Vertex weighting */
3333 
3334 				vof = 0;				/* First vertex offset is 0 */
3335 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
3336 				wo0 = (wo0 >> 23);		/* Extract weighting value */
3337 				vwe = 256 - wo0;		/* Baricentric weighting */
3338 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
3339 				ova1  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
3340 				vof += nvof;			/* Move to next vertex */
3341 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
3342 				wo1 = (wo1 >> 23);		/* Extract weighting value */
3343 				vwe = wo0 - wo1;		/* Baricentric weighting */
3344 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
3345 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
3346 				vof += nvof;			/* Move to next vertex */
3347 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
3348 				wo2 = (wo2 >> 23);		/* Extract weighting value */
3349 				vwe = wo1 - wo2;		/* Baricentric weighting */
3350 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
3351 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
3352 				vof += nvof;			/* Move to next vertex */
3353 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
3354 				wo3 = (wo3 >> 23);		/* Extract weighting value */
3355 				vwe = wo2 - wo3;		/* Baricentric weighting */
3356 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
3357 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
3358 				vof += nvof;			/* Move to next vertex */
3359 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
3360 				wo4 = (wo4 >> 23);		/* Extract weighting value */
3361 				vwe = wo3 - wo4;		/* Baricentric weighting */
3362 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
3363 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
3364 				vof += nvof;			/* Move to next vertex */
3365 				vwe = wo4;				/* Baricentric weighting */
3366 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
3367 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
3368 			}
3369 		}
3370 		{
3371 			unsigned int oti;	/* Vertex offset value */
3372 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
3373 			op0[0] = OT_E(ot0, oti);	/* Write result */
3374 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
3375 			op0[1] = OT_E(ot1, oti);	/* Write result */
3376 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
3377 			op0[2] = OT_E(ot2, oti);	/* Write result */
3378 		}
3379 	}
3380 }
3381 #undef IT_WO
3382 #undef IT_IX
3383 #undef CEX
3384 #undef IM_O
3385 #undef IM_FE
3386 #undef IM_PE
3387 #undef OT_E
3388 
3389 void
imdi_k11_gen(genspec * g)3390 imdi_k11_gen(
3391 genspec *g			/* structure to be initialised */
3392 ) {
3393 	static unsigned char data[] = {
3394 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
3395 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3396 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3397 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3398 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3399 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3400 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3401 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
3402 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
3403 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
3404 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3405 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3406 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3407 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3408 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3409 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3410 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3411 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3412 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3413 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3414 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3415 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3416 		0xd0, 0x85, 0x04, 0x08, 0x4c, 0x69, 0x6e, 0x75,
3417 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3418 		0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
3419 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
3420 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3421 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3422 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3423 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3424 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
3425 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
3426 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3427 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3428 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3429 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3430 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3431 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3432 		0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3433 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
3434 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
3435 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
3436 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
3437 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
3438 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
3439 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
3440 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
3441 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
3442 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3443 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
3444 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
3445 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x33, 0x5f,
3446 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
3447 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
3448 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
3449 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
3450 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
3451 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
3452 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
3453 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3454 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3455 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3456 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3457 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
3458 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x31,
3459 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3460 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3461 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
3462 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
3463 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
3464 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
3465 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
3466 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
3467 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
3468 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
3469 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
3470 		0x00, 0xf0, 0x04, 0x08
3471 	};	/* Structure image */
3472 
3473 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
3474 }
3475 
3476 void
imdi_k11_tab(tabspec * t)3477 imdi_k11_tab(
3478 tabspec *t			/* structure to be initialised */
3479 ) {
3480 	static unsigned char data[] = {
3481 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3482 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3483 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3484 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
3485 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
3486 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
3487 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3488 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
3489 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
3490 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3491 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
3492 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
3493 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
3494 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
3495 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
3496 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3497 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3498 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3499 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
3500 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3501 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3502 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
3503 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
3504 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
3505 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3506 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3507 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
3508 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
3509 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3510 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3511 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
3512 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
3513 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
3514 	};	/* Structure image */
3515 
3516 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
3517 }
3518 
3519 
3520 
3521 
3522 
3523 
3524 /* Integer Multi-Dimensional Interpolation */
3525 /* Interpolation Kernel Code */
3526 /* Generated by cgen */
3527 /* Copyright 2000 - 2002 Graeme W. Gill */
3528 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
3529 
3530 /* see the Licence.txt file for licencing details.*/
3531 
3532 
3533 /*
3534    Interpolation kernel specs:
3535 
3536    Input channels per pixel = 6
3537    Input channel 0 bits = 8
3538    Input channel 0 increment = 6
3539    Input channel 1 bits = 8
3540    Input channel 1 increment = 6
3541    Input channel 2 bits = 8
3542    Input channel 2 increment = 6
3543    Input channel 3 bits = 8
3544    Input channel 3 increment = 6
3545    Input channel 4 bits = 8
3546    Input channel 4 increment = 6
3547    Input channel 5 bits = 8
3548    Input channel 5 increment = 6
3549    Input is channel interleaved
3550    Input channels are separate words
3551    Input value extraction is done in input table lookup
3552 
3553    Output channels per pixel = 3
3554    Output channel 0 bits = 8
3555    Output channel 0 increment = 3
3556    Output channel 1 bits = 8
3557    Output channel 1 increment = 3
3558    Output channel 2 bits = 8
3559    Output channel 2 increment = 3
3560    Output is channel interleaved
3561 
3562    Output channels are separate words
3563    Weight+voffset bits       = 32
3564    Interpolation table index bits = 32
3565    Interpolation table max resolution = 24
3566  */
3567 
3568 /*
3569    Machine architecture specs:
3570 
3571    Little endian
3572    Reading and writing pixel values separately
3573    Pointer size = 32 bits
3574 
3575    Ordinal size  8 bits is known as 'unsigned char'
3576    Ordinal size 16 bits is known as 'unsigned short'
3577    Ordinal size 32 bits is known as 'unsigned int'
3578    Natural ordinal is 'unsigned int'
3579 
3580    Integer size  8 bits is known as 'signed char'
3581    Integer size 16 bits is known as 'short'
3582    Integer size 32 bits is known as 'int'
3583    Natural integer is 'int'
3584 
3585  */
3586 
3587 #ifndef  IMDI_INCLUDED
3588 #include <memory.h>
3589 #include "imdi_imp.h"
3590 #define  IMDI_INCLUDED
3591 #endif  /* IMDI_INCLUDED */
3592 
3593 #ifndef DEFINED_pointer
3594 #define DEFINED_pointer
3595 typedef unsigned char * pointer;
3596 #endif
3597 
3598 /* Input table interp. index */
3599 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
3600 
3601 /* Input table input weighting/offset value enty */
3602 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
3603 
3604 /* Conditional exchange for sorting */
3605 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
3606 
3607 /* Interpolation multi-dim. table access */
3608 #define IM_O(off) ((off) * 8)
3609 
3610 /* Interpolation table - get vertex values */
3611 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
3612 #define IM_PE(p, v) *((unsigned int *)((p) + 4 + (v) * 8))
3613 
3614 /* Output table indexes */
3615 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
3616 
3617 void
imdi_k12(imdi * s,void ** outp,void ** inp,unsigned int npix)3618 imdi_k12(
3619 imdi *s,			/* imdi context */
3620 void **outp,		/* pointer to output pointers */
3621 void **inp,		/* pointer to input pointers */
3622 unsigned int npix	/* Number of pixels to process */
3623 ) {
3624 	imdi_imp *p = (imdi_imp *)(s->impl);
3625 	unsigned char *ip0 = (unsigned char *)inp[0];
3626 	unsigned char *op0 = (unsigned char *)outp[0];
3627 	unsigned char *ep = ip0 + npix * 6 ;
3628 	pointer it0 = (pointer)p->in_tables[0];
3629 	pointer it1 = (pointer)p->in_tables[1];
3630 	pointer it2 = (pointer)p->in_tables[2];
3631 	pointer it3 = (pointer)p->in_tables[3];
3632 	pointer it4 = (pointer)p->in_tables[4];
3633 	pointer it5 = (pointer)p->in_tables[5];
3634 	pointer ot0 = (pointer)p->out_tables[0];
3635 	pointer ot1 = (pointer)p->out_tables[1];
3636 	pointer ot2 = (pointer)p->out_tables[2];
3637 	pointer im_base = (pointer)p->im_table;
3638 
3639 	for(;ip0 < ep; ip0 += 6, op0 += 3) {
3640 		unsigned int ova0;	/* Output value accumulator */
3641 		unsigned int ova1;	/* Output value partial accumulator */
3642 		{
3643 			pointer imp;
3644 			unsigned int wo0;	/* Weighting value and vertex offset variable */
3645 			unsigned int wo1;	/* Weighting value and vertex offset variable */
3646 			unsigned int wo2;	/* Weighting value and vertex offset variable */
3647 			unsigned int wo3;	/* Weighting value and vertex offset variable */
3648 			unsigned int wo4;	/* Weighting value and vertex offset variable */
3649 			unsigned int wo5;	/* Weighting value and vertex offset variable */
3650 			{
3651 				unsigned int ti_i;	/* Interpolation index variable */
3652 
3653 				ti_i  = IT_IX(it0, ip0[0]);
3654 				wo0   = IT_WO(it0, ip0[0]);
3655 				ti_i += IT_IX(it1, ip0[1]);
3656 				wo1   = IT_WO(it1, ip0[1]);
3657 				ti_i += IT_IX(it2, ip0[2]);
3658 				wo2   = IT_WO(it2, ip0[2]);
3659 				ti_i += IT_IX(it3, ip0[3]);
3660 				wo3   = IT_WO(it3, ip0[3]);
3661 				ti_i += IT_IX(it4, ip0[4]);
3662 				wo4   = IT_WO(it4, ip0[4]);
3663 				ti_i += IT_IX(it5, ip0[5]);
3664 				wo5   = IT_WO(it5, ip0[5]);
3665 
3666 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
3667 
3668 				/* Sort weighting values and vertex offset values */
3669 				CEX(wo0, wo1);
3670 				CEX(wo0, wo2);
3671 				CEX(wo0, wo3);
3672 				CEX(wo0, wo4);
3673 				CEX(wo0, wo5);
3674 				CEX(wo1, wo2);
3675 				CEX(wo1, wo3);
3676 				CEX(wo1, wo4);
3677 				CEX(wo1, wo5);
3678 				CEX(wo2, wo3);
3679 				CEX(wo2, wo4);
3680 				CEX(wo2, wo5);
3681 				CEX(wo3, wo4);
3682 				CEX(wo3, wo5);
3683 				CEX(wo4, wo5);
3684 			}
3685 			{
3686 				unsigned int nvof;	/* Next vertex offset value */
3687 				unsigned int vof;	/* Vertex offset value */
3688 				unsigned int vwe;	/* Vertex weighting */
3689 
3690 				vof = 0;				/* First vertex offset is 0 */
3691 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
3692 				wo0 = (wo0 >> 23);		/* Extract weighting value */
3693 				vwe = 256 - wo0;		/* Baricentric weighting */
3694 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
3695 				ova1  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
3696 				vof += nvof;			/* Move to next vertex */
3697 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
3698 				wo1 = (wo1 >> 23);		/* Extract weighting value */
3699 				vwe = wo0 - wo1;		/* Baricentric weighting */
3700 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
3701 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
3702 				vof += nvof;			/* Move to next vertex */
3703 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
3704 				wo2 = (wo2 >> 23);		/* Extract weighting value */
3705 				vwe = wo1 - wo2;		/* Baricentric weighting */
3706 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
3707 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
3708 				vof += nvof;			/* Move to next vertex */
3709 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
3710 				wo3 = (wo3 >> 23);		/* Extract weighting value */
3711 				vwe = wo2 - wo3;		/* Baricentric weighting */
3712 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
3713 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
3714 				vof += nvof;			/* Move to next vertex */
3715 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
3716 				wo4 = (wo4 >> 23);		/* Extract weighting value */
3717 				vwe = wo3 - wo4;		/* Baricentric weighting */
3718 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
3719 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
3720 				vof += nvof;			/* Move to next vertex */
3721 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
3722 				wo5 = (wo5 >> 23);		/* Extract weighting value */
3723 				vwe = wo4 - wo5;		/* Baricentric weighting */
3724 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
3725 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
3726 				vof += nvof;			/* Move to next vertex */
3727 				vwe = wo5;				/* Baricentric weighting */
3728 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
3729 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
3730 			}
3731 		}
3732 		{
3733 			unsigned int oti;	/* Vertex offset value */
3734 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
3735 			op0[0] = OT_E(ot0, oti);	/* Write result */
3736 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
3737 			op0[1] = OT_E(ot1, oti);	/* Write result */
3738 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
3739 			op0[2] = OT_E(ot2, oti);	/* Write result */
3740 		}
3741 	}
3742 }
3743 #undef IT_WO
3744 #undef IT_IX
3745 #undef CEX
3746 #undef IM_O
3747 #undef IM_FE
3748 #undef IM_PE
3749 #undef OT_E
3750 
3751 void
imdi_k12_gen(genspec * g)3752 imdi_k12_gen(
3753 genspec *g			/* structure to be initialised */
3754 ) {
3755 	static unsigned char data[] = {
3756 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
3757 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3758 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3759 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3760 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3761 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3762 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3763 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
3764 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
3765 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
3766 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3767 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3768 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3769 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3770 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3771 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3772 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3773 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3774 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3775 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3776 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3777 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3778 		0xd0, 0x85, 0x04, 0x08, 0x4c, 0x69, 0x6e, 0x75,
3779 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3780 		0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
3781 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
3782 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3783 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3784 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3785 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3786 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
3787 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
3788 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3789 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3790 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3791 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3792 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3793 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3794 		0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3795 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
3796 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
3797 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
3798 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
3799 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
3800 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
3801 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
3802 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
3803 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
3804 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3805 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
3806 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
3807 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x33, 0x5f,
3808 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
3809 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
3810 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
3811 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
3812 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
3813 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
3814 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
3815 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3816 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3817 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3818 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3819 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
3820 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x32,
3821 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3822 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3823 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
3824 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
3825 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
3826 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
3827 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
3828 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
3829 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
3830 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
3831 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
3832 		0x00, 0xf0, 0x04, 0x08
3833 	};	/* Structure image */
3834 
3835 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
3836 }
3837 
3838 void
imdi_k12_tab(tabspec * t)3839 imdi_k12_tab(
3840 tabspec *t			/* structure to be initialised */
3841 ) {
3842 	static unsigned char data[] = {
3843 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3844 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3845 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3846 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
3847 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
3848 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
3849 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3850 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
3851 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
3852 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3853 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
3854 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
3855 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
3856 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
3857 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
3858 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3859 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3860 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3861 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
3862 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3863 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
3864 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
3865 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
3866 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
3867 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3868 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3869 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
3870 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
3871 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3872 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
3873 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
3874 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
3875 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
3876 	};	/* Structure image */
3877 
3878 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
3879 }
3880 
3881 
3882 
3883 
3884 
3885 
3886 /* Integer Multi-Dimensional Interpolation */
3887 /* Interpolation Kernel Code */
3888 /* Generated by cgen */
3889 /* Copyright 2000 - 2002 Graeme W. Gill */
3890 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
3891 
3892 /* see the Licence.txt file for licencing details.*/
3893 
3894 
3895 /*
3896    Interpolation kernel specs:
3897 
3898    Input channels per pixel = 7
3899    Input channel 0 bits = 8
3900    Input channel 0 increment = 7
3901    Input channel 1 bits = 8
3902    Input channel 1 increment = 7
3903    Input channel 2 bits = 8
3904    Input channel 2 increment = 7
3905    Input channel 3 bits = 8
3906    Input channel 3 increment = 7
3907    Input channel 4 bits = 8
3908    Input channel 4 increment = 7
3909    Input channel 5 bits = 8
3910    Input channel 5 increment = 7
3911    Input channel 6 bits = 8
3912    Input channel 6 increment = 7
3913    Input is channel interleaved
3914    Input channels are separate words
3915    Input value extraction is done in input table lookup
3916 
3917    Output channels per pixel = 3
3918    Output channel 0 bits = 8
3919    Output channel 0 increment = 3
3920    Output channel 1 bits = 8
3921    Output channel 1 increment = 3
3922    Output channel 2 bits = 8
3923    Output channel 2 increment = 3
3924    Output is channel interleaved
3925 
3926    Output channels are separate words
3927    Weight+voffset bits       = 32
3928    Interpolation table index bits = 32
3929    Interpolation table max resolution = 14
3930  */
3931 
3932 /*
3933    Machine architecture specs:
3934 
3935    Little endian
3936    Reading and writing pixel values separately
3937    Pointer size = 32 bits
3938 
3939    Ordinal size  8 bits is known as 'unsigned char'
3940    Ordinal size 16 bits is known as 'unsigned short'
3941    Ordinal size 32 bits is known as 'unsigned int'
3942    Natural ordinal is 'unsigned int'
3943 
3944    Integer size  8 bits is known as 'signed char'
3945    Integer size 16 bits is known as 'short'
3946    Integer size 32 bits is known as 'int'
3947    Natural integer is 'int'
3948 
3949  */
3950 
3951 #ifndef  IMDI_INCLUDED
3952 #include <memory.h>
3953 #include "imdi_imp.h"
3954 #define  IMDI_INCLUDED
3955 #endif  /* IMDI_INCLUDED */
3956 
3957 #ifndef DEFINED_pointer
3958 #define DEFINED_pointer
3959 typedef unsigned char * pointer;
3960 #endif
3961 
3962 /* Input table interp. index */
3963 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
3964 
3965 /* Input table input weighting/offset value enty */
3966 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
3967 
3968 /* Conditional exchange for sorting */
3969 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
3970 
3971 /* Interpolation multi-dim. table access */
3972 #define IM_O(off) ((off) * 8)
3973 
3974 /* Interpolation table - get vertex values */
3975 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
3976 #define IM_PE(p, v) *((unsigned int *)((p) + 4 + (v) * 8))
3977 
3978 /* Output table indexes */
3979 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
3980 
3981 void
imdi_k13(imdi * s,void ** outp,void ** inp,unsigned int npix)3982 imdi_k13(
3983 imdi *s,			/* imdi context */
3984 void **outp,		/* pointer to output pointers */
3985 void **inp,		/* pointer to input pointers */
3986 unsigned int npix	/* Number of pixels to process */
3987 ) {
3988 	imdi_imp *p = (imdi_imp *)(s->impl);
3989 	unsigned char *ip0 = (unsigned char *)inp[0];
3990 	unsigned char *op0 = (unsigned char *)outp[0];
3991 	unsigned char *ep = ip0 + npix * 7 ;
3992 	pointer it0 = (pointer)p->in_tables[0];
3993 	pointer it1 = (pointer)p->in_tables[1];
3994 	pointer it2 = (pointer)p->in_tables[2];
3995 	pointer it3 = (pointer)p->in_tables[3];
3996 	pointer it4 = (pointer)p->in_tables[4];
3997 	pointer it5 = (pointer)p->in_tables[5];
3998 	pointer it6 = (pointer)p->in_tables[6];
3999 	pointer ot0 = (pointer)p->out_tables[0];
4000 	pointer ot1 = (pointer)p->out_tables[1];
4001 	pointer ot2 = (pointer)p->out_tables[2];
4002 	pointer im_base = (pointer)p->im_table;
4003 
4004 	for(;ip0 < ep; ip0 += 7, op0 += 3) {
4005 		unsigned int ova0;	/* Output value accumulator */
4006 		unsigned int ova1;	/* Output value partial accumulator */
4007 		{
4008 			pointer imp;
4009 			unsigned int wo0;	/* Weighting value and vertex offset variable */
4010 			unsigned int wo1;	/* Weighting value and vertex offset variable */
4011 			unsigned int wo2;	/* Weighting value and vertex offset variable */
4012 			unsigned int wo3;	/* Weighting value and vertex offset variable */
4013 			unsigned int wo4;	/* Weighting value and vertex offset variable */
4014 			unsigned int wo5;	/* Weighting value and vertex offset variable */
4015 			unsigned int wo6;	/* Weighting value and vertex offset variable */
4016 			{
4017 				unsigned int ti_i;	/* Interpolation index variable */
4018 
4019 				ti_i  = IT_IX(it0, ip0[0]);
4020 				wo0   = IT_WO(it0, ip0[0]);
4021 				ti_i += IT_IX(it1, ip0[1]);
4022 				wo1   = IT_WO(it1, ip0[1]);
4023 				ti_i += IT_IX(it2, ip0[2]);
4024 				wo2   = IT_WO(it2, ip0[2]);
4025 				ti_i += IT_IX(it3, ip0[3]);
4026 				wo3   = IT_WO(it3, ip0[3]);
4027 				ti_i += IT_IX(it4, ip0[4]);
4028 				wo4   = IT_WO(it4, ip0[4]);
4029 				ti_i += IT_IX(it5, ip0[5]);
4030 				wo5   = IT_WO(it5, ip0[5]);
4031 				ti_i += IT_IX(it6, ip0[6]);
4032 				wo6   = IT_WO(it6, ip0[6]);
4033 
4034 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
4035 
4036 				/* Sort weighting values and vertex offset values */
4037 				CEX(wo0, wo1);
4038 				CEX(wo0, wo2);
4039 				CEX(wo0, wo3);
4040 				CEX(wo0, wo4);
4041 				CEX(wo0, wo5);
4042 				CEX(wo0, wo6);
4043 				CEX(wo1, wo2);
4044 				CEX(wo1, wo3);
4045 				CEX(wo1, wo4);
4046 				CEX(wo1, wo5);
4047 				CEX(wo1, wo6);
4048 				CEX(wo2, wo3);
4049 				CEX(wo2, wo4);
4050 				CEX(wo2, wo5);
4051 				CEX(wo2, wo6);
4052 				CEX(wo3, wo4);
4053 				CEX(wo3, wo5);
4054 				CEX(wo3, wo6);
4055 				CEX(wo4, wo5);
4056 				CEX(wo4, wo6);
4057 				CEX(wo5, wo6);
4058 			}
4059 			{
4060 				unsigned int nvof;	/* Next vertex offset value */
4061 				unsigned int vof;	/* Vertex offset value */
4062 				unsigned int vwe;	/* Vertex weighting */
4063 
4064 				vof = 0;				/* First vertex offset is 0 */
4065 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
4066 				wo0 = (wo0 >> 23);		/* Extract weighting value */
4067 				vwe = 256 - wo0;		/* Baricentric weighting */
4068 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
4069 				ova1  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
4070 				vof += nvof;			/* Move to next vertex */
4071 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
4072 				wo1 = (wo1 >> 23);		/* Extract weighting value */
4073 				vwe = wo0 - wo1;		/* Baricentric weighting */
4074 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
4075 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
4076 				vof += nvof;			/* Move to next vertex */
4077 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
4078 				wo2 = (wo2 >> 23);		/* Extract weighting value */
4079 				vwe = wo1 - wo2;		/* Baricentric weighting */
4080 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
4081 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
4082 				vof += nvof;			/* Move to next vertex */
4083 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
4084 				wo3 = (wo3 >> 23);		/* Extract weighting value */
4085 				vwe = wo2 - wo3;		/* Baricentric weighting */
4086 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
4087 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
4088 				vof += nvof;			/* Move to next vertex */
4089 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
4090 				wo4 = (wo4 >> 23);		/* Extract weighting value */
4091 				vwe = wo3 - wo4;		/* Baricentric weighting */
4092 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
4093 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
4094 				vof += nvof;			/* Move to next vertex */
4095 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
4096 				wo5 = (wo5 >> 23);		/* Extract weighting value */
4097 				vwe = wo4 - wo5;		/* Baricentric weighting */
4098 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
4099 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
4100 				vof += nvof;			/* Move to next vertex */
4101 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
4102 				wo6 = (wo6 >> 23);		/* Extract weighting value */
4103 				vwe = wo5 - wo6;		/* Baricentric weighting */
4104 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
4105 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
4106 				vof += nvof;			/* Move to next vertex */
4107 				vwe = wo6;				/* Baricentric weighting */
4108 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
4109 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
4110 			}
4111 		}
4112 		{
4113 			unsigned int oti;	/* Vertex offset value */
4114 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
4115 			op0[0] = OT_E(ot0, oti);	/* Write result */
4116 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
4117 			op0[1] = OT_E(ot1, oti);	/* Write result */
4118 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
4119 			op0[2] = OT_E(ot2, oti);	/* Write result */
4120 		}
4121 	}
4122 }
4123 #undef IT_WO
4124 #undef IT_IX
4125 #undef CEX
4126 #undef IM_O
4127 #undef IM_FE
4128 #undef IM_PE
4129 #undef OT_E
4130 
4131 void
imdi_k13_gen(genspec * g)4132 imdi_k13_gen(
4133 genspec *g			/* structure to be initialised */
4134 ) {
4135 	static unsigned char data[] = {
4136 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
4137 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4138 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4139 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4140 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4141 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4142 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4143 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
4144 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
4145 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
4146 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
4147 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4148 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4149 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4150 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4151 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4152 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4153 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4154 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4155 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4156 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4157 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4158 		0xd0, 0x85, 0x04, 0x08, 0x4c, 0x69, 0x6e, 0x75,
4159 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4160 		0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
4161 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
4162 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4163 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4164 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4165 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4166 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
4167 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
4168 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4169 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4170 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4171 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4172 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4173 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4174 		0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4175 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
4176 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
4177 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
4178 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
4179 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
4180 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
4181 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
4182 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
4183 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
4184 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4185 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
4186 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
4187 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x33, 0x5f,
4188 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
4189 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
4190 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
4191 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
4192 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
4193 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
4194 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
4195 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4196 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4197 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4198 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4199 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
4200 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x33,
4201 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4202 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4203 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
4204 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
4205 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
4206 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
4207 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
4208 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
4209 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
4210 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
4211 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
4212 		0x00, 0xf0, 0x04, 0x08
4213 	};	/* Structure image */
4214 
4215 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
4216 }
4217 
4218 void
imdi_k13_tab(tabspec * t)4219 imdi_k13_tab(
4220 tabspec *t			/* structure to be initialised */
4221 ) {
4222 	static unsigned char data[] = {
4223 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4224 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4225 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4226 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
4227 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
4228 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
4229 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4230 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
4231 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
4232 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4233 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
4234 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
4235 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
4236 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
4237 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
4238 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4239 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4240 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4241 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
4242 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4243 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4244 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
4245 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
4246 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
4247 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4248 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4249 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
4250 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
4251 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4252 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4253 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
4254 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
4255 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
4256 	};	/* Structure image */
4257 
4258 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
4259 }
4260 
4261 
4262 
4263 
4264 
4265 
4266 /* Integer Multi-Dimensional Interpolation */
4267 /* Interpolation Kernel Code */
4268 /* Generated by cgen */
4269 /* Copyright 2000 - 2002 Graeme W. Gill */
4270 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
4271 
4272 /* see the Licence.txt file for licencing details.*/
4273 
4274 
4275 /*
4276    Interpolation kernel specs:
4277 
4278    Input channels per pixel = 8
4279    Input channel 0 bits = 8
4280    Input channel 0 increment = 8
4281    Input channel 1 bits = 8
4282    Input channel 1 increment = 8
4283    Input channel 2 bits = 8
4284    Input channel 2 increment = 8
4285    Input channel 3 bits = 8
4286    Input channel 3 increment = 8
4287    Input channel 4 bits = 8
4288    Input channel 4 increment = 8
4289    Input channel 5 bits = 8
4290    Input channel 5 increment = 8
4291    Input channel 6 bits = 8
4292    Input channel 6 increment = 8
4293    Input channel 7 bits = 8
4294    Input channel 7 increment = 8
4295    Input is channel interleaved
4296    Input channels are separate words
4297    Input value extraction is done in input table lookup
4298 
4299    Output channels per pixel = 3
4300    Output channel 0 bits = 8
4301    Output channel 0 increment = 3
4302    Output channel 1 bits = 8
4303    Output channel 1 increment = 3
4304    Output channel 2 bits = 8
4305    Output channel 2 increment = 3
4306    Output is channel interleaved
4307 
4308    Output channels are separate words
4309    Weight+voffset bits       = 32
4310    Interpolation table index bits = 32
4311    Interpolation table max resolution = 9
4312  */
4313 
4314 /*
4315    Machine architecture specs:
4316 
4317    Little endian
4318    Reading and writing pixel values separately
4319    Pointer size = 32 bits
4320 
4321    Ordinal size  8 bits is known as 'unsigned char'
4322    Ordinal size 16 bits is known as 'unsigned short'
4323    Ordinal size 32 bits is known as 'unsigned int'
4324    Natural ordinal is 'unsigned int'
4325 
4326    Integer size  8 bits is known as 'signed char'
4327    Integer size 16 bits is known as 'short'
4328    Integer size 32 bits is known as 'int'
4329    Natural integer is 'int'
4330 
4331  */
4332 
4333 #ifndef  IMDI_INCLUDED
4334 #include <memory.h>
4335 #include "imdi_imp.h"
4336 #define  IMDI_INCLUDED
4337 #endif  /* IMDI_INCLUDED */
4338 
4339 #ifndef DEFINED_pointer
4340 #define DEFINED_pointer
4341 typedef unsigned char * pointer;
4342 #endif
4343 
4344 /* Input table interp. index */
4345 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
4346 
4347 /* Input table input weighting/offset value enty */
4348 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
4349 
4350 /* Conditional exchange for sorting */
4351 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
4352 
4353 /* Interpolation multi-dim. table access */
4354 #define IM_O(off) ((off) * 8)
4355 
4356 /* Interpolation table - get vertex values */
4357 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
4358 #define IM_PE(p, v) *((unsigned int *)((p) + 4 + (v) * 8))
4359 
4360 /* Output table indexes */
4361 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
4362 
4363 void
imdi_k14(imdi * s,void ** outp,void ** inp,unsigned int npix)4364 imdi_k14(
4365 imdi *s,			/* imdi context */
4366 void **outp,		/* pointer to output pointers */
4367 void **inp,		/* pointer to input pointers */
4368 unsigned int npix	/* Number of pixels to process */
4369 ) {
4370 	imdi_imp *p = (imdi_imp *)(s->impl);
4371 	unsigned char *ip0 = (unsigned char *)inp[0];
4372 	unsigned char *op0 = (unsigned char *)outp[0];
4373 	unsigned char *ep = ip0 + npix * 8 ;
4374 	pointer it0 = (pointer)p->in_tables[0];
4375 	pointer it1 = (pointer)p->in_tables[1];
4376 	pointer it2 = (pointer)p->in_tables[2];
4377 	pointer it3 = (pointer)p->in_tables[3];
4378 	pointer it4 = (pointer)p->in_tables[4];
4379 	pointer it5 = (pointer)p->in_tables[5];
4380 	pointer it6 = (pointer)p->in_tables[6];
4381 	pointer it7 = (pointer)p->in_tables[7];
4382 	pointer ot0 = (pointer)p->out_tables[0];
4383 	pointer ot1 = (pointer)p->out_tables[1];
4384 	pointer ot2 = (pointer)p->out_tables[2];
4385 	pointer im_base = (pointer)p->im_table;
4386 
4387 	for(;ip0 < ep; ip0 += 8, op0 += 3) {
4388 		unsigned int ova0;	/* Output value accumulator */
4389 		unsigned int ova1;	/* Output value partial accumulator */
4390 		{
4391 			pointer imp;
4392 			unsigned int wo0;	/* Weighting value and vertex offset variable */
4393 			unsigned int wo1;	/* Weighting value and vertex offset variable */
4394 			unsigned int wo2;	/* Weighting value and vertex offset variable */
4395 			unsigned int wo3;	/* Weighting value and vertex offset variable */
4396 			unsigned int wo4;	/* Weighting value and vertex offset variable */
4397 			unsigned int wo5;	/* Weighting value and vertex offset variable */
4398 			unsigned int wo6;	/* Weighting value and vertex offset variable */
4399 			unsigned int wo7;	/* Weighting value and vertex offset variable */
4400 			{
4401 				unsigned int ti_i;	/* Interpolation index variable */
4402 
4403 				ti_i  = IT_IX(it0, ip0[0]);
4404 				wo0   = IT_WO(it0, ip0[0]);
4405 				ti_i += IT_IX(it1, ip0[1]);
4406 				wo1   = IT_WO(it1, ip0[1]);
4407 				ti_i += IT_IX(it2, ip0[2]);
4408 				wo2   = IT_WO(it2, ip0[2]);
4409 				ti_i += IT_IX(it3, ip0[3]);
4410 				wo3   = IT_WO(it3, ip0[3]);
4411 				ti_i += IT_IX(it4, ip0[4]);
4412 				wo4   = IT_WO(it4, ip0[4]);
4413 				ti_i += IT_IX(it5, ip0[5]);
4414 				wo5   = IT_WO(it5, ip0[5]);
4415 				ti_i += IT_IX(it6, ip0[6]);
4416 				wo6   = IT_WO(it6, ip0[6]);
4417 				ti_i += IT_IX(it7, ip0[7]);
4418 				wo7   = IT_WO(it7, ip0[7]);
4419 
4420 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
4421 
4422 				/* Sort weighting values and vertex offset values */
4423 				CEX(wo0, wo1);
4424 				CEX(wo0, wo2);
4425 				CEX(wo0, wo3);
4426 				CEX(wo0, wo4);
4427 				CEX(wo0, wo5);
4428 				CEX(wo0, wo6);
4429 				CEX(wo0, wo7);
4430 				CEX(wo1, wo2);
4431 				CEX(wo1, wo3);
4432 				CEX(wo1, wo4);
4433 				CEX(wo1, wo5);
4434 				CEX(wo1, wo6);
4435 				CEX(wo1, wo7);
4436 				CEX(wo2, wo3);
4437 				CEX(wo2, wo4);
4438 				CEX(wo2, wo5);
4439 				CEX(wo2, wo6);
4440 				CEX(wo2, wo7);
4441 				CEX(wo3, wo4);
4442 				CEX(wo3, wo5);
4443 				CEX(wo3, wo6);
4444 				CEX(wo3, wo7);
4445 				CEX(wo4, wo5);
4446 				CEX(wo4, wo6);
4447 				CEX(wo4, wo7);
4448 				CEX(wo5, wo6);
4449 				CEX(wo5, wo7);
4450 				CEX(wo6, wo7);
4451 			}
4452 			{
4453 				unsigned int nvof;	/* Next vertex offset value */
4454 				unsigned int vof;	/* Vertex offset value */
4455 				unsigned int vwe;	/* Vertex weighting */
4456 
4457 				vof = 0;				/* First vertex offset is 0 */
4458 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
4459 				wo0 = (wo0 >> 23);		/* Extract weighting value */
4460 				vwe = 256 - wo0;		/* Baricentric weighting */
4461 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
4462 				ova1  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
4463 				vof += nvof;			/* Move to next vertex */
4464 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
4465 				wo1 = (wo1 >> 23);		/* Extract weighting value */
4466 				vwe = wo0 - wo1;		/* Baricentric weighting */
4467 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
4468 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
4469 				vof += nvof;			/* Move to next vertex */
4470 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
4471 				wo2 = (wo2 >> 23);		/* Extract weighting value */
4472 				vwe = wo1 - wo2;		/* Baricentric weighting */
4473 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
4474 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
4475 				vof += nvof;			/* Move to next vertex */
4476 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
4477 				wo3 = (wo3 >> 23);		/* Extract weighting value */
4478 				vwe = wo2 - wo3;		/* Baricentric weighting */
4479 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
4480 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
4481 				vof += nvof;			/* Move to next vertex */
4482 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
4483 				wo4 = (wo4 >> 23);		/* Extract weighting value */
4484 				vwe = wo3 - wo4;		/* Baricentric weighting */
4485 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
4486 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
4487 				vof += nvof;			/* Move to next vertex */
4488 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
4489 				wo5 = (wo5 >> 23);		/* Extract weighting value */
4490 				vwe = wo4 - wo5;		/* Baricentric weighting */
4491 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
4492 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
4493 				vof += nvof;			/* Move to next vertex */
4494 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
4495 				wo6 = (wo6 >> 23);		/* Extract weighting value */
4496 				vwe = wo5 - wo6;		/* Baricentric weighting */
4497 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
4498 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
4499 				vof += nvof;			/* Move to next vertex */
4500 				nvof = (wo7 & 0x7fffff);	/* Extract offset value */
4501 				wo7 = (wo7 >> 23);		/* Extract weighting value */
4502 				vwe = wo6 - wo7;		/* Baricentric weighting */
4503 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
4504 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
4505 				vof += nvof;			/* Move to next vertex */
4506 				vwe = wo7;				/* Baricentric weighting */
4507 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
4508 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
4509 			}
4510 		}
4511 		{
4512 			unsigned int oti;	/* Vertex offset value */
4513 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
4514 			op0[0] = OT_E(ot0, oti);	/* Write result */
4515 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
4516 			op0[1] = OT_E(ot1, oti);	/* Write result */
4517 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
4518 			op0[2] = OT_E(ot2, oti);	/* Write result */
4519 		}
4520 	}
4521 }
4522 #undef IT_WO
4523 #undef IT_IX
4524 #undef CEX
4525 #undef IM_O
4526 #undef IM_FE
4527 #undef IM_PE
4528 #undef OT_E
4529 
4530 void
imdi_k14_gen(genspec * g)4531 imdi_k14_gen(
4532 genspec *g			/* structure to be initialised */
4533 ) {
4534 	static unsigned char data[] = {
4535 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4536 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4537 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4538 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4539 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4540 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4541 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4542 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4543 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4544 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4545 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4546 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4547 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4548 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4549 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4550 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4551 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4552 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4553 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4554 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4555 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4556 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4557 		0xd0, 0x85, 0x04, 0x08, 0x4c, 0x69, 0x6e, 0x75,
4558 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4559 		0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
4560 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
4561 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4562 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4563 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4564 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4565 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
4566 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
4567 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4568 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4569 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4570 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4571 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4572 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4573 		0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4574 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
4575 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
4576 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
4577 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
4578 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
4579 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
4580 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
4581 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
4582 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
4583 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4584 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
4585 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
4586 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x33, 0x5f,
4587 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
4588 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
4589 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
4590 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
4591 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
4592 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
4593 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
4594 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4595 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4596 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4597 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4598 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
4599 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x34,
4600 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4601 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4602 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
4603 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
4604 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
4605 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
4606 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
4607 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
4608 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
4609 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
4610 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
4611 		0x00, 0xf0, 0x04, 0x08
4612 	};	/* Structure image */
4613 
4614 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
4615 }
4616 
4617 void
imdi_k14_tab(tabspec * t)4618 imdi_k14_tab(
4619 tabspec *t			/* structure to be initialised */
4620 ) {
4621 	static unsigned char data[] = {
4622 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4623 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4624 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4625 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
4626 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
4627 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
4628 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4629 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
4630 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
4631 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4632 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
4633 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
4634 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
4635 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
4636 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
4637 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4638 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4639 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4640 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
4641 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4642 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4643 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
4644 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
4645 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
4646 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4647 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4648 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
4649 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
4650 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4651 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4652 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
4653 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
4654 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
4655 	};	/* Structure image */
4656 
4657 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
4658 }
4659 
4660 
4661 
4662 
4663 
4664 
4665 /* Integer Multi-Dimensional Interpolation */
4666 /* Interpolation Kernel Code */
4667 /* Generated by cgen */
4668 /* Copyright 2000 - 2002 Graeme W. Gill */
4669 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
4670 
4671 /* see the Licence.txt file for licencing details.*/
4672 
4673 
4674 /*
4675    Interpolation kernel specs:
4676 
4677    Input channels per pixel = 1
4678    Input channel 0 bits = 8
4679    Input channel 0 increment = 1
4680    Input is channel interleaved
4681    Input channels are separate words
4682    Input value extraction is done in input table lookup
4683 
4684    Output channels per pixel = 4
4685    Output channel 0 bits = 8
4686    Output channel 0 increment = 4
4687    Output channel 1 bits = 8
4688    Output channel 1 increment = 4
4689    Output channel 2 bits = 8
4690    Output channel 2 increment = 4
4691    Output channel 3 bits = 8
4692    Output channel 3 increment = 4
4693    Output is channel interleaved
4694 
4695    Output channels are separate words
4696    Simplex table index bits       = 0
4697    Interpolation table index bits = 8
4698    Simplex table max resolution = 1
4699    Interpolation table max resolution = 255
4700  */
4701 
4702 /*
4703    Machine architecture specs:
4704 
4705    Little endian
4706    Reading and writing pixel values separately
4707    Pointer size = 32 bits
4708 
4709    Ordinal size  8 bits is known as 'unsigned char'
4710    Ordinal size 16 bits is known as 'unsigned short'
4711    Ordinal size 32 bits is known as 'unsigned int'
4712    Natural ordinal is 'unsigned int'
4713 
4714    Integer size  8 bits is known as 'signed char'
4715    Integer size 16 bits is known as 'short'
4716    Integer size 32 bits is known as 'int'
4717    Natural integer is 'int'
4718 
4719  */
4720 
4721 #ifndef  IMDI_INCLUDED
4722 #include <memory.h>
4723 #include "imdi_imp.h"
4724 #define  IMDI_INCLUDED
4725 #endif  /* IMDI_INCLUDED */
4726 
4727 #ifndef DEFINED_pointer
4728 #define DEFINED_pointer
4729 typedef unsigned char * pointer;
4730 #endif
4731 
4732 /* Input table inter & simplex indexes */
4733 #define IT_IT(p, off) *((unsigned char *)((p) + 0 + (off) * 1))
4734 
4735 /* Simplex weighting table access */
4736 #define SW_O(off) ((off) * 4)
4737 
4738 /* Simplex table - get weighting/offset value */
4739 #define SX_WO(p, v) *((unsigned short *)((p) + (v) * 2))
4740 
4741 /* Interpolation multi-dim. table access */
4742 #define IM_O(off) ((off) * 8)
4743 
4744 /* Interpolation table - get vertex values */
4745 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
4746 
4747 /* Output table indexes */
4748 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
4749 
4750 void
imdi_k15(imdi * s,void ** outp,void ** inp,unsigned int npix)4751 imdi_k15(
4752 imdi *s,			/* imdi context */
4753 void **outp,		/* pointer to output pointers */
4754 void **inp,		/* pointer to input pointers */
4755 unsigned int npix	/* Number of pixels to process */
4756 ) {
4757 	imdi_imp *p = (imdi_imp *)(s->impl);
4758 	unsigned char *ip0 = (unsigned char *)inp[0];
4759 	unsigned char *op0 = (unsigned char *)outp[0];
4760 	unsigned char *ep = ip0 + npix * 1 ;
4761 	pointer it0 = (pointer)p->in_tables[0];
4762 	pointer ot0 = (pointer)p->out_tables[0];
4763 	pointer ot1 = (pointer)p->out_tables[1];
4764 	pointer ot2 = (pointer)p->out_tables[2];
4765 	pointer ot3 = (pointer)p->out_tables[3];
4766 	pointer sw_base = (pointer)p->sw_table;
4767 	pointer im_base = (pointer)p->im_table;
4768 
4769 	for(;ip0 < ep; ip0 += 1, op0 += 4) {
4770 		unsigned int ova0;	/* Output value accumulator */
4771 		unsigned int ova1;	/* Output value accumulator */
4772 		{
4773 			pointer swp;
4774 			pointer imp;
4775 			{
4776 				unsigned int ti;	/* Simplex+Interpolation index variable */
4777 
4778 				ti  = IT_IT(it0, ip0[0]);
4779 
4780 				imp = im_base + IM_O(ti >> 0);		/* Extract interp. index and comp. entry */
4781 				swp = sw_base + SW_O(ti & 0x0);	/* Extract simplex index and comp. entry */
4782 			}
4783 			{
4784 				unsigned int vowr;	/* Vertex offset/weight value */
4785 				unsigned int vof;	/* Vertex offset value */
4786 				unsigned int vwe;	/* Vertex weighting */
4787 
4788 				vowr = SX_WO(swp, 0);	/* Read vertex offset+weighting values */
4789 				vof = (vowr & 0x7f);	/* Extract offset value */
4790 				vwe = (vowr >> 7);	/* Extract weighting value */
4791 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
4792 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
4793 				vowr = SX_WO(swp, 1);	/* Read vertex offset+weighting values */
4794 				vof = (vowr & 0x7f);	/* Extract offset value */
4795 				vwe = (vowr >> 7);	/* Extract weighting value */
4796 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
4797 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
4798 			}
4799 		}
4800 		{
4801 			unsigned int oti;	/* Vertex offset value */
4802 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
4803 			op0[0] = OT_E(ot0, oti);	/* Write result */
4804 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
4805 			op0[1] = OT_E(ot1, oti);	/* Write result */
4806 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
4807 			op0[2] = OT_E(ot2, oti);	/* Write result */
4808 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
4809 			op0[3] = OT_E(ot3, oti);	/* Write result */
4810 		}
4811 	}
4812 }
4813 #undef IT_IT
4814 #undef SW_O
4815 #undef SX_WO
4816 #undef IM_O
4817 #undef IM_FE
4818 #undef OT_E
4819 
4820 void
imdi_k15_gen(genspec * g)4821 imdi_k15_gen(
4822 genspec *g			/* structure to be initialised */
4823 ) {
4824 	static unsigned char data[] = {
4825 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4826 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4827 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4828 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4829 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4830 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4831 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4832 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4833 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4834 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4835 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4836 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4837 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4838 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4839 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4840 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4841 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4842 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4843 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4844 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4845 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4846 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4847 		0x08, 0x00, 0x00, 0x00, 0x4c, 0x69, 0x6e, 0x75,
4848 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4849 		0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
4850 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
4851 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4852 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4853 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4854 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4855 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
4856 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
4857 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4858 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4859 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4860 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4861 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4862 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4863 		0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4864 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
4865 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
4866 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
4867 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
4868 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
4869 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
4870 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
4871 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
4872 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
4873 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4874 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
4875 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
4876 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x34, 0x5f,
4877 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
4878 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
4879 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
4880 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
4881 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
4882 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
4883 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
4884 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4885 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4886 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4887 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4888 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
4889 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x35,
4890 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4891 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4892 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
4893 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
4894 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
4895 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
4896 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
4897 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
4898 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
4899 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
4900 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
4901 		0x00, 0xf0, 0x04, 0x08
4902 	};	/* Structure image */
4903 
4904 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
4905 }
4906 
4907 void
imdi_k15_tab(tabspec * t)4908 imdi_k15_tab(
4909 tabspec *t			/* structure to be initialised */
4910 ) {
4911 	static unsigned char data[] = {
4912 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4913 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4914 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4915 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
4916 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
4917 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
4918 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4919 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
4920 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4921 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4922 		0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
4923 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4924 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
4925 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
4926 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
4927 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4928 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4929 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
4930 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4931 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4932 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
4933 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
4934 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
4935 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
4936 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4937 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4938 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
4939 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
4940 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4941 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
4942 		0x08, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
4943 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
4944 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
4945 	};	/* Structure image */
4946 
4947 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
4948 }
4949 
4950 
4951 
4952 
4953 
4954 
4955 /* Integer Multi-Dimensional Interpolation */
4956 /* Interpolation Kernel Code */
4957 /* Generated by cgen */
4958 /* Copyright 2000 - 2002 Graeme W. Gill */
4959 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
4960 
4961 /* see the Licence.txt file for licencing details.*/
4962 
4963 
4964 /*
4965    Interpolation kernel specs:
4966 
4967    Input channels per pixel = 3
4968    Input channel 0 bits = 8
4969    Input channel 0 increment = 3
4970    Input channel 1 bits = 8
4971    Input channel 1 increment = 3
4972    Input channel 2 bits = 8
4973    Input channel 2 increment = 3
4974    Input is channel interleaved
4975    Input channels are separate words
4976    Input value extraction is done in input table lookup
4977 
4978    Output channels per pixel = 4
4979    Output channel 0 bits = 8
4980    Output channel 0 increment = 4
4981    Output channel 1 bits = 8
4982    Output channel 1 increment = 4
4983    Output channel 2 bits = 8
4984    Output channel 2 increment = 4
4985    Output channel 3 bits = 8
4986    Output channel 3 increment = 4
4987    Output is channel interleaved
4988 
4989    Output channels are separate words
4990    Simplex table index bits       = 12
4991    Interpolation table index bits = 20
4992    Simplex table max resolution = 16
4993    Interpolation table max resolution = 101
4994  */
4995 
4996 /*
4997    Machine architecture specs:
4998 
4999    Little endian
5000    Reading and writing pixel values separately
5001    Pointer size = 32 bits
5002 
5003    Ordinal size  8 bits is known as 'unsigned char'
5004    Ordinal size 16 bits is known as 'unsigned short'
5005    Ordinal size 32 bits is known as 'unsigned int'
5006    Natural ordinal is 'unsigned int'
5007 
5008    Integer size  8 bits is known as 'signed char'
5009    Integer size 16 bits is known as 'short'
5010    Integer size 32 bits is known as 'int'
5011    Natural integer is 'int'
5012 
5013  */
5014 
5015 #ifndef  IMDI_INCLUDED
5016 #include <memory.h>
5017 #include "imdi_imp.h"
5018 #define  IMDI_INCLUDED
5019 #endif  /* IMDI_INCLUDED */
5020 
5021 #ifndef DEFINED_pointer
5022 #define DEFINED_pointer
5023 typedef unsigned char * pointer;
5024 #endif
5025 
5026 /* Input table inter & simplex indexes */
5027 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
5028 
5029 /* Simplex weighting table access */
5030 #define SW_O(off) ((off) * 16)
5031 
5032 /* Simplex table - get weighting value */
5033 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
5034 
5035 /* Simplex table - get offset value */
5036 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
5037 
5038 /* Interpolation multi-dim. table access */
5039 #define IM_O(off) ((off) * 8)
5040 
5041 /* Interpolation table - get vertex values */
5042 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
5043 
5044 /* Output table indexes */
5045 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
5046 
5047 void
imdi_k16(imdi * s,void ** outp,void ** inp,unsigned int npix)5048 imdi_k16(
5049 imdi *s,			/* imdi context */
5050 void **outp,		/* pointer to output pointers */
5051 void **inp,		/* pointer to input pointers */
5052 unsigned int npix	/* Number of pixels to process */
5053 ) {
5054 	imdi_imp *p = (imdi_imp *)(s->impl);
5055 	unsigned char *ip0 = (unsigned char *)inp[0];
5056 	unsigned char *op0 = (unsigned char *)outp[0];
5057 	unsigned char *ep = ip0 + npix * 3 ;
5058 	pointer it0 = (pointer)p->in_tables[0];
5059 	pointer it1 = (pointer)p->in_tables[1];
5060 	pointer it2 = (pointer)p->in_tables[2];
5061 	pointer ot0 = (pointer)p->out_tables[0];
5062 	pointer ot1 = (pointer)p->out_tables[1];
5063 	pointer ot2 = (pointer)p->out_tables[2];
5064 	pointer ot3 = (pointer)p->out_tables[3];
5065 	pointer sw_base = (pointer)p->sw_table;
5066 	pointer im_base = (pointer)p->im_table;
5067 
5068 	for(;ip0 < ep; ip0 += 3, op0 += 4) {
5069 		unsigned int ova0;	/* Output value accumulator */
5070 		unsigned int ova1;	/* Output value accumulator */
5071 		{
5072 			pointer swp;
5073 			pointer imp;
5074 			{
5075 				unsigned int ti;	/* Simplex+Interpolation index variable */
5076 
5077 				ti  = IT_IT(it0, ip0[0]);
5078 				ti += IT_IT(it1, ip0[1]);
5079 				ti += IT_IT(it2, ip0[2]);
5080 
5081 				imp = im_base + IM_O(ti >> 12);		/* Extract interp. index and comp. entry */
5082 				swp = sw_base + SW_O(ti & 0xfff);	/* Extract simplex index and comp. entry */
5083 			}
5084 			{
5085 				unsigned int vof;	/* Vertex offset value */
5086 				unsigned int vwe;	/* Vertex weighting */
5087 
5088 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
5089 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
5090 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
5091 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
5092 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
5093 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
5094 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
5095 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
5096 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
5097 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
5098 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
5099 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
5100 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
5101 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
5102 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
5103 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
5104 			}
5105 		}
5106 		{
5107 			unsigned int oti;	/* Vertex offset value */
5108 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
5109 			op0[0] = OT_E(ot0, oti);	/* Write result */
5110 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
5111 			op0[1] = OT_E(ot1, oti);	/* Write result */
5112 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
5113 			op0[2] = OT_E(ot2, oti);	/* Write result */
5114 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
5115 			op0[3] = OT_E(ot3, oti);	/* Write result */
5116 		}
5117 	}
5118 }
5119 #undef IT_IT
5120 #undef SW_O
5121 #undef SX_WE
5122 #undef SX_VO
5123 #undef IM_O
5124 #undef IM_FE
5125 #undef OT_E
5126 
5127 void
imdi_k16_gen(genspec * g)5128 imdi_k16_gen(
5129 genspec *g			/* structure to be initialised */
5130 ) {
5131 	static unsigned char data[] = {
5132 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
5133 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5134 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5135 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5136 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5137 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5138 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5139 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
5140 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
5141 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5142 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5143 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5144 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5145 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5146 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5147 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5148 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5149 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5150 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5151 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5152 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5153 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5154 		0x08, 0x00, 0x00, 0x00, 0x4c, 0x69, 0x6e, 0x75,
5155 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5156 		0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
5157 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
5158 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5159 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5160 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5161 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5162 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
5163 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
5164 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5165 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5166 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5167 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5168 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5169 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5170 		0x65, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
5171 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
5172 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
5173 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
5174 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
5175 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
5176 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
5177 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
5178 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
5179 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
5180 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5181 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
5182 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
5183 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x34, 0x5f,
5184 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
5185 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
5186 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
5187 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
5188 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
5189 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
5190 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
5191 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5192 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5193 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5194 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5195 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
5196 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x36,
5197 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5198 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5199 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
5200 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
5201 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
5202 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
5203 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
5204 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
5205 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
5206 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
5207 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
5208 		0x00, 0xf0, 0x04, 0x08
5209 	};	/* Structure image */
5210 
5211 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
5212 }
5213 
5214 void
imdi_k16_tab(tabspec * t)5215 imdi_k16_tab(
5216 tabspec *t			/* structure to be initialised */
5217 ) {
5218 	static unsigned char data[] = {
5219 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5220 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5221 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5222 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
5223 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
5224 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
5225 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
5226 		0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
5227 		0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
5228 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5229 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
5230 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5231 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
5232 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
5233 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
5234 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5235 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5236 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
5237 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5238 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5239 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5240 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
5241 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
5242 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
5243 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5244 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5245 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
5246 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
5247 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5248 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5249 		0x08, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
5250 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
5251 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
5252 	};	/* Structure image */
5253 
5254 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
5255 }
5256 
5257 
5258 
5259 
5260 
5261 
5262 /* Integer Multi-Dimensional Interpolation */
5263 /* Interpolation Kernel Code */
5264 /* Generated by cgen */
5265 /* Copyright 2000 - 2002 Graeme W. Gill */
5266 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
5267 
5268 /* see the Licence.txt file for licencing details.*/
5269 
5270 
5271 /*
5272    Interpolation kernel specs:
5273 
5274    Input channels per pixel = 4
5275    Input channel 0 bits = 8
5276    Input channel 0 increment = 4
5277    Input channel 1 bits = 8
5278    Input channel 1 increment = 4
5279    Input channel 2 bits = 8
5280    Input channel 2 increment = 4
5281    Input channel 3 bits = 8
5282    Input channel 3 increment = 4
5283    Input is channel interleaved
5284    Input channels are separate words
5285    Input value extraction is done in input table lookup
5286 
5287    Output channels per pixel = 4
5288    Output channel 0 bits = 8
5289    Output channel 0 increment = 4
5290    Output channel 1 bits = 8
5291    Output channel 1 increment = 4
5292    Output channel 2 bits = 8
5293    Output channel 2 increment = 4
5294    Output channel 3 bits = 8
5295    Output channel 3 increment = 4
5296    Output is channel interleaved
5297 
5298    Output channels are separate words
5299    Simplex table index bits       = 32
5300    Interpolation table index bits = 32
5301    Simplex table max resolution = 255
5302    Interpolation table max resolution = 39
5303  */
5304 
5305 /*
5306    Machine architecture specs:
5307 
5308    Little endian
5309    Reading and writing pixel values separately
5310    Pointer size = 32 bits
5311 
5312    Ordinal size  8 bits is known as 'unsigned char'
5313    Ordinal size 16 bits is known as 'unsigned short'
5314    Ordinal size 32 bits is known as 'unsigned int'
5315    Natural ordinal is 'unsigned int'
5316 
5317    Integer size  8 bits is known as 'signed char'
5318    Integer size 16 bits is known as 'short'
5319    Integer size 32 bits is known as 'int'
5320    Natural integer is 'int'
5321 
5322  */
5323 
5324 #ifndef  IMDI_INCLUDED
5325 #include <memory.h>
5326 #include "imdi_imp.h"
5327 #define  IMDI_INCLUDED
5328 #endif  /* IMDI_INCLUDED */
5329 
5330 #ifndef DEFINED_pointer
5331 #define DEFINED_pointer
5332 typedef unsigned char * pointer;
5333 #endif
5334 
5335 /* Input table interp. index */
5336 #define IT_IX(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
5337 
5338 /* Input table simplex index enty */
5339 #define IT_SX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
5340 
5341 /* Simplex weighting table access */
5342 #define SW_O(off) ((off) * 20)
5343 
5344 /* Simplex table - get weighting value */
5345 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
5346 
5347 /* Simplex table - get offset value */
5348 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
5349 
5350 /* Interpolation multi-dim. table access */
5351 #define IM_O(off) ((off) * 8)
5352 
5353 /* Interpolation table - get vertex values */
5354 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
5355 
5356 /* Output table indexes */
5357 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
5358 
5359 void
imdi_k17(imdi * s,void ** outp,void ** inp,unsigned int npix)5360 imdi_k17(
5361 imdi *s,			/* imdi context */
5362 void **outp,		/* pointer to output pointers */
5363 void **inp,		/* pointer to input pointers */
5364 unsigned int npix	/* Number of pixels to process */
5365 ) {
5366 	imdi_imp *p = (imdi_imp *)(s->impl);
5367 	unsigned char *ip0 = (unsigned char *)inp[0];
5368 	unsigned char *op0 = (unsigned char *)outp[0];
5369 	unsigned char *ep = ip0 + npix * 4 ;
5370 	pointer it0 = (pointer)p->in_tables[0];
5371 	pointer it1 = (pointer)p->in_tables[1];
5372 	pointer it2 = (pointer)p->in_tables[2];
5373 	pointer it3 = (pointer)p->in_tables[3];
5374 	pointer ot0 = (pointer)p->out_tables[0];
5375 	pointer ot1 = (pointer)p->out_tables[1];
5376 	pointer ot2 = (pointer)p->out_tables[2];
5377 	pointer ot3 = (pointer)p->out_tables[3];
5378 	pointer sw_base = (pointer)p->sw_table;
5379 	pointer im_base = (pointer)p->im_table;
5380 
5381 	for(;ip0 < ep; ip0 += 4, op0 += 4) {
5382 		unsigned int ova0;	/* Output value accumulator */
5383 		unsigned int ova1;	/* Output value accumulator */
5384 		{
5385 			pointer swp;
5386 			pointer imp;
5387 			{
5388 				unsigned int ti_s;	/* Simplex index variable */
5389 				unsigned int ti_i;	/* Interpolation index variable */
5390 
5391 				ti_i  = IT_IX(it0, ip0[0]);
5392 				ti_s  = IT_SX(it0, ip0[0]);
5393 				ti_i += IT_IX(it1, ip0[1]);
5394 				ti_s += IT_SX(it1, ip0[1]);
5395 				ti_i += IT_IX(it2, ip0[2]);
5396 				ti_s += IT_SX(it2, ip0[2]);
5397 				ti_i += IT_IX(it3, ip0[3]);
5398 				ti_s += IT_SX(it3, ip0[3]);
5399 
5400 				swp = sw_base + SW_O(ti_s);		/* Compute simplex table entry pointer */
5401 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
5402 			}
5403 			{
5404 				unsigned int vof;	/* Vertex offset value */
5405 				unsigned int vwe;	/* Vertex weighting */
5406 
5407 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
5408 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
5409 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
5410 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
5411 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
5412 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
5413 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
5414 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
5415 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
5416 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
5417 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
5418 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
5419 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
5420 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
5421 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
5422 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
5423 				vof = SX_VO(swp, 4);	/* Read vertex offset value */
5424 				vwe = SX_WE(swp, 4);	/* Read vertex weighting value */
5425 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
5426 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
5427 			}
5428 		}
5429 		{
5430 			unsigned int oti;	/* Vertex offset value */
5431 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
5432 			op0[0] = OT_E(ot0, oti);	/* Write result */
5433 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
5434 			op0[1] = OT_E(ot1, oti);	/* Write result */
5435 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
5436 			op0[2] = OT_E(ot2, oti);	/* Write result */
5437 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
5438 			op0[3] = OT_E(ot3, oti);	/* Write result */
5439 		}
5440 	}
5441 }
5442 #undef IT_IX
5443 #undef IT_SX
5444 #undef SW_O
5445 #undef SX_WE
5446 #undef SX_VO
5447 #undef IM_O
5448 #undef IM_FE
5449 #undef OT_E
5450 
5451 void
imdi_k17_gen(genspec * g)5452 imdi_k17_gen(
5453 genspec *g			/* structure to be initialised */
5454 ) {
5455 	static unsigned char data[] = {
5456 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
5457 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5458 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5459 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5460 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5461 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5462 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5463 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
5464 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
5465 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5466 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5467 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5468 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5469 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5470 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5471 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5472 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5473 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5474 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5475 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5476 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5477 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5478 		0x08, 0x00, 0x00, 0x00, 0x4c, 0x69, 0x6e, 0x75,
5479 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5480 		0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
5481 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
5482 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5483 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5484 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5485 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5486 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
5487 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
5488 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5489 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5490 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5491 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5492 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5493 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5494 		0x27, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
5495 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
5496 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
5497 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
5498 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
5499 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
5500 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
5501 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
5502 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
5503 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
5504 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5505 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
5506 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
5507 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x34, 0x5f,
5508 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
5509 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
5510 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
5511 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
5512 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
5513 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
5514 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
5515 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5516 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5517 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5518 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5519 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
5520 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x37,
5521 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5522 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5523 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
5524 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
5525 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
5526 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
5527 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
5528 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
5529 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
5530 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
5531 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
5532 		0x00, 0xf0, 0x04, 0x08
5533 	};	/* Structure image */
5534 
5535 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
5536 }
5537 
5538 void
imdi_k17_tab(tabspec * t)5539 imdi_k17_tab(
5540 tabspec *t			/* structure to be initialised */
5541 ) {
5542 	static unsigned char data[] = {
5543 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5544 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5545 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5546 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
5547 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
5548 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
5549 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5550 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
5551 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
5552 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5553 		0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
5554 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5555 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
5556 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
5557 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
5558 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5559 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5560 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
5561 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5562 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5563 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5564 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
5565 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
5566 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
5567 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5568 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5569 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
5570 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
5571 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5572 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5573 		0x08, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
5574 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
5575 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
5576 	};	/* Structure image */
5577 
5578 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
5579 }
5580 
5581 
5582 
5583 
5584 
5585 
5586 /* Integer Multi-Dimensional Interpolation */
5587 /* Interpolation Kernel Code */
5588 /* Generated by cgen */
5589 /* Copyright 2000 - 2002 Graeme W. Gill */
5590 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
5591 
5592 /* see the Licence.txt file for licencing details.*/
5593 
5594 
5595 /*
5596    Interpolation kernel specs:
5597 
5598    Input channels per pixel = 5
5599    Input channel 0 bits = 8
5600    Input channel 0 increment = 5
5601    Input channel 1 bits = 8
5602    Input channel 1 increment = 5
5603    Input channel 2 bits = 8
5604    Input channel 2 increment = 5
5605    Input channel 3 bits = 8
5606    Input channel 3 increment = 5
5607    Input channel 4 bits = 8
5608    Input channel 4 increment = 5
5609    Input is channel interleaved
5610    Input channels are separate words
5611    Input value extraction is done in input table lookup
5612 
5613    Output channels per pixel = 4
5614    Output channel 0 bits = 8
5615    Output channel 0 increment = 4
5616    Output channel 1 bits = 8
5617    Output channel 1 increment = 4
5618    Output channel 2 bits = 8
5619    Output channel 2 increment = 4
5620    Output channel 3 bits = 8
5621    Output channel 3 increment = 4
5622    Output is channel interleaved
5623 
5624    Output channels are separate words
5625    Weight+voffset bits       = 32
5626    Interpolation table index bits = 32
5627    Interpolation table max resolution = 53
5628  */
5629 
5630 /*
5631    Machine architecture specs:
5632 
5633    Little endian
5634    Reading and writing pixel values separately
5635    Pointer size = 32 bits
5636 
5637    Ordinal size  8 bits is known as 'unsigned char'
5638    Ordinal size 16 bits is known as 'unsigned short'
5639    Ordinal size 32 bits is known as 'unsigned int'
5640    Natural ordinal is 'unsigned int'
5641 
5642    Integer size  8 bits is known as 'signed char'
5643    Integer size 16 bits is known as 'short'
5644    Integer size 32 bits is known as 'int'
5645    Natural integer is 'int'
5646 
5647  */
5648 
5649 #ifndef  IMDI_INCLUDED
5650 #include <memory.h>
5651 #include "imdi_imp.h"
5652 #define  IMDI_INCLUDED
5653 #endif  /* IMDI_INCLUDED */
5654 
5655 #ifndef DEFINED_pointer
5656 #define DEFINED_pointer
5657 typedef unsigned char * pointer;
5658 #endif
5659 
5660 /* Input table interp. index */
5661 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
5662 
5663 /* Input table input weighting/offset value enty */
5664 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
5665 
5666 /* Conditional exchange for sorting */
5667 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
5668 
5669 /* Interpolation multi-dim. table access */
5670 #define IM_O(off) ((off) * 8)
5671 
5672 /* Interpolation table - get vertex values */
5673 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
5674 
5675 /* Output table indexes */
5676 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
5677 
5678 void
imdi_k18(imdi * s,void ** outp,void ** inp,unsigned int npix)5679 imdi_k18(
5680 imdi *s,			/* imdi context */
5681 void **outp,		/* pointer to output pointers */
5682 void **inp,		/* pointer to input pointers */
5683 unsigned int npix	/* Number of pixels to process */
5684 ) {
5685 	imdi_imp *p = (imdi_imp *)(s->impl);
5686 	unsigned char *ip0 = (unsigned char *)inp[0];
5687 	unsigned char *op0 = (unsigned char *)outp[0];
5688 	unsigned char *ep = ip0 + npix * 5 ;
5689 	pointer it0 = (pointer)p->in_tables[0];
5690 	pointer it1 = (pointer)p->in_tables[1];
5691 	pointer it2 = (pointer)p->in_tables[2];
5692 	pointer it3 = (pointer)p->in_tables[3];
5693 	pointer it4 = (pointer)p->in_tables[4];
5694 	pointer ot0 = (pointer)p->out_tables[0];
5695 	pointer ot1 = (pointer)p->out_tables[1];
5696 	pointer ot2 = (pointer)p->out_tables[2];
5697 	pointer ot3 = (pointer)p->out_tables[3];
5698 	pointer im_base = (pointer)p->im_table;
5699 
5700 	for(;ip0 < ep; ip0 += 5, op0 += 4) {
5701 		unsigned int ova0;	/* Output value accumulator */
5702 		unsigned int ova1;	/* Output value accumulator */
5703 		{
5704 			pointer imp;
5705 			unsigned int wo0;	/* Weighting value and vertex offset variable */
5706 			unsigned int wo1;	/* Weighting value and vertex offset variable */
5707 			unsigned int wo2;	/* Weighting value and vertex offset variable */
5708 			unsigned int wo3;	/* Weighting value and vertex offset variable */
5709 			unsigned int wo4;	/* Weighting value and vertex offset variable */
5710 			{
5711 				unsigned int ti_i;	/* Interpolation index variable */
5712 
5713 				ti_i  = IT_IX(it0, ip0[0]);
5714 				wo0   = IT_WO(it0, ip0[0]);
5715 				ti_i += IT_IX(it1, ip0[1]);
5716 				wo1   = IT_WO(it1, ip0[1]);
5717 				ti_i += IT_IX(it2, ip0[2]);
5718 				wo2   = IT_WO(it2, ip0[2]);
5719 				ti_i += IT_IX(it3, ip0[3]);
5720 				wo3   = IT_WO(it3, ip0[3]);
5721 				ti_i += IT_IX(it4, ip0[4]);
5722 				wo4   = IT_WO(it4, ip0[4]);
5723 
5724 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
5725 
5726 				/* Sort weighting values and vertex offset values */
5727 				CEX(wo0, wo1);
5728 				CEX(wo0, wo2);
5729 				CEX(wo0, wo3);
5730 				CEX(wo0, wo4);
5731 				CEX(wo1, wo2);
5732 				CEX(wo1, wo3);
5733 				CEX(wo1, wo4);
5734 				CEX(wo2, wo3);
5735 				CEX(wo2, wo4);
5736 				CEX(wo3, wo4);
5737 			}
5738 			{
5739 				unsigned int nvof;	/* Next vertex offset value */
5740 				unsigned int vof;	/* Vertex offset value */
5741 				unsigned int vwe;	/* Vertex weighting */
5742 
5743 				vof = 0;				/* First vertex offset is 0 */
5744 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
5745 				wo0 = (wo0 >> 23);		/* Extract weighting value */
5746 				vwe = 256 - wo0;		/* Baricentric weighting */
5747 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
5748 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
5749 				vof += nvof;			/* Move to next vertex */
5750 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
5751 				wo1 = (wo1 >> 23);		/* Extract weighting value */
5752 				vwe = wo0 - wo1;		/* Baricentric weighting */
5753 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
5754 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
5755 				vof += nvof;			/* Move to next vertex */
5756 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
5757 				wo2 = (wo2 >> 23);		/* Extract weighting value */
5758 				vwe = wo1 - wo2;		/* Baricentric weighting */
5759 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
5760 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
5761 				vof += nvof;			/* Move to next vertex */
5762 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
5763 				wo3 = (wo3 >> 23);		/* Extract weighting value */
5764 				vwe = wo2 - wo3;		/* Baricentric weighting */
5765 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
5766 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
5767 				vof += nvof;			/* Move to next vertex */
5768 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
5769 				wo4 = (wo4 >> 23);		/* Extract weighting value */
5770 				vwe = wo3 - wo4;		/* Baricentric weighting */
5771 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
5772 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
5773 				vof += nvof;			/* Move to next vertex */
5774 				vwe = wo4;				/* Baricentric weighting */
5775 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
5776 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
5777 			}
5778 		}
5779 		{
5780 			unsigned int oti;	/* Vertex offset value */
5781 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
5782 			op0[0] = OT_E(ot0, oti);	/* Write result */
5783 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
5784 			op0[1] = OT_E(ot1, oti);	/* Write result */
5785 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
5786 			op0[2] = OT_E(ot2, oti);	/* Write result */
5787 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
5788 			op0[3] = OT_E(ot3, oti);	/* Write result */
5789 		}
5790 	}
5791 }
5792 #undef IT_WO
5793 #undef IT_IX
5794 #undef CEX
5795 #undef IM_O
5796 #undef IM_FE
5797 #undef OT_E
5798 
5799 void
imdi_k18_gen(genspec * g)5800 imdi_k18_gen(
5801 genspec *g			/* structure to be initialised */
5802 ) {
5803 	static unsigned char data[] = {
5804 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
5805 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5806 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5807 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5808 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5809 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5810 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5811 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
5812 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
5813 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
5814 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5815 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5816 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5817 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5818 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5819 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5820 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5821 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5822 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5823 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5824 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5825 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5826 		0x08, 0x00, 0x00, 0x00, 0x4c, 0x69, 0x6e, 0x75,
5827 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5828 		0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
5829 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
5830 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5831 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5832 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5833 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5834 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
5835 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
5836 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5837 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5838 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5839 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5840 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5841 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5842 		0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5843 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
5844 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
5845 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
5846 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
5847 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
5848 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
5849 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
5850 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
5851 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
5852 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5853 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
5854 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
5855 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x34, 0x5f,
5856 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
5857 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
5858 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
5859 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
5860 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
5861 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
5862 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
5863 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5864 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5865 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5866 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5867 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
5868 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x38,
5869 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5870 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5871 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
5872 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
5873 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
5874 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
5875 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
5876 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
5877 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
5878 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
5879 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
5880 		0x00, 0xf0, 0x04, 0x08
5881 	};	/* Structure image */
5882 
5883 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
5884 }
5885 
5886 void
imdi_k18_tab(tabspec * t)5887 imdi_k18_tab(
5888 tabspec *t			/* structure to be initialised */
5889 ) {
5890 	static unsigned char data[] = {
5891 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5892 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5893 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5894 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
5895 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
5896 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
5897 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5898 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
5899 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
5900 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5901 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
5902 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
5903 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
5904 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
5905 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
5906 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5907 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5908 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
5909 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5910 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5911 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
5912 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
5913 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
5914 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
5915 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5916 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5917 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
5918 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
5919 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5920 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
5921 		0x08, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
5922 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
5923 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
5924 	};	/* Structure image */
5925 
5926 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
5927 }
5928 
5929 
5930 
5931 
5932 
5933 
5934 /* Integer Multi-Dimensional Interpolation */
5935 /* Interpolation Kernel Code */
5936 /* Generated by cgen */
5937 /* Copyright 2000 - 2002 Graeme W. Gill */
5938 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
5939 
5940 /* see the Licence.txt file for licencing details.*/
5941 
5942 
5943 /*
5944    Interpolation kernel specs:
5945 
5946    Input channels per pixel = 6
5947    Input channel 0 bits = 8
5948    Input channel 0 increment = 6
5949    Input channel 1 bits = 8
5950    Input channel 1 increment = 6
5951    Input channel 2 bits = 8
5952    Input channel 2 increment = 6
5953    Input channel 3 bits = 8
5954    Input channel 3 increment = 6
5955    Input channel 4 bits = 8
5956    Input channel 4 increment = 6
5957    Input channel 5 bits = 8
5958    Input channel 5 increment = 6
5959    Input is channel interleaved
5960    Input channels are separate words
5961    Input value extraction is done in input table lookup
5962 
5963    Output channels per pixel = 4
5964    Output channel 0 bits = 8
5965    Output channel 0 increment = 4
5966    Output channel 1 bits = 8
5967    Output channel 1 increment = 4
5968    Output channel 2 bits = 8
5969    Output channel 2 increment = 4
5970    Output channel 3 bits = 8
5971    Output channel 3 increment = 4
5972    Output is channel interleaved
5973 
5974    Output channels are separate words
5975    Weight+voffset bits       = 32
5976    Interpolation table index bits = 32
5977    Interpolation table max resolution = 24
5978  */
5979 
5980 /*
5981    Machine architecture specs:
5982 
5983    Little endian
5984    Reading and writing pixel values separately
5985    Pointer size = 32 bits
5986 
5987    Ordinal size  8 bits is known as 'unsigned char'
5988    Ordinal size 16 bits is known as 'unsigned short'
5989    Ordinal size 32 bits is known as 'unsigned int'
5990    Natural ordinal is 'unsigned int'
5991 
5992    Integer size  8 bits is known as 'signed char'
5993    Integer size 16 bits is known as 'short'
5994    Integer size 32 bits is known as 'int'
5995    Natural integer is 'int'
5996 
5997  */
5998 
5999 #ifndef  IMDI_INCLUDED
6000 #include <memory.h>
6001 #include "imdi_imp.h"
6002 #define  IMDI_INCLUDED
6003 #endif  /* IMDI_INCLUDED */
6004 
6005 #ifndef DEFINED_pointer
6006 #define DEFINED_pointer
6007 typedef unsigned char * pointer;
6008 #endif
6009 
6010 /* Input table interp. index */
6011 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
6012 
6013 /* Input table input weighting/offset value enty */
6014 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
6015 
6016 /* Conditional exchange for sorting */
6017 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
6018 
6019 /* Interpolation multi-dim. table access */
6020 #define IM_O(off) ((off) * 8)
6021 
6022 /* Interpolation table - get vertex values */
6023 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
6024 
6025 /* Output table indexes */
6026 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
6027 
6028 void
imdi_k19(imdi * s,void ** outp,void ** inp,unsigned int npix)6029 imdi_k19(
6030 imdi *s,			/* imdi context */
6031 void **outp,		/* pointer to output pointers */
6032 void **inp,		/* pointer to input pointers */
6033 unsigned int npix	/* Number of pixels to process */
6034 ) {
6035 	imdi_imp *p = (imdi_imp *)(s->impl);
6036 	unsigned char *ip0 = (unsigned char *)inp[0];
6037 	unsigned char *op0 = (unsigned char *)outp[0];
6038 	unsigned char *ep = ip0 + npix * 6 ;
6039 	pointer it0 = (pointer)p->in_tables[0];
6040 	pointer it1 = (pointer)p->in_tables[1];
6041 	pointer it2 = (pointer)p->in_tables[2];
6042 	pointer it3 = (pointer)p->in_tables[3];
6043 	pointer it4 = (pointer)p->in_tables[4];
6044 	pointer it5 = (pointer)p->in_tables[5];
6045 	pointer ot0 = (pointer)p->out_tables[0];
6046 	pointer ot1 = (pointer)p->out_tables[1];
6047 	pointer ot2 = (pointer)p->out_tables[2];
6048 	pointer ot3 = (pointer)p->out_tables[3];
6049 	pointer im_base = (pointer)p->im_table;
6050 
6051 	for(;ip0 < ep; ip0 += 6, op0 += 4) {
6052 		unsigned int ova0;	/* Output value accumulator */
6053 		unsigned int ova1;	/* Output value accumulator */
6054 		{
6055 			pointer imp;
6056 			unsigned int wo0;	/* Weighting value and vertex offset variable */
6057 			unsigned int wo1;	/* Weighting value and vertex offset variable */
6058 			unsigned int wo2;	/* Weighting value and vertex offset variable */
6059 			unsigned int wo3;	/* Weighting value and vertex offset variable */
6060 			unsigned int wo4;	/* Weighting value and vertex offset variable */
6061 			unsigned int wo5;	/* Weighting value and vertex offset variable */
6062 			{
6063 				unsigned int ti_i;	/* Interpolation index variable */
6064 
6065 				ti_i  = IT_IX(it0, ip0[0]);
6066 				wo0   = IT_WO(it0, ip0[0]);
6067 				ti_i += IT_IX(it1, ip0[1]);
6068 				wo1   = IT_WO(it1, ip0[1]);
6069 				ti_i += IT_IX(it2, ip0[2]);
6070 				wo2   = IT_WO(it2, ip0[2]);
6071 				ti_i += IT_IX(it3, ip0[3]);
6072 				wo3   = IT_WO(it3, ip0[3]);
6073 				ti_i += IT_IX(it4, ip0[4]);
6074 				wo4   = IT_WO(it4, ip0[4]);
6075 				ti_i += IT_IX(it5, ip0[5]);
6076 				wo5   = IT_WO(it5, ip0[5]);
6077 
6078 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
6079 
6080 				/* Sort weighting values and vertex offset values */
6081 				CEX(wo0, wo1);
6082 				CEX(wo0, wo2);
6083 				CEX(wo0, wo3);
6084 				CEX(wo0, wo4);
6085 				CEX(wo0, wo5);
6086 				CEX(wo1, wo2);
6087 				CEX(wo1, wo3);
6088 				CEX(wo1, wo4);
6089 				CEX(wo1, wo5);
6090 				CEX(wo2, wo3);
6091 				CEX(wo2, wo4);
6092 				CEX(wo2, wo5);
6093 				CEX(wo3, wo4);
6094 				CEX(wo3, wo5);
6095 				CEX(wo4, wo5);
6096 			}
6097 			{
6098 				unsigned int nvof;	/* Next vertex offset value */
6099 				unsigned int vof;	/* Vertex offset value */
6100 				unsigned int vwe;	/* Vertex weighting */
6101 
6102 				vof = 0;				/* First vertex offset is 0 */
6103 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
6104 				wo0 = (wo0 >> 23);		/* Extract weighting value */
6105 				vwe = 256 - wo0;		/* Baricentric weighting */
6106 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6107 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6108 				vof += nvof;			/* Move to next vertex */
6109 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
6110 				wo1 = (wo1 >> 23);		/* Extract weighting value */
6111 				vwe = wo0 - wo1;		/* Baricentric weighting */
6112 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6113 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6114 				vof += nvof;			/* Move to next vertex */
6115 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
6116 				wo2 = (wo2 >> 23);		/* Extract weighting value */
6117 				vwe = wo1 - wo2;		/* Baricentric weighting */
6118 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6119 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6120 				vof += nvof;			/* Move to next vertex */
6121 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
6122 				wo3 = (wo3 >> 23);		/* Extract weighting value */
6123 				vwe = wo2 - wo3;		/* Baricentric weighting */
6124 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6125 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6126 				vof += nvof;			/* Move to next vertex */
6127 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
6128 				wo4 = (wo4 >> 23);		/* Extract weighting value */
6129 				vwe = wo3 - wo4;		/* Baricentric weighting */
6130 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6131 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6132 				vof += nvof;			/* Move to next vertex */
6133 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
6134 				wo5 = (wo5 >> 23);		/* Extract weighting value */
6135 				vwe = wo4 - wo5;		/* Baricentric weighting */
6136 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6137 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6138 				vof += nvof;			/* Move to next vertex */
6139 				vwe = wo5;				/* Baricentric weighting */
6140 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6141 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6142 			}
6143 		}
6144 		{
6145 			unsigned int oti;	/* Vertex offset value */
6146 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
6147 			op0[0] = OT_E(ot0, oti);	/* Write result */
6148 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
6149 			op0[1] = OT_E(ot1, oti);	/* Write result */
6150 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
6151 			op0[2] = OT_E(ot2, oti);	/* Write result */
6152 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
6153 			op0[3] = OT_E(ot3, oti);	/* Write result */
6154 		}
6155 	}
6156 }
6157 #undef IT_WO
6158 #undef IT_IX
6159 #undef CEX
6160 #undef IM_O
6161 #undef IM_FE
6162 #undef OT_E
6163 
6164 void
imdi_k19_gen(genspec * g)6165 imdi_k19_gen(
6166 genspec *g			/* structure to be initialised */
6167 ) {
6168 	static unsigned char data[] = {
6169 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
6170 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6171 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6172 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6173 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6174 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6175 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6176 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
6177 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
6178 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
6179 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6180 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6181 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6182 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6183 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6184 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6185 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6186 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6187 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6188 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6189 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6190 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6191 		0x08, 0x00, 0x00, 0x00, 0x4c, 0x69, 0x6e, 0x75,
6192 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6193 		0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
6194 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
6195 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6196 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6197 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6198 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6199 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
6200 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
6201 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6202 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6203 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6204 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6205 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6206 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6207 		0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6208 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
6209 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
6210 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
6211 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
6212 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
6213 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
6214 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
6215 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
6216 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
6217 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6218 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
6219 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
6220 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x34, 0x5f,
6221 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
6222 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
6223 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
6224 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
6225 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
6226 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
6227 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
6228 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6229 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6230 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6231 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6232 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
6233 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x39,
6234 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6235 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6236 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
6237 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
6238 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
6239 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
6240 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
6241 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
6242 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
6243 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
6244 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
6245 		0x00, 0xf0, 0x04, 0x08
6246 	};	/* Structure image */
6247 
6248 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
6249 }
6250 
6251 void
imdi_k19_tab(tabspec * t)6252 imdi_k19_tab(
6253 tabspec *t			/* structure to be initialised */
6254 ) {
6255 	static unsigned char data[] = {
6256 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6257 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6258 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6259 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
6260 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
6261 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
6262 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6263 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
6264 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
6265 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6266 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
6267 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
6268 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
6269 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
6270 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
6271 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6272 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6273 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
6274 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6275 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6276 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6277 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
6278 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
6279 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
6280 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6281 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6282 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
6283 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
6284 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6285 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6286 		0x08, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
6287 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
6288 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
6289 	};	/* Structure image */
6290 
6291 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
6292 }
6293 
6294 
6295 
6296 
6297 
6298 
6299 /* Integer Multi-Dimensional Interpolation */
6300 /* Interpolation Kernel Code */
6301 /* Generated by cgen */
6302 /* Copyright 2000 - 2002 Graeme W. Gill */
6303 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
6304 
6305 /* see the Licence.txt file for licencing details.*/
6306 
6307 
6308 /*
6309    Interpolation kernel specs:
6310 
6311    Input channels per pixel = 7
6312    Input channel 0 bits = 8
6313    Input channel 0 increment = 7
6314    Input channel 1 bits = 8
6315    Input channel 1 increment = 7
6316    Input channel 2 bits = 8
6317    Input channel 2 increment = 7
6318    Input channel 3 bits = 8
6319    Input channel 3 increment = 7
6320    Input channel 4 bits = 8
6321    Input channel 4 increment = 7
6322    Input channel 5 bits = 8
6323    Input channel 5 increment = 7
6324    Input channel 6 bits = 8
6325    Input channel 6 increment = 7
6326    Input is channel interleaved
6327    Input channels are separate words
6328    Input value extraction is done in input table lookup
6329 
6330    Output channels per pixel = 4
6331    Output channel 0 bits = 8
6332    Output channel 0 increment = 4
6333    Output channel 1 bits = 8
6334    Output channel 1 increment = 4
6335    Output channel 2 bits = 8
6336    Output channel 2 increment = 4
6337    Output channel 3 bits = 8
6338    Output channel 3 increment = 4
6339    Output is channel interleaved
6340 
6341    Output channels are separate words
6342    Weight+voffset bits       = 32
6343    Interpolation table index bits = 32
6344    Interpolation table max resolution = 14
6345  */
6346 
6347 /*
6348    Machine architecture specs:
6349 
6350    Little endian
6351    Reading and writing pixel values separately
6352    Pointer size = 32 bits
6353 
6354    Ordinal size  8 bits is known as 'unsigned char'
6355    Ordinal size 16 bits is known as 'unsigned short'
6356    Ordinal size 32 bits is known as 'unsigned int'
6357    Natural ordinal is 'unsigned int'
6358 
6359    Integer size  8 bits is known as 'signed char'
6360    Integer size 16 bits is known as 'short'
6361    Integer size 32 bits is known as 'int'
6362    Natural integer is 'int'
6363 
6364  */
6365 
6366 #ifndef  IMDI_INCLUDED
6367 #include <memory.h>
6368 #include "imdi_imp.h"
6369 #define  IMDI_INCLUDED
6370 #endif  /* IMDI_INCLUDED */
6371 
6372 #ifndef DEFINED_pointer
6373 #define DEFINED_pointer
6374 typedef unsigned char * pointer;
6375 #endif
6376 
6377 /* Input table interp. index */
6378 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
6379 
6380 /* Input table input weighting/offset value enty */
6381 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
6382 
6383 /* Conditional exchange for sorting */
6384 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
6385 
6386 /* Interpolation multi-dim. table access */
6387 #define IM_O(off) ((off) * 8)
6388 
6389 /* Interpolation table - get vertex values */
6390 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
6391 
6392 /* Output table indexes */
6393 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
6394 
6395 void
imdi_k20(imdi * s,void ** outp,void ** inp,unsigned int npix)6396 imdi_k20(
6397 imdi *s,			/* imdi context */
6398 void **outp,		/* pointer to output pointers */
6399 void **inp,		/* pointer to input pointers */
6400 unsigned int npix	/* Number of pixels to process */
6401 ) {
6402 	imdi_imp *p = (imdi_imp *)(s->impl);
6403 	unsigned char *ip0 = (unsigned char *)inp[0];
6404 	unsigned char *op0 = (unsigned char *)outp[0];
6405 	unsigned char *ep = ip0 + npix * 7 ;
6406 	pointer it0 = (pointer)p->in_tables[0];
6407 	pointer it1 = (pointer)p->in_tables[1];
6408 	pointer it2 = (pointer)p->in_tables[2];
6409 	pointer it3 = (pointer)p->in_tables[3];
6410 	pointer it4 = (pointer)p->in_tables[4];
6411 	pointer it5 = (pointer)p->in_tables[5];
6412 	pointer it6 = (pointer)p->in_tables[6];
6413 	pointer ot0 = (pointer)p->out_tables[0];
6414 	pointer ot1 = (pointer)p->out_tables[1];
6415 	pointer ot2 = (pointer)p->out_tables[2];
6416 	pointer ot3 = (pointer)p->out_tables[3];
6417 	pointer im_base = (pointer)p->im_table;
6418 
6419 	for(;ip0 < ep; ip0 += 7, op0 += 4) {
6420 		unsigned int ova0;	/* Output value accumulator */
6421 		unsigned int ova1;	/* Output value accumulator */
6422 		{
6423 			pointer imp;
6424 			unsigned int wo0;	/* Weighting value and vertex offset variable */
6425 			unsigned int wo1;	/* Weighting value and vertex offset variable */
6426 			unsigned int wo2;	/* Weighting value and vertex offset variable */
6427 			unsigned int wo3;	/* Weighting value and vertex offset variable */
6428 			unsigned int wo4;	/* Weighting value and vertex offset variable */
6429 			unsigned int wo5;	/* Weighting value and vertex offset variable */
6430 			unsigned int wo6;	/* Weighting value and vertex offset variable */
6431 			{
6432 				unsigned int ti_i;	/* Interpolation index variable */
6433 
6434 				ti_i  = IT_IX(it0, ip0[0]);
6435 				wo0   = IT_WO(it0, ip0[0]);
6436 				ti_i += IT_IX(it1, ip0[1]);
6437 				wo1   = IT_WO(it1, ip0[1]);
6438 				ti_i += IT_IX(it2, ip0[2]);
6439 				wo2   = IT_WO(it2, ip0[2]);
6440 				ti_i += IT_IX(it3, ip0[3]);
6441 				wo3   = IT_WO(it3, ip0[3]);
6442 				ti_i += IT_IX(it4, ip0[4]);
6443 				wo4   = IT_WO(it4, ip0[4]);
6444 				ti_i += IT_IX(it5, ip0[5]);
6445 				wo5   = IT_WO(it5, ip0[5]);
6446 				ti_i += IT_IX(it6, ip0[6]);
6447 				wo6   = IT_WO(it6, ip0[6]);
6448 
6449 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
6450 
6451 				/* Sort weighting values and vertex offset values */
6452 				CEX(wo0, wo1);
6453 				CEX(wo0, wo2);
6454 				CEX(wo0, wo3);
6455 				CEX(wo0, wo4);
6456 				CEX(wo0, wo5);
6457 				CEX(wo0, wo6);
6458 				CEX(wo1, wo2);
6459 				CEX(wo1, wo3);
6460 				CEX(wo1, wo4);
6461 				CEX(wo1, wo5);
6462 				CEX(wo1, wo6);
6463 				CEX(wo2, wo3);
6464 				CEX(wo2, wo4);
6465 				CEX(wo2, wo5);
6466 				CEX(wo2, wo6);
6467 				CEX(wo3, wo4);
6468 				CEX(wo3, wo5);
6469 				CEX(wo3, wo6);
6470 				CEX(wo4, wo5);
6471 				CEX(wo4, wo6);
6472 				CEX(wo5, wo6);
6473 			}
6474 			{
6475 				unsigned int nvof;	/* Next vertex offset value */
6476 				unsigned int vof;	/* Vertex offset value */
6477 				unsigned int vwe;	/* Vertex weighting */
6478 
6479 				vof = 0;				/* First vertex offset is 0 */
6480 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
6481 				wo0 = (wo0 >> 23);		/* Extract weighting value */
6482 				vwe = 256 - wo0;		/* Baricentric weighting */
6483 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6484 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6485 				vof += nvof;			/* Move to next vertex */
6486 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
6487 				wo1 = (wo1 >> 23);		/* Extract weighting value */
6488 				vwe = wo0 - wo1;		/* Baricentric weighting */
6489 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6490 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6491 				vof += nvof;			/* Move to next vertex */
6492 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
6493 				wo2 = (wo2 >> 23);		/* Extract weighting value */
6494 				vwe = wo1 - wo2;		/* Baricentric weighting */
6495 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6496 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6497 				vof += nvof;			/* Move to next vertex */
6498 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
6499 				wo3 = (wo3 >> 23);		/* Extract weighting value */
6500 				vwe = wo2 - wo3;		/* Baricentric weighting */
6501 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6502 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6503 				vof += nvof;			/* Move to next vertex */
6504 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
6505 				wo4 = (wo4 >> 23);		/* Extract weighting value */
6506 				vwe = wo3 - wo4;		/* Baricentric weighting */
6507 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6508 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6509 				vof += nvof;			/* Move to next vertex */
6510 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
6511 				wo5 = (wo5 >> 23);		/* Extract weighting value */
6512 				vwe = wo4 - wo5;		/* Baricentric weighting */
6513 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6514 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6515 				vof += nvof;			/* Move to next vertex */
6516 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
6517 				wo6 = (wo6 >> 23);		/* Extract weighting value */
6518 				vwe = wo5 - wo6;		/* Baricentric weighting */
6519 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6520 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6521 				vof += nvof;			/* Move to next vertex */
6522 				vwe = wo6;				/* Baricentric weighting */
6523 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6524 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6525 			}
6526 		}
6527 		{
6528 			unsigned int oti;	/* Vertex offset value */
6529 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
6530 			op0[0] = OT_E(ot0, oti);	/* Write result */
6531 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
6532 			op0[1] = OT_E(ot1, oti);	/* Write result */
6533 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
6534 			op0[2] = OT_E(ot2, oti);	/* Write result */
6535 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
6536 			op0[3] = OT_E(ot3, oti);	/* Write result */
6537 		}
6538 	}
6539 }
6540 #undef IT_WO
6541 #undef IT_IX
6542 #undef CEX
6543 #undef IM_O
6544 #undef IM_FE
6545 #undef OT_E
6546 
6547 void
imdi_k20_gen(genspec * g)6548 imdi_k20_gen(
6549 genspec *g			/* structure to be initialised */
6550 ) {
6551 	static unsigned char data[] = {
6552 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
6553 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6554 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6555 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6556 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6557 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6558 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6559 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
6560 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
6561 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
6562 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
6563 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6564 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6565 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6566 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6567 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6568 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6569 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6570 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6571 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6572 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6573 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6574 		0x08, 0x00, 0x00, 0x00, 0x4c, 0x69, 0x6e, 0x75,
6575 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6576 		0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
6577 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
6578 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6579 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6580 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6581 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6582 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
6583 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
6584 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6585 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6586 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6587 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6588 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6589 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6590 		0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6591 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
6592 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
6593 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
6594 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
6595 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
6596 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
6597 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
6598 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
6599 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
6600 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6601 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
6602 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
6603 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x34, 0x5f,
6604 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
6605 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
6606 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
6607 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
6608 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
6609 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
6610 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
6611 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6612 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6613 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6614 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6615 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
6616 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x32, 0x30,
6617 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6618 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6619 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
6620 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
6621 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
6622 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
6623 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
6624 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
6625 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
6626 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
6627 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
6628 		0x00, 0xf0, 0x04, 0x08
6629 	};	/* Structure image */
6630 
6631 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
6632 }
6633 
6634 void
imdi_k20_tab(tabspec * t)6635 imdi_k20_tab(
6636 tabspec *t			/* structure to be initialised */
6637 ) {
6638 	static unsigned char data[] = {
6639 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6640 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6641 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6642 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
6643 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
6644 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
6645 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6646 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
6647 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
6648 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6649 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
6650 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
6651 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
6652 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
6653 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
6654 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6655 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6656 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
6657 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6658 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6659 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6660 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
6661 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
6662 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
6663 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6664 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6665 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
6666 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
6667 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6668 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6669 		0x08, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
6670 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
6671 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
6672 	};	/* Structure image */
6673 
6674 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
6675 }
6676 
6677 
6678 
6679 
6680 
6681 
6682 /* Integer Multi-Dimensional Interpolation */
6683 /* Interpolation Kernel Code */
6684 /* Generated by cgen */
6685 /* Copyright 2000 - 2002 Graeme W. Gill */
6686 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
6687 
6688 /* see the Licence.txt file for licencing details.*/
6689 
6690 
6691 /*
6692    Interpolation kernel specs:
6693 
6694    Input channels per pixel = 8
6695    Input channel 0 bits = 8
6696    Input channel 0 increment = 8
6697    Input channel 1 bits = 8
6698    Input channel 1 increment = 8
6699    Input channel 2 bits = 8
6700    Input channel 2 increment = 8
6701    Input channel 3 bits = 8
6702    Input channel 3 increment = 8
6703    Input channel 4 bits = 8
6704    Input channel 4 increment = 8
6705    Input channel 5 bits = 8
6706    Input channel 5 increment = 8
6707    Input channel 6 bits = 8
6708    Input channel 6 increment = 8
6709    Input channel 7 bits = 8
6710    Input channel 7 increment = 8
6711    Input is channel interleaved
6712    Input channels are separate words
6713    Input value extraction is done in input table lookup
6714 
6715    Output channels per pixel = 4
6716    Output channel 0 bits = 8
6717    Output channel 0 increment = 4
6718    Output channel 1 bits = 8
6719    Output channel 1 increment = 4
6720    Output channel 2 bits = 8
6721    Output channel 2 increment = 4
6722    Output channel 3 bits = 8
6723    Output channel 3 increment = 4
6724    Output is channel interleaved
6725 
6726    Output channels are separate words
6727    Weight+voffset bits       = 32
6728    Interpolation table index bits = 32
6729    Interpolation table max resolution = 9
6730  */
6731 
6732 /*
6733    Machine architecture specs:
6734 
6735    Little endian
6736    Reading and writing pixel values separately
6737    Pointer size = 32 bits
6738 
6739    Ordinal size  8 bits is known as 'unsigned char'
6740    Ordinal size 16 bits is known as 'unsigned short'
6741    Ordinal size 32 bits is known as 'unsigned int'
6742    Natural ordinal is 'unsigned int'
6743 
6744    Integer size  8 bits is known as 'signed char'
6745    Integer size 16 bits is known as 'short'
6746    Integer size 32 bits is known as 'int'
6747    Natural integer is 'int'
6748 
6749  */
6750 
6751 #ifndef  IMDI_INCLUDED
6752 #include <memory.h>
6753 #include "imdi_imp.h"
6754 #define  IMDI_INCLUDED
6755 #endif  /* IMDI_INCLUDED */
6756 
6757 #ifndef DEFINED_pointer
6758 #define DEFINED_pointer
6759 typedef unsigned char * pointer;
6760 #endif
6761 
6762 /* Input table interp. index */
6763 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
6764 
6765 /* Input table input weighting/offset value enty */
6766 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
6767 
6768 /* Conditional exchange for sorting */
6769 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
6770 
6771 /* Interpolation multi-dim. table access */
6772 #define IM_O(off) ((off) * 8)
6773 
6774 /* Interpolation table - get vertex values */
6775 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
6776 
6777 /* Output table indexes */
6778 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
6779 
6780 void
imdi_k21(imdi * s,void ** outp,void ** inp,unsigned int npix)6781 imdi_k21(
6782 imdi *s,			/* imdi context */
6783 void **outp,		/* pointer to output pointers */
6784 void **inp,		/* pointer to input pointers */
6785 unsigned int npix	/* Number of pixels to process */
6786 ) {
6787 	imdi_imp *p = (imdi_imp *)(s->impl);
6788 	unsigned char *ip0 = (unsigned char *)inp[0];
6789 	unsigned char *op0 = (unsigned char *)outp[0];
6790 	unsigned char *ep = ip0 + npix * 8 ;
6791 	pointer it0 = (pointer)p->in_tables[0];
6792 	pointer it1 = (pointer)p->in_tables[1];
6793 	pointer it2 = (pointer)p->in_tables[2];
6794 	pointer it3 = (pointer)p->in_tables[3];
6795 	pointer it4 = (pointer)p->in_tables[4];
6796 	pointer it5 = (pointer)p->in_tables[5];
6797 	pointer it6 = (pointer)p->in_tables[6];
6798 	pointer it7 = (pointer)p->in_tables[7];
6799 	pointer ot0 = (pointer)p->out_tables[0];
6800 	pointer ot1 = (pointer)p->out_tables[1];
6801 	pointer ot2 = (pointer)p->out_tables[2];
6802 	pointer ot3 = (pointer)p->out_tables[3];
6803 	pointer im_base = (pointer)p->im_table;
6804 
6805 	for(;ip0 < ep; ip0 += 8, op0 += 4) {
6806 		unsigned int ova0;	/* Output value accumulator */
6807 		unsigned int ova1;	/* Output value accumulator */
6808 		{
6809 			pointer imp;
6810 			unsigned int wo0;	/* Weighting value and vertex offset variable */
6811 			unsigned int wo1;	/* Weighting value and vertex offset variable */
6812 			unsigned int wo2;	/* Weighting value and vertex offset variable */
6813 			unsigned int wo3;	/* Weighting value and vertex offset variable */
6814 			unsigned int wo4;	/* Weighting value and vertex offset variable */
6815 			unsigned int wo5;	/* Weighting value and vertex offset variable */
6816 			unsigned int wo6;	/* Weighting value and vertex offset variable */
6817 			unsigned int wo7;	/* Weighting value and vertex offset variable */
6818 			{
6819 				unsigned int ti_i;	/* Interpolation index variable */
6820 
6821 				ti_i  = IT_IX(it0, ip0[0]);
6822 				wo0   = IT_WO(it0, ip0[0]);
6823 				ti_i += IT_IX(it1, ip0[1]);
6824 				wo1   = IT_WO(it1, ip0[1]);
6825 				ti_i += IT_IX(it2, ip0[2]);
6826 				wo2   = IT_WO(it2, ip0[2]);
6827 				ti_i += IT_IX(it3, ip0[3]);
6828 				wo3   = IT_WO(it3, ip0[3]);
6829 				ti_i += IT_IX(it4, ip0[4]);
6830 				wo4   = IT_WO(it4, ip0[4]);
6831 				ti_i += IT_IX(it5, ip0[5]);
6832 				wo5   = IT_WO(it5, ip0[5]);
6833 				ti_i += IT_IX(it6, ip0[6]);
6834 				wo6   = IT_WO(it6, ip0[6]);
6835 				ti_i += IT_IX(it7, ip0[7]);
6836 				wo7   = IT_WO(it7, ip0[7]);
6837 
6838 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
6839 
6840 				/* Sort weighting values and vertex offset values */
6841 				CEX(wo0, wo1);
6842 				CEX(wo0, wo2);
6843 				CEX(wo0, wo3);
6844 				CEX(wo0, wo4);
6845 				CEX(wo0, wo5);
6846 				CEX(wo0, wo6);
6847 				CEX(wo0, wo7);
6848 				CEX(wo1, wo2);
6849 				CEX(wo1, wo3);
6850 				CEX(wo1, wo4);
6851 				CEX(wo1, wo5);
6852 				CEX(wo1, wo6);
6853 				CEX(wo1, wo7);
6854 				CEX(wo2, wo3);
6855 				CEX(wo2, wo4);
6856 				CEX(wo2, wo5);
6857 				CEX(wo2, wo6);
6858 				CEX(wo2, wo7);
6859 				CEX(wo3, wo4);
6860 				CEX(wo3, wo5);
6861 				CEX(wo3, wo6);
6862 				CEX(wo3, wo7);
6863 				CEX(wo4, wo5);
6864 				CEX(wo4, wo6);
6865 				CEX(wo4, wo7);
6866 				CEX(wo5, wo6);
6867 				CEX(wo5, wo7);
6868 				CEX(wo6, wo7);
6869 			}
6870 			{
6871 				unsigned int nvof;	/* Next vertex offset value */
6872 				unsigned int vof;	/* Vertex offset value */
6873 				unsigned int vwe;	/* Vertex weighting */
6874 
6875 				vof = 0;				/* First vertex offset is 0 */
6876 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
6877 				wo0 = (wo0 >> 23);		/* Extract weighting value */
6878 				vwe = 256 - wo0;		/* Baricentric weighting */
6879 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6880 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6881 				vof += nvof;			/* Move to next vertex */
6882 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
6883 				wo1 = (wo1 >> 23);		/* Extract weighting value */
6884 				vwe = wo0 - wo1;		/* Baricentric weighting */
6885 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6886 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6887 				vof += nvof;			/* Move to next vertex */
6888 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
6889 				wo2 = (wo2 >> 23);		/* Extract weighting value */
6890 				vwe = wo1 - wo2;		/* Baricentric weighting */
6891 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6892 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6893 				vof += nvof;			/* Move to next vertex */
6894 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
6895 				wo3 = (wo3 >> 23);		/* Extract weighting value */
6896 				vwe = wo2 - wo3;		/* Baricentric weighting */
6897 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6898 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6899 				vof += nvof;			/* Move to next vertex */
6900 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
6901 				wo4 = (wo4 >> 23);		/* Extract weighting value */
6902 				vwe = wo3 - wo4;		/* Baricentric weighting */
6903 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6904 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6905 				vof += nvof;			/* Move to next vertex */
6906 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
6907 				wo5 = (wo5 >> 23);		/* Extract weighting value */
6908 				vwe = wo4 - wo5;		/* Baricentric weighting */
6909 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6910 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6911 				vof += nvof;			/* Move to next vertex */
6912 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
6913 				wo6 = (wo6 >> 23);		/* Extract weighting value */
6914 				vwe = wo5 - wo6;		/* Baricentric weighting */
6915 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6916 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6917 				vof += nvof;			/* Move to next vertex */
6918 				nvof = (wo7 & 0x7fffff);	/* Extract offset value */
6919 				wo7 = (wo7 >> 23);		/* Extract weighting value */
6920 				vwe = wo6 - wo7;		/* Baricentric weighting */
6921 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6922 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6923 				vof += nvof;			/* Move to next vertex */
6924 				vwe = wo7;				/* Baricentric weighting */
6925 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
6926 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
6927 			}
6928 		}
6929 		{
6930 			unsigned int oti;	/* Vertex offset value */
6931 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
6932 			op0[0] = OT_E(ot0, oti);	/* Write result */
6933 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
6934 			op0[1] = OT_E(ot1, oti);	/* Write result */
6935 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
6936 			op0[2] = OT_E(ot2, oti);	/* Write result */
6937 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
6938 			op0[3] = OT_E(ot3, oti);	/* Write result */
6939 		}
6940 	}
6941 }
6942 #undef IT_WO
6943 #undef IT_IX
6944 #undef CEX
6945 #undef IM_O
6946 #undef IM_FE
6947 #undef OT_E
6948 
6949 void
imdi_k21_gen(genspec * g)6950 imdi_k21_gen(
6951 genspec *g			/* structure to be initialised */
6952 ) {
6953 	static unsigned char data[] = {
6954 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6955 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6956 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6957 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6958 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6959 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6960 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6961 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6962 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6963 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6964 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6965 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6966 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6967 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6968 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6969 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6970 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6971 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6972 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6973 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6974 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6975 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6976 		0x08, 0x00, 0x00, 0x00, 0x4c, 0x69, 0x6e, 0x75,
6977 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6978 		0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
6979 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
6980 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6981 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6982 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6983 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6984 		0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x79, 0x72,
6985 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
6986 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6987 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
6988 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6989 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6990 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6991 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
6992 		0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6993 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
6994 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
6995 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
6996 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
6997 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
6998 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
6999 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
7000 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
7001 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
7002 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7003 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
7004 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
7005 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x34, 0x5f,
7006 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
7007 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
7008 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
7009 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
7010 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
7011 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
7012 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
7013 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7014 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7015 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7016 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7017 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
7018 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x32, 0x31,
7019 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7020 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7021 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
7022 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
7023 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
7024 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
7025 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
7026 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
7027 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
7028 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
7029 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
7030 		0x00, 0xf0, 0x04, 0x08
7031 	};	/* Structure image */
7032 
7033 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
7034 }
7035 
7036 void
imdi_k21_tab(tabspec * t)7037 imdi_k21_tab(
7038 tabspec *t			/* structure to be initialised */
7039 ) {
7040 	static unsigned char data[] = {
7041 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7042 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7043 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7044 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
7045 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
7046 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
7047 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7048 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
7049 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
7050 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7051 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
7052 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
7053 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
7054 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
7055 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
7056 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7057 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7058 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
7059 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7060 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7061 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7062 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
7063 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
7064 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
7065 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7066 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7067 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
7068 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
7069 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7070 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7071 		0x08, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
7072 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
7073 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
7074 	};	/* Structure image */
7075 
7076 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
7077 }
7078 
7079 
7080 
7081 
7082 
7083 
7084 /* Integer Multi-Dimensional Interpolation */
7085 /* Interpolation Kernel Code */
7086 /* Generated by cgen */
7087 /* Copyright 2000 - 2002 Graeme W. Gill */
7088 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
7089 
7090 /* see the Licence.txt file for licencing details.*/
7091 
7092 
7093 /*
7094    Interpolation kernel specs:
7095 
7096    Input channels per pixel = 1
7097    Input channel 0 bits = 8
7098    Input channel 0 increment = 1
7099    Input is channel interleaved
7100    Input channels are separate words
7101    Input value extraction is done in input table lookup
7102 
7103    Output channels per pixel = 5
7104    Output channel 0 bits = 8
7105    Output channel 0 increment = 5
7106    Output channel 1 bits = 8
7107    Output channel 1 increment = 5
7108    Output channel 2 bits = 8
7109    Output channel 2 increment = 5
7110    Output channel 3 bits = 8
7111    Output channel 3 increment = 5
7112    Output channel 4 bits = 8
7113    Output channel 4 increment = 5
7114    Output is channel interleaved
7115 
7116    Output channels are separate words
7117    Simplex table index bits       = 0
7118    Interpolation table index bits = 8
7119    Simplex table max resolution = 1
7120    Interpolation table max resolution = 255
7121  */
7122 
7123 /*
7124    Machine architecture specs:
7125 
7126    Little endian
7127    Reading and writing pixel values separately
7128    Pointer size = 32 bits
7129 
7130    Ordinal size  8 bits is known as 'unsigned char'
7131    Ordinal size 16 bits is known as 'unsigned short'
7132    Ordinal size 32 bits is known as 'unsigned int'
7133    Natural ordinal is 'unsigned int'
7134 
7135    Integer size  8 bits is known as 'signed char'
7136    Integer size 16 bits is known as 'short'
7137    Integer size 32 bits is known as 'int'
7138    Natural integer is 'int'
7139 
7140  */
7141 
7142 #ifndef  IMDI_INCLUDED
7143 #include <memory.h>
7144 #include "imdi_imp.h"
7145 #define  IMDI_INCLUDED
7146 #endif  /* IMDI_INCLUDED */
7147 
7148 #ifndef DEFINED_pointer
7149 #define DEFINED_pointer
7150 typedef unsigned char * pointer;
7151 #endif
7152 
7153 /* Input table inter & simplex indexes */
7154 #define IT_IT(p, off) *((unsigned char *)((p) + 0 + (off) * 1))
7155 
7156 /* Simplex weighting table access */
7157 #define SW_O(off) ((off) * 4)
7158 
7159 /* Simplex table - get weighting/offset value */
7160 #define SX_WO(p, v) *((unsigned short *)((p) + (v) * 2))
7161 
7162 /* Interpolation multi-dim. table access */
7163 #define IM_O(off) ((off) * 12)
7164 
7165 /* Interpolation table - get vertex values */
7166 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
7167 #define IM_PE(p, v) *((unsigned int *)((p) + 8 + (v) * 4))
7168 
7169 /* Output table indexes */
7170 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
7171 
7172 void
imdi_k22(imdi * s,void ** outp,void ** inp,unsigned int npix)7173 imdi_k22(
7174 imdi *s,			/* imdi context */
7175 void **outp,		/* pointer to output pointers */
7176 void **inp,		/* pointer to input pointers */
7177 unsigned int npix	/* Number of pixels to process */
7178 ) {
7179 	imdi_imp *p = (imdi_imp *)(s->impl);
7180 	unsigned char *ip0 = (unsigned char *)inp[0];
7181 	unsigned char *op0 = (unsigned char *)outp[0];
7182 	unsigned char *ep = ip0 + npix * 1 ;
7183 	pointer it0 = (pointer)p->in_tables[0];
7184 	pointer ot0 = (pointer)p->out_tables[0];
7185 	pointer ot1 = (pointer)p->out_tables[1];
7186 	pointer ot2 = (pointer)p->out_tables[2];
7187 	pointer ot3 = (pointer)p->out_tables[3];
7188 	pointer ot4 = (pointer)p->out_tables[4];
7189 	pointer sw_base = (pointer)p->sw_table;
7190 	pointer im_base = (pointer)p->im_table;
7191 
7192 	for(;ip0 < ep; ip0 += 1, op0 += 5) {
7193 		unsigned int ova0;	/* Output value accumulator */
7194 		unsigned int ova1;	/* Output value accumulator */
7195 		unsigned int ova2;	/* Output value partial accumulator */
7196 		{
7197 			pointer swp;
7198 			pointer imp;
7199 			{
7200 				unsigned int ti;	/* Simplex+Interpolation index variable */
7201 
7202 				ti  = IT_IT(it0, ip0[0]);
7203 
7204 				imp = im_base + IM_O(ti >> 0);		/* Extract interp. index and comp. entry */
7205 				swp = sw_base + SW_O(ti & 0x0);	/* Extract simplex index and comp. entry */
7206 			}
7207 			{
7208 				unsigned int vowr;	/* Vertex offset/weight value */
7209 				unsigned int vof;	/* Vertex offset value */
7210 				unsigned int vwe;	/* Vertex weighting */
7211 
7212 				vowr = SX_WO(swp, 0);	/* Read vertex offset+weighting values */
7213 				vof = (vowr & 0x7f);	/* Extract offset value */
7214 				vwe = (vowr >> 7);	/* Extract weighting value */
7215 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
7216 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
7217 				ova2  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
7218 				vowr = SX_WO(swp, 1);	/* Read vertex offset+weighting values */
7219 				vof = (vowr & 0x7f);	/* Extract offset value */
7220 				vwe = (vowr >> 7);	/* Extract weighting value */
7221 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
7222 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
7223 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
7224 			}
7225 		}
7226 		{
7227 			unsigned int oti;	/* Vertex offset value */
7228 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
7229 			op0[0] = OT_E(ot0, oti);	/* Write result */
7230 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
7231 			op0[1] = OT_E(ot1, oti);	/* Write result */
7232 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
7233 			op0[2] = OT_E(ot2, oti);	/* Write result */
7234 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
7235 			op0[3] = OT_E(ot3, oti);	/* Write result */
7236 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
7237 			op0[4] = OT_E(ot4, oti);	/* Write result */
7238 		}
7239 	}
7240 }
7241 #undef IT_IT
7242 #undef SW_O
7243 #undef SX_WO
7244 #undef IM_O
7245 #undef IM_FE
7246 #undef IM_PE
7247 #undef OT_E
7248 
7249 void
imdi_k22_gen(genspec * g)7250 imdi_k22_gen(
7251 genspec *g			/* structure to be initialised */
7252 ) {
7253 	static unsigned char data[] = {
7254 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7255 		0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7256 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7257 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7258 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7259 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7260 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7261 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7262 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7263 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7264 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7265 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7266 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7267 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7268 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7269 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7270 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7271 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7272 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7273 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7274 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7275 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7276 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7277 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7278 		0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
7279 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
7280 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
7281 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7282 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7283 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7284 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7285 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
7286 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7287 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7288 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7289 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7290 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7291 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7292 		0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7293 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
7294 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
7295 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
7296 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
7297 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
7298 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
7299 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
7300 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
7301 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
7302 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7303 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
7304 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
7305 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x35, 0x5f,
7306 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
7307 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
7308 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
7309 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
7310 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
7311 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
7312 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
7313 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7314 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7315 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7316 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7317 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
7318 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x32, 0x32,
7319 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7320 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7321 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
7322 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
7323 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
7324 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
7325 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
7326 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
7327 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
7328 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
7329 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
7330 		0x00, 0xf0, 0x04, 0x08
7331 	};	/* Structure image */
7332 
7333 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
7334 }
7335 
7336 void
imdi_k22_tab(tabspec * t)7337 imdi_k22_tab(
7338 tabspec *t			/* structure to be initialised */
7339 ) {
7340 	static unsigned char data[] = {
7341 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7342 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7343 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7344 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
7345 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
7346 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
7347 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7348 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
7349 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7350 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7351 		0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
7352 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7353 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
7354 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
7355 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
7356 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7357 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
7358 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
7359 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
7360 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7361 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7362 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
7363 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7364 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
7365 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7366 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7367 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7368 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
7369 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7370 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7371 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7372 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
7373 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
7374 	};	/* Structure image */
7375 
7376 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
7377 }
7378 
7379 
7380 
7381 
7382 
7383 
7384 /* Integer Multi-Dimensional Interpolation */
7385 /* Interpolation Kernel Code */
7386 /* Generated by cgen */
7387 /* Copyright 2000 - 2002 Graeme W. Gill */
7388 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
7389 
7390 /* see the Licence.txt file for licencing details.*/
7391 
7392 
7393 /*
7394    Interpolation kernel specs:
7395 
7396    Input channels per pixel = 3
7397    Input channel 0 bits = 8
7398    Input channel 0 increment = 3
7399    Input channel 1 bits = 8
7400    Input channel 1 increment = 3
7401    Input channel 2 bits = 8
7402    Input channel 2 increment = 3
7403    Input is channel interleaved
7404    Input channels are separate words
7405    Input value extraction is done in input table lookup
7406 
7407    Output channels per pixel = 5
7408    Output channel 0 bits = 8
7409    Output channel 0 increment = 5
7410    Output channel 1 bits = 8
7411    Output channel 1 increment = 5
7412    Output channel 2 bits = 8
7413    Output channel 2 increment = 5
7414    Output channel 3 bits = 8
7415    Output channel 3 increment = 5
7416    Output channel 4 bits = 8
7417    Output channel 4 increment = 5
7418    Output is channel interleaved
7419 
7420    Output channels are separate words
7421    Simplex table index bits       = 12
7422    Interpolation table index bits = 20
7423    Simplex table max resolution = 16
7424    Interpolation table max resolution = 101
7425  */
7426 
7427 /*
7428    Machine architecture specs:
7429 
7430    Little endian
7431    Reading and writing pixel values separately
7432    Pointer size = 32 bits
7433 
7434    Ordinal size  8 bits is known as 'unsigned char'
7435    Ordinal size 16 bits is known as 'unsigned short'
7436    Ordinal size 32 bits is known as 'unsigned int'
7437    Natural ordinal is 'unsigned int'
7438 
7439    Integer size  8 bits is known as 'signed char'
7440    Integer size 16 bits is known as 'short'
7441    Integer size 32 bits is known as 'int'
7442    Natural integer is 'int'
7443 
7444  */
7445 
7446 #ifndef  IMDI_INCLUDED
7447 #include <memory.h>
7448 #include "imdi_imp.h"
7449 #define  IMDI_INCLUDED
7450 #endif  /* IMDI_INCLUDED */
7451 
7452 #ifndef DEFINED_pointer
7453 #define DEFINED_pointer
7454 typedef unsigned char * pointer;
7455 #endif
7456 
7457 /* Input table inter & simplex indexes */
7458 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
7459 
7460 /* Simplex weighting table access */
7461 #define SW_O(off) ((off) * 16)
7462 
7463 /* Simplex table - get weighting value */
7464 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
7465 
7466 /* Simplex table - get offset value */
7467 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
7468 
7469 /* Interpolation multi-dim. table access */
7470 #define IM_O(off) ((off) * 12)
7471 
7472 /* Interpolation table - get vertex values */
7473 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
7474 #define IM_PE(p, v) *((unsigned int *)((p) + 8 + (v) * 4))
7475 
7476 /* Output table indexes */
7477 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
7478 
7479 void
imdi_k23(imdi * s,void ** outp,void ** inp,unsigned int npix)7480 imdi_k23(
7481 imdi *s,			/* imdi context */
7482 void **outp,		/* pointer to output pointers */
7483 void **inp,		/* pointer to input pointers */
7484 unsigned int npix	/* Number of pixels to process */
7485 ) {
7486 	imdi_imp *p = (imdi_imp *)(s->impl);
7487 	unsigned char *ip0 = (unsigned char *)inp[0];
7488 	unsigned char *op0 = (unsigned char *)outp[0];
7489 	unsigned char *ep = ip0 + npix * 3 ;
7490 	pointer it0 = (pointer)p->in_tables[0];
7491 	pointer it1 = (pointer)p->in_tables[1];
7492 	pointer it2 = (pointer)p->in_tables[2];
7493 	pointer ot0 = (pointer)p->out_tables[0];
7494 	pointer ot1 = (pointer)p->out_tables[1];
7495 	pointer ot2 = (pointer)p->out_tables[2];
7496 	pointer ot3 = (pointer)p->out_tables[3];
7497 	pointer ot4 = (pointer)p->out_tables[4];
7498 	pointer sw_base = (pointer)p->sw_table;
7499 	pointer im_base = (pointer)p->im_table;
7500 
7501 	for(;ip0 < ep; ip0 += 3, op0 += 5) {
7502 		unsigned int ova0;	/* Output value accumulator */
7503 		unsigned int ova1;	/* Output value accumulator */
7504 		unsigned int ova2;	/* Output value partial accumulator */
7505 		{
7506 			pointer swp;
7507 			pointer imp;
7508 			{
7509 				unsigned int ti;	/* Simplex+Interpolation index variable */
7510 
7511 				ti  = IT_IT(it0, ip0[0]);
7512 				ti += IT_IT(it1, ip0[1]);
7513 				ti += IT_IT(it2, ip0[2]);
7514 
7515 				imp = im_base + IM_O(ti >> 12);		/* Extract interp. index and comp. entry */
7516 				swp = sw_base + SW_O(ti & 0xfff);	/* Extract simplex index and comp. entry */
7517 			}
7518 			{
7519 				unsigned int vof;	/* Vertex offset value */
7520 				unsigned int vwe;	/* Vertex weighting */
7521 
7522 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
7523 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
7524 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
7525 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
7526 				ova2  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
7527 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
7528 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
7529 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
7530 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
7531 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
7532 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
7533 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
7534 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
7535 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
7536 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
7537 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
7538 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
7539 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
7540 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
7541 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
7542 			}
7543 		}
7544 		{
7545 			unsigned int oti;	/* Vertex offset value */
7546 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
7547 			op0[0] = OT_E(ot0, oti);	/* Write result */
7548 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
7549 			op0[1] = OT_E(ot1, oti);	/* Write result */
7550 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
7551 			op0[2] = OT_E(ot2, oti);	/* Write result */
7552 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
7553 			op0[3] = OT_E(ot3, oti);	/* Write result */
7554 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
7555 			op0[4] = OT_E(ot4, oti);	/* Write result */
7556 		}
7557 	}
7558 }
7559 #undef IT_IT
7560 #undef SW_O
7561 #undef SX_WE
7562 #undef SX_VO
7563 #undef IM_O
7564 #undef IM_FE
7565 #undef IM_PE
7566 #undef OT_E
7567 
7568 void
imdi_k23_gen(genspec * g)7569 imdi_k23_gen(
7570 genspec *g			/* structure to be initialised */
7571 ) {
7572 	static unsigned char data[] = {
7573 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
7574 		0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7575 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7576 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7577 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7578 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7579 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7580 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
7581 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
7582 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7583 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7584 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7585 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7586 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7587 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7588 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7589 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7590 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7591 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7592 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7593 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7594 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7595 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7596 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7597 		0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
7598 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
7599 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
7600 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7601 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7602 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7603 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7604 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
7605 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7606 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7607 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7608 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7609 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7610 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7611 		0x65, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
7612 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
7613 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
7614 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
7615 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
7616 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
7617 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
7618 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
7619 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
7620 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
7621 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7622 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
7623 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
7624 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x35, 0x5f,
7625 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
7626 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
7627 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
7628 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
7629 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
7630 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
7631 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
7632 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7633 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7634 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7635 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7636 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
7637 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x32, 0x33,
7638 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7639 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7640 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
7641 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
7642 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
7643 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
7644 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
7645 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
7646 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
7647 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
7648 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
7649 		0x00, 0xf0, 0x04, 0x08
7650 	};	/* Structure image */
7651 
7652 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
7653 }
7654 
7655 void
imdi_k23_tab(tabspec * t)7656 imdi_k23_tab(
7657 tabspec *t			/* structure to be initialised */
7658 ) {
7659 	static unsigned char data[] = {
7660 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7661 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7662 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7663 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
7664 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
7665 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
7666 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
7667 		0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
7668 		0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
7669 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7670 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
7671 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7672 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
7673 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
7674 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
7675 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7676 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
7677 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
7678 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
7679 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7680 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7681 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
7682 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7683 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
7684 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7685 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7686 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7687 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
7688 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7689 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7690 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7691 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
7692 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
7693 	};	/* Structure image */
7694 
7695 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
7696 }
7697 
7698 
7699 
7700 
7701 
7702 
7703 /* Integer Multi-Dimensional Interpolation */
7704 /* Interpolation Kernel Code */
7705 /* Generated by cgen */
7706 /* Copyright 2000 - 2002 Graeme W. Gill */
7707 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
7708 
7709 /* see the Licence.txt file for licencing details.*/
7710 
7711 
7712 /*
7713    Interpolation kernel specs:
7714 
7715    Input channels per pixel = 4
7716    Input channel 0 bits = 8
7717    Input channel 0 increment = 4
7718    Input channel 1 bits = 8
7719    Input channel 1 increment = 4
7720    Input channel 2 bits = 8
7721    Input channel 2 increment = 4
7722    Input channel 3 bits = 8
7723    Input channel 3 increment = 4
7724    Input is channel interleaved
7725    Input channels are separate words
7726    Input value extraction is done in input table lookup
7727 
7728    Output channels per pixel = 5
7729    Output channel 0 bits = 8
7730    Output channel 0 increment = 5
7731    Output channel 1 bits = 8
7732    Output channel 1 increment = 5
7733    Output channel 2 bits = 8
7734    Output channel 2 increment = 5
7735    Output channel 3 bits = 8
7736    Output channel 3 increment = 5
7737    Output channel 4 bits = 8
7738    Output channel 4 increment = 5
7739    Output is channel interleaved
7740 
7741    Output channels are separate words
7742    Simplex table index bits       = 32
7743    Interpolation table index bits = 32
7744    Simplex table max resolution = 255
7745    Interpolation table max resolution = 27
7746  */
7747 
7748 /*
7749    Machine architecture specs:
7750 
7751    Little endian
7752    Reading and writing pixel values separately
7753    Pointer size = 32 bits
7754 
7755    Ordinal size  8 bits is known as 'unsigned char'
7756    Ordinal size 16 bits is known as 'unsigned short'
7757    Ordinal size 32 bits is known as 'unsigned int'
7758    Natural ordinal is 'unsigned int'
7759 
7760    Integer size  8 bits is known as 'signed char'
7761    Integer size 16 bits is known as 'short'
7762    Integer size 32 bits is known as 'int'
7763    Natural integer is 'int'
7764 
7765  */
7766 
7767 #ifndef  IMDI_INCLUDED
7768 #include <memory.h>
7769 #include "imdi_imp.h"
7770 #define  IMDI_INCLUDED
7771 #endif  /* IMDI_INCLUDED */
7772 
7773 #ifndef DEFINED_pointer
7774 #define DEFINED_pointer
7775 typedef unsigned char * pointer;
7776 #endif
7777 
7778 /* Input table interp. index */
7779 #define IT_IX(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
7780 
7781 /* Input table simplex index enty */
7782 #define IT_SX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
7783 
7784 /* Simplex weighting table access */
7785 #define SW_O(off) ((off) * 20)
7786 
7787 /* Simplex table - get weighting value */
7788 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
7789 
7790 /* Simplex table - get offset value */
7791 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
7792 
7793 /* Interpolation multi-dim. table access */
7794 #define IM_O(off) ((off) * 12)
7795 
7796 /* Interpolation table - get vertex values */
7797 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
7798 #define IM_PE(p, v) *((unsigned int *)((p) + 8 + (v) * 4))
7799 
7800 /* Output table indexes */
7801 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
7802 
7803 void
imdi_k24(imdi * s,void ** outp,void ** inp,unsigned int npix)7804 imdi_k24(
7805 imdi *s,			/* imdi context */
7806 void **outp,		/* pointer to output pointers */
7807 void **inp,		/* pointer to input pointers */
7808 unsigned int npix	/* Number of pixels to process */
7809 ) {
7810 	imdi_imp *p = (imdi_imp *)(s->impl);
7811 	unsigned char *ip0 = (unsigned char *)inp[0];
7812 	unsigned char *op0 = (unsigned char *)outp[0];
7813 	unsigned char *ep = ip0 + npix * 4 ;
7814 	pointer it0 = (pointer)p->in_tables[0];
7815 	pointer it1 = (pointer)p->in_tables[1];
7816 	pointer it2 = (pointer)p->in_tables[2];
7817 	pointer it3 = (pointer)p->in_tables[3];
7818 	pointer ot0 = (pointer)p->out_tables[0];
7819 	pointer ot1 = (pointer)p->out_tables[1];
7820 	pointer ot2 = (pointer)p->out_tables[2];
7821 	pointer ot3 = (pointer)p->out_tables[3];
7822 	pointer ot4 = (pointer)p->out_tables[4];
7823 	pointer sw_base = (pointer)p->sw_table;
7824 	pointer im_base = (pointer)p->im_table;
7825 
7826 	for(;ip0 < ep; ip0 += 4, op0 += 5) {
7827 		unsigned int ova0;	/* Output value accumulator */
7828 		unsigned int ova1;	/* Output value accumulator */
7829 		unsigned int ova2;	/* Output value partial accumulator */
7830 		{
7831 			pointer swp;
7832 			pointer imp;
7833 			{
7834 				unsigned int ti_s;	/* Simplex index variable */
7835 				unsigned int ti_i;	/* Interpolation index variable */
7836 
7837 				ti_i  = IT_IX(it0, ip0[0]);
7838 				ti_s  = IT_SX(it0, ip0[0]);
7839 				ti_i += IT_IX(it1, ip0[1]);
7840 				ti_s += IT_SX(it1, ip0[1]);
7841 				ti_i += IT_IX(it2, ip0[2]);
7842 				ti_s += IT_SX(it2, ip0[2]);
7843 				ti_i += IT_IX(it3, ip0[3]);
7844 				ti_s += IT_SX(it3, ip0[3]);
7845 
7846 				swp = sw_base + SW_O(ti_s);		/* Compute simplex table entry pointer */
7847 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
7848 			}
7849 			{
7850 				unsigned int vof;	/* Vertex offset value */
7851 				unsigned int vwe;	/* Vertex weighting */
7852 
7853 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
7854 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
7855 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
7856 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
7857 				ova2  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
7858 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
7859 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
7860 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
7861 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
7862 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
7863 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
7864 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
7865 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
7866 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
7867 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
7868 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
7869 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
7870 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
7871 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
7872 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
7873 				vof = SX_VO(swp, 4);	/* Read vertex offset value */
7874 				vwe = SX_WE(swp, 4);	/* Read vertex weighting value */
7875 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
7876 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
7877 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
7878 			}
7879 		}
7880 		{
7881 			unsigned int oti;	/* Vertex offset value */
7882 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
7883 			op0[0] = OT_E(ot0, oti);	/* Write result */
7884 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
7885 			op0[1] = OT_E(ot1, oti);	/* Write result */
7886 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
7887 			op0[2] = OT_E(ot2, oti);	/* Write result */
7888 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
7889 			op0[3] = OT_E(ot3, oti);	/* Write result */
7890 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
7891 			op0[4] = OT_E(ot4, oti);	/* Write result */
7892 		}
7893 	}
7894 }
7895 #undef IT_IX
7896 #undef IT_SX
7897 #undef SW_O
7898 #undef SX_WE
7899 #undef SX_VO
7900 #undef IM_O
7901 #undef IM_FE
7902 #undef IM_PE
7903 #undef OT_E
7904 
7905 void
imdi_k24_gen(genspec * g)7906 imdi_k24_gen(
7907 genspec *g			/* structure to be initialised */
7908 ) {
7909 	static unsigned char data[] = {
7910 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
7911 		0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7912 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7913 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7914 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7915 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7916 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7917 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
7918 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
7919 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7920 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7921 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7922 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7923 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7924 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7925 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7926 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7927 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7928 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7929 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7930 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7931 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7932 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7933 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7934 		0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
7935 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
7936 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
7937 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7938 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7939 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7940 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7941 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
7942 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7943 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7944 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
7945 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7946 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7947 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7948 		0x1b, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
7949 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
7950 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
7951 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
7952 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
7953 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
7954 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
7955 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
7956 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
7957 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
7958 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7959 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
7960 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
7961 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x35, 0x5f,
7962 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
7963 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
7964 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
7965 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
7966 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
7967 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
7968 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
7969 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7970 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7971 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7972 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7973 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
7974 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x32, 0x34,
7975 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7976 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7977 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
7978 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
7979 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
7980 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
7981 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
7982 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
7983 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
7984 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
7985 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
7986 		0x00, 0xf0, 0x04, 0x08
7987 	};	/* Structure image */
7988 
7989 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
7990 }
7991 
7992 void
imdi_k24_tab(tabspec * t)7993 imdi_k24_tab(
7994 tabspec *t			/* structure to be initialised */
7995 ) {
7996 	static unsigned char data[] = {
7997 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7998 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
7999 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8000 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
8001 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
8002 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
8003 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8004 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
8005 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
8006 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8007 		0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
8008 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8009 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
8010 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
8011 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
8012 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8013 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
8014 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
8015 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
8016 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8017 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8018 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
8019 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8020 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
8021 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8022 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8023 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8024 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
8025 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8026 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8027 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8028 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
8029 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
8030 	};	/* Structure image */
8031 
8032 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
8033 }
8034 
8035 
8036 
8037 
8038 
8039 
8040 /* Integer Multi-Dimensional Interpolation */
8041 /* Interpolation Kernel Code */
8042 /* Generated by cgen */
8043 /* Copyright 2000 - 2002 Graeme W. Gill */
8044 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
8045 
8046 /* see the Licence.txt file for licencing details.*/
8047 
8048 
8049 /*
8050    Interpolation kernel specs:
8051 
8052    Input channels per pixel = 5
8053    Input channel 0 bits = 8
8054    Input channel 0 increment = 5
8055    Input channel 1 bits = 8
8056    Input channel 1 increment = 5
8057    Input channel 2 bits = 8
8058    Input channel 2 increment = 5
8059    Input channel 3 bits = 8
8060    Input channel 3 increment = 5
8061    Input channel 4 bits = 8
8062    Input channel 4 increment = 5
8063    Input is channel interleaved
8064    Input channels are separate words
8065    Input value extraction is done in input table lookup
8066 
8067    Output channels per pixel = 5
8068    Output channel 0 bits = 8
8069    Output channel 0 increment = 5
8070    Output channel 1 bits = 8
8071    Output channel 1 increment = 5
8072    Output channel 2 bits = 8
8073    Output channel 2 increment = 5
8074    Output channel 3 bits = 8
8075    Output channel 3 increment = 5
8076    Output channel 4 bits = 8
8077    Output channel 4 increment = 5
8078    Output is channel interleaved
8079 
8080    Output channels are separate words
8081    Weight+voffset bits       = 32
8082    Interpolation table index bits = 32
8083    Interpolation table max resolution = 40
8084  */
8085 
8086 /*
8087    Machine architecture specs:
8088 
8089    Little endian
8090    Reading and writing pixel values separately
8091    Pointer size = 32 bits
8092 
8093    Ordinal size  8 bits is known as 'unsigned char'
8094    Ordinal size 16 bits is known as 'unsigned short'
8095    Ordinal size 32 bits is known as 'unsigned int'
8096    Natural ordinal is 'unsigned int'
8097 
8098    Integer size  8 bits is known as 'signed char'
8099    Integer size 16 bits is known as 'short'
8100    Integer size 32 bits is known as 'int'
8101    Natural integer is 'int'
8102 
8103  */
8104 
8105 #ifndef  IMDI_INCLUDED
8106 #include <memory.h>
8107 #include "imdi_imp.h"
8108 #define  IMDI_INCLUDED
8109 #endif  /* IMDI_INCLUDED */
8110 
8111 #ifndef DEFINED_pointer
8112 #define DEFINED_pointer
8113 typedef unsigned char * pointer;
8114 #endif
8115 
8116 /* Input table interp. index */
8117 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
8118 
8119 /* Input table input weighting/offset value enty */
8120 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
8121 
8122 /* Conditional exchange for sorting */
8123 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
8124 
8125 /* Interpolation multi-dim. table access */
8126 #define IM_O(off) ((off) * 12)
8127 
8128 /* Interpolation table - get vertex values */
8129 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
8130 #define IM_PE(p, v) *((unsigned int *)((p) + 8 + (v) * 4))
8131 
8132 /* Output table indexes */
8133 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
8134 
8135 void
imdi_k25(imdi * s,void ** outp,void ** inp,unsigned int npix)8136 imdi_k25(
8137 imdi *s,			/* imdi context */
8138 void **outp,		/* pointer to output pointers */
8139 void **inp,		/* pointer to input pointers */
8140 unsigned int npix	/* Number of pixels to process */
8141 ) {
8142 	imdi_imp *p = (imdi_imp *)(s->impl);
8143 	unsigned char *ip0 = (unsigned char *)inp[0];
8144 	unsigned char *op0 = (unsigned char *)outp[0];
8145 	unsigned char *ep = ip0 + npix * 5 ;
8146 	pointer it0 = (pointer)p->in_tables[0];
8147 	pointer it1 = (pointer)p->in_tables[1];
8148 	pointer it2 = (pointer)p->in_tables[2];
8149 	pointer it3 = (pointer)p->in_tables[3];
8150 	pointer it4 = (pointer)p->in_tables[4];
8151 	pointer ot0 = (pointer)p->out_tables[0];
8152 	pointer ot1 = (pointer)p->out_tables[1];
8153 	pointer ot2 = (pointer)p->out_tables[2];
8154 	pointer ot3 = (pointer)p->out_tables[3];
8155 	pointer ot4 = (pointer)p->out_tables[4];
8156 	pointer im_base = (pointer)p->im_table;
8157 
8158 	for(;ip0 < ep; ip0 += 5, op0 += 5) {
8159 		unsigned int ova0;	/* Output value accumulator */
8160 		unsigned int ova1;	/* Output value accumulator */
8161 		unsigned int ova2;	/* Output value partial accumulator */
8162 		{
8163 			pointer imp;
8164 			unsigned int wo0;	/* Weighting value and vertex offset variable */
8165 			unsigned int wo1;	/* Weighting value and vertex offset variable */
8166 			unsigned int wo2;	/* Weighting value and vertex offset variable */
8167 			unsigned int wo3;	/* Weighting value and vertex offset variable */
8168 			unsigned int wo4;	/* Weighting value and vertex offset variable */
8169 			{
8170 				unsigned int ti_i;	/* Interpolation index variable */
8171 
8172 				ti_i  = IT_IX(it0, ip0[0]);
8173 				wo0   = IT_WO(it0, ip0[0]);
8174 				ti_i += IT_IX(it1, ip0[1]);
8175 				wo1   = IT_WO(it1, ip0[1]);
8176 				ti_i += IT_IX(it2, ip0[2]);
8177 				wo2   = IT_WO(it2, ip0[2]);
8178 				ti_i += IT_IX(it3, ip0[3]);
8179 				wo3   = IT_WO(it3, ip0[3]);
8180 				ti_i += IT_IX(it4, ip0[4]);
8181 				wo4   = IT_WO(it4, ip0[4]);
8182 
8183 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
8184 
8185 				/* Sort weighting values and vertex offset values */
8186 				CEX(wo0, wo1);
8187 				CEX(wo0, wo2);
8188 				CEX(wo0, wo3);
8189 				CEX(wo0, wo4);
8190 				CEX(wo1, wo2);
8191 				CEX(wo1, wo3);
8192 				CEX(wo1, wo4);
8193 				CEX(wo2, wo3);
8194 				CEX(wo2, wo4);
8195 				CEX(wo3, wo4);
8196 			}
8197 			{
8198 				unsigned int nvof;	/* Next vertex offset value */
8199 				unsigned int vof;	/* Vertex offset value */
8200 				unsigned int vwe;	/* Vertex weighting */
8201 
8202 				vof = 0;				/* First vertex offset is 0 */
8203 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
8204 				wo0 = (wo0 >> 23);		/* Extract weighting value */
8205 				vwe = 256 - wo0;		/* Baricentric weighting */
8206 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
8207 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
8208 				ova2  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
8209 				vof += nvof;			/* Move to next vertex */
8210 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
8211 				wo1 = (wo1 >> 23);		/* Extract weighting value */
8212 				vwe = wo0 - wo1;		/* Baricentric weighting */
8213 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
8214 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
8215 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
8216 				vof += nvof;			/* Move to next vertex */
8217 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
8218 				wo2 = (wo2 >> 23);		/* Extract weighting value */
8219 				vwe = wo1 - wo2;		/* Baricentric weighting */
8220 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
8221 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
8222 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
8223 				vof += nvof;			/* Move to next vertex */
8224 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
8225 				wo3 = (wo3 >> 23);		/* Extract weighting value */
8226 				vwe = wo2 - wo3;		/* Baricentric weighting */
8227 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
8228 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
8229 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
8230 				vof += nvof;			/* Move to next vertex */
8231 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
8232 				wo4 = (wo4 >> 23);		/* Extract weighting value */
8233 				vwe = wo3 - wo4;		/* Baricentric weighting */
8234 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
8235 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
8236 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
8237 				vof += nvof;			/* Move to next vertex */
8238 				vwe = wo4;				/* Baricentric weighting */
8239 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
8240 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
8241 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
8242 			}
8243 		}
8244 		{
8245 			unsigned int oti;	/* Vertex offset value */
8246 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
8247 			op0[0] = OT_E(ot0, oti);	/* Write result */
8248 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
8249 			op0[1] = OT_E(ot1, oti);	/* Write result */
8250 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
8251 			op0[2] = OT_E(ot2, oti);	/* Write result */
8252 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
8253 			op0[3] = OT_E(ot3, oti);	/* Write result */
8254 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
8255 			op0[4] = OT_E(ot4, oti);	/* Write result */
8256 		}
8257 	}
8258 }
8259 #undef IT_WO
8260 #undef IT_IX
8261 #undef CEX
8262 #undef IM_O
8263 #undef IM_FE
8264 #undef IM_PE
8265 #undef OT_E
8266 
8267 void
imdi_k25_gen(genspec * g)8268 imdi_k25_gen(
8269 genspec *g			/* structure to be initialised */
8270 ) {
8271 	static unsigned char data[] = {
8272 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
8273 		0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8274 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8275 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8276 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8277 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8278 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8279 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
8280 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
8281 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
8282 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8283 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8284 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8285 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8286 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8287 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8288 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8289 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8290 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8291 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8292 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8293 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8294 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8295 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8296 		0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
8297 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
8298 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
8299 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8300 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8301 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8302 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8303 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
8304 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8305 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8306 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8307 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8308 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8309 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8310 		0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8311 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
8312 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
8313 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
8314 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
8315 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
8316 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
8317 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
8318 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
8319 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
8320 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8321 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
8322 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
8323 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x35, 0x5f,
8324 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
8325 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
8326 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
8327 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
8328 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
8329 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
8330 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
8331 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8332 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8333 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8334 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8335 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
8336 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x32, 0x35,
8337 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8338 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8339 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
8340 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
8341 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
8342 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
8343 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
8344 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
8345 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
8346 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
8347 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
8348 		0x00, 0xf0, 0x04, 0x08
8349 	};	/* Structure image */
8350 
8351 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
8352 }
8353 
8354 void
imdi_k25_tab(tabspec * t)8355 imdi_k25_tab(
8356 tabspec *t			/* structure to be initialised */
8357 ) {
8358 	static unsigned char data[] = {
8359 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8360 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8361 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8362 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
8363 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
8364 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
8365 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8366 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
8367 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
8368 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8369 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
8370 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
8371 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
8372 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
8373 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
8374 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8375 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
8376 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
8377 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
8378 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8379 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8380 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
8381 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8382 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
8383 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8384 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8385 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8386 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
8387 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8388 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8389 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8390 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
8391 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
8392 	};	/* Structure image */
8393 
8394 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
8395 }
8396 
8397 
8398 
8399 
8400 
8401 
8402 /* Integer Multi-Dimensional Interpolation */
8403 /* Interpolation Kernel Code */
8404 /* Generated by cgen */
8405 /* Copyright 2000 - 2002 Graeme W. Gill */
8406 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
8407 
8408 /* see the Licence.txt file for licencing details.*/
8409 
8410 
8411 /*
8412    Interpolation kernel specs:
8413 
8414    Input channels per pixel = 6
8415    Input channel 0 bits = 8
8416    Input channel 0 increment = 6
8417    Input channel 1 bits = 8
8418    Input channel 1 increment = 6
8419    Input channel 2 bits = 8
8420    Input channel 2 increment = 6
8421    Input channel 3 bits = 8
8422    Input channel 3 increment = 6
8423    Input channel 4 bits = 8
8424    Input channel 4 increment = 6
8425    Input channel 5 bits = 8
8426    Input channel 5 increment = 6
8427    Input is channel interleaved
8428    Input channels are separate words
8429    Input value extraction is done in input table lookup
8430 
8431    Output channels per pixel = 5
8432    Output channel 0 bits = 8
8433    Output channel 0 increment = 5
8434    Output channel 1 bits = 8
8435    Output channel 1 increment = 5
8436    Output channel 2 bits = 8
8437    Output channel 2 increment = 5
8438    Output channel 3 bits = 8
8439    Output channel 3 increment = 5
8440    Output channel 4 bits = 8
8441    Output channel 4 increment = 5
8442    Output is channel interleaved
8443 
8444    Output channels are separate words
8445    Weight+voffset bits       = 32
8446    Interpolation table index bits = 32
8447    Interpolation table max resolution = 19
8448  */
8449 
8450 /*
8451    Machine architecture specs:
8452 
8453    Little endian
8454    Reading and writing pixel values separately
8455    Pointer size = 32 bits
8456 
8457    Ordinal size  8 bits is known as 'unsigned char'
8458    Ordinal size 16 bits is known as 'unsigned short'
8459    Ordinal size 32 bits is known as 'unsigned int'
8460    Natural ordinal is 'unsigned int'
8461 
8462    Integer size  8 bits is known as 'signed char'
8463    Integer size 16 bits is known as 'short'
8464    Integer size 32 bits is known as 'int'
8465    Natural integer is 'int'
8466 
8467  */
8468 
8469 #ifndef  IMDI_INCLUDED
8470 #include <memory.h>
8471 #include "imdi_imp.h"
8472 #define  IMDI_INCLUDED
8473 #endif  /* IMDI_INCLUDED */
8474 
8475 #ifndef DEFINED_pointer
8476 #define DEFINED_pointer
8477 typedef unsigned char * pointer;
8478 #endif
8479 
8480 /* Input table interp. index */
8481 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
8482 
8483 /* Input table input weighting/offset value enty */
8484 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
8485 
8486 /* Conditional exchange for sorting */
8487 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
8488 
8489 /* Interpolation multi-dim. table access */
8490 #define IM_O(off) ((off) * 12)
8491 
8492 /* Interpolation table - get vertex values */
8493 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
8494 #define IM_PE(p, v) *((unsigned int *)((p) + 8 + (v) * 4))
8495 
8496 /* Output table indexes */
8497 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
8498 
8499 void
imdi_k26(imdi * s,void ** outp,void ** inp,unsigned int npix)8500 imdi_k26(
8501 imdi *s,			/* imdi context */
8502 void **outp,		/* pointer to output pointers */
8503 void **inp,		/* pointer to input pointers */
8504 unsigned int npix	/* Number of pixels to process */
8505 ) {
8506 	imdi_imp *p = (imdi_imp *)(s->impl);
8507 	unsigned char *ip0 = (unsigned char *)inp[0];
8508 	unsigned char *op0 = (unsigned char *)outp[0];
8509 	unsigned char *ep = ip0 + npix * 6 ;
8510 	pointer it0 = (pointer)p->in_tables[0];
8511 	pointer it1 = (pointer)p->in_tables[1];
8512 	pointer it2 = (pointer)p->in_tables[2];
8513 	pointer it3 = (pointer)p->in_tables[3];
8514 	pointer it4 = (pointer)p->in_tables[4];
8515 	pointer it5 = (pointer)p->in_tables[5];
8516 	pointer ot0 = (pointer)p->out_tables[0];
8517 	pointer ot1 = (pointer)p->out_tables[1];
8518 	pointer ot2 = (pointer)p->out_tables[2];
8519 	pointer ot3 = (pointer)p->out_tables[3];
8520 	pointer ot4 = (pointer)p->out_tables[4];
8521 	pointer im_base = (pointer)p->im_table;
8522 
8523 	for(;ip0 < ep; ip0 += 6, op0 += 5) {
8524 		unsigned int ova0;	/* Output value accumulator */
8525 		unsigned int ova1;	/* Output value accumulator */
8526 		unsigned int ova2;	/* Output value partial accumulator */
8527 		{
8528 			pointer imp;
8529 			unsigned int wo0;	/* Weighting value and vertex offset variable */
8530 			unsigned int wo1;	/* Weighting value and vertex offset variable */
8531 			unsigned int wo2;	/* Weighting value and vertex offset variable */
8532 			unsigned int wo3;	/* Weighting value and vertex offset variable */
8533 			unsigned int wo4;	/* Weighting value and vertex offset variable */
8534 			unsigned int wo5;	/* Weighting value and vertex offset variable */
8535 			{
8536 				unsigned int ti_i;	/* Interpolation index variable */
8537 
8538 				ti_i  = IT_IX(it0, ip0[0]);
8539 				wo0   = IT_WO(it0, ip0[0]);
8540 				ti_i += IT_IX(it1, ip0[1]);
8541 				wo1   = IT_WO(it1, ip0[1]);
8542 				ti_i += IT_IX(it2, ip0[2]);
8543 				wo2   = IT_WO(it2, ip0[2]);
8544 				ti_i += IT_IX(it3, ip0[3]);
8545 				wo3   = IT_WO(it3, ip0[3]);
8546 				ti_i += IT_IX(it4, ip0[4]);
8547 				wo4   = IT_WO(it4, ip0[4]);
8548 				ti_i += IT_IX(it5, ip0[5]);
8549 				wo5   = IT_WO(it5, ip0[5]);
8550 
8551 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
8552 
8553 				/* Sort weighting values and vertex offset values */
8554 				CEX(wo0, wo1);
8555 				CEX(wo0, wo2);
8556 				CEX(wo0, wo3);
8557 				CEX(wo0, wo4);
8558 				CEX(wo0, wo5);
8559 				CEX(wo1, wo2);
8560 				CEX(wo1, wo3);
8561 				CEX(wo1, wo4);
8562 				CEX(wo1, wo5);
8563 				CEX(wo2, wo3);
8564 				CEX(wo2, wo4);
8565 				CEX(wo2, wo5);
8566 				CEX(wo3, wo4);
8567 				CEX(wo3, wo5);
8568 				CEX(wo4, wo5);
8569 			}
8570 			{
8571 				unsigned int nvof;	/* Next vertex offset value */
8572 				unsigned int vof;	/* Vertex offset value */
8573 				unsigned int vwe;	/* Vertex weighting */
8574 
8575 				vof = 0;				/* First vertex offset is 0 */
8576 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
8577 				wo0 = (wo0 >> 23);		/* Extract weighting value */
8578 				vwe = 256 - wo0;		/* Baricentric weighting */
8579 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
8580 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
8581 				ova2  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
8582 				vof += nvof;			/* Move to next vertex */
8583 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
8584 				wo1 = (wo1 >> 23);		/* Extract weighting value */
8585 				vwe = wo0 - wo1;		/* Baricentric weighting */
8586 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
8587 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
8588 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
8589 				vof += nvof;			/* Move to next vertex */
8590 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
8591 				wo2 = (wo2 >> 23);		/* Extract weighting value */
8592 				vwe = wo1 - wo2;		/* Baricentric weighting */
8593 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
8594 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
8595 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
8596 				vof += nvof;			/* Move to next vertex */
8597 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
8598 				wo3 = (wo3 >> 23);		/* Extract weighting value */
8599 				vwe = wo2 - wo3;		/* Baricentric weighting */
8600 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
8601 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
8602 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
8603 				vof += nvof;			/* Move to next vertex */
8604 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
8605 				wo4 = (wo4 >> 23);		/* Extract weighting value */
8606 				vwe = wo3 - wo4;		/* Baricentric weighting */
8607 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
8608 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
8609 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
8610 				vof += nvof;			/* Move to next vertex */
8611 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
8612 				wo5 = (wo5 >> 23);		/* Extract weighting value */
8613 				vwe = wo4 - wo5;		/* Baricentric weighting */
8614 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
8615 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
8616 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
8617 				vof += nvof;			/* Move to next vertex */
8618 				vwe = wo5;				/* Baricentric weighting */
8619 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
8620 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
8621 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
8622 			}
8623 		}
8624 		{
8625 			unsigned int oti;	/* Vertex offset value */
8626 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
8627 			op0[0] = OT_E(ot0, oti);	/* Write result */
8628 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
8629 			op0[1] = OT_E(ot1, oti);	/* Write result */
8630 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
8631 			op0[2] = OT_E(ot2, oti);	/* Write result */
8632 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
8633 			op0[3] = OT_E(ot3, oti);	/* Write result */
8634 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
8635 			op0[4] = OT_E(ot4, oti);	/* Write result */
8636 		}
8637 	}
8638 }
8639 #undef IT_WO
8640 #undef IT_IX
8641 #undef CEX
8642 #undef IM_O
8643 #undef IM_FE
8644 #undef IM_PE
8645 #undef OT_E
8646 
8647 void
imdi_k26_gen(genspec * g)8648 imdi_k26_gen(
8649 genspec *g			/* structure to be initialised */
8650 ) {
8651 	static unsigned char data[] = {
8652 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
8653 		0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8654 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8655 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8656 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8657 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8658 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8659 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
8660 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
8661 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
8662 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8663 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8664 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8665 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8666 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8667 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8668 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8669 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8670 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8671 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8672 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8673 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8674 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8675 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8676 		0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
8677 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
8678 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
8679 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8680 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8681 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8682 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8683 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
8684 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8685 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8686 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8687 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8688 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8689 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8690 		0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8691 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
8692 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
8693 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
8694 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
8695 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
8696 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
8697 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
8698 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
8699 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
8700 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8701 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
8702 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
8703 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x35, 0x5f,
8704 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
8705 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
8706 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
8707 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
8708 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
8709 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
8710 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
8711 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8712 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8713 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8714 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8715 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
8716 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x32, 0x36,
8717 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8718 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8719 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
8720 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
8721 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
8722 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
8723 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
8724 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
8725 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
8726 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
8727 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
8728 		0x00, 0xf0, 0x04, 0x08
8729 	};	/* Structure image */
8730 
8731 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
8732 }
8733 
8734 void
imdi_k26_tab(tabspec * t)8735 imdi_k26_tab(
8736 tabspec *t			/* structure to be initialised */
8737 ) {
8738 	static unsigned char data[] = {
8739 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8740 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8741 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8742 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
8743 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
8744 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
8745 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8746 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
8747 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
8748 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8749 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
8750 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
8751 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
8752 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
8753 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
8754 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8755 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
8756 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
8757 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
8758 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8759 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
8760 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
8761 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8762 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
8763 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8764 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8765 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8766 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
8767 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8768 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8769 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
8770 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
8771 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
8772 	};	/* Structure image */
8773 
8774 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
8775 }
8776 
8777 
8778 
8779 
8780 
8781 
8782 /* Integer Multi-Dimensional Interpolation */
8783 /* Interpolation Kernel Code */
8784 /* Generated by cgen */
8785 /* Copyright 2000 - 2002 Graeme W. Gill */
8786 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
8787 
8788 /* see the Licence.txt file for licencing details.*/
8789 
8790 
8791 /*
8792    Interpolation kernel specs:
8793 
8794    Input channels per pixel = 7
8795    Input channel 0 bits = 8
8796    Input channel 0 increment = 7
8797    Input channel 1 bits = 8
8798    Input channel 1 increment = 7
8799    Input channel 2 bits = 8
8800    Input channel 2 increment = 7
8801    Input channel 3 bits = 8
8802    Input channel 3 increment = 7
8803    Input channel 4 bits = 8
8804    Input channel 4 increment = 7
8805    Input channel 5 bits = 8
8806    Input channel 5 increment = 7
8807    Input channel 6 bits = 8
8808    Input channel 6 increment = 7
8809    Input is channel interleaved
8810    Input channels are separate words
8811    Input value extraction is done in input table lookup
8812 
8813    Output channels per pixel = 5
8814    Output channel 0 bits = 8
8815    Output channel 0 increment = 5
8816    Output channel 1 bits = 8
8817    Output channel 1 increment = 5
8818    Output channel 2 bits = 8
8819    Output channel 2 increment = 5
8820    Output channel 3 bits = 8
8821    Output channel 3 increment = 5
8822    Output channel 4 bits = 8
8823    Output channel 4 increment = 5
8824    Output is channel interleaved
8825 
8826    Output channels are separate words
8827    Weight+voffset bits       = 32
8828    Interpolation table index bits = 32
8829    Interpolation table max resolution = 11
8830  */
8831 
8832 /*
8833    Machine architecture specs:
8834 
8835    Little endian
8836    Reading and writing pixel values separately
8837    Pointer size = 32 bits
8838 
8839    Ordinal size  8 bits is known as 'unsigned char'
8840    Ordinal size 16 bits is known as 'unsigned short'
8841    Ordinal size 32 bits is known as 'unsigned int'
8842    Natural ordinal is 'unsigned int'
8843 
8844    Integer size  8 bits is known as 'signed char'
8845    Integer size 16 bits is known as 'short'
8846    Integer size 32 bits is known as 'int'
8847    Natural integer is 'int'
8848 
8849  */
8850 
8851 #ifndef  IMDI_INCLUDED
8852 #include <memory.h>
8853 #include "imdi_imp.h"
8854 #define  IMDI_INCLUDED
8855 #endif  /* IMDI_INCLUDED */
8856 
8857 #ifndef DEFINED_pointer
8858 #define DEFINED_pointer
8859 typedef unsigned char * pointer;
8860 #endif
8861 
8862 /* Input table interp. index */
8863 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
8864 
8865 /* Input table input weighting/offset value enty */
8866 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
8867 
8868 /* Conditional exchange for sorting */
8869 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
8870 
8871 /* Interpolation multi-dim. table access */
8872 #define IM_O(off) ((off) * 12)
8873 
8874 /* Interpolation table - get vertex values */
8875 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
8876 #define IM_PE(p, v) *((unsigned int *)((p) + 8 + (v) * 4))
8877 
8878 /* Output table indexes */
8879 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
8880 
8881 void
imdi_k27(imdi * s,void ** outp,void ** inp,unsigned int npix)8882 imdi_k27(
8883 imdi *s,			/* imdi context */
8884 void **outp,		/* pointer to output pointers */
8885 void **inp,		/* pointer to input pointers */
8886 unsigned int npix	/* Number of pixels to process */
8887 ) {
8888 	imdi_imp *p = (imdi_imp *)(s->impl);
8889 	unsigned char *ip0 = (unsigned char *)inp[0];
8890 	unsigned char *op0 = (unsigned char *)outp[0];
8891 	unsigned char *ep = ip0 + npix * 7 ;
8892 	pointer it0 = (pointer)p->in_tables[0];
8893 	pointer it1 = (pointer)p->in_tables[1];
8894 	pointer it2 = (pointer)p->in_tables[2];
8895 	pointer it3 = (pointer)p->in_tables[3];
8896 	pointer it4 = (pointer)p->in_tables[4];
8897 	pointer it5 = (pointer)p->in_tables[5];
8898 	pointer it6 = (pointer)p->in_tables[6];
8899 	pointer ot0 = (pointer)p->out_tables[0];
8900 	pointer ot1 = (pointer)p->out_tables[1];
8901 	pointer ot2 = (pointer)p->out_tables[2];
8902 	pointer ot3 = (pointer)p->out_tables[3];
8903 	pointer ot4 = (pointer)p->out_tables[4];
8904 	pointer im_base = (pointer)p->im_table;
8905 
8906 	for(;ip0 < ep; ip0 += 7, op0 += 5) {
8907 		unsigned int ova0;	/* Output value accumulator */
8908 		unsigned int ova1;	/* Output value accumulator */
8909 		unsigned int ova2;	/* Output value partial accumulator */
8910 		{
8911 			pointer imp;
8912 			unsigned int wo0;	/* Weighting value and vertex offset variable */
8913 			unsigned int wo1;	/* Weighting value and vertex offset variable */
8914 			unsigned int wo2;	/* Weighting value and vertex offset variable */
8915 			unsigned int wo3;	/* Weighting value and vertex offset variable */
8916 			unsigned int wo4;	/* Weighting value and vertex offset variable */
8917 			unsigned int wo5;	/* Weighting value and vertex offset variable */
8918 			unsigned int wo6;	/* Weighting value and vertex offset variable */
8919 			{
8920 				unsigned int ti_i;	/* Interpolation index variable */
8921 
8922 				ti_i  = IT_IX(it0, ip0[0]);
8923 				wo0   = IT_WO(it0, ip0[0]);
8924 				ti_i += IT_IX(it1, ip0[1]);
8925 				wo1   = IT_WO(it1, ip0[1]);
8926 				ti_i += IT_IX(it2, ip0[2]);
8927 				wo2   = IT_WO(it2, ip0[2]);
8928 				ti_i += IT_IX(it3, ip0[3]);
8929 				wo3   = IT_WO(it3, ip0[3]);
8930 				ti_i += IT_IX(it4, ip0[4]);
8931 				wo4   = IT_WO(it4, ip0[4]);
8932 				ti_i += IT_IX(it5, ip0[5]);
8933 				wo5   = IT_WO(it5, ip0[5]);
8934 				ti_i += IT_IX(it6, ip0[6]);
8935 				wo6   = IT_WO(it6, ip0[6]);
8936 
8937 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
8938 
8939 				/* Sort weighting values and vertex offset values */
8940 				CEX(wo0, wo1);
8941 				CEX(wo0, wo2);
8942 				CEX(wo0, wo3);
8943 				CEX(wo0, wo4);
8944 				CEX(wo0, wo5);
8945 				CEX(wo0, wo6);
8946 				CEX(wo1, wo2);
8947 				CEX(wo1, wo3);
8948 				CEX(wo1, wo4);
8949 				CEX(wo1, wo5);
8950 				CEX(wo1, wo6);
8951 				CEX(wo2, wo3);
8952 				CEX(wo2, wo4);
8953 				CEX(wo2, wo5);
8954 				CEX(wo2, wo6);
8955 				CEX(wo3, wo4);
8956 				CEX(wo3, wo5);
8957 				CEX(wo3, wo6);
8958 				CEX(wo4, wo5);
8959 				CEX(wo4, wo6);
8960 				CEX(wo5, wo6);
8961 			}
8962 			{
8963 				unsigned int nvof;	/* Next vertex offset value */
8964 				unsigned int vof;	/* Vertex offset value */
8965 				unsigned int vwe;	/* Vertex weighting */
8966 
8967 				vof = 0;				/* First vertex offset is 0 */
8968 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
8969 				wo0 = (wo0 >> 23);		/* Extract weighting value */
8970 				vwe = 256 - wo0;		/* Baricentric weighting */
8971 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
8972 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
8973 				ova2  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
8974 				vof += nvof;			/* Move to next vertex */
8975 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
8976 				wo1 = (wo1 >> 23);		/* Extract weighting value */
8977 				vwe = wo0 - wo1;		/* Baricentric weighting */
8978 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
8979 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
8980 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
8981 				vof += nvof;			/* Move to next vertex */
8982 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
8983 				wo2 = (wo2 >> 23);		/* Extract weighting value */
8984 				vwe = wo1 - wo2;		/* Baricentric weighting */
8985 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
8986 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
8987 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
8988 				vof += nvof;			/* Move to next vertex */
8989 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
8990 				wo3 = (wo3 >> 23);		/* Extract weighting value */
8991 				vwe = wo2 - wo3;		/* Baricentric weighting */
8992 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
8993 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
8994 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
8995 				vof += nvof;			/* Move to next vertex */
8996 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
8997 				wo4 = (wo4 >> 23);		/* Extract weighting value */
8998 				vwe = wo3 - wo4;		/* Baricentric weighting */
8999 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
9000 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
9001 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
9002 				vof += nvof;			/* Move to next vertex */
9003 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
9004 				wo5 = (wo5 >> 23);		/* Extract weighting value */
9005 				vwe = wo4 - wo5;		/* Baricentric weighting */
9006 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
9007 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
9008 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
9009 				vof += nvof;			/* Move to next vertex */
9010 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
9011 				wo6 = (wo6 >> 23);		/* Extract weighting value */
9012 				vwe = wo5 - wo6;		/* Baricentric weighting */
9013 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
9014 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
9015 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
9016 				vof += nvof;			/* Move to next vertex */
9017 				vwe = wo6;				/* Baricentric weighting */
9018 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
9019 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
9020 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
9021 			}
9022 		}
9023 		{
9024 			unsigned int oti;	/* Vertex offset value */
9025 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
9026 			op0[0] = OT_E(ot0, oti);	/* Write result */
9027 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
9028 			op0[1] = OT_E(ot1, oti);	/* Write result */
9029 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
9030 			op0[2] = OT_E(ot2, oti);	/* Write result */
9031 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
9032 			op0[3] = OT_E(ot3, oti);	/* Write result */
9033 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
9034 			op0[4] = OT_E(ot4, oti);	/* Write result */
9035 		}
9036 	}
9037 }
9038 #undef IT_WO
9039 #undef IT_IX
9040 #undef CEX
9041 #undef IM_O
9042 #undef IM_FE
9043 #undef IM_PE
9044 #undef OT_E
9045 
9046 void
imdi_k27_gen(genspec * g)9047 imdi_k27_gen(
9048 genspec *g			/* structure to be initialised */
9049 ) {
9050 	static unsigned char data[] = {
9051 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
9052 		0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9053 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9054 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9055 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9056 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9057 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9058 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
9059 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
9060 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
9061 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
9062 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9063 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9064 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9065 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9066 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9067 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9068 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9069 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9070 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9071 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9072 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9073 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9074 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9075 		0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
9076 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
9077 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
9078 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9079 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9080 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9081 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9082 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
9083 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9084 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9085 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9086 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9087 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9088 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9089 		0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9090 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
9091 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
9092 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
9093 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
9094 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
9095 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
9096 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
9097 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
9098 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
9099 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9100 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
9101 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
9102 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x35, 0x5f,
9103 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
9104 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
9105 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
9106 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
9107 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
9108 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
9109 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
9110 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9111 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9112 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9113 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9114 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
9115 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x32, 0x37,
9116 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9117 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9118 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
9119 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
9120 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
9121 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
9122 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
9123 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
9124 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
9125 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
9126 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
9127 		0x00, 0xf0, 0x04, 0x08
9128 	};	/* Structure image */
9129 
9130 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
9131 }
9132 
9133 void
imdi_k27_tab(tabspec * t)9134 imdi_k27_tab(
9135 tabspec *t			/* structure to be initialised */
9136 ) {
9137 	static unsigned char data[] = {
9138 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9139 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9140 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9141 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
9142 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
9143 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
9144 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9145 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
9146 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
9147 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9148 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
9149 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
9150 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
9151 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
9152 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
9153 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9154 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
9155 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
9156 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
9157 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9158 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9159 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
9160 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9161 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
9162 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9163 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9164 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9165 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
9166 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9167 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9168 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9169 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
9170 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
9171 	};	/* Structure image */
9172 
9173 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
9174 }
9175 
9176 
9177 
9178 
9179 
9180 
9181 /* Integer Multi-Dimensional Interpolation */
9182 /* Interpolation Kernel Code */
9183 /* Generated by cgen */
9184 /* Copyright 2000 - 2002 Graeme W. Gill */
9185 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
9186 
9187 /* see the Licence.txt file for licencing details.*/
9188 
9189 
9190 /*
9191    Interpolation kernel specs:
9192 
9193    Input channels per pixel = 8
9194    Input channel 0 bits = 8
9195    Input channel 0 increment = 8
9196    Input channel 1 bits = 8
9197    Input channel 1 increment = 8
9198    Input channel 2 bits = 8
9199    Input channel 2 increment = 8
9200    Input channel 3 bits = 8
9201    Input channel 3 increment = 8
9202    Input channel 4 bits = 8
9203    Input channel 4 increment = 8
9204    Input channel 5 bits = 8
9205    Input channel 5 increment = 8
9206    Input channel 6 bits = 8
9207    Input channel 6 increment = 8
9208    Input channel 7 bits = 8
9209    Input channel 7 increment = 8
9210    Input is channel interleaved
9211    Input channels are separate words
9212    Input value extraction is done in input table lookup
9213 
9214    Output channels per pixel = 5
9215    Output channel 0 bits = 8
9216    Output channel 0 increment = 5
9217    Output channel 1 bits = 8
9218    Output channel 1 increment = 5
9219    Output channel 2 bits = 8
9220    Output channel 2 increment = 5
9221    Output channel 3 bits = 8
9222    Output channel 3 increment = 5
9223    Output channel 4 bits = 8
9224    Output channel 4 increment = 5
9225    Output is channel interleaved
9226 
9227    Output channels are separate words
9228    Weight+voffset bits       = 32
9229    Interpolation table index bits = 32
9230    Interpolation table max resolution = 8
9231  */
9232 
9233 /*
9234    Machine architecture specs:
9235 
9236    Little endian
9237    Reading and writing pixel values separately
9238    Pointer size = 32 bits
9239 
9240    Ordinal size  8 bits is known as 'unsigned char'
9241    Ordinal size 16 bits is known as 'unsigned short'
9242    Ordinal size 32 bits is known as 'unsigned int'
9243    Natural ordinal is 'unsigned int'
9244 
9245    Integer size  8 bits is known as 'signed char'
9246    Integer size 16 bits is known as 'short'
9247    Integer size 32 bits is known as 'int'
9248    Natural integer is 'int'
9249 
9250  */
9251 
9252 #ifndef  IMDI_INCLUDED
9253 #include <memory.h>
9254 #include "imdi_imp.h"
9255 #define  IMDI_INCLUDED
9256 #endif  /* IMDI_INCLUDED */
9257 
9258 #ifndef DEFINED_pointer
9259 #define DEFINED_pointer
9260 typedef unsigned char * pointer;
9261 #endif
9262 
9263 /* Input table interp. index */
9264 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
9265 
9266 /* Input table input weighting/offset value enty */
9267 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
9268 
9269 /* Conditional exchange for sorting */
9270 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
9271 
9272 /* Interpolation multi-dim. table access */
9273 #define IM_O(off) ((off) * 12)
9274 
9275 /* Interpolation table - get vertex values */
9276 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
9277 #define IM_PE(p, v) *((unsigned int *)((p) + 8 + (v) * 4))
9278 
9279 /* Output table indexes */
9280 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
9281 
9282 void
imdi_k28(imdi * s,void ** outp,void ** inp,unsigned int npix)9283 imdi_k28(
9284 imdi *s,			/* imdi context */
9285 void **outp,		/* pointer to output pointers */
9286 void **inp,		/* pointer to input pointers */
9287 unsigned int npix	/* Number of pixels to process */
9288 ) {
9289 	imdi_imp *p = (imdi_imp *)(s->impl);
9290 	unsigned char *ip0 = (unsigned char *)inp[0];
9291 	unsigned char *op0 = (unsigned char *)outp[0];
9292 	unsigned char *ep = ip0 + npix * 8 ;
9293 	pointer it0 = (pointer)p->in_tables[0];
9294 	pointer it1 = (pointer)p->in_tables[1];
9295 	pointer it2 = (pointer)p->in_tables[2];
9296 	pointer it3 = (pointer)p->in_tables[3];
9297 	pointer it4 = (pointer)p->in_tables[4];
9298 	pointer it5 = (pointer)p->in_tables[5];
9299 	pointer it6 = (pointer)p->in_tables[6];
9300 	pointer it7 = (pointer)p->in_tables[7];
9301 	pointer ot0 = (pointer)p->out_tables[0];
9302 	pointer ot1 = (pointer)p->out_tables[1];
9303 	pointer ot2 = (pointer)p->out_tables[2];
9304 	pointer ot3 = (pointer)p->out_tables[3];
9305 	pointer ot4 = (pointer)p->out_tables[4];
9306 	pointer im_base = (pointer)p->im_table;
9307 
9308 	for(;ip0 < ep; ip0 += 8, op0 += 5) {
9309 		unsigned int ova0;	/* Output value accumulator */
9310 		unsigned int ova1;	/* Output value accumulator */
9311 		unsigned int ova2;	/* Output value partial accumulator */
9312 		{
9313 			pointer imp;
9314 			unsigned int wo0;	/* Weighting value and vertex offset variable */
9315 			unsigned int wo1;	/* Weighting value and vertex offset variable */
9316 			unsigned int wo2;	/* Weighting value and vertex offset variable */
9317 			unsigned int wo3;	/* Weighting value and vertex offset variable */
9318 			unsigned int wo4;	/* Weighting value and vertex offset variable */
9319 			unsigned int wo5;	/* Weighting value and vertex offset variable */
9320 			unsigned int wo6;	/* Weighting value and vertex offset variable */
9321 			unsigned int wo7;	/* Weighting value and vertex offset variable */
9322 			{
9323 				unsigned int ti_i;	/* Interpolation index variable */
9324 
9325 				ti_i  = IT_IX(it0, ip0[0]);
9326 				wo0   = IT_WO(it0, ip0[0]);
9327 				ti_i += IT_IX(it1, ip0[1]);
9328 				wo1   = IT_WO(it1, ip0[1]);
9329 				ti_i += IT_IX(it2, ip0[2]);
9330 				wo2   = IT_WO(it2, ip0[2]);
9331 				ti_i += IT_IX(it3, ip0[3]);
9332 				wo3   = IT_WO(it3, ip0[3]);
9333 				ti_i += IT_IX(it4, ip0[4]);
9334 				wo4   = IT_WO(it4, ip0[4]);
9335 				ti_i += IT_IX(it5, ip0[5]);
9336 				wo5   = IT_WO(it5, ip0[5]);
9337 				ti_i += IT_IX(it6, ip0[6]);
9338 				wo6   = IT_WO(it6, ip0[6]);
9339 				ti_i += IT_IX(it7, ip0[7]);
9340 				wo7   = IT_WO(it7, ip0[7]);
9341 
9342 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
9343 
9344 				/* Sort weighting values and vertex offset values */
9345 				CEX(wo0, wo1);
9346 				CEX(wo0, wo2);
9347 				CEX(wo0, wo3);
9348 				CEX(wo0, wo4);
9349 				CEX(wo0, wo5);
9350 				CEX(wo0, wo6);
9351 				CEX(wo0, wo7);
9352 				CEX(wo1, wo2);
9353 				CEX(wo1, wo3);
9354 				CEX(wo1, wo4);
9355 				CEX(wo1, wo5);
9356 				CEX(wo1, wo6);
9357 				CEX(wo1, wo7);
9358 				CEX(wo2, wo3);
9359 				CEX(wo2, wo4);
9360 				CEX(wo2, wo5);
9361 				CEX(wo2, wo6);
9362 				CEX(wo2, wo7);
9363 				CEX(wo3, wo4);
9364 				CEX(wo3, wo5);
9365 				CEX(wo3, wo6);
9366 				CEX(wo3, wo7);
9367 				CEX(wo4, wo5);
9368 				CEX(wo4, wo6);
9369 				CEX(wo4, wo7);
9370 				CEX(wo5, wo6);
9371 				CEX(wo5, wo7);
9372 				CEX(wo6, wo7);
9373 			}
9374 			{
9375 				unsigned int nvof;	/* Next vertex offset value */
9376 				unsigned int vof;	/* Vertex offset value */
9377 				unsigned int vwe;	/* Vertex weighting */
9378 
9379 				vof = 0;				/* First vertex offset is 0 */
9380 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
9381 				wo0 = (wo0 >> 23);		/* Extract weighting value */
9382 				vwe = 256 - wo0;		/* Baricentric weighting */
9383 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
9384 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
9385 				ova2  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
9386 				vof += nvof;			/* Move to next vertex */
9387 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
9388 				wo1 = (wo1 >> 23);		/* Extract weighting value */
9389 				vwe = wo0 - wo1;		/* Baricentric weighting */
9390 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
9391 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
9392 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
9393 				vof += nvof;			/* Move to next vertex */
9394 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
9395 				wo2 = (wo2 >> 23);		/* Extract weighting value */
9396 				vwe = wo1 - wo2;		/* Baricentric weighting */
9397 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
9398 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
9399 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
9400 				vof += nvof;			/* Move to next vertex */
9401 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
9402 				wo3 = (wo3 >> 23);		/* Extract weighting value */
9403 				vwe = wo2 - wo3;		/* Baricentric weighting */
9404 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
9405 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
9406 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
9407 				vof += nvof;			/* Move to next vertex */
9408 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
9409 				wo4 = (wo4 >> 23);		/* Extract weighting value */
9410 				vwe = wo3 - wo4;		/* Baricentric weighting */
9411 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
9412 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
9413 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
9414 				vof += nvof;			/* Move to next vertex */
9415 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
9416 				wo5 = (wo5 >> 23);		/* Extract weighting value */
9417 				vwe = wo4 - wo5;		/* Baricentric weighting */
9418 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
9419 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
9420 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
9421 				vof += nvof;			/* Move to next vertex */
9422 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
9423 				wo6 = (wo6 >> 23);		/* Extract weighting value */
9424 				vwe = wo5 - wo6;		/* Baricentric weighting */
9425 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
9426 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
9427 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
9428 				vof += nvof;			/* Move to next vertex */
9429 				nvof = (wo7 & 0x7fffff);	/* Extract offset value */
9430 				wo7 = (wo7 >> 23);		/* Extract weighting value */
9431 				vwe = wo6 - wo7;		/* Baricentric weighting */
9432 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
9433 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
9434 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
9435 				vof += nvof;			/* Move to next vertex */
9436 				vwe = wo7;				/* Baricentric weighting */
9437 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
9438 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
9439 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
9440 			}
9441 		}
9442 		{
9443 			unsigned int oti;	/* Vertex offset value */
9444 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
9445 			op0[0] = OT_E(ot0, oti);	/* Write result */
9446 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
9447 			op0[1] = OT_E(ot1, oti);	/* Write result */
9448 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
9449 			op0[2] = OT_E(ot2, oti);	/* Write result */
9450 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
9451 			op0[3] = OT_E(ot3, oti);	/* Write result */
9452 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
9453 			op0[4] = OT_E(ot4, oti);	/* Write result */
9454 		}
9455 	}
9456 }
9457 #undef IT_WO
9458 #undef IT_IX
9459 #undef CEX
9460 #undef IM_O
9461 #undef IM_FE
9462 #undef IM_PE
9463 #undef OT_E
9464 
9465 void
imdi_k28_gen(genspec * g)9466 imdi_k28_gen(
9467 genspec *g			/* structure to be initialised */
9468 ) {
9469 	static unsigned char data[] = {
9470 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9471 		0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9472 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9473 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9474 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9475 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9476 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9477 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9478 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9479 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9480 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9481 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9482 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9483 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9484 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9485 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9486 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9487 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9488 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9489 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9490 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9491 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9492 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9493 		0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9494 		0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
9495 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
9496 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
9497 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9498 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9499 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9500 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9501 		0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
9502 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9503 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9504 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9505 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9506 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9507 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9508 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9509 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
9510 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
9511 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
9512 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
9513 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
9514 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
9515 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
9516 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
9517 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
9518 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9519 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
9520 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
9521 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x35, 0x5f,
9522 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
9523 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
9524 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
9525 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
9526 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
9527 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
9528 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
9529 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9530 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9531 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9532 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9533 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
9534 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x32, 0x38,
9535 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9536 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9537 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
9538 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
9539 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
9540 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
9541 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
9542 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
9543 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
9544 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
9545 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
9546 		0x00, 0xf0, 0x04, 0x08
9547 	};	/* Structure image */
9548 
9549 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
9550 }
9551 
9552 void
imdi_k28_tab(tabspec * t)9553 imdi_k28_tab(
9554 tabspec *t			/* structure to be initialised */
9555 ) {
9556 	static unsigned char data[] = {
9557 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9558 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9559 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9560 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
9561 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
9562 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
9563 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9564 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
9565 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
9566 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9567 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
9568 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
9569 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
9570 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
9571 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
9572 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9573 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
9574 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
9575 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
9576 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9577 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9578 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
9579 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9580 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
9581 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9582 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9583 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9584 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
9585 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9586 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9587 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9588 		0x20, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
9589 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
9590 	};	/* Structure image */
9591 
9592 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
9593 }
9594 
9595 
9596 
9597 
9598 
9599 
9600 /* Integer Multi-Dimensional Interpolation */
9601 /* Interpolation Kernel Code */
9602 /* Generated by cgen */
9603 /* Copyright 2000 - 2002 Graeme W. Gill */
9604 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
9605 
9606 /* see the Licence.txt file for licencing details.*/
9607 
9608 
9609 /*
9610    Interpolation kernel specs:
9611 
9612    Input channels per pixel = 1
9613    Input channel 0 bits = 8
9614    Input channel 0 increment = 1
9615    Input is channel interleaved
9616    Input channels are separate words
9617    Input value extraction is done in input table lookup
9618 
9619    Output channels per pixel = 6
9620    Output channel 0 bits = 8
9621    Output channel 0 increment = 6
9622    Output channel 1 bits = 8
9623    Output channel 1 increment = 6
9624    Output channel 2 bits = 8
9625    Output channel 2 increment = 6
9626    Output channel 3 bits = 8
9627    Output channel 3 increment = 6
9628    Output channel 4 bits = 8
9629    Output channel 4 increment = 6
9630    Output channel 5 bits = 8
9631    Output channel 5 increment = 6
9632    Output is channel interleaved
9633 
9634    Output channels are separate words
9635    Simplex table index bits       = 0
9636    Interpolation table index bits = 8
9637    Simplex table max resolution = 1
9638    Interpolation table max resolution = 255
9639  */
9640 
9641 /*
9642    Machine architecture specs:
9643 
9644    Little endian
9645    Reading and writing pixel values separately
9646    Pointer size = 32 bits
9647 
9648    Ordinal size  8 bits is known as 'unsigned char'
9649    Ordinal size 16 bits is known as 'unsigned short'
9650    Ordinal size 32 bits is known as 'unsigned int'
9651    Natural ordinal is 'unsigned int'
9652 
9653    Integer size  8 bits is known as 'signed char'
9654    Integer size 16 bits is known as 'short'
9655    Integer size 32 bits is known as 'int'
9656    Natural integer is 'int'
9657 
9658  */
9659 
9660 #ifndef  IMDI_INCLUDED
9661 #include <memory.h>
9662 #include "imdi_imp.h"
9663 #define  IMDI_INCLUDED
9664 #endif  /* IMDI_INCLUDED */
9665 
9666 #ifndef DEFINED_pointer
9667 #define DEFINED_pointer
9668 typedef unsigned char * pointer;
9669 #endif
9670 
9671 /* Input table inter & simplex indexes */
9672 #define IT_IT(p, off) *((unsigned char *)((p) + 0 + (off) * 1))
9673 
9674 /* Simplex weighting table access */
9675 #define SW_O(off) ((off) * 4)
9676 
9677 /* Simplex table - get weighting/offset value */
9678 #define SX_WO(p, v) *((unsigned short *)((p) + (v) * 2))
9679 
9680 /* Interpolation multi-dim. table access */
9681 #define IM_O(off) ((off) * 12)
9682 
9683 /* Interpolation table - get vertex values */
9684 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
9685 
9686 /* Output table indexes */
9687 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
9688 
9689 void
imdi_k29(imdi * s,void ** outp,void ** inp,unsigned int npix)9690 imdi_k29(
9691 imdi *s,			/* imdi context */
9692 void **outp,		/* pointer to output pointers */
9693 void **inp,		/* pointer to input pointers */
9694 unsigned int npix	/* Number of pixels to process */
9695 ) {
9696 	imdi_imp *p = (imdi_imp *)(s->impl);
9697 	unsigned char *ip0 = (unsigned char *)inp[0];
9698 	unsigned char *op0 = (unsigned char *)outp[0];
9699 	unsigned char *ep = ip0 + npix * 1 ;
9700 	pointer it0 = (pointer)p->in_tables[0];
9701 	pointer ot0 = (pointer)p->out_tables[0];
9702 	pointer ot1 = (pointer)p->out_tables[1];
9703 	pointer ot2 = (pointer)p->out_tables[2];
9704 	pointer ot3 = (pointer)p->out_tables[3];
9705 	pointer ot4 = (pointer)p->out_tables[4];
9706 	pointer ot5 = (pointer)p->out_tables[5];
9707 	pointer sw_base = (pointer)p->sw_table;
9708 	pointer im_base = (pointer)p->im_table;
9709 
9710 	for(;ip0 < ep; ip0 += 1, op0 += 6) {
9711 		unsigned int ova0;	/* Output value accumulator */
9712 		unsigned int ova1;	/* Output value accumulator */
9713 		unsigned int ova2;	/* Output value accumulator */
9714 		{
9715 			pointer swp;
9716 			pointer imp;
9717 			{
9718 				unsigned int ti;	/* Simplex+Interpolation index variable */
9719 
9720 				ti  = IT_IT(it0, ip0[0]);
9721 
9722 				imp = im_base + IM_O(ti >> 0);		/* Extract interp. index and comp. entry */
9723 				swp = sw_base + SW_O(ti & 0x0);	/* Extract simplex index and comp. entry */
9724 			}
9725 			{
9726 				unsigned int vowr;	/* Vertex offset/weight value */
9727 				unsigned int vof;	/* Vertex offset value */
9728 				unsigned int vwe;	/* Vertex weighting */
9729 
9730 				vowr = SX_WO(swp, 0);	/* Read vertex offset+weighting values */
9731 				vof = (vowr & 0x7f);	/* Extract offset value */
9732 				vwe = (vowr >> 7);	/* Extract weighting value */
9733 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
9734 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
9735 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
9736 				vowr = SX_WO(swp, 1);	/* Read vertex offset+weighting values */
9737 				vof = (vowr & 0x7f);	/* Extract offset value */
9738 				vwe = (vowr >> 7);	/* Extract weighting value */
9739 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
9740 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
9741 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
9742 			}
9743 		}
9744 		{
9745 			unsigned int oti;	/* Vertex offset value */
9746 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
9747 			op0[0] = OT_E(ot0, oti);	/* Write result */
9748 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
9749 			op0[1] = OT_E(ot1, oti);	/* Write result */
9750 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
9751 			op0[2] = OT_E(ot2, oti);	/* Write result */
9752 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
9753 			op0[3] = OT_E(ot3, oti);	/* Write result */
9754 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
9755 			op0[4] = OT_E(ot4, oti);	/* Write result */
9756 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
9757 			op0[5] = OT_E(ot5, oti);	/* Write result */
9758 		}
9759 	}
9760 }
9761 #undef IT_IT
9762 #undef SW_O
9763 #undef SX_WO
9764 #undef IM_O
9765 #undef IM_FE
9766 #undef OT_E
9767 
9768 void
imdi_k29_gen(genspec * g)9769 imdi_k29_gen(
9770 genspec *g			/* structure to be initialised */
9771 ) {
9772 	static unsigned char data[] = {
9773 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9774 		0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9775 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9776 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9777 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9778 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9779 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9780 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9781 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9782 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9783 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9784 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9785 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9786 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9787 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9788 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9789 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9790 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9791 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9792 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9793 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9794 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9795 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9796 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9797 		0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
9798 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
9799 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
9800 		0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9801 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9802 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9803 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9804 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9805 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9806 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9807 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9808 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9809 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9810 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9811 		0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9812 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
9813 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
9814 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
9815 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
9816 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
9817 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
9818 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
9819 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
9820 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
9821 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9822 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
9823 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
9824 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x36, 0x5f,
9825 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
9826 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
9827 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
9828 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
9829 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
9830 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
9831 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
9832 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9833 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9834 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9835 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9836 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
9837 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x32, 0x39,
9838 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9839 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9840 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
9841 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
9842 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
9843 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
9844 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
9845 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
9846 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
9847 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
9848 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
9849 		0x00, 0xf0, 0x04, 0x08
9850 	};	/* Structure image */
9851 
9852 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
9853 }
9854 
9855 void
imdi_k29_tab(tabspec * t)9856 imdi_k29_tab(
9857 tabspec *t			/* structure to be initialised */
9858 ) {
9859 	static unsigned char data[] = {
9860 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9861 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9862 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9863 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
9864 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
9865 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
9866 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9867 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
9868 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9869 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9870 		0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
9871 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9872 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
9873 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
9874 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
9875 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9876 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
9877 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
9878 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9879 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9880 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9881 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
9882 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
9883 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
9884 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9885 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9886 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9887 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
9888 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9889 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9890 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
9891 		0x08, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
9892 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
9893 	};	/* Structure image */
9894 
9895 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
9896 }
9897 
9898 
9899 
9900 
9901 
9902 
9903 /* Integer Multi-Dimensional Interpolation */
9904 /* Interpolation Kernel Code */
9905 /* Generated by cgen */
9906 /* Copyright 2000 - 2002 Graeme W. Gill */
9907 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
9908 
9909 /* see the Licence.txt file for licencing details.*/
9910 
9911 
9912 /*
9913    Interpolation kernel specs:
9914 
9915    Input channels per pixel = 3
9916    Input channel 0 bits = 8
9917    Input channel 0 increment = 3
9918    Input channel 1 bits = 8
9919    Input channel 1 increment = 3
9920    Input channel 2 bits = 8
9921    Input channel 2 increment = 3
9922    Input is channel interleaved
9923    Input channels are separate words
9924    Input value extraction is done in input table lookup
9925 
9926    Output channels per pixel = 6
9927    Output channel 0 bits = 8
9928    Output channel 0 increment = 6
9929    Output channel 1 bits = 8
9930    Output channel 1 increment = 6
9931    Output channel 2 bits = 8
9932    Output channel 2 increment = 6
9933    Output channel 3 bits = 8
9934    Output channel 3 increment = 6
9935    Output channel 4 bits = 8
9936    Output channel 4 increment = 6
9937    Output channel 5 bits = 8
9938    Output channel 5 increment = 6
9939    Output is channel interleaved
9940 
9941    Output channels are separate words
9942    Simplex table index bits       = 12
9943    Interpolation table index bits = 20
9944    Simplex table max resolution = 16
9945    Interpolation table max resolution = 101
9946  */
9947 
9948 /*
9949    Machine architecture specs:
9950 
9951    Little endian
9952    Reading and writing pixel values separately
9953    Pointer size = 32 bits
9954 
9955    Ordinal size  8 bits is known as 'unsigned char'
9956    Ordinal size 16 bits is known as 'unsigned short'
9957    Ordinal size 32 bits is known as 'unsigned int'
9958    Natural ordinal is 'unsigned int'
9959 
9960    Integer size  8 bits is known as 'signed char'
9961    Integer size 16 bits is known as 'short'
9962    Integer size 32 bits is known as 'int'
9963    Natural integer is 'int'
9964 
9965  */
9966 
9967 #ifndef  IMDI_INCLUDED
9968 #include <memory.h>
9969 #include "imdi_imp.h"
9970 #define  IMDI_INCLUDED
9971 #endif  /* IMDI_INCLUDED */
9972 
9973 #ifndef DEFINED_pointer
9974 #define DEFINED_pointer
9975 typedef unsigned char * pointer;
9976 #endif
9977 
9978 /* Input table inter & simplex indexes */
9979 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
9980 
9981 /* Simplex weighting table access */
9982 #define SW_O(off) ((off) * 16)
9983 
9984 /* Simplex table - get weighting value */
9985 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
9986 
9987 /* Simplex table - get offset value */
9988 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
9989 
9990 /* Interpolation multi-dim. table access */
9991 #define IM_O(off) ((off) * 12)
9992 
9993 /* Interpolation table - get vertex values */
9994 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
9995 
9996 /* Output table indexes */
9997 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
9998 
9999 void
imdi_k30(imdi * s,void ** outp,void ** inp,unsigned int npix)10000 imdi_k30(
10001 imdi *s,			/* imdi context */
10002 void **outp,		/* pointer to output pointers */
10003 void **inp,		/* pointer to input pointers */
10004 unsigned int npix	/* Number of pixels to process */
10005 ) {
10006 	imdi_imp *p = (imdi_imp *)(s->impl);
10007 	unsigned char *ip0 = (unsigned char *)inp[0];
10008 	unsigned char *op0 = (unsigned char *)outp[0];
10009 	unsigned char *ep = ip0 + npix * 3 ;
10010 	pointer it0 = (pointer)p->in_tables[0];
10011 	pointer it1 = (pointer)p->in_tables[1];
10012 	pointer it2 = (pointer)p->in_tables[2];
10013 	pointer ot0 = (pointer)p->out_tables[0];
10014 	pointer ot1 = (pointer)p->out_tables[1];
10015 	pointer ot2 = (pointer)p->out_tables[2];
10016 	pointer ot3 = (pointer)p->out_tables[3];
10017 	pointer ot4 = (pointer)p->out_tables[4];
10018 	pointer ot5 = (pointer)p->out_tables[5];
10019 	pointer sw_base = (pointer)p->sw_table;
10020 	pointer im_base = (pointer)p->im_table;
10021 
10022 	for(;ip0 < ep; ip0 += 3, op0 += 6) {
10023 		unsigned int ova0;	/* Output value accumulator */
10024 		unsigned int ova1;	/* Output value accumulator */
10025 		unsigned int ova2;	/* Output value accumulator */
10026 		{
10027 			pointer swp;
10028 			pointer imp;
10029 			{
10030 				unsigned int ti;	/* Simplex+Interpolation index variable */
10031 
10032 				ti  = IT_IT(it0, ip0[0]);
10033 				ti += IT_IT(it1, ip0[1]);
10034 				ti += IT_IT(it2, ip0[2]);
10035 
10036 				imp = im_base + IM_O(ti >> 12);		/* Extract interp. index and comp. entry */
10037 				swp = sw_base + SW_O(ti & 0xfff);	/* Extract simplex index and comp. entry */
10038 			}
10039 			{
10040 				unsigned int vof;	/* Vertex offset value */
10041 				unsigned int vwe;	/* Vertex weighting */
10042 
10043 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
10044 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
10045 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
10046 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
10047 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
10048 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
10049 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
10050 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
10051 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
10052 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
10053 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
10054 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
10055 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
10056 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
10057 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
10058 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
10059 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
10060 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
10061 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
10062 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
10063 			}
10064 		}
10065 		{
10066 			unsigned int oti;	/* Vertex offset value */
10067 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
10068 			op0[0] = OT_E(ot0, oti);	/* Write result */
10069 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
10070 			op0[1] = OT_E(ot1, oti);	/* Write result */
10071 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
10072 			op0[2] = OT_E(ot2, oti);	/* Write result */
10073 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
10074 			op0[3] = OT_E(ot3, oti);	/* Write result */
10075 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
10076 			op0[4] = OT_E(ot4, oti);	/* Write result */
10077 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
10078 			op0[5] = OT_E(ot5, oti);	/* Write result */
10079 		}
10080 	}
10081 }
10082 #undef IT_IT
10083 #undef SW_O
10084 #undef SX_WE
10085 #undef SX_VO
10086 #undef IM_O
10087 #undef IM_FE
10088 #undef OT_E
10089 
10090 void
imdi_k30_gen(genspec * g)10091 imdi_k30_gen(
10092 genspec *g			/* structure to be initialised */
10093 ) {
10094 	static unsigned char data[] = {
10095 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
10096 		0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10097 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10098 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10099 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10100 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10101 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10102 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
10103 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
10104 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10105 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10106 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10107 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10108 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10109 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10110 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10111 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10112 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10113 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10114 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10115 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10116 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10117 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10118 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10119 		0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
10120 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
10121 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
10122 		0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10123 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10124 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10125 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10126 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10127 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10128 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10129 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10130 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10131 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10132 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10133 		0x65, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
10134 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
10135 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
10136 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
10137 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
10138 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
10139 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
10140 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
10141 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
10142 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
10143 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10144 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
10145 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
10146 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x36, 0x5f,
10147 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
10148 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
10149 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
10150 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
10151 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
10152 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
10153 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
10154 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10155 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10156 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10157 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10158 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
10159 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x33, 0x30,
10160 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10161 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10162 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
10163 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
10164 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
10165 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
10166 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
10167 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
10168 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
10169 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
10170 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
10171 		0x00, 0xf0, 0x04, 0x08
10172 	};	/* Structure image */
10173 
10174 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
10175 }
10176 
10177 void
imdi_k30_tab(tabspec * t)10178 imdi_k30_tab(
10179 tabspec *t			/* structure to be initialised */
10180 ) {
10181 	static unsigned char data[] = {
10182 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10183 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10184 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10185 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
10186 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
10187 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
10188 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
10189 		0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
10190 		0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
10191 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10192 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
10193 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10194 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
10195 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
10196 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
10197 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10198 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
10199 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
10200 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10201 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10202 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10203 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
10204 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
10205 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
10206 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10207 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10208 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10209 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
10210 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10211 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10212 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10213 		0x08, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
10214 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
10215 	};	/* Structure image */
10216 
10217 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
10218 }
10219 
10220 
10221 
10222 
10223 
10224 
10225 /* Integer Multi-Dimensional Interpolation */
10226 /* Interpolation Kernel Code */
10227 /* Generated by cgen */
10228 /* Copyright 2000 - 2002 Graeme W. Gill */
10229 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
10230 
10231 /* see the Licence.txt file for licencing details.*/
10232 
10233 
10234 /*
10235    Interpolation kernel specs:
10236 
10237    Input channels per pixel = 4
10238    Input channel 0 bits = 8
10239    Input channel 0 increment = 4
10240    Input channel 1 bits = 8
10241    Input channel 1 increment = 4
10242    Input channel 2 bits = 8
10243    Input channel 2 increment = 4
10244    Input channel 3 bits = 8
10245    Input channel 3 increment = 4
10246    Input is channel interleaved
10247    Input channels are separate words
10248    Input value extraction is done in input table lookup
10249 
10250    Output channels per pixel = 6
10251    Output channel 0 bits = 8
10252    Output channel 0 increment = 6
10253    Output channel 1 bits = 8
10254    Output channel 1 increment = 6
10255    Output channel 2 bits = 8
10256    Output channel 2 increment = 6
10257    Output channel 3 bits = 8
10258    Output channel 3 increment = 6
10259    Output channel 4 bits = 8
10260    Output channel 4 increment = 6
10261    Output channel 5 bits = 8
10262    Output channel 5 increment = 6
10263    Output is channel interleaved
10264 
10265    Output channels are separate words
10266    Simplex table index bits       = 32
10267    Interpolation table index bits = 32
10268    Simplex table max resolution = 255
10269    Interpolation table max resolution = 27
10270  */
10271 
10272 /*
10273    Machine architecture specs:
10274 
10275    Little endian
10276    Reading and writing pixel values separately
10277    Pointer size = 32 bits
10278 
10279    Ordinal size  8 bits is known as 'unsigned char'
10280    Ordinal size 16 bits is known as 'unsigned short'
10281    Ordinal size 32 bits is known as 'unsigned int'
10282    Natural ordinal is 'unsigned int'
10283 
10284    Integer size  8 bits is known as 'signed char'
10285    Integer size 16 bits is known as 'short'
10286    Integer size 32 bits is known as 'int'
10287    Natural integer is 'int'
10288 
10289  */
10290 
10291 #ifndef  IMDI_INCLUDED
10292 #include <memory.h>
10293 #include "imdi_imp.h"
10294 #define  IMDI_INCLUDED
10295 #endif  /* IMDI_INCLUDED */
10296 
10297 #ifndef DEFINED_pointer
10298 #define DEFINED_pointer
10299 typedef unsigned char * pointer;
10300 #endif
10301 
10302 /* Input table interp. index */
10303 #define IT_IX(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
10304 
10305 /* Input table simplex index enty */
10306 #define IT_SX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
10307 
10308 /* Simplex weighting table access */
10309 #define SW_O(off) ((off) * 20)
10310 
10311 /* Simplex table - get weighting value */
10312 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
10313 
10314 /* Simplex table - get offset value */
10315 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
10316 
10317 /* Interpolation multi-dim. table access */
10318 #define IM_O(off) ((off) * 12)
10319 
10320 /* Interpolation table - get vertex values */
10321 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
10322 
10323 /* Output table indexes */
10324 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
10325 
10326 void
imdi_k31(imdi * s,void ** outp,void ** inp,unsigned int npix)10327 imdi_k31(
10328 imdi *s,			/* imdi context */
10329 void **outp,		/* pointer to output pointers */
10330 void **inp,		/* pointer to input pointers */
10331 unsigned int npix	/* Number of pixels to process */
10332 ) {
10333 	imdi_imp *p = (imdi_imp *)(s->impl);
10334 	unsigned char *ip0 = (unsigned char *)inp[0];
10335 	unsigned char *op0 = (unsigned char *)outp[0];
10336 	unsigned char *ep = ip0 + npix * 4 ;
10337 	pointer it0 = (pointer)p->in_tables[0];
10338 	pointer it1 = (pointer)p->in_tables[1];
10339 	pointer it2 = (pointer)p->in_tables[2];
10340 	pointer it3 = (pointer)p->in_tables[3];
10341 	pointer ot0 = (pointer)p->out_tables[0];
10342 	pointer ot1 = (pointer)p->out_tables[1];
10343 	pointer ot2 = (pointer)p->out_tables[2];
10344 	pointer ot3 = (pointer)p->out_tables[3];
10345 	pointer ot4 = (pointer)p->out_tables[4];
10346 	pointer ot5 = (pointer)p->out_tables[5];
10347 	pointer sw_base = (pointer)p->sw_table;
10348 	pointer im_base = (pointer)p->im_table;
10349 
10350 	for(;ip0 < ep; ip0 += 4, op0 += 6) {
10351 		unsigned int ova0;	/* Output value accumulator */
10352 		unsigned int ova1;	/* Output value accumulator */
10353 		unsigned int ova2;	/* Output value accumulator */
10354 		{
10355 			pointer swp;
10356 			pointer imp;
10357 			{
10358 				unsigned int ti_s;	/* Simplex index variable */
10359 				unsigned int ti_i;	/* Interpolation index variable */
10360 
10361 				ti_i  = IT_IX(it0, ip0[0]);
10362 				ti_s  = IT_SX(it0, ip0[0]);
10363 				ti_i += IT_IX(it1, ip0[1]);
10364 				ti_s += IT_SX(it1, ip0[1]);
10365 				ti_i += IT_IX(it2, ip0[2]);
10366 				ti_s += IT_SX(it2, ip0[2]);
10367 				ti_i += IT_IX(it3, ip0[3]);
10368 				ti_s += IT_SX(it3, ip0[3]);
10369 
10370 				swp = sw_base + SW_O(ti_s);		/* Compute simplex table entry pointer */
10371 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
10372 			}
10373 			{
10374 				unsigned int vof;	/* Vertex offset value */
10375 				unsigned int vwe;	/* Vertex weighting */
10376 
10377 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
10378 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
10379 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
10380 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
10381 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
10382 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
10383 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
10384 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
10385 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
10386 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
10387 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
10388 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
10389 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
10390 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
10391 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
10392 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
10393 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
10394 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
10395 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
10396 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
10397 				vof = SX_VO(swp, 4);	/* Read vertex offset value */
10398 				vwe = SX_WE(swp, 4);	/* Read vertex weighting value */
10399 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
10400 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
10401 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
10402 			}
10403 		}
10404 		{
10405 			unsigned int oti;	/* Vertex offset value */
10406 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
10407 			op0[0] = OT_E(ot0, oti);	/* Write result */
10408 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
10409 			op0[1] = OT_E(ot1, oti);	/* Write result */
10410 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
10411 			op0[2] = OT_E(ot2, oti);	/* Write result */
10412 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
10413 			op0[3] = OT_E(ot3, oti);	/* Write result */
10414 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
10415 			op0[4] = OT_E(ot4, oti);	/* Write result */
10416 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
10417 			op0[5] = OT_E(ot5, oti);	/* Write result */
10418 		}
10419 	}
10420 }
10421 #undef IT_IX
10422 #undef IT_SX
10423 #undef SW_O
10424 #undef SX_WE
10425 #undef SX_VO
10426 #undef IM_O
10427 #undef IM_FE
10428 #undef OT_E
10429 
10430 void
imdi_k31_gen(genspec * g)10431 imdi_k31_gen(
10432 genspec *g			/* structure to be initialised */
10433 ) {
10434 	static unsigned char data[] = {
10435 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
10436 		0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10437 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10438 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10439 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10440 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10441 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10442 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
10443 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
10444 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10445 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10446 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10447 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10448 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10449 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10450 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10451 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10452 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10453 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10454 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10455 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10456 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10457 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10458 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10459 		0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
10460 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
10461 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
10462 		0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10463 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10464 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10465 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10466 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10467 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10468 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10469 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10470 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10471 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10472 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10473 		0x1b, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
10474 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
10475 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
10476 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
10477 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
10478 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
10479 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
10480 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
10481 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
10482 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
10483 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10484 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
10485 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
10486 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x36, 0x5f,
10487 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
10488 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
10489 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
10490 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
10491 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
10492 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
10493 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
10494 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10495 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10496 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10497 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10498 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
10499 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x33, 0x31,
10500 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10501 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10502 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
10503 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
10504 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
10505 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
10506 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
10507 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
10508 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
10509 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
10510 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
10511 		0x00, 0xf0, 0x04, 0x08
10512 	};	/* Structure image */
10513 
10514 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
10515 }
10516 
10517 void
imdi_k31_tab(tabspec * t)10518 imdi_k31_tab(
10519 tabspec *t			/* structure to be initialised */
10520 ) {
10521 	static unsigned char data[] = {
10522 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10523 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10524 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10525 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
10526 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
10527 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
10528 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10529 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
10530 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
10531 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10532 		0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
10533 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10534 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
10535 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
10536 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
10537 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10538 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
10539 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
10540 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10541 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10542 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10543 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
10544 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
10545 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
10546 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10547 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10548 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10549 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
10550 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10551 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10552 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10553 		0x08, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
10554 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
10555 	};	/* Structure image */
10556 
10557 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
10558 }
10559 
10560 
10561 
10562 
10563 
10564 
10565 /* Integer Multi-Dimensional Interpolation */
10566 /* Interpolation Kernel Code */
10567 /* Generated by cgen */
10568 /* Copyright 2000 - 2002 Graeme W. Gill */
10569 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
10570 
10571 /* see the Licence.txt file for licencing details.*/
10572 
10573 
10574 /*
10575    Interpolation kernel specs:
10576 
10577    Input channels per pixel = 5
10578    Input channel 0 bits = 8
10579    Input channel 0 increment = 5
10580    Input channel 1 bits = 8
10581    Input channel 1 increment = 5
10582    Input channel 2 bits = 8
10583    Input channel 2 increment = 5
10584    Input channel 3 bits = 8
10585    Input channel 3 increment = 5
10586    Input channel 4 bits = 8
10587    Input channel 4 increment = 5
10588    Input is channel interleaved
10589    Input channels are separate words
10590    Input value extraction is done in input table lookup
10591 
10592    Output channels per pixel = 6
10593    Output channel 0 bits = 8
10594    Output channel 0 increment = 6
10595    Output channel 1 bits = 8
10596    Output channel 1 increment = 6
10597    Output channel 2 bits = 8
10598    Output channel 2 increment = 6
10599    Output channel 3 bits = 8
10600    Output channel 3 increment = 6
10601    Output channel 4 bits = 8
10602    Output channel 4 increment = 6
10603    Output channel 5 bits = 8
10604    Output channel 5 increment = 6
10605    Output is channel interleaved
10606 
10607    Output channels are separate words
10608    Weight+voffset bits       = 32
10609    Interpolation table index bits = 32
10610    Interpolation table max resolution = 40
10611  */
10612 
10613 /*
10614    Machine architecture specs:
10615 
10616    Little endian
10617    Reading and writing pixel values separately
10618    Pointer size = 32 bits
10619 
10620    Ordinal size  8 bits is known as 'unsigned char'
10621    Ordinal size 16 bits is known as 'unsigned short'
10622    Ordinal size 32 bits is known as 'unsigned int'
10623    Natural ordinal is 'unsigned int'
10624 
10625    Integer size  8 bits is known as 'signed char'
10626    Integer size 16 bits is known as 'short'
10627    Integer size 32 bits is known as 'int'
10628    Natural integer is 'int'
10629 
10630  */
10631 
10632 #ifndef  IMDI_INCLUDED
10633 #include <memory.h>
10634 #include "imdi_imp.h"
10635 #define  IMDI_INCLUDED
10636 #endif  /* IMDI_INCLUDED */
10637 
10638 #ifndef DEFINED_pointer
10639 #define DEFINED_pointer
10640 typedef unsigned char * pointer;
10641 #endif
10642 
10643 /* Input table interp. index */
10644 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
10645 
10646 /* Input table input weighting/offset value enty */
10647 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
10648 
10649 /* Conditional exchange for sorting */
10650 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
10651 
10652 /* Interpolation multi-dim. table access */
10653 #define IM_O(off) ((off) * 12)
10654 
10655 /* Interpolation table - get vertex values */
10656 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
10657 
10658 /* Output table indexes */
10659 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
10660 
10661 void
imdi_k32(imdi * s,void ** outp,void ** inp,unsigned int npix)10662 imdi_k32(
10663 imdi *s,			/* imdi context */
10664 void **outp,		/* pointer to output pointers */
10665 void **inp,		/* pointer to input pointers */
10666 unsigned int npix	/* Number of pixels to process */
10667 ) {
10668 	imdi_imp *p = (imdi_imp *)(s->impl);
10669 	unsigned char *ip0 = (unsigned char *)inp[0];
10670 	unsigned char *op0 = (unsigned char *)outp[0];
10671 	unsigned char *ep = ip0 + npix * 5 ;
10672 	pointer it0 = (pointer)p->in_tables[0];
10673 	pointer it1 = (pointer)p->in_tables[1];
10674 	pointer it2 = (pointer)p->in_tables[2];
10675 	pointer it3 = (pointer)p->in_tables[3];
10676 	pointer it4 = (pointer)p->in_tables[4];
10677 	pointer ot0 = (pointer)p->out_tables[0];
10678 	pointer ot1 = (pointer)p->out_tables[1];
10679 	pointer ot2 = (pointer)p->out_tables[2];
10680 	pointer ot3 = (pointer)p->out_tables[3];
10681 	pointer ot4 = (pointer)p->out_tables[4];
10682 	pointer ot5 = (pointer)p->out_tables[5];
10683 	pointer im_base = (pointer)p->im_table;
10684 
10685 	for(;ip0 < ep; ip0 += 5, op0 += 6) {
10686 		unsigned int ova0;	/* Output value accumulator */
10687 		unsigned int ova1;	/* Output value accumulator */
10688 		unsigned int ova2;	/* Output value accumulator */
10689 		{
10690 			pointer imp;
10691 			unsigned int wo0;	/* Weighting value and vertex offset variable */
10692 			unsigned int wo1;	/* Weighting value and vertex offset variable */
10693 			unsigned int wo2;	/* Weighting value and vertex offset variable */
10694 			unsigned int wo3;	/* Weighting value and vertex offset variable */
10695 			unsigned int wo4;	/* Weighting value and vertex offset variable */
10696 			{
10697 				unsigned int ti_i;	/* Interpolation index variable */
10698 
10699 				ti_i  = IT_IX(it0, ip0[0]);
10700 				wo0   = IT_WO(it0, ip0[0]);
10701 				ti_i += IT_IX(it1, ip0[1]);
10702 				wo1   = IT_WO(it1, ip0[1]);
10703 				ti_i += IT_IX(it2, ip0[2]);
10704 				wo2   = IT_WO(it2, ip0[2]);
10705 				ti_i += IT_IX(it3, ip0[3]);
10706 				wo3   = IT_WO(it3, ip0[3]);
10707 				ti_i += IT_IX(it4, ip0[4]);
10708 				wo4   = IT_WO(it4, ip0[4]);
10709 
10710 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
10711 
10712 				/* Sort weighting values and vertex offset values */
10713 				CEX(wo0, wo1);
10714 				CEX(wo0, wo2);
10715 				CEX(wo0, wo3);
10716 				CEX(wo0, wo4);
10717 				CEX(wo1, wo2);
10718 				CEX(wo1, wo3);
10719 				CEX(wo1, wo4);
10720 				CEX(wo2, wo3);
10721 				CEX(wo2, wo4);
10722 				CEX(wo3, wo4);
10723 			}
10724 			{
10725 				unsigned int nvof;	/* Next vertex offset value */
10726 				unsigned int vof;	/* Vertex offset value */
10727 				unsigned int vwe;	/* Vertex weighting */
10728 
10729 				vof = 0;				/* First vertex offset is 0 */
10730 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
10731 				wo0 = (wo0 >> 23);		/* Extract weighting value */
10732 				vwe = 256 - wo0;		/* Baricentric weighting */
10733 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
10734 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
10735 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
10736 				vof += nvof;			/* Move to next vertex */
10737 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
10738 				wo1 = (wo1 >> 23);		/* Extract weighting value */
10739 				vwe = wo0 - wo1;		/* Baricentric weighting */
10740 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
10741 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
10742 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
10743 				vof += nvof;			/* Move to next vertex */
10744 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
10745 				wo2 = (wo2 >> 23);		/* Extract weighting value */
10746 				vwe = wo1 - wo2;		/* Baricentric weighting */
10747 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
10748 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
10749 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
10750 				vof += nvof;			/* Move to next vertex */
10751 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
10752 				wo3 = (wo3 >> 23);		/* Extract weighting value */
10753 				vwe = wo2 - wo3;		/* Baricentric weighting */
10754 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
10755 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
10756 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
10757 				vof += nvof;			/* Move to next vertex */
10758 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
10759 				wo4 = (wo4 >> 23);		/* Extract weighting value */
10760 				vwe = wo3 - wo4;		/* Baricentric weighting */
10761 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
10762 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
10763 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
10764 				vof += nvof;			/* Move to next vertex */
10765 				vwe = wo4;				/* Baricentric weighting */
10766 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
10767 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
10768 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
10769 			}
10770 		}
10771 		{
10772 			unsigned int oti;	/* Vertex offset value */
10773 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
10774 			op0[0] = OT_E(ot0, oti);	/* Write result */
10775 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
10776 			op0[1] = OT_E(ot1, oti);	/* Write result */
10777 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
10778 			op0[2] = OT_E(ot2, oti);	/* Write result */
10779 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
10780 			op0[3] = OT_E(ot3, oti);	/* Write result */
10781 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
10782 			op0[4] = OT_E(ot4, oti);	/* Write result */
10783 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
10784 			op0[5] = OT_E(ot5, oti);	/* Write result */
10785 		}
10786 	}
10787 }
10788 #undef IT_WO
10789 #undef IT_IX
10790 #undef CEX
10791 #undef IM_O
10792 #undef IM_FE
10793 #undef OT_E
10794 
10795 void
imdi_k32_gen(genspec * g)10796 imdi_k32_gen(
10797 genspec *g			/* structure to be initialised */
10798 ) {
10799 	static unsigned char data[] = {
10800 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
10801 		0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10802 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10803 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10804 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10805 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10806 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10807 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
10808 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
10809 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
10810 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10811 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10812 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10813 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10814 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10815 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10816 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10817 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10818 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10819 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10820 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10821 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10822 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10823 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10824 		0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
10825 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
10826 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
10827 		0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10828 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10829 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10830 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10831 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10832 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10833 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10834 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10835 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10836 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10837 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10838 		0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10839 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
10840 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
10841 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
10842 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
10843 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
10844 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
10845 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
10846 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
10847 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
10848 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10849 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
10850 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
10851 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x36, 0x5f,
10852 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
10853 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
10854 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
10855 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
10856 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
10857 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
10858 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
10859 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10860 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10861 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10862 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10863 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
10864 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x33, 0x32,
10865 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10866 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10867 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
10868 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
10869 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
10870 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
10871 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
10872 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
10873 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
10874 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
10875 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
10876 		0x00, 0xf0, 0x04, 0x08
10877 	};	/* Structure image */
10878 
10879 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
10880 }
10881 
10882 void
imdi_k32_tab(tabspec * t)10883 imdi_k32_tab(
10884 tabspec *t			/* structure to be initialised */
10885 ) {
10886 	static unsigned char data[] = {
10887 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10888 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10889 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10890 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
10891 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
10892 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
10893 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10894 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
10895 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
10896 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10897 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
10898 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
10899 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
10900 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
10901 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
10902 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10903 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
10904 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
10905 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10906 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10907 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10908 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
10909 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
10910 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
10911 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10912 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10913 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10914 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
10915 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10916 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10917 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
10918 		0x08, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
10919 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
10920 	};	/* Structure image */
10921 
10922 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
10923 }
10924 
10925 
10926 
10927 
10928 
10929 
10930 /* Integer Multi-Dimensional Interpolation */
10931 /* Interpolation Kernel Code */
10932 /* Generated by cgen */
10933 /* Copyright 2000 - 2002 Graeme W. Gill */
10934 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
10935 
10936 /* see the Licence.txt file for licencing details.*/
10937 
10938 
10939 /*
10940    Interpolation kernel specs:
10941 
10942    Input channels per pixel = 6
10943    Input channel 0 bits = 8
10944    Input channel 0 increment = 6
10945    Input channel 1 bits = 8
10946    Input channel 1 increment = 6
10947    Input channel 2 bits = 8
10948    Input channel 2 increment = 6
10949    Input channel 3 bits = 8
10950    Input channel 3 increment = 6
10951    Input channel 4 bits = 8
10952    Input channel 4 increment = 6
10953    Input channel 5 bits = 8
10954    Input channel 5 increment = 6
10955    Input is channel interleaved
10956    Input channels are separate words
10957    Input value extraction is done in input table lookup
10958 
10959    Output channels per pixel = 6
10960    Output channel 0 bits = 8
10961    Output channel 0 increment = 6
10962    Output channel 1 bits = 8
10963    Output channel 1 increment = 6
10964    Output channel 2 bits = 8
10965    Output channel 2 increment = 6
10966    Output channel 3 bits = 8
10967    Output channel 3 increment = 6
10968    Output channel 4 bits = 8
10969    Output channel 4 increment = 6
10970    Output channel 5 bits = 8
10971    Output channel 5 increment = 6
10972    Output is channel interleaved
10973 
10974    Output channels are separate words
10975    Weight+voffset bits       = 32
10976    Interpolation table index bits = 32
10977    Interpolation table max resolution = 19
10978  */
10979 
10980 /*
10981    Machine architecture specs:
10982 
10983    Little endian
10984    Reading and writing pixel values separately
10985    Pointer size = 32 bits
10986 
10987    Ordinal size  8 bits is known as 'unsigned char'
10988    Ordinal size 16 bits is known as 'unsigned short'
10989    Ordinal size 32 bits is known as 'unsigned int'
10990    Natural ordinal is 'unsigned int'
10991 
10992    Integer size  8 bits is known as 'signed char'
10993    Integer size 16 bits is known as 'short'
10994    Integer size 32 bits is known as 'int'
10995    Natural integer is 'int'
10996 
10997  */
10998 
10999 #ifndef  IMDI_INCLUDED
11000 #include <memory.h>
11001 #include "imdi_imp.h"
11002 #define  IMDI_INCLUDED
11003 #endif  /* IMDI_INCLUDED */
11004 
11005 #ifndef DEFINED_pointer
11006 #define DEFINED_pointer
11007 typedef unsigned char * pointer;
11008 #endif
11009 
11010 /* Input table interp. index */
11011 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
11012 
11013 /* Input table input weighting/offset value enty */
11014 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
11015 
11016 /* Conditional exchange for sorting */
11017 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
11018 
11019 /* Interpolation multi-dim. table access */
11020 #define IM_O(off) ((off) * 12)
11021 
11022 /* Interpolation table - get vertex values */
11023 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
11024 
11025 /* Output table indexes */
11026 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
11027 
11028 void
imdi_k33(imdi * s,void ** outp,void ** inp,unsigned int npix)11029 imdi_k33(
11030 imdi *s,			/* imdi context */
11031 void **outp,		/* pointer to output pointers */
11032 void **inp,		/* pointer to input pointers */
11033 unsigned int npix	/* Number of pixels to process */
11034 ) {
11035 	imdi_imp *p = (imdi_imp *)(s->impl);
11036 	unsigned char *ip0 = (unsigned char *)inp[0];
11037 	unsigned char *op0 = (unsigned char *)outp[0];
11038 	unsigned char *ep = ip0 + npix * 6 ;
11039 	pointer it0 = (pointer)p->in_tables[0];
11040 	pointer it1 = (pointer)p->in_tables[1];
11041 	pointer it2 = (pointer)p->in_tables[2];
11042 	pointer it3 = (pointer)p->in_tables[3];
11043 	pointer it4 = (pointer)p->in_tables[4];
11044 	pointer it5 = (pointer)p->in_tables[5];
11045 	pointer ot0 = (pointer)p->out_tables[0];
11046 	pointer ot1 = (pointer)p->out_tables[1];
11047 	pointer ot2 = (pointer)p->out_tables[2];
11048 	pointer ot3 = (pointer)p->out_tables[3];
11049 	pointer ot4 = (pointer)p->out_tables[4];
11050 	pointer ot5 = (pointer)p->out_tables[5];
11051 	pointer im_base = (pointer)p->im_table;
11052 
11053 	for(;ip0 < ep; ip0 += 6, op0 += 6) {
11054 		unsigned int ova0;	/* Output value accumulator */
11055 		unsigned int ova1;	/* Output value accumulator */
11056 		unsigned int ova2;	/* Output value accumulator */
11057 		{
11058 			pointer imp;
11059 			unsigned int wo0;	/* Weighting value and vertex offset variable */
11060 			unsigned int wo1;	/* Weighting value and vertex offset variable */
11061 			unsigned int wo2;	/* Weighting value and vertex offset variable */
11062 			unsigned int wo3;	/* Weighting value and vertex offset variable */
11063 			unsigned int wo4;	/* Weighting value and vertex offset variable */
11064 			unsigned int wo5;	/* Weighting value and vertex offset variable */
11065 			{
11066 				unsigned int ti_i;	/* Interpolation index variable */
11067 
11068 				ti_i  = IT_IX(it0, ip0[0]);
11069 				wo0   = IT_WO(it0, ip0[0]);
11070 				ti_i += IT_IX(it1, ip0[1]);
11071 				wo1   = IT_WO(it1, ip0[1]);
11072 				ti_i += IT_IX(it2, ip0[2]);
11073 				wo2   = IT_WO(it2, ip0[2]);
11074 				ti_i += IT_IX(it3, ip0[3]);
11075 				wo3   = IT_WO(it3, ip0[3]);
11076 				ti_i += IT_IX(it4, ip0[4]);
11077 				wo4   = IT_WO(it4, ip0[4]);
11078 				ti_i += IT_IX(it5, ip0[5]);
11079 				wo5   = IT_WO(it5, ip0[5]);
11080 
11081 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
11082 
11083 				/* Sort weighting values and vertex offset values */
11084 				CEX(wo0, wo1);
11085 				CEX(wo0, wo2);
11086 				CEX(wo0, wo3);
11087 				CEX(wo0, wo4);
11088 				CEX(wo0, wo5);
11089 				CEX(wo1, wo2);
11090 				CEX(wo1, wo3);
11091 				CEX(wo1, wo4);
11092 				CEX(wo1, wo5);
11093 				CEX(wo2, wo3);
11094 				CEX(wo2, wo4);
11095 				CEX(wo2, wo5);
11096 				CEX(wo3, wo4);
11097 				CEX(wo3, wo5);
11098 				CEX(wo4, wo5);
11099 			}
11100 			{
11101 				unsigned int nvof;	/* Next vertex offset value */
11102 				unsigned int vof;	/* Vertex offset value */
11103 				unsigned int vwe;	/* Vertex weighting */
11104 
11105 				vof = 0;				/* First vertex offset is 0 */
11106 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
11107 				wo0 = (wo0 >> 23);		/* Extract weighting value */
11108 				vwe = 256 - wo0;		/* Baricentric weighting */
11109 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11110 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11111 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11112 				vof += nvof;			/* Move to next vertex */
11113 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
11114 				wo1 = (wo1 >> 23);		/* Extract weighting value */
11115 				vwe = wo0 - wo1;		/* Baricentric weighting */
11116 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11117 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11118 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11119 				vof += nvof;			/* Move to next vertex */
11120 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
11121 				wo2 = (wo2 >> 23);		/* Extract weighting value */
11122 				vwe = wo1 - wo2;		/* Baricentric weighting */
11123 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11124 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11125 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11126 				vof += nvof;			/* Move to next vertex */
11127 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
11128 				wo3 = (wo3 >> 23);		/* Extract weighting value */
11129 				vwe = wo2 - wo3;		/* Baricentric weighting */
11130 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11131 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11132 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11133 				vof += nvof;			/* Move to next vertex */
11134 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
11135 				wo4 = (wo4 >> 23);		/* Extract weighting value */
11136 				vwe = wo3 - wo4;		/* Baricentric weighting */
11137 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11138 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11139 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11140 				vof += nvof;			/* Move to next vertex */
11141 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
11142 				wo5 = (wo5 >> 23);		/* Extract weighting value */
11143 				vwe = wo4 - wo5;		/* Baricentric weighting */
11144 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11145 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11146 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11147 				vof += nvof;			/* Move to next vertex */
11148 				vwe = wo5;				/* Baricentric weighting */
11149 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11150 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11151 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11152 			}
11153 		}
11154 		{
11155 			unsigned int oti;	/* Vertex offset value */
11156 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
11157 			op0[0] = OT_E(ot0, oti);	/* Write result */
11158 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
11159 			op0[1] = OT_E(ot1, oti);	/* Write result */
11160 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
11161 			op0[2] = OT_E(ot2, oti);	/* Write result */
11162 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
11163 			op0[3] = OT_E(ot3, oti);	/* Write result */
11164 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
11165 			op0[4] = OT_E(ot4, oti);	/* Write result */
11166 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
11167 			op0[5] = OT_E(ot5, oti);	/* Write result */
11168 		}
11169 	}
11170 }
11171 #undef IT_WO
11172 #undef IT_IX
11173 #undef CEX
11174 #undef IM_O
11175 #undef IM_FE
11176 #undef OT_E
11177 
11178 void
imdi_k33_gen(genspec * g)11179 imdi_k33_gen(
11180 genspec *g			/* structure to be initialised */
11181 ) {
11182 	static unsigned char data[] = {
11183 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
11184 		0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11185 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11186 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11187 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11188 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11189 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11190 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
11191 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
11192 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
11193 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11194 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11195 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11196 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11197 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11198 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11199 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11200 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11201 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11202 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11203 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11204 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11205 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11206 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11207 		0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
11208 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
11209 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
11210 		0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11211 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11212 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11213 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11214 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11215 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11216 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11217 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11218 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11219 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11220 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11221 		0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11222 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
11223 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
11224 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
11225 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
11226 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
11227 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
11228 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
11229 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
11230 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
11231 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11232 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
11233 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
11234 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x36, 0x5f,
11235 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
11236 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
11237 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
11238 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
11239 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
11240 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
11241 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
11242 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11243 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11244 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11245 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11246 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
11247 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x33, 0x33,
11248 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11249 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11250 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
11251 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
11252 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
11253 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
11254 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
11255 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
11256 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
11257 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
11258 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
11259 		0x00, 0xf0, 0x04, 0x08
11260 	};	/* Structure image */
11261 
11262 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
11263 }
11264 
11265 void
imdi_k33_tab(tabspec * t)11266 imdi_k33_tab(
11267 tabspec *t			/* structure to be initialised */
11268 ) {
11269 	static unsigned char data[] = {
11270 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11271 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11272 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11273 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
11274 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
11275 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
11276 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11277 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
11278 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
11279 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11280 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
11281 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
11282 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
11283 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
11284 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
11285 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11286 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
11287 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
11288 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11289 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11290 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11291 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
11292 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
11293 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
11294 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11295 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11296 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11297 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
11298 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11299 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11300 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11301 		0x08, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
11302 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
11303 	};	/* Structure image */
11304 
11305 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
11306 }
11307 
11308 
11309 
11310 
11311 
11312 
11313 /* Integer Multi-Dimensional Interpolation */
11314 /* Interpolation Kernel Code */
11315 /* Generated by cgen */
11316 /* Copyright 2000 - 2002 Graeme W. Gill */
11317 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
11318 
11319 /* see the Licence.txt file for licencing details.*/
11320 
11321 
11322 /*
11323    Interpolation kernel specs:
11324 
11325    Input channels per pixel = 7
11326    Input channel 0 bits = 8
11327    Input channel 0 increment = 7
11328    Input channel 1 bits = 8
11329    Input channel 1 increment = 7
11330    Input channel 2 bits = 8
11331    Input channel 2 increment = 7
11332    Input channel 3 bits = 8
11333    Input channel 3 increment = 7
11334    Input channel 4 bits = 8
11335    Input channel 4 increment = 7
11336    Input channel 5 bits = 8
11337    Input channel 5 increment = 7
11338    Input channel 6 bits = 8
11339    Input channel 6 increment = 7
11340    Input is channel interleaved
11341    Input channels are separate words
11342    Input value extraction is done in input table lookup
11343 
11344    Output channels per pixel = 6
11345    Output channel 0 bits = 8
11346    Output channel 0 increment = 6
11347    Output channel 1 bits = 8
11348    Output channel 1 increment = 6
11349    Output channel 2 bits = 8
11350    Output channel 2 increment = 6
11351    Output channel 3 bits = 8
11352    Output channel 3 increment = 6
11353    Output channel 4 bits = 8
11354    Output channel 4 increment = 6
11355    Output channel 5 bits = 8
11356    Output channel 5 increment = 6
11357    Output is channel interleaved
11358 
11359    Output channels are separate words
11360    Weight+voffset bits       = 32
11361    Interpolation table index bits = 32
11362    Interpolation table max resolution = 11
11363  */
11364 
11365 /*
11366    Machine architecture specs:
11367 
11368    Little endian
11369    Reading and writing pixel values separately
11370    Pointer size = 32 bits
11371 
11372    Ordinal size  8 bits is known as 'unsigned char'
11373    Ordinal size 16 bits is known as 'unsigned short'
11374    Ordinal size 32 bits is known as 'unsigned int'
11375    Natural ordinal is 'unsigned int'
11376 
11377    Integer size  8 bits is known as 'signed char'
11378    Integer size 16 bits is known as 'short'
11379    Integer size 32 bits is known as 'int'
11380    Natural integer is 'int'
11381 
11382  */
11383 
11384 #ifndef  IMDI_INCLUDED
11385 #include <memory.h>
11386 #include "imdi_imp.h"
11387 #define  IMDI_INCLUDED
11388 #endif  /* IMDI_INCLUDED */
11389 
11390 #ifndef DEFINED_pointer
11391 #define DEFINED_pointer
11392 typedef unsigned char * pointer;
11393 #endif
11394 
11395 /* Input table interp. index */
11396 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
11397 
11398 /* Input table input weighting/offset value enty */
11399 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
11400 
11401 /* Conditional exchange for sorting */
11402 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
11403 
11404 /* Interpolation multi-dim. table access */
11405 #define IM_O(off) ((off) * 12)
11406 
11407 /* Interpolation table - get vertex values */
11408 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
11409 
11410 /* Output table indexes */
11411 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
11412 
11413 void
imdi_k34(imdi * s,void ** outp,void ** inp,unsigned int npix)11414 imdi_k34(
11415 imdi *s,			/* imdi context */
11416 void **outp,		/* pointer to output pointers */
11417 void **inp,		/* pointer to input pointers */
11418 unsigned int npix	/* Number of pixels to process */
11419 ) {
11420 	imdi_imp *p = (imdi_imp *)(s->impl);
11421 	unsigned char *ip0 = (unsigned char *)inp[0];
11422 	unsigned char *op0 = (unsigned char *)outp[0];
11423 	unsigned char *ep = ip0 + npix * 7 ;
11424 	pointer it0 = (pointer)p->in_tables[0];
11425 	pointer it1 = (pointer)p->in_tables[1];
11426 	pointer it2 = (pointer)p->in_tables[2];
11427 	pointer it3 = (pointer)p->in_tables[3];
11428 	pointer it4 = (pointer)p->in_tables[4];
11429 	pointer it5 = (pointer)p->in_tables[5];
11430 	pointer it6 = (pointer)p->in_tables[6];
11431 	pointer ot0 = (pointer)p->out_tables[0];
11432 	pointer ot1 = (pointer)p->out_tables[1];
11433 	pointer ot2 = (pointer)p->out_tables[2];
11434 	pointer ot3 = (pointer)p->out_tables[3];
11435 	pointer ot4 = (pointer)p->out_tables[4];
11436 	pointer ot5 = (pointer)p->out_tables[5];
11437 	pointer im_base = (pointer)p->im_table;
11438 
11439 	for(;ip0 < ep; ip0 += 7, op0 += 6) {
11440 		unsigned int ova0;	/* Output value accumulator */
11441 		unsigned int ova1;	/* Output value accumulator */
11442 		unsigned int ova2;	/* Output value accumulator */
11443 		{
11444 			pointer imp;
11445 			unsigned int wo0;	/* Weighting value and vertex offset variable */
11446 			unsigned int wo1;	/* Weighting value and vertex offset variable */
11447 			unsigned int wo2;	/* Weighting value and vertex offset variable */
11448 			unsigned int wo3;	/* Weighting value and vertex offset variable */
11449 			unsigned int wo4;	/* Weighting value and vertex offset variable */
11450 			unsigned int wo5;	/* Weighting value and vertex offset variable */
11451 			unsigned int wo6;	/* Weighting value and vertex offset variable */
11452 			{
11453 				unsigned int ti_i;	/* Interpolation index variable */
11454 
11455 				ti_i  = IT_IX(it0, ip0[0]);
11456 				wo0   = IT_WO(it0, ip0[0]);
11457 				ti_i += IT_IX(it1, ip0[1]);
11458 				wo1   = IT_WO(it1, ip0[1]);
11459 				ti_i += IT_IX(it2, ip0[2]);
11460 				wo2   = IT_WO(it2, ip0[2]);
11461 				ti_i += IT_IX(it3, ip0[3]);
11462 				wo3   = IT_WO(it3, ip0[3]);
11463 				ti_i += IT_IX(it4, ip0[4]);
11464 				wo4   = IT_WO(it4, ip0[4]);
11465 				ti_i += IT_IX(it5, ip0[5]);
11466 				wo5   = IT_WO(it5, ip0[5]);
11467 				ti_i += IT_IX(it6, ip0[6]);
11468 				wo6   = IT_WO(it6, ip0[6]);
11469 
11470 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
11471 
11472 				/* Sort weighting values and vertex offset values */
11473 				CEX(wo0, wo1);
11474 				CEX(wo0, wo2);
11475 				CEX(wo0, wo3);
11476 				CEX(wo0, wo4);
11477 				CEX(wo0, wo5);
11478 				CEX(wo0, wo6);
11479 				CEX(wo1, wo2);
11480 				CEX(wo1, wo3);
11481 				CEX(wo1, wo4);
11482 				CEX(wo1, wo5);
11483 				CEX(wo1, wo6);
11484 				CEX(wo2, wo3);
11485 				CEX(wo2, wo4);
11486 				CEX(wo2, wo5);
11487 				CEX(wo2, wo6);
11488 				CEX(wo3, wo4);
11489 				CEX(wo3, wo5);
11490 				CEX(wo3, wo6);
11491 				CEX(wo4, wo5);
11492 				CEX(wo4, wo6);
11493 				CEX(wo5, wo6);
11494 			}
11495 			{
11496 				unsigned int nvof;	/* Next vertex offset value */
11497 				unsigned int vof;	/* Vertex offset value */
11498 				unsigned int vwe;	/* Vertex weighting */
11499 
11500 				vof = 0;				/* First vertex offset is 0 */
11501 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
11502 				wo0 = (wo0 >> 23);		/* Extract weighting value */
11503 				vwe = 256 - wo0;		/* Baricentric weighting */
11504 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11505 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11506 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11507 				vof += nvof;			/* Move to next vertex */
11508 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
11509 				wo1 = (wo1 >> 23);		/* Extract weighting value */
11510 				vwe = wo0 - wo1;		/* Baricentric weighting */
11511 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11512 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11513 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11514 				vof += nvof;			/* Move to next vertex */
11515 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
11516 				wo2 = (wo2 >> 23);		/* Extract weighting value */
11517 				vwe = wo1 - wo2;		/* Baricentric weighting */
11518 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11519 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11520 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11521 				vof += nvof;			/* Move to next vertex */
11522 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
11523 				wo3 = (wo3 >> 23);		/* Extract weighting value */
11524 				vwe = wo2 - wo3;		/* Baricentric weighting */
11525 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11526 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11527 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11528 				vof += nvof;			/* Move to next vertex */
11529 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
11530 				wo4 = (wo4 >> 23);		/* Extract weighting value */
11531 				vwe = wo3 - wo4;		/* Baricentric weighting */
11532 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11533 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11534 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11535 				vof += nvof;			/* Move to next vertex */
11536 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
11537 				wo5 = (wo5 >> 23);		/* Extract weighting value */
11538 				vwe = wo4 - wo5;		/* Baricentric weighting */
11539 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11540 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11541 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11542 				vof += nvof;			/* Move to next vertex */
11543 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
11544 				wo6 = (wo6 >> 23);		/* Extract weighting value */
11545 				vwe = wo5 - wo6;		/* Baricentric weighting */
11546 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11547 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11548 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11549 				vof += nvof;			/* Move to next vertex */
11550 				vwe = wo6;				/* Baricentric weighting */
11551 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11552 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11553 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11554 			}
11555 		}
11556 		{
11557 			unsigned int oti;	/* Vertex offset value */
11558 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
11559 			op0[0] = OT_E(ot0, oti);	/* Write result */
11560 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
11561 			op0[1] = OT_E(ot1, oti);	/* Write result */
11562 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
11563 			op0[2] = OT_E(ot2, oti);	/* Write result */
11564 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
11565 			op0[3] = OT_E(ot3, oti);	/* Write result */
11566 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
11567 			op0[4] = OT_E(ot4, oti);	/* Write result */
11568 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
11569 			op0[5] = OT_E(ot5, oti);	/* Write result */
11570 		}
11571 	}
11572 }
11573 #undef IT_WO
11574 #undef IT_IX
11575 #undef CEX
11576 #undef IM_O
11577 #undef IM_FE
11578 #undef OT_E
11579 
11580 void
imdi_k34_gen(genspec * g)11581 imdi_k34_gen(
11582 genspec *g			/* structure to be initialised */
11583 ) {
11584 	static unsigned char data[] = {
11585 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
11586 		0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11587 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11588 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11589 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11590 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11591 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11592 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
11593 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
11594 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
11595 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
11596 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11597 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11598 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11599 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11600 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11601 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11602 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11603 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11604 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11605 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11606 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11607 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11608 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11609 		0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
11610 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
11611 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
11612 		0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11613 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11614 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11615 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11616 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11617 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11618 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11619 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11620 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11621 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11622 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11623 		0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11624 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
11625 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
11626 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
11627 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
11628 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
11629 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
11630 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
11631 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
11632 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
11633 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11634 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
11635 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
11636 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x36, 0x5f,
11637 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
11638 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
11639 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
11640 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
11641 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
11642 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
11643 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
11644 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11645 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11646 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11647 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11648 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
11649 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x33, 0x34,
11650 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11651 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11652 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
11653 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
11654 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
11655 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
11656 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
11657 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
11658 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
11659 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
11660 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
11661 		0x00, 0xf0, 0x04, 0x08
11662 	};	/* Structure image */
11663 
11664 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
11665 }
11666 
11667 void
imdi_k34_tab(tabspec * t)11668 imdi_k34_tab(
11669 tabspec *t			/* structure to be initialised */
11670 ) {
11671 	static unsigned char data[] = {
11672 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11673 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11674 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11675 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
11676 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
11677 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
11678 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11679 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
11680 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
11681 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11682 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
11683 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
11684 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
11685 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
11686 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
11687 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11688 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
11689 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
11690 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11691 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11692 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11693 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
11694 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
11695 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
11696 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11697 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11698 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11699 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
11700 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11701 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11702 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
11703 		0x08, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
11704 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
11705 	};	/* Structure image */
11706 
11707 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
11708 }
11709 
11710 
11711 
11712 
11713 
11714 
11715 /* Integer Multi-Dimensional Interpolation */
11716 /* Interpolation Kernel Code */
11717 /* Generated by cgen */
11718 /* Copyright 2000 - 2002 Graeme W. Gill */
11719 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
11720 
11721 /* see the Licence.txt file for licencing details.*/
11722 
11723 
11724 /*
11725    Interpolation kernel specs:
11726 
11727    Input channels per pixel = 8
11728    Input channel 0 bits = 8
11729    Input channel 0 increment = 8
11730    Input channel 1 bits = 8
11731    Input channel 1 increment = 8
11732    Input channel 2 bits = 8
11733    Input channel 2 increment = 8
11734    Input channel 3 bits = 8
11735    Input channel 3 increment = 8
11736    Input channel 4 bits = 8
11737    Input channel 4 increment = 8
11738    Input channel 5 bits = 8
11739    Input channel 5 increment = 8
11740    Input channel 6 bits = 8
11741    Input channel 6 increment = 8
11742    Input channel 7 bits = 8
11743    Input channel 7 increment = 8
11744    Input is channel interleaved
11745    Input channels are separate words
11746    Input value extraction is done in input table lookup
11747 
11748    Output channels per pixel = 6
11749    Output channel 0 bits = 8
11750    Output channel 0 increment = 6
11751    Output channel 1 bits = 8
11752    Output channel 1 increment = 6
11753    Output channel 2 bits = 8
11754    Output channel 2 increment = 6
11755    Output channel 3 bits = 8
11756    Output channel 3 increment = 6
11757    Output channel 4 bits = 8
11758    Output channel 4 increment = 6
11759    Output channel 5 bits = 8
11760    Output channel 5 increment = 6
11761    Output is channel interleaved
11762 
11763    Output channels are separate words
11764    Weight+voffset bits       = 32
11765    Interpolation table index bits = 32
11766    Interpolation table max resolution = 8
11767  */
11768 
11769 /*
11770    Machine architecture specs:
11771 
11772    Little endian
11773    Reading and writing pixel values separately
11774    Pointer size = 32 bits
11775 
11776    Ordinal size  8 bits is known as 'unsigned char'
11777    Ordinal size 16 bits is known as 'unsigned short'
11778    Ordinal size 32 bits is known as 'unsigned int'
11779    Natural ordinal is 'unsigned int'
11780 
11781    Integer size  8 bits is known as 'signed char'
11782    Integer size 16 bits is known as 'short'
11783    Integer size 32 bits is known as 'int'
11784    Natural integer is 'int'
11785 
11786  */
11787 
11788 #ifndef  IMDI_INCLUDED
11789 #include <memory.h>
11790 #include "imdi_imp.h"
11791 #define  IMDI_INCLUDED
11792 #endif  /* IMDI_INCLUDED */
11793 
11794 #ifndef DEFINED_pointer
11795 #define DEFINED_pointer
11796 typedef unsigned char * pointer;
11797 #endif
11798 
11799 /* Input table interp. index */
11800 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
11801 
11802 /* Input table input weighting/offset value enty */
11803 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
11804 
11805 /* Conditional exchange for sorting */
11806 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
11807 
11808 /* Interpolation multi-dim. table access */
11809 #define IM_O(off) ((off) * 12)
11810 
11811 /* Interpolation table - get vertex values */
11812 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
11813 
11814 /* Output table indexes */
11815 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
11816 
11817 void
imdi_k35(imdi * s,void ** outp,void ** inp,unsigned int npix)11818 imdi_k35(
11819 imdi *s,			/* imdi context */
11820 void **outp,		/* pointer to output pointers */
11821 void **inp,		/* pointer to input pointers */
11822 unsigned int npix	/* Number of pixels to process */
11823 ) {
11824 	imdi_imp *p = (imdi_imp *)(s->impl);
11825 	unsigned char *ip0 = (unsigned char *)inp[0];
11826 	unsigned char *op0 = (unsigned char *)outp[0];
11827 	unsigned char *ep = ip0 + npix * 8 ;
11828 	pointer it0 = (pointer)p->in_tables[0];
11829 	pointer it1 = (pointer)p->in_tables[1];
11830 	pointer it2 = (pointer)p->in_tables[2];
11831 	pointer it3 = (pointer)p->in_tables[3];
11832 	pointer it4 = (pointer)p->in_tables[4];
11833 	pointer it5 = (pointer)p->in_tables[5];
11834 	pointer it6 = (pointer)p->in_tables[6];
11835 	pointer it7 = (pointer)p->in_tables[7];
11836 	pointer ot0 = (pointer)p->out_tables[0];
11837 	pointer ot1 = (pointer)p->out_tables[1];
11838 	pointer ot2 = (pointer)p->out_tables[2];
11839 	pointer ot3 = (pointer)p->out_tables[3];
11840 	pointer ot4 = (pointer)p->out_tables[4];
11841 	pointer ot5 = (pointer)p->out_tables[5];
11842 	pointer im_base = (pointer)p->im_table;
11843 
11844 	for(;ip0 < ep; ip0 += 8, op0 += 6) {
11845 		unsigned int ova0;	/* Output value accumulator */
11846 		unsigned int ova1;	/* Output value accumulator */
11847 		unsigned int ova2;	/* Output value accumulator */
11848 		{
11849 			pointer imp;
11850 			unsigned int wo0;	/* Weighting value and vertex offset variable */
11851 			unsigned int wo1;	/* Weighting value and vertex offset variable */
11852 			unsigned int wo2;	/* Weighting value and vertex offset variable */
11853 			unsigned int wo3;	/* Weighting value and vertex offset variable */
11854 			unsigned int wo4;	/* Weighting value and vertex offset variable */
11855 			unsigned int wo5;	/* Weighting value and vertex offset variable */
11856 			unsigned int wo6;	/* Weighting value and vertex offset variable */
11857 			unsigned int wo7;	/* Weighting value and vertex offset variable */
11858 			{
11859 				unsigned int ti_i;	/* Interpolation index variable */
11860 
11861 				ti_i  = IT_IX(it0, ip0[0]);
11862 				wo0   = IT_WO(it0, ip0[0]);
11863 				ti_i += IT_IX(it1, ip0[1]);
11864 				wo1   = IT_WO(it1, ip0[1]);
11865 				ti_i += IT_IX(it2, ip0[2]);
11866 				wo2   = IT_WO(it2, ip0[2]);
11867 				ti_i += IT_IX(it3, ip0[3]);
11868 				wo3   = IT_WO(it3, ip0[3]);
11869 				ti_i += IT_IX(it4, ip0[4]);
11870 				wo4   = IT_WO(it4, ip0[4]);
11871 				ti_i += IT_IX(it5, ip0[5]);
11872 				wo5   = IT_WO(it5, ip0[5]);
11873 				ti_i += IT_IX(it6, ip0[6]);
11874 				wo6   = IT_WO(it6, ip0[6]);
11875 				ti_i += IT_IX(it7, ip0[7]);
11876 				wo7   = IT_WO(it7, ip0[7]);
11877 
11878 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
11879 
11880 				/* Sort weighting values and vertex offset values */
11881 				CEX(wo0, wo1);
11882 				CEX(wo0, wo2);
11883 				CEX(wo0, wo3);
11884 				CEX(wo0, wo4);
11885 				CEX(wo0, wo5);
11886 				CEX(wo0, wo6);
11887 				CEX(wo0, wo7);
11888 				CEX(wo1, wo2);
11889 				CEX(wo1, wo3);
11890 				CEX(wo1, wo4);
11891 				CEX(wo1, wo5);
11892 				CEX(wo1, wo6);
11893 				CEX(wo1, wo7);
11894 				CEX(wo2, wo3);
11895 				CEX(wo2, wo4);
11896 				CEX(wo2, wo5);
11897 				CEX(wo2, wo6);
11898 				CEX(wo2, wo7);
11899 				CEX(wo3, wo4);
11900 				CEX(wo3, wo5);
11901 				CEX(wo3, wo6);
11902 				CEX(wo3, wo7);
11903 				CEX(wo4, wo5);
11904 				CEX(wo4, wo6);
11905 				CEX(wo4, wo7);
11906 				CEX(wo5, wo6);
11907 				CEX(wo5, wo7);
11908 				CEX(wo6, wo7);
11909 			}
11910 			{
11911 				unsigned int nvof;	/* Next vertex offset value */
11912 				unsigned int vof;	/* Vertex offset value */
11913 				unsigned int vwe;	/* Vertex weighting */
11914 
11915 				vof = 0;				/* First vertex offset is 0 */
11916 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
11917 				wo0 = (wo0 >> 23);		/* Extract weighting value */
11918 				vwe = 256 - wo0;		/* Baricentric weighting */
11919 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11920 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11921 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11922 				vof += nvof;			/* Move to next vertex */
11923 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
11924 				wo1 = (wo1 >> 23);		/* Extract weighting value */
11925 				vwe = wo0 - wo1;		/* Baricentric weighting */
11926 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11927 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11928 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11929 				vof += nvof;			/* Move to next vertex */
11930 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
11931 				wo2 = (wo2 >> 23);		/* Extract weighting value */
11932 				vwe = wo1 - wo2;		/* Baricentric weighting */
11933 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11934 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11935 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11936 				vof += nvof;			/* Move to next vertex */
11937 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
11938 				wo3 = (wo3 >> 23);		/* Extract weighting value */
11939 				vwe = wo2 - wo3;		/* Baricentric weighting */
11940 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11941 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11942 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11943 				vof += nvof;			/* Move to next vertex */
11944 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
11945 				wo4 = (wo4 >> 23);		/* Extract weighting value */
11946 				vwe = wo3 - wo4;		/* Baricentric weighting */
11947 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11948 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11949 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11950 				vof += nvof;			/* Move to next vertex */
11951 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
11952 				wo5 = (wo5 >> 23);		/* Extract weighting value */
11953 				vwe = wo4 - wo5;		/* Baricentric weighting */
11954 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11955 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11956 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11957 				vof += nvof;			/* Move to next vertex */
11958 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
11959 				wo6 = (wo6 >> 23);		/* Extract weighting value */
11960 				vwe = wo5 - wo6;		/* Baricentric weighting */
11961 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11962 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11963 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11964 				vof += nvof;			/* Move to next vertex */
11965 				nvof = (wo7 & 0x7fffff);	/* Extract offset value */
11966 				wo7 = (wo7 >> 23);		/* Extract weighting value */
11967 				vwe = wo6 - wo7;		/* Baricentric weighting */
11968 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11969 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11970 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11971 				vof += nvof;			/* Move to next vertex */
11972 				vwe = wo7;				/* Baricentric weighting */
11973 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
11974 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
11975 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
11976 			}
11977 		}
11978 		{
11979 			unsigned int oti;	/* Vertex offset value */
11980 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
11981 			op0[0] = OT_E(ot0, oti);	/* Write result */
11982 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
11983 			op0[1] = OT_E(ot1, oti);	/* Write result */
11984 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
11985 			op0[2] = OT_E(ot2, oti);	/* Write result */
11986 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
11987 			op0[3] = OT_E(ot3, oti);	/* Write result */
11988 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
11989 			op0[4] = OT_E(ot4, oti);	/* Write result */
11990 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
11991 			op0[5] = OT_E(ot5, oti);	/* Write result */
11992 		}
11993 	}
11994 }
11995 #undef IT_WO
11996 #undef IT_IX
11997 #undef CEX
11998 #undef IM_O
11999 #undef IM_FE
12000 #undef OT_E
12001 
12002 void
imdi_k35_gen(genspec * g)12003 imdi_k35_gen(
12004 genspec *g			/* structure to be initialised */
12005 ) {
12006 	static unsigned char data[] = {
12007 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12008 		0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12009 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12010 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12011 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12012 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12013 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12014 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12015 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12016 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12017 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12018 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12019 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12020 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12021 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12022 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12023 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12024 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12025 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12026 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12027 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12028 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12029 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12030 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12031 		0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
12032 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
12033 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
12034 		0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12035 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12036 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12037 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12038 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12039 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12040 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12041 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12042 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12043 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12044 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12045 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12046 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
12047 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
12048 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
12049 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
12050 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
12051 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
12052 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
12053 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
12054 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
12055 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12056 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
12057 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
12058 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x36, 0x5f,
12059 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
12060 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
12061 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
12062 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
12063 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
12064 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
12065 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
12066 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12067 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12068 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12069 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12070 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
12071 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x33, 0x35,
12072 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12073 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12074 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
12075 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
12076 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
12077 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
12078 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
12079 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
12080 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
12081 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
12082 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
12083 		0x00, 0xf0, 0x04, 0x08
12084 	};	/* Structure image */
12085 
12086 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
12087 }
12088 
12089 void
imdi_k35_tab(tabspec * t)12090 imdi_k35_tab(
12091 tabspec *t			/* structure to be initialised */
12092 ) {
12093 	static unsigned char data[] = {
12094 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12095 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12096 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12097 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
12098 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
12099 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
12100 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12101 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
12102 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
12103 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12104 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
12105 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
12106 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
12107 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
12108 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
12109 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12110 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
12111 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
12112 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12113 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12114 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12115 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
12116 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
12117 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
12118 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12119 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12120 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12121 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
12122 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12123 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12124 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12125 		0x08, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
12126 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
12127 	};	/* Structure image */
12128 
12129 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
12130 }
12131 
12132 
12133 
12134 
12135 
12136 
12137 /* Integer Multi-Dimensional Interpolation */
12138 /* Interpolation Kernel Code */
12139 /* Generated by cgen */
12140 /* Copyright 2000 - 2002 Graeme W. Gill */
12141 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
12142 
12143 /* see the Licence.txt file for licencing details.*/
12144 
12145 
12146 /*
12147    Interpolation kernel specs:
12148 
12149    Input channels per pixel = 1
12150    Input channel 0 bits = 8
12151    Input channel 0 increment = 1
12152    Input is channel interleaved
12153    Input channels are separate words
12154    Input value extraction is done in input table lookup
12155 
12156    Output channels per pixel = 7
12157    Output channel 0 bits = 8
12158    Output channel 0 increment = 7
12159    Output channel 1 bits = 8
12160    Output channel 1 increment = 7
12161    Output channel 2 bits = 8
12162    Output channel 2 increment = 7
12163    Output channel 3 bits = 8
12164    Output channel 3 increment = 7
12165    Output channel 4 bits = 8
12166    Output channel 4 increment = 7
12167    Output channel 5 bits = 8
12168    Output channel 5 increment = 7
12169    Output channel 6 bits = 8
12170    Output channel 6 increment = 7
12171    Output is channel interleaved
12172 
12173    Output channels are separate words
12174    Simplex table index bits       = 0
12175    Interpolation table index bits = 8
12176    Simplex table max resolution = 1
12177    Interpolation table max resolution = 255
12178  */
12179 
12180 /*
12181    Machine architecture specs:
12182 
12183    Little endian
12184    Reading and writing pixel values separately
12185    Pointer size = 32 bits
12186 
12187    Ordinal size  8 bits is known as 'unsigned char'
12188    Ordinal size 16 bits is known as 'unsigned short'
12189    Ordinal size 32 bits is known as 'unsigned int'
12190    Natural ordinal is 'unsigned int'
12191 
12192    Integer size  8 bits is known as 'signed char'
12193    Integer size 16 bits is known as 'short'
12194    Integer size 32 bits is known as 'int'
12195    Natural integer is 'int'
12196 
12197  */
12198 
12199 #ifndef  IMDI_INCLUDED
12200 #include <memory.h>
12201 #include "imdi_imp.h"
12202 #define  IMDI_INCLUDED
12203 #endif  /* IMDI_INCLUDED */
12204 
12205 #ifndef DEFINED_pointer
12206 #define DEFINED_pointer
12207 typedef unsigned char * pointer;
12208 #endif
12209 
12210 /* Input table inter & simplex indexes */
12211 #define IT_IT(p, off) *((unsigned char *)((p) + 0 + (off) * 1))
12212 
12213 /* Simplex weighting table access */
12214 #define SW_O(off) ((off) * 4)
12215 
12216 /* Simplex table - get weighting/offset value */
12217 #define SX_WO(p, v) *((unsigned short *)((p) + (v) * 2))
12218 
12219 /* Interpolation multi-dim. table access */
12220 #define IM_O(off) ((off) * 16)
12221 
12222 /* Interpolation table - get vertex values */
12223 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
12224 #define IM_PE(p, v) *((unsigned int *)((p) + 12 + (v) * 8))
12225 
12226 /* Output table indexes */
12227 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
12228 
12229 void
imdi_k36(imdi * s,void ** outp,void ** inp,unsigned int npix)12230 imdi_k36(
12231 imdi *s,			/* imdi context */
12232 void **outp,		/* pointer to output pointers */
12233 void **inp,		/* pointer to input pointers */
12234 unsigned int npix	/* Number of pixels to process */
12235 ) {
12236 	imdi_imp *p = (imdi_imp *)(s->impl);
12237 	unsigned char *ip0 = (unsigned char *)inp[0];
12238 	unsigned char *op0 = (unsigned char *)outp[0];
12239 	unsigned char *ep = ip0 + npix * 1 ;
12240 	pointer it0 = (pointer)p->in_tables[0];
12241 	pointer ot0 = (pointer)p->out_tables[0];
12242 	pointer ot1 = (pointer)p->out_tables[1];
12243 	pointer ot2 = (pointer)p->out_tables[2];
12244 	pointer ot3 = (pointer)p->out_tables[3];
12245 	pointer ot4 = (pointer)p->out_tables[4];
12246 	pointer ot5 = (pointer)p->out_tables[5];
12247 	pointer ot6 = (pointer)p->out_tables[6];
12248 	pointer sw_base = (pointer)p->sw_table;
12249 	pointer im_base = (pointer)p->im_table;
12250 
12251 	for(;ip0 < ep; ip0 += 1, op0 += 7) {
12252 		unsigned int ova0;	/* Output value accumulator */
12253 		unsigned int ova1;	/* Output value accumulator */
12254 		unsigned int ova2;	/* Output value accumulator */
12255 		unsigned int ova3;	/* Output value partial accumulator */
12256 		{
12257 			pointer swp;
12258 			pointer imp;
12259 			{
12260 				unsigned int ti;	/* Simplex+Interpolation index variable */
12261 
12262 				ti  = IT_IT(it0, ip0[0]);
12263 
12264 				imp = im_base + IM_O(ti >> 0);		/* Extract interp. index and comp. entry */
12265 				swp = sw_base + SW_O(ti & 0x0);	/* Extract simplex index and comp. entry */
12266 			}
12267 			{
12268 				unsigned int vowr;	/* Vertex offset/weight value */
12269 				unsigned int vof;	/* Vertex offset value */
12270 				unsigned int vwe;	/* Vertex weighting */
12271 
12272 				vowr = SX_WO(swp, 0);	/* Read vertex offset+weighting values */
12273 				vof = (vowr & 0x7f);	/* Extract offset value */
12274 				vwe = (vowr >> 7);	/* Extract weighting value */
12275 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
12276 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
12277 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
12278 				ova3  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
12279 				vowr = SX_WO(swp, 1);	/* Read vertex offset+weighting values */
12280 				vof = (vowr & 0x7f);	/* Extract offset value */
12281 				vwe = (vowr >> 7);	/* Extract weighting value */
12282 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
12283 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
12284 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
12285 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
12286 			}
12287 		}
12288 		{
12289 			unsigned int oti;	/* Vertex offset value */
12290 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
12291 			op0[0] = OT_E(ot0, oti);	/* Write result */
12292 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
12293 			op0[1] = OT_E(ot1, oti);	/* Write result */
12294 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
12295 			op0[2] = OT_E(ot2, oti);	/* Write result */
12296 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
12297 			op0[3] = OT_E(ot3, oti);	/* Write result */
12298 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
12299 			op0[4] = OT_E(ot4, oti);	/* Write result */
12300 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
12301 			op0[5] = OT_E(ot5, oti);	/* Write result */
12302 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
12303 			op0[6] = OT_E(ot6, oti);	/* Write result */
12304 		}
12305 	}
12306 }
12307 #undef IT_IT
12308 #undef SW_O
12309 #undef SX_WO
12310 #undef IM_O
12311 #undef IM_FE
12312 #undef IM_PE
12313 #undef OT_E
12314 
12315 void
imdi_k36_gen(genspec * g)12316 imdi_k36_gen(
12317 genspec *g			/* structure to be initialised */
12318 ) {
12319 	static unsigned char data[] = {
12320 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12321 		0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12322 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12323 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12324 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12325 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12326 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12327 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12328 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12329 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12330 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12331 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12332 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12333 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12334 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12335 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12336 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12337 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12338 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12339 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12340 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12341 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12342 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12343 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12344 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
12345 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
12346 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
12347 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
12348 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12349 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12350 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12351 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12352 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12353 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12354 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12355 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12356 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12357 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12358 		0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12359 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
12360 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
12361 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
12362 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
12363 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
12364 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
12365 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
12366 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
12367 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
12368 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12369 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
12370 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
12371 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x37, 0x5f,
12372 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
12373 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
12374 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
12375 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
12376 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
12377 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
12378 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
12379 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12380 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12381 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12382 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12383 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
12384 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x33, 0x36,
12385 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12386 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12387 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
12388 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
12389 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
12390 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
12391 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
12392 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
12393 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
12394 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
12395 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
12396 		0x00, 0xf0, 0x04, 0x08
12397 	};	/* Structure image */
12398 
12399 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
12400 }
12401 
12402 void
imdi_k36_tab(tabspec * t)12403 imdi_k36_tab(
12404 tabspec *t			/* structure to be initialised */
12405 ) {
12406 	static unsigned char data[] = {
12407 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12408 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12409 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12410 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
12411 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
12412 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
12413 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12414 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
12415 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12416 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12417 		0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
12418 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12419 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
12420 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
12421 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
12422 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12423 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12424 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
12425 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
12426 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12427 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12428 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
12429 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
12430 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
12431 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12432 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12433 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12434 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12435 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12436 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12437 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12438 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12439 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
12440 	};	/* Structure image */
12441 
12442 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
12443 }
12444 
12445 
12446 
12447 
12448 
12449 
12450 /* Integer Multi-Dimensional Interpolation */
12451 /* Interpolation Kernel Code */
12452 /* Generated by cgen */
12453 /* Copyright 2000 - 2002 Graeme W. Gill */
12454 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
12455 
12456 /* see the Licence.txt file for licencing details.*/
12457 
12458 
12459 /*
12460    Interpolation kernel specs:
12461 
12462    Input channels per pixel = 3
12463    Input channel 0 bits = 8
12464    Input channel 0 increment = 3
12465    Input channel 1 bits = 8
12466    Input channel 1 increment = 3
12467    Input channel 2 bits = 8
12468    Input channel 2 increment = 3
12469    Input is channel interleaved
12470    Input channels are separate words
12471    Input value extraction is done in input table lookup
12472 
12473    Output channels per pixel = 7
12474    Output channel 0 bits = 8
12475    Output channel 0 increment = 7
12476    Output channel 1 bits = 8
12477    Output channel 1 increment = 7
12478    Output channel 2 bits = 8
12479    Output channel 2 increment = 7
12480    Output channel 3 bits = 8
12481    Output channel 3 increment = 7
12482    Output channel 4 bits = 8
12483    Output channel 4 increment = 7
12484    Output channel 5 bits = 8
12485    Output channel 5 increment = 7
12486    Output channel 6 bits = 8
12487    Output channel 6 increment = 7
12488    Output is channel interleaved
12489 
12490    Output channels are separate words
12491    Simplex table index bits       = 12
12492    Interpolation table index bits = 20
12493    Simplex table max resolution = 16
12494    Interpolation table max resolution = 101
12495  */
12496 
12497 /*
12498    Machine architecture specs:
12499 
12500    Little endian
12501    Reading and writing pixel values separately
12502    Pointer size = 32 bits
12503 
12504    Ordinal size  8 bits is known as 'unsigned char'
12505    Ordinal size 16 bits is known as 'unsigned short'
12506    Ordinal size 32 bits is known as 'unsigned int'
12507    Natural ordinal is 'unsigned int'
12508 
12509    Integer size  8 bits is known as 'signed char'
12510    Integer size 16 bits is known as 'short'
12511    Integer size 32 bits is known as 'int'
12512    Natural integer is 'int'
12513 
12514  */
12515 
12516 #ifndef  IMDI_INCLUDED
12517 #include <memory.h>
12518 #include "imdi_imp.h"
12519 #define  IMDI_INCLUDED
12520 #endif  /* IMDI_INCLUDED */
12521 
12522 #ifndef DEFINED_pointer
12523 #define DEFINED_pointer
12524 typedef unsigned char * pointer;
12525 #endif
12526 
12527 /* Input table inter & simplex indexes */
12528 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
12529 
12530 /* Simplex weighting table access */
12531 #define SW_O(off) ((off) * 16)
12532 
12533 /* Simplex table - get weighting value */
12534 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
12535 
12536 /* Simplex table - get offset value */
12537 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
12538 
12539 /* Interpolation multi-dim. table access */
12540 #define IM_O(off) ((off) * 16)
12541 
12542 /* Interpolation table - get vertex values */
12543 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
12544 #define IM_PE(p, v) *((unsigned int *)((p) + 12 + (v) * 8))
12545 
12546 /* Output table indexes */
12547 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
12548 
12549 void
imdi_k37(imdi * s,void ** outp,void ** inp,unsigned int npix)12550 imdi_k37(
12551 imdi *s,			/* imdi context */
12552 void **outp,		/* pointer to output pointers */
12553 void **inp,		/* pointer to input pointers */
12554 unsigned int npix	/* Number of pixels to process */
12555 ) {
12556 	imdi_imp *p = (imdi_imp *)(s->impl);
12557 	unsigned char *ip0 = (unsigned char *)inp[0];
12558 	unsigned char *op0 = (unsigned char *)outp[0];
12559 	unsigned char *ep = ip0 + npix * 3 ;
12560 	pointer it0 = (pointer)p->in_tables[0];
12561 	pointer it1 = (pointer)p->in_tables[1];
12562 	pointer it2 = (pointer)p->in_tables[2];
12563 	pointer ot0 = (pointer)p->out_tables[0];
12564 	pointer ot1 = (pointer)p->out_tables[1];
12565 	pointer ot2 = (pointer)p->out_tables[2];
12566 	pointer ot3 = (pointer)p->out_tables[3];
12567 	pointer ot4 = (pointer)p->out_tables[4];
12568 	pointer ot5 = (pointer)p->out_tables[5];
12569 	pointer ot6 = (pointer)p->out_tables[6];
12570 	pointer sw_base = (pointer)p->sw_table;
12571 	pointer im_base = (pointer)p->im_table;
12572 
12573 	for(;ip0 < ep; ip0 += 3, op0 += 7) {
12574 		unsigned int ova0;	/* Output value accumulator */
12575 		unsigned int ova1;	/* Output value accumulator */
12576 		unsigned int ova2;	/* Output value accumulator */
12577 		unsigned int ova3;	/* Output value partial accumulator */
12578 		{
12579 			pointer swp;
12580 			pointer imp;
12581 			{
12582 				unsigned int ti;	/* Simplex+Interpolation index variable */
12583 
12584 				ti  = IT_IT(it0, ip0[0]);
12585 				ti += IT_IT(it1, ip0[1]);
12586 				ti += IT_IT(it2, ip0[2]);
12587 
12588 				imp = im_base + IM_O(ti >> 12);		/* Extract interp. index and comp. entry */
12589 				swp = sw_base + SW_O(ti & 0xfff);	/* Extract simplex index and comp. entry */
12590 			}
12591 			{
12592 				unsigned int vof;	/* Vertex offset value */
12593 				unsigned int vwe;	/* Vertex weighting */
12594 
12595 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
12596 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
12597 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
12598 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
12599 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
12600 				ova3  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
12601 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
12602 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
12603 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
12604 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
12605 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
12606 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
12607 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
12608 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
12609 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
12610 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
12611 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
12612 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
12613 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
12614 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
12615 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
12616 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
12617 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
12618 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
12619 			}
12620 		}
12621 		{
12622 			unsigned int oti;	/* Vertex offset value */
12623 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
12624 			op0[0] = OT_E(ot0, oti);	/* Write result */
12625 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
12626 			op0[1] = OT_E(ot1, oti);	/* Write result */
12627 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
12628 			op0[2] = OT_E(ot2, oti);	/* Write result */
12629 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
12630 			op0[3] = OT_E(ot3, oti);	/* Write result */
12631 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
12632 			op0[4] = OT_E(ot4, oti);	/* Write result */
12633 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
12634 			op0[5] = OT_E(ot5, oti);	/* Write result */
12635 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
12636 			op0[6] = OT_E(ot6, oti);	/* Write result */
12637 		}
12638 	}
12639 }
12640 #undef IT_IT
12641 #undef SW_O
12642 #undef SX_WE
12643 #undef SX_VO
12644 #undef IM_O
12645 #undef IM_FE
12646 #undef IM_PE
12647 #undef OT_E
12648 
12649 void
imdi_k37_gen(genspec * g)12650 imdi_k37_gen(
12651 genspec *g			/* structure to be initialised */
12652 ) {
12653 	static unsigned char data[] = {
12654 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
12655 		0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12656 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12657 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12658 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12659 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12660 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12661 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
12662 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
12663 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12664 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12665 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12666 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12667 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12668 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12669 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12670 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12671 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12672 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12673 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12674 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12675 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12676 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12677 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12678 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
12679 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
12680 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
12681 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
12682 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12683 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12684 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12685 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12686 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12687 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12688 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12689 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12690 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12691 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12692 		0x65, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
12693 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
12694 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
12695 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
12696 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
12697 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
12698 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
12699 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
12700 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
12701 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
12702 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12703 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
12704 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
12705 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x37, 0x5f,
12706 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
12707 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
12708 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
12709 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
12710 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
12711 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
12712 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
12713 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12714 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12715 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12716 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12717 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
12718 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x33, 0x37,
12719 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12720 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12721 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
12722 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
12723 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
12724 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
12725 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
12726 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
12727 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
12728 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
12729 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
12730 		0x00, 0xf0, 0x04, 0x08
12731 	};	/* Structure image */
12732 
12733 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
12734 }
12735 
12736 void
imdi_k37_tab(tabspec * t)12737 imdi_k37_tab(
12738 tabspec *t			/* structure to be initialised */
12739 ) {
12740 	static unsigned char data[] = {
12741 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12742 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12743 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12744 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
12745 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
12746 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
12747 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
12748 		0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
12749 		0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
12750 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12751 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
12752 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12753 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
12754 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
12755 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
12756 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12757 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12758 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
12759 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
12760 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12761 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
12762 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
12763 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
12764 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
12765 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12766 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12767 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12768 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12769 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12770 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12771 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12772 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
12773 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
12774 	};	/* Structure image */
12775 
12776 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
12777 }
12778 
12779 
12780 
12781 
12782 
12783 
12784 /* Integer Multi-Dimensional Interpolation */
12785 /* Interpolation Kernel Code */
12786 /* Generated by cgen */
12787 /* Copyright 2000 - 2002 Graeme W. Gill */
12788 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
12789 
12790 /* see the Licence.txt file for licencing details.*/
12791 
12792 
12793 /*
12794    Interpolation kernel specs:
12795 
12796    Input channels per pixel = 4
12797    Input channel 0 bits = 8
12798    Input channel 0 increment = 4
12799    Input channel 1 bits = 8
12800    Input channel 1 increment = 4
12801    Input channel 2 bits = 8
12802    Input channel 2 increment = 4
12803    Input channel 3 bits = 8
12804    Input channel 3 increment = 4
12805    Input is channel interleaved
12806    Input channels are separate words
12807    Input value extraction is done in input table lookup
12808 
12809    Output channels per pixel = 7
12810    Output channel 0 bits = 8
12811    Output channel 0 increment = 7
12812    Output channel 1 bits = 8
12813    Output channel 1 increment = 7
12814    Output channel 2 bits = 8
12815    Output channel 2 increment = 7
12816    Output channel 3 bits = 8
12817    Output channel 3 increment = 7
12818    Output channel 4 bits = 8
12819    Output channel 4 increment = 7
12820    Output channel 5 bits = 8
12821    Output channel 5 increment = 7
12822    Output channel 6 bits = 8
12823    Output channel 6 increment = 7
12824    Output is channel interleaved
12825 
12826    Output channels are separate words
12827    Simplex table index bits       = 32
12828    Interpolation table index bits = 32
12829    Simplex table max resolution = 255
12830    Interpolation table max resolution = 31
12831  */
12832 
12833 /*
12834    Machine architecture specs:
12835 
12836    Little endian
12837    Reading and writing pixel values separately
12838    Pointer size = 32 bits
12839 
12840    Ordinal size  8 bits is known as 'unsigned char'
12841    Ordinal size 16 bits is known as 'unsigned short'
12842    Ordinal size 32 bits is known as 'unsigned int'
12843    Natural ordinal is 'unsigned int'
12844 
12845    Integer size  8 bits is known as 'signed char'
12846    Integer size 16 bits is known as 'short'
12847    Integer size 32 bits is known as 'int'
12848    Natural integer is 'int'
12849 
12850  */
12851 
12852 #ifndef  IMDI_INCLUDED
12853 #include <memory.h>
12854 #include "imdi_imp.h"
12855 #define  IMDI_INCLUDED
12856 #endif  /* IMDI_INCLUDED */
12857 
12858 #ifndef DEFINED_pointer
12859 #define DEFINED_pointer
12860 typedef unsigned char * pointer;
12861 #endif
12862 
12863 /* Input table interp. index */
12864 #define IT_IX(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
12865 
12866 /* Input table simplex index enty */
12867 #define IT_SX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
12868 
12869 /* Simplex weighting table access */
12870 #define SW_O(off) ((off) * 20)
12871 
12872 /* Simplex table - get weighting value */
12873 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
12874 
12875 /* Simplex table - get offset value */
12876 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
12877 
12878 /* Interpolation multi-dim. table access */
12879 #define IM_O(off) ((off) * 16)
12880 
12881 /* Interpolation table - get vertex values */
12882 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
12883 #define IM_PE(p, v) *((unsigned int *)((p) + 12 + (v) * 8))
12884 
12885 /* Output table indexes */
12886 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
12887 
12888 void
imdi_k38(imdi * s,void ** outp,void ** inp,unsigned int npix)12889 imdi_k38(
12890 imdi *s,			/* imdi context */
12891 void **outp,		/* pointer to output pointers */
12892 void **inp,		/* pointer to input pointers */
12893 unsigned int npix	/* Number of pixels to process */
12894 ) {
12895 	imdi_imp *p = (imdi_imp *)(s->impl);
12896 	unsigned char *ip0 = (unsigned char *)inp[0];
12897 	unsigned char *op0 = (unsigned char *)outp[0];
12898 	unsigned char *ep = ip0 + npix * 4 ;
12899 	pointer it0 = (pointer)p->in_tables[0];
12900 	pointer it1 = (pointer)p->in_tables[1];
12901 	pointer it2 = (pointer)p->in_tables[2];
12902 	pointer it3 = (pointer)p->in_tables[3];
12903 	pointer ot0 = (pointer)p->out_tables[0];
12904 	pointer ot1 = (pointer)p->out_tables[1];
12905 	pointer ot2 = (pointer)p->out_tables[2];
12906 	pointer ot3 = (pointer)p->out_tables[3];
12907 	pointer ot4 = (pointer)p->out_tables[4];
12908 	pointer ot5 = (pointer)p->out_tables[5];
12909 	pointer ot6 = (pointer)p->out_tables[6];
12910 	pointer sw_base = (pointer)p->sw_table;
12911 	pointer im_base = (pointer)p->im_table;
12912 
12913 	for(;ip0 < ep; ip0 += 4, op0 += 7) {
12914 		unsigned int ova0;	/* Output value accumulator */
12915 		unsigned int ova1;	/* Output value accumulator */
12916 		unsigned int ova2;	/* Output value accumulator */
12917 		unsigned int ova3;	/* Output value partial accumulator */
12918 		{
12919 			pointer swp;
12920 			pointer imp;
12921 			{
12922 				unsigned int ti_s;	/* Simplex index variable */
12923 				unsigned int ti_i;	/* Interpolation index variable */
12924 
12925 				ti_i  = IT_IX(it0, ip0[0]);
12926 				ti_s  = IT_SX(it0, ip0[0]);
12927 				ti_i += IT_IX(it1, ip0[1]);
12928 				ti_s += IT_SX(it1, ip0[1]);
12929 				ti_i += IT_IX(it2, ip0[2]);
12930 				ti_s += IT_SX(it2, ip0[2]);
12931 				ti_i += IT_IX(it3, ip0[3]);
12932 				ti_s += IT_SX(it3, ip0[3]);
12933 
12934 				swp = sw_base + SW_O(ti_s);		/* Compute simplex table entry pointer */
12935 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
12936 			}
12937 			{
12938 				unsigned int vof;	/* Vertex offset value */
12939 				unsigned int vwe;	/* Vertex weighting */
12940 
12941 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
12942 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
12943 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
12944 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
12945 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
12946 				ova3  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
12947 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
12948 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
12949 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
12950 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
12951 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
12952 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
12953 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
12954 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
12955 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
12956 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
12957 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
12958 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
12959 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
12960 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
12961 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
12962 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
12963 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
12964 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
12965 				vof = SX_VO(swp, 4);	/* Read vertex offset value */
12966 				vwe = SX_WE(swp, 4);	/* Read vertex weighting value */
12967 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
12968 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
12969 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
12970 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
12971 			}
12972 		}
12973 		{
12974 			unsigned int oti;	/* Vertex offset value */
12975 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
12976 			op0[0] = OT_E(ot0, oti);	/* Write result */
12977 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
12978 			op0[1] = OT_E(ot1, oti);	/* Write result */
12979 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
12980 			op0[2] = OT_E(ot2, oti);	/* Write result */
12981 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
12982 			op0[3] = OT_E(ot3, oti);	/* Write result */
12983 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
12984 			op0[4] = OT_E(ot4, oti);	/* Write result */
12985 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
12986 			op0[5] = OT_E(ot5, oti);	/* Write result */
12987 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
12988 			op0[6] = OT_E(ot6, oti);	/* Write result */
12989 		}
12990 	}
12991 }
12992 #undef IT_IX
12993 #undef IT_SX
12994 #undef SW_O
12995 #undef SX_WE
12996 #undef SX_VO
12997 #undef IM_O
12998 #undef IM_FE
12999 #undef IM_PE
13000 #undef OT_E
13001 
13002 void
imdi_k38_gen(genspec * g)13003 imdi_k38_gen(
13004 genspec *g			/* structure to be initialised */
13005 ) {
13006 	static unsigned char data[] = {
13007 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
13008 		0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13009 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13010 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13011 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13012 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13013 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13014 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
13015 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
13016 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13017 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13018 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13019 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13020 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13021 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13022 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13023 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13024 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13025 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13026 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13027 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13028 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13029 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13030 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13031 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
13032 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
13033 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
13034 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
13035 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13036 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13037 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13038 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13039 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13040 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13041 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13042 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13043 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13044 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13045 		0x1f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
13046 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
13047 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
13048 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
13049 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
13050 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
13051 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
13052 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
13053 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
13054 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
13055 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13056 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
13057 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
13058 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x37, 0x5f,
13059 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
13060 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
13061 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
13062 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
13063 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
13064 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
13065 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
13066 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13067 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13068 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13069 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13070 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
13071 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x33, 0x38,
13072 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13073 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13074 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
13075 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
13076 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
13077 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
13078 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
13079 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
13080 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
13081 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
13082 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
13083 		0x00, 0xf0, 0x04, 0x08
13084 	};	/* Structure image */
13085 
13086 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
13087 }
13088 
13089 void
imdi_k38_tab(tabspec * t)13090 imdi_k38_tab(
13091 tabspec *t			/* structure to be initialised */
13092 ) {
13093 	static unsigned char data[] = {
13094 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13095 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13096 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13097 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
13098 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
13099 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
13100 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13101 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
13102 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
13103 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13104 		0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
13105 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13106 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
13107 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
13108 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
13109 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13110 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13111 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
13112 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
13113 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13114 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13115 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
13116 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
13117 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
13118 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13119 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13120 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13121 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13122 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13123 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13124 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13125 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13126 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
13127 	};	/* Structure image */
13128 
13129 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
13130 }
13131 
13132 
13133 
13134 
13135 
13136 
13137 /* Integer Multi-Dimensional Interpolation */
13138 /* Interpolation Kernel Code */
13139 /* Generated by cgen */
13140 /* Copyright 2000 - 2002 Graeme W. Gill */
13141 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
13142 
13143 /* see the Licence.txt file for licencing details.*/
13144 
13145 
13146 /*
13147    Interpolation kernel specs:
13148 
13149    Input channels per pixel = 5
13150    Input channel 0 bits = 8
13151    Input channel 0 increment = 5
13152    Input channel 1 bits = 8
13153    Input channel 1 increment = 5
13154    Input channel 2 bits = 8
13155    Input channel 2 increment = 5
13156    Input channel 3 bits = 8
13157    Input channel 3 increment = 5
13158    Input channel 4 bits = 8
13159    Input channel 4 increment = 5
13160    Input is channel interleaved
13161    Input channels are separate words
13162    Input value extraction is done in input table lookup
13163 
13164    Output channels per pixel = 7
13165    Output channel 0 bits = 8
13166    Output channel 0 increment = 7
13167    Output channel 1 bits = 8
13168    Output channel 1 increment = 7
13169    Output channel 2 bits = 8
13170    Output channel 2 increment = 7
13171    Output channel 3 bits = 8
13172    Output channel 3 increment = 7
13173    Output channel 4 bits = 8
13174    Output channel 4 increment = 7
13175    Output channel 5 bits = 8
13176    Output channel 5 increment = 7
13177    Output channel 6 bits = 8
13178    Output channel 6 increment = 7
13179    Output is channel interleaved
13180 
13181    Output channels are separate words
13182    Weight+voffset bits       = 32
13183    Interpolation table index bits = 32
13184    Interpolation table max resolution = 45
13185  */
13186 
13187 /*
13188    Machine architecture specs:
13189 
13190    Little endian
13191    Reading and writing pixel values separately
13192    Pointer size = 32 bits
13193 
13194    Ordinal size  8 bits is known as 'unsigned char'
13195    Ordinal size 16 bits is known as 'unsigned short'
13196    Ordinal size 32 bits is known as 'unsigned int'
13197    Natural ordinal is 'unsigned int'
13198 
13199    Integer size  8 bits is known as 'signed char'
13200    Integer size 16 bits is known as 'short'
13201    Integer size 32 bits is known as 'int'
13202    Natural integer is 'int'
13203 
13204  */
13205 
13206 #ifndef  IMDI_INCLUDED
13207 #include <memory.h>
13208 #include "imdi_imp.h"
13209 #define  IMDI_INCLUDED
13210 #endif  /* IMDI_INCLUDED */
13211 
13212 #ifndef DEFINED_pointer
13213 #define DEFINED_pointer
13214 typedef unsigned char * pointer;
13215 #endif
13216 
13217 /* Input table interp. index */
13218 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
13219 
13220 /* Input table input weighting/offset value enty */
13221 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
13222 
13223 /* Conditional exchange for sorting */
13224 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
13225 
13226 /* Interpolation multi-dim. table access */
13227 #define IM_O(off) ((off) * 16)
13228 
13229 /* Interpolation table - get vertex values */
13230 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
13231 #define IM_PE(p, v) *((unsigned int *)((p) + 12 + (v) * 8))
13232 
13233 /* Output table indexes */
13234 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
13235 
13236 void
imdi_k39(imdi * s,void ** outp,void ** inp,unsigned int npix)13237 imdi_k39(
13238 imdi *s,			/* imdi context */
13239 void **outp,		/* pointer to output pointers */
13240 void **inp,		/* pointer to input pointers */
13241 unsigned int npix	/* Number of pixels to process */
13242 ) {
13243 	imdi_imp *p = (imdi_imp *)(s->impl);
13244 	unsigned char *ip0 = (unsigned char *)inp[0];
13245 	unsigned char *op0 = (unsigned char *)outp[0];
13246 	unsigned char *ep = ip0 + npix * 5 ;
13247 	pointer it0 = (pointer)p->in_tables[0];
13248 	pointer it1 = (pointer)p->in_tables[1];
13249 	pointer it2 = (pointer)p->in_tables[2];
13250 	pointer it3 = (pointer)p->in_tables[3];
13251 	pointer it4 = (pointer)p->in_tables[4];
13252 	pointer ot0 = (pointer)p->out_tables[0];
13253 	pointer ot1 = (pointer)p->out_tables[1];
13254 	pointer ot2 = (pointer)p->out_tables[2];
13255 	pointer ot3 = (pointer)p->out_tables[3];
13256 	pointer ot4 = (pointer)p->out_tables[4];
13257 	pointer ot5 = (pointer)p->out_tables[5];
13258 	pointer ot6 = (pointer)p->out_tables[6];
13259 	pointer im_base = (pointer)p->im_table;
13260 
13261 	for(;ip0 < ep; ip0 += 5, op0 += 7) {
13262 		unsigned int ova0;	/* Output value accumulator */
13263 		unsigned int ova1;	/* Output value accumulator */
13264 		unsigned int ova2;	/* Output value accumulator */
13265 		unsigned int ova3;	/* Output value partial accumulator */
13266 		{
13267 			pointer imp;
13268 			unsigned int wo0;	/* Weighting value and vertex offset variable */
13269 			unsigned int wo1;	/* Weighting value and vertex offset variable */
13270 			unsigned int wo2;	/* Weighting value and vertex offset variable */
13271 			unsigned int wo3;	/* Weighting value and vertex offset variable */
13272 			unsigned int wo4;	/* Weighting value and vertex offset variable */
13273 			{
13274 				unsigned int ti_i;	/* Interpolation index variable */
13275 
13276 				ti_i  = IT_IX(it0, ip0[0]);
13277 				wo0   = IT_WO(it0, ip0[0]);
13278 				ti_i += IT_IX(it1, ip0[1]);
13279 				wo1   = IT_WO(it1, ip0[1]);
13280 				ti_i += IT_IX(it2, ip0[2]);
13281 				wo2   = IT_WO(it2, ip0[2]);
13282 				ti_i += IT_IX(it3, ip0[3]);
13283 				wo3   = IT_WO(it3, ip0[3]);
13284 				ti_i += IT_IX(it4, ip0[4]);
13285 				wo4   = IT_WO(it4, ip0[4]);
13286 
13287 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
13288 
13289 				/* Sort weighting values and vertex offset values */
13290 				CEX(wo0, wo1);
13291 				CEX(wo0, wo2);
13292 				CEX(wo0, wo3);
13293 				CEX(wo0, wo4);
13294 				CEX(wo1, wo2);
13295 				CEX(wo1, wo3);
13296 				CEX(wo1, wo4);
13297 				CEX(wo2, wo3);
13298 				CEX(wo2, wo4);
13299 				CEX(wo3, wo4);
13300 			}
13301 			{
13302 				unsigned int nvof;	/* Next vertex offset value */
13303 				unsigned int vof;	/* Vertex offset value */
13304 				unsigned int vwe;	/* Vertex weighting */
13305 
13306 				vof = 0;				/* First vertex offset is 0 */
13307 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
13308 				wo0 = (wo0 >> 23);		/* Extract weighting value */
13309 				vwe = 256 - wo0;		/* Baricentric weighting */
13310 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
13311 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
13312 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
13313 				ova3  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
13314 				vof += nvof;			/* Move to next vertex */
13315 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
13316 				wo1 = (wo1 >> 23);		/* Extract weighting value */
13317 				vwe = wo0 - wo1;		/* Baricentric weighting */
13318 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
13319 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
13320 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
13321 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
13322 				vof += nvof;			/* Move to next vertex */
13323 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
13324 				wo2 = (wo2 >> 23);		/* Extract weighting value */
13325 				vwe = wo1 - wo2;		/* Baricentric weighting */
13326 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
13327 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
13328 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
13329 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
13330 				vof += nvof;			/* Move to next vertex */
13331 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
13332 				wo3 = (wo3 >> 23);		/* Extract weighting value */
13333 				vwe = wo2 - wo3;		/* Baricentric weighting */
13334 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
13335 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
13336 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
13337 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
13338 				vof += nvof;			/* Move to next vertex */
13339 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
13340 				wo4 = (wo4 >> 23);		/* Extract weighting value */
13341 				vwe = wo3 - wo4;		/* Baricentric weighting */
13342 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
13343 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
13344 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
13345 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
13346 				vof += nvof;			/* Move to next vertex */
13347 				vwe = wo4;				/* Baricentric weighting */
13348 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
13349 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
13350 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
13351 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
13352 			}
13353 		}
13354 		{
13355 			unsigned int oti;	/* Vertex offset value */
13356 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
13357 			op0[0] = OT_E(ot0, oti);	/* Write result */
13358 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
13359 			op0[1] = OT_E(ot1, oti);	/* Write result */
13360 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
13361 			op0[2] = OT_E(ot2, oti);	/* Write result */
13362 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
13363 			op0[3] = OT_E(ot3, oti);	/* Write result */
13364 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
13365 			op0[4] = OT_E(ot4, oti);	/* Write result */
13366 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
13367 			op0[5] = OT_E(ot5, oti);	/* Write result */
13368 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
13369 			op0[6] = OT_E(ot6, oti);	/* Write result */
13370 		}
13371 	}
13372 }
13373 #undef IT_WO
13374 #undef IT_IX
13375 #undef CEX
13376 #undef IM_O
13377 #undef IM_FE
13378 #undef IM_PE
13379 #undef OT_E
13380 
13381 void
imdi_k39_gen(genspec * g)13382 imdi_k39_gen(
13383 genspec *g			/* structure to be initialised */
13384 ) {
13385 	static unsigned char data[] = {
13386 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
13387 		0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13388 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13389 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13390 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13391 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13392 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13393 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
13394 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
13395 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
13396 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13397 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13398 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13399 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13400 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13401 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13402 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13403 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13404 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13405 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13406 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13407 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13408 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13409 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13410 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
13411 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
13412 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
13413 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
13414 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13415 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13416 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13417 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13418 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13419 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13420 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13421 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13422 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13423 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13424 		0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13425 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
13426 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
13427 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
13428 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
13429 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
13430 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
13431 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
13432 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
13433 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
13434 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13435 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
13436 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
13437 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x37, 0x5f,
13438 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
13439 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
13440 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
13441 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
13442 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
13443 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
13444 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
13445 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13446 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13447 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13448 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13449 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
13450 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x33, 0x39,
13451 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13452 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13453 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
13454 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
13455 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
13456 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
13457 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
13458 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
13459 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
13460 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
13461 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
13462 		0x00, 0xf0, 0x04, 0x08
13463 	};	/* Structure image */
13464 
13465 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
13466 }
13467 
13468 void
imdi_k39_tab(tabspec * t)13469 imdi_k39_tab(
13470 tabspec *t			/* structure to be initialised */
13471 ) {
13472 	static unsigned char data[] = {
13473 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13474 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13475 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13476 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
13477 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
13478 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
13479 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13480 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
13481 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
13482 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13483 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
13484 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
13485 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
13486 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
13487 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
13488 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13489 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13490 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
13491 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
13492 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13493 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13494 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
13495 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
13496 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
13497 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13498 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13499 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13500 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13501 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13502 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13503 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13504 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13505 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
13506 	};	/* Structure image */
13507 
13508 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
13509 }
13510 
13511 
13512 
13513 
13514 
13515 
13516 /* Integer Multi-Dimensional Interpolation */
13517 /* Interpolation Kernel Code */
13518 /* Generated by cgen */
13519 /* Copyright 2000 - 2002 Graeme W. Gill */
13520 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
13521 
13522 /* see the Licence.txt file for licencing details.*/
13523 
13524 
13525 /*
13526    Interpolation kernel specs:
13527 
13528    Input channels per pixel = 6
13529    Input channel 0 bits = 8
13530    Input channel 0 increment = 6
13531    Input channel 1 bits = 8
13532    Input channel 1 increment = 6
13533    Input channel 2 bits = 8
13534    Input channel 2 increment = 6
13535    Input channel 3 bits = 8
13536    Input channel 3 increment = 6
13537    Input channel 4 bits = 8
13538    Input channel 4 increment = 6
13539    Input channel 5 bits = 8
13540    Input channel 5 increment = 6
13541    Input is channel interleaved
13542    Input channels are separate words
13543    Input value extraction is done in input table lookup
13544 
13545    Output channels per pixel = 7
13546    Output channel 0 bits = 8
13547    Output channel 0 increment = 7
13548    Output channel 1 bits = 8
13549    Output channel 1 increment = 7
13550    Output channel 2 bits = 8
13551    Output channel 2 increment = 7
13552    Output channel 3 bits = 8
13553    Output channel 3 increment = 7
13554    Output channel 4 bits = 8
13555    Output channel 4 increment = 7
13556    Output channel 5 bits = 8
13557    Output channel 5 increment = 7
13558    Output channel 6 bits = 8
13559    Output channel 6 increment = 7
13560    Output is channel interleaved
13561 
13562    Output channels are separate words
13563    Weight+voffset bits       = 32
13564    Interpolation table index bits = 32
13565    Interpolation table max resolution = 20
13566  */
13567 
13568 /*
13569    Machine architecture specs:
13570 
13571    Little endian
13572    Reading and writing pixel values separately
13573    Pointer size = 32 bits
13574 
13575    Ordinal size  8 bits is known as 'unsigned char'
13576    Ordinal size 16 bits is known as 'unsigned short'
13577    Ordinal size 32 bits is known as 'unsigned int'
13578    Natural ordinal is 'unsigned int'
13579 
13580    Integer size  8 bits is known as 'signed char'
13581    Integer size 16 bits is known as 'short'
13582    Integer size 32 bits is known as 'int'
13583    Natural integer is 'int'
13584 
13585  */
13586 
13587 #ifndef  IMDI_INCLUDED
13588 #include <memory.h>
13589 #include "imdi_imp.h"
13590 #define  IMDI_INCLUDED
13591 #endif  /* IMDI_INCLUDED */
13592 
13593 #ifndef DEFINED_pointer
13594 #define DEFINED_pointer
13595 typedef unsigned char * pointer;
13596 #endif
13597 
13598 /* Input table interp. index */
13599 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
13600 
13601 /* Input table input weighting/offset value enty */
13602 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
13603 
13604 /* Conditional exchange for sorting */
13605 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
13606 
13607 /* Interpolation multi-dim. table access */
13608 #define IM_O(off) ((off) * 16)
13609 
13610 /* Interpolation table - get vertex values */
13611 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
13612 #define IM_PE(p, v) *((unsigned int *)((p) + 12 + (v) * 8))
13613 
13614 /* Output table indexes */
13615 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
13616 
13617 void
imdi_k40(imdi * s,void ** outp,void ** inp,unsigned int npix)13618 imdi_k40(
13619 imdi *s,			/* imdi context */
13620 void **outp,		/* pointer to output pointers */
13621 void **inp,		/* pointer to input pointers */
13622 unsigned int npix	/* Number of pixels to process */
13623 ) {
13624 	imdi_imp *p = (imdi_imp *)(s->impl);
13625 	unsigned char *ip0 = (unsigned char *)inp[0];
13626 	unsigned char *op0 = (unsigned char *)outp[0];
13627 	unsigned char *ep = ip0 + npix * 6 ;
13628 	pointer it0 = (pointer)p->in_tables[0];
13629 	pointer it1 = (pointer)p->in_tables[1];
13630 	pointer it2 = (pointer)p->in_tables[2];
13631 	pointer it3 = (pointer)p->in_tables[3];
13632 	pointer it4 = (pointer)p->in_tables[4];
13633 	pointer it5 = (pointer)p->in_tables[5];
13634 	pointer ot0 = (pointer)p->out_tables[0];
13635 	pointer ot1 = (pointer)p->out_tables[1];
13636 	pointer ot2 = (pointer)p->out_tables[2];
13637 	pointer ot3 = (pointer)p->out_tables[3];
13638 	pointer ot4 = (pointer)p->out_tables[4];
13639 	pointer ot5 = (pointer)p->out_tables[5];
13640 	pointer ot6 = (pointer)p->out_tables[6];
13641 	pointer im_base = (pointer)p->im_table;
13642 
13643 	for(;ip0 < ep; ip0 += 6, op0 += 7) {
13644 		unsigned int ova0;	/* Output value accumulator */
13645 		unsigned int ova1;	/* Output value accumulator */
13646 		unsigned int ova2;	/* Output value accumulator */
13647 		unsigned int ova3;	/* Output value partial accumulator */
13648 		{
13649 			pointer imp;
13650 			unsigned int wo0;	/* Weighting value and vertex offset variable */
13651 			unsigned int wo1;	/* Weighting value and vertex offset variable */
13652 			unsigned int wo2;	/* Weighting value and vertex offset variable */
13653 			unsigned int wo3;	/* Weighting value and vertex offset variable */
13654 			unsigned int wo4;	/* Weighting value and vertex offset variable */
13655 			unsigned int wo5;	/* Weighting value and vertex offset variable */
13656 			{
13657 				unsigned int ti_i;	/* Interpolation index variable */
13658 
13659 				ti_i  = IT_IX(it0, ip0[0]);
13660 				wo0   = IT_WO(it0, ip0[0]);
13661 				ti_i += IT_IX(it1, ip0[1]);
13662 				wo1   = IT_WO(it1, ip0[1]);
13663 				ti_i += IT_IX(it2, ip0[2]);
13664 				wo2   = IT_WO(it2, ip0[2]);
13665 				ti_i += IT_IX(it3, ip0[3]);
13666 				wo3   = IT_WO(it3, ip0[3]);
13667 				ti_i += IT_IX(it4, ip0[4]);
13668 				wo4   = IT_WO(it4, ip0[4]);
13669 				ti_i += IT_IX(it5, ip0[5]);
13670 				wo5   = IT_WO(it5, ip0[5]);
13671 
13672 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
13673 
13674 				/* Sort weighting values and vertex offset values */
13675 				CEX(wo0, wo1);
13676 				CEX(wo0, wo2);
13677 				CEX(wo0, wo3);
13678 				CEX(wo0, wo4);
13679 				CEX(wo0, wo5);
13680 				CEX(wo1, wo2);
13681 				CEX(wo1, wo3);
13682 				CEX(wo1, wo4);
13683 				CEX(wo1, wo5);
13684 				CEX(wo2, wo3);
13685 				CEX(wo2, wo4);
13686 				CEX(wo2, wo5);
13687 				CEX(wo3, wo4);
13688 				CEX(wo3, wo5);
13689 				CEX(wo4, wo5);
13690 			}
13691 			{
13692 				unsigned int nvof;	/* Next vertex offset value */
13693 				unsigned int vof;	/* Vertex offset value */
13694 				unsigned int vwe;	/* Vertex weighting */
13695 
13696 				vof = 0;				/* First vertex offset is 0 */
13697 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
13698 				wo0 = (wo0 >> 23);		/* Extract weighting value */
13699 				vwe = 256 - wo0;		/* Baricentric weighting */
13700 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
13701 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
13702 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
13703 				ova3  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
13704 				vof += nvof;			/* Move to next vertex */
13705 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
13706 				wo1 = (wo1 >> 23);		/* Extract weighting value */
13707 				vwe = wo0 - wo1;		/* Baricentric weighting */
13708 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
13709 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
13710 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
13711 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
13712 				vof += nvof;			/* Move to next vertex */
13713 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
13714 				wo2 = (wo2 >> 23);		/* Extract weighting value */
13715 				vwe = wo1 - wo2;		/* Baricentric weighting */
13716 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
13717 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
13718 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
13719 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
13720 				vof += nvof;			/* Move to next vertex */
13721 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
13722 				wo3 = (wo3 >> 23);		/* Extract weighting value */
13723 				vwe = wo2 - wo3;		/* Baricentric weighting */
13724 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
13725 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
13726 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
13727 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
13728 				vof += nvof;			/* Move to next vertex */
13729 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
13730 				wo4 = (wo4 >> 23);		/* Extract weighting value */
13731 				vwe = wo3 - wo4;		/* Baricentric weighting */
13732 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
13733 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
13734 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
13735 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
13736 				vof += nvof;			/* Move to next vertex */
13737 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
13738 				wo5 = (wo5 >> 23);		/* Extract weighting value */
13739 				vwe = wo4 - wo5;		/* Baricentric weighting */
13740 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
13741 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
13742 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
13743 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
13744 				vof += nvof;			/* Move to next vertex */
13745 				vwe = wo5;				/* Baricentric weighting */
13746 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
13747 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
13748 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
13749 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
13750 			}
13751 		}
13752 		{
13753 			unsigned int oti;	/* Vertex offset value */
13754 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
13755 			op0[0] = OT_E(ot0, oti);	/* Write result */
13756 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
13757 			op0[1] = OT_E(ot1, oti);	/* Write result */
13758 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
13759 			op0[2] = OT_E(ot2, oti);	/* Write result */
13760 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
13761 			op0[3] = OT_E(ot3, oti);	/* Write result */
13762 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
13763 			op0[4] = OT_E(ot4, oti);	/* Write result */
13764 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
13765 			op0[5] = OT_E(ot5, oti);	/* Write result */
13766 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
13767 			op0[6] = OT_E(ot6, oti);	/* Write result */
13768 		}
13769 	}
13770 }
13771 #undef IT_WO
13772 #undef IT_IX
13773 #undef CEX
13774 #undef IM_O
13775 #undef IM_FE
13776 #undef IM_PE
13777 #undef OT_E
13778 
13779 void
imdi_k40_gen(genspec * g)13780 imdi_k40_gen(
13781 genspec *g			/* structure to be initialised */
13782 ) {
13783 	static unsigned char data[] = {
13784 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
13785 		0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13786 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13787 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13788 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13789 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13790 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13791 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
13792 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
13793 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
13794 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13795 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13796 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13797 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13798 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13799 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13800 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13801 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13802 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13803 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13804 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13805 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13806 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13807 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13808 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
13809 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
13810 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
13811 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
13812 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13813 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13814 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13815 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13816 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13817 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13818 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13819 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13820 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13821 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13822 		0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13823 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
13824 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
13825 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
13826 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
13827 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
13828 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
13829 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
13830 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
13831 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
13832 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13833 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
13834 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
13835 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x37, 0x5f,
13836 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
13837 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
13838 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
13839 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
13840 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
13841 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
13842 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
13843 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13844 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13845 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13846 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13847 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
13848 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x34, 0x30,
13849 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13850 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13851 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
13852 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
13853 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
13854 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
13855 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
13856 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
13857 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
13858 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
13859 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
13860 		0x00, 0xf0, 0x04, 0x08
13861 	};	/* Structure image */
13862 
13863 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
13864 }
13865 
13866 void
imdi_k40_tab(tabspec * t)13867 imdi_k40_tab(
13868 tabspec *t			/* structure to be initialised */
13869 ) {
13870 	static unsigned char data[] = {
13871 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13872 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13873 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13874 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
13875 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
13876 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
13877 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13878 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
13879 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
13880 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13881 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
13882 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
13883 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
13884 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
13885 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
13886 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13887 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13888 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
13889 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
13890 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13891 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
13892 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
13893 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
13894 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
13895 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13896 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13897 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13898 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13899 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13900 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13901 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13902 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
13903 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
13904 	};	/* Structure image */
13905 
13906 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
13907 }
13908 
13909 
13910 
13911 
13912 
13913 
13914 /* Integer Multi-Dimensional Interpolation */
13915 /* Interpolation Kernel Code */
13916 /* Generated by cgen */
13917 /* Copyright 2000 - 2002 Graeme W. Gill */
13918 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
13919 
13920 /* see the Licence.txt file for licencing details.*/
13921 
13922 
13923 /*
13924    Interpolation kernel specs:
13925 
13926    Input channels per pixel = 7
13927    Input channel 0 bits = 8
13928    Input channel 0 increment = 7
13929    Input channel 1 bits = 8
13930    Input channel 1 increment = 7
13931    Input channel 2 bits = 8
13932    Input channel 2 increment = 7
13933    Input channel 3 bits = 8
13934    Input channel 3 increment = 7
13935    Input channel 4 bits = 8
13936    Input channel 4 increment = 7
13937    Input channel 5 bits = 8
13938    Input channel 5 increment = 7
13939    Input channel 6 bits = 8
13940    Input channel 6 increment = 7
13941    Input is channel interleaved
13942    Input channels are separate words
13943    Input value extraction is done in input table lookup
13944 
13945    Output channels per pixel = 7
13946    Output channel 0 bits = 8
13947    Output channel 0 increment = 7
13948    Output channel 1 bits = 8
13949    Output channel 1 increment = 7
13950    Output channel 2 bits = 8
13951    Output channel 2 increment = 7
13952    Output channel 3 bits = 8
13953    Output channel 3 increment = 7
13954    Output channel 4 bits = 8
13955    Output channel 4 increment = 7
13956    Output channel 5 bits = 8
13957    Output channel 5 increment = 7
13958    Output channel 6 bits = 8
13959    Output channel 6 increment = 7
13960    Output is channel interleaved
13961 
13962    Output channels are separate words
13963    Weight+voffset bits       = 32
13964    Interpolation table index bits = 32
13965    Interpolation table max resolution = 12
13966  */
13967 
13968 /*
13969    Machine architecture specs:
13970 
13971    Little endian
13972    Reading and writing pixel values separately
13973    Pointer size = 32 bits
13974 
13975    Ordinal size  8 bits is known as 'unsigned char'
13976    Ordinal size 16 bits is known as 'unsigned short'
13977    Ordinal size 32 bits is known as 'unsigned int'
13978    Natural ordinal is 'unsigned int'
13979 
13980    Integer size  8 bits is known as 'signed char'
13981    Integer size 16 bits is known as 'short'
13982    Integer size 32 bits is known as 'int'
13983    Natural integer is 'int'
13984 
13985  */
13986 
13987 #ifndef  IMDI_INCLUDED
13988 #include <memory.h>
13989 #include "imdi_imp.h"
13990 #define  IMDI_INCLUDED
13991 #endif  /* IMDI_INCLUDED */
13992 
13993 #ifndef DEFINED_pointer
13994 #define DEFINED_pointer
13995 typedef unsigned char * pointer;
13996 #endif
13997 
13998 /* Input table interp. index */
13999 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
14000 
14001 /* Input table input weighting/offset value enty */
14002 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
14003 
14004 /* Conditional exchange for sorting */
14005 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
14006 
14007 /* Interpolation multi-dim. table access */
14008 #define IM_O(off) ((off) * 16)
14009 
14010 /* Interpolation table - get vertex values */
14011 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
14012 #define IM_PE(p, v) *((unsigned int *)((p) + 12 + (v) * 8))
14013 
14014 /* Output table indexes */
14015 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
14016 
14017 void
imdi_k41(imdi * s,void ** outp,void ** inp,unsigned int npix)14018 imdi_k41(
14019 imdi *s,			/* imdi context */
14020 void **outp,		/* pointer to output pointers */
14021 void **inp,		/* pointer to input pointers */
14022 unsigned int npix	/* Number of pixels to process */
14023 ) {
14024 	imdi_imp *p = (imdi_imp *)(s->impl);
14025 	unsigned char *ip0 = (unsigned char *)inp[0];
14026 	unsigned char *op0 = (unsigned char *)outp[0];
14027 	unsigned char *ep = ip0 + npix * 7 ;
14028 	pointer it0 = (pointer)p->in_tables[0];
14029 	pointer it1 = (pointer)p->in_tables[1];
14030 	pointer it2 = (pointer)p->in_tables[2];
14031 	pointer it3 = (pointer)p->in_tables[3];
14032 	pointer it4 = (pointer)p->in_tables[4];
14033 	pointer it5 = (pointer)p->in_tables[5];
14034 	pointer it6 = (pointer)p->in_tables[6];
14035 	pointer ot0 = (pointer)p->out_tables[0];
14036 	pointer ot1 = (pointer)p->out_tables[1];
14037 	pointer ot2 = (pointer)p->out_tables[2];
14038 	pointer ot3 = (pointer)p->out_tables[3];
14039 	pointer ot4 = (pointer)p->out_tables[4];
14040 	pointer ot5 = (pointer)p->out_tables[5];
14041 	pointer ot6 = (pointer)p->out_tables[6];
14042 	pointer im_base = (pointer)p->im_table;
14043 
14044 	for(;ip0 < ep; ip0 += 7, op0 += 7) {
14045 		unsigned int ova0;	/* Output value accumulator */
14046 		unsigned int ova1;	/* Output value accumulator */
14047 		unsigned int ova2;	/* Output value accumulator */
14048 		unsigned int ova3;	/* Output value partial accumulator */
14049 		{
14050 			pointer imp;
14051 			unsigned int wo0;	/* Weighting value and vertex offset variable */
14052 			unsigned int wo1;	/* Weighting value and vertex offset variable */
14053 			unsigned int wo2;	/* Weighting value and vertex offset variable */
14054 			unsigned int wo3;	/* Weighting value and vertex offset variable */
14055 			unsigned int wo4;	/* Weighting value and vertex offset variable */
14056 			unsigned int wo5;	/* Weighting value and vertex offset variable */
14057 			unsigned int wo6;	/* Weighting value and vertex offset variable */
14058 			{
14059 				unsigned int ti_i;	/* Interpolation index variable */
14060 
14061 				ti_i  = IT_IX(it0, ip0[0]);
14062 				wo0   = IT_WO(it0, ip0[0]);
14063 				ti_i += IT_IX(it1, ip0[1]);
14064 				wo1   = IT_WO(it1, ip0[1]);
14065 				ti_i += IT_IX(it2, ip0[2]);
14066 				wo2   = IT_WO(it2, ip0[2]);
14067 				ti_i += IT_IX(it3, ip0[3]);
14068 				wo3   = IT_WO(it3, ip0[3]);
14069 				ti_i += IT_IX(it4, ip0[4]);
14070 				wo4   = IT_WO(it4, ip0[4]);
14071 				ti_i += IT_IX(it5, ip0[5]);
14072 				wo5   = IT_WO(it5, ip0[5]);
14073 				ti_i += IT_IX(it6, ip0[6]);
14074 				wo6   = IT_WO(it6, ip0[6]);
14075 
14076 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
14077 
14078 				/* Sort weighting values and vertex offset values */
14079 				CEX(wo0, wo1);
14080 				CEX(wo0, wo2);
14081 				CEX(wo0, wo3);
14082 				CEX(wo0, wo4);
14083 				CEX(wo0, wo5);
14084 				CEX(wo0, wo6);
14085 				CEX(wo1, wo2);
14086 				CEX(wo1, wo3);
14087 				CEX(wo1, wo4);
14088 				CEX(wo1, wo5);
14089 				CEX(wo1, wo6);
14090 				CEX(wo2, wo3);
14091 				CEX(wo2, wo4);
14092 				CEX(wo2, wo5);
14093 				CEX(wo2, wo6);
14094 				CEX(wo3, wo4);
14095 				CEX(wo3, wo5);
14096 				CEX(wo3, wo6);
14097 				CEX(wo4, wo5);
14098 				CEX(wo4, wo6);
14099 				CEX(wo5, wo6);
14100 			}
14101 			{
14102 				unsigned int nvof;	/* Next vertex offset value */
14103 				unsigned int vof;	/* Vertex offset value */
14104 				unsigned int vwe;	/* Vertex weighting */
14105 
14106 				vof = 0;				/* First vertex offset is 0 */
14107 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
14108 				wo0 = (wo0 >> 23);		/* Extract weighting value */
14109 				vwe = 256 - wo0;		/* Baricentric weighting */
14110 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
14111 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
14112 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
14113 				ova3  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
14114 				vof += nvof;			/* Move to next vertex */
14115 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
14116 				wo1 = (wo1 >> 23);		/* Extract weighting value */
14117 				vwe = wo0 - wo1;		/* Baricentric weighting */
14118 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
14119 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
14120 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
14121 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
14122 				vof += nvof;			/* Move to next vertex */
14123 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
14124 				wo2 = (wo2 >> 23);		/* Extract weighting value */
14125 				vwe = wo1 - wo2;		/* Baricentric weighting */
14126 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
14127 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
14128 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
14129 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
14130 				vof += nvof;			/* Move to next vertex */
14131 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
14132 				wo3 = (wo3 >> 23);		/* Extract weighting value */
14133 				vwe = wo2 - wo3;		/* Baricentric weighting */
14134 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
14135 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
14136 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
14137 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
14138 				vof += nvof;			/* Move to next vertex */
14139 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
14140 				wo4 = (wo4 >> 23);		/* Extract weighting value */
14141 				vwe = wo3 - wo4;		/* Baricentric weighting */
14142 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
14143 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
14144 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
14145 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
14146 				vof += nvof;			/* Move to next vertex */
14147 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
14148 				wo5 = (wo5 >> 23);		/* Extract weighting value */
14149 				vwe = wo4 - wo5;		/* Baricentric weighting */
14150 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
14151 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
14152 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
14153 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
14154 				vof += nvof;			/* Move to next vertex */
14155 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
14156 				wo6 = (wo6 >> 23);		/* Extract weighting value */
14157 				vwe = wo5 - wo6;		/* Baricentric weighting */
14158 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
14159 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
14160 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
14161 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
14162 				vof += nvof;			/* Move to next vertex */
14163 				vwe = wo6;				/* Baricentric weighting */
14164 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
14165 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
14166 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
14167 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
14168 			}
14169 		}
14170 		{
14171 			unsigned int oti;	/* Vertex offset value */
14172 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
14173 			op0[0] = OT_E(ot0, oti);	/* Write result */
14174 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
14175 			op0[1] = OT_E(ot1, oti);	/* Write result */
14176 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
14177 			op0[2] = OT_E(ot2, oti);	/* Write result */
14178 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
14179 			op0[3] = OT_E(ot3, oti);	/* Write result */
14180 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
14181 			op0[4] = OT_E(ot4, oti);	/* Write result */
14182 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
14183 			op0[5] = OT_E(ot5, oti);	/* Write result */
14184 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
14185 			op0[6] = OT_E(ot6, oti);	/* Write result */
14186 		}
14187 	}
14188 }
14189 #undef IT_WO
14190 #undef IT_IX
14191 #undef CEX
14192 #undef IM_O
14193 #undef IM_FE
14194 #undef IM_PE
14195 #undef OT_E
14196 
14197 void
imdi_k41_gen(genspec * g)14198 imdi_k41_gen(
14199 genspec *g			/* structure to be initialised */
14200 ) {
14201 	static unsigned char data[] = {
14202 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
14203 		0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14204 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14205 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14206 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14207 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14208 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14209 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
14210 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
14211 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
14212 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
14213 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14214 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14215 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14216 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14217 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14218 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14219 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14220 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14221 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14222 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14223 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14224 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14225 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14226 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
14227 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
14228 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
14229 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
14230 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14231 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14232 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14233 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14234 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14235 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14236 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14237 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14238 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14239 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14240 		0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14241 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
14242 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
14243 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
14244 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
14245 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
14246 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
14247 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
14248 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
14249 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
14250 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14251 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
14252 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
14253 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x37, 0x5f,
14254 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
14255 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
14256 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
14257 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
14258 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
14259 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
14260 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
14261 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14262 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14263 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14264 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14265 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
14266 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x34, 0x31,
14267 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14268 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14269 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
14270 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
14271 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
14272 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
14273 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
14274 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
14275 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
14276 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
14277 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
14278 		0x00, 0xf0, 0x04, 0x08
14279 	};	/* Structure image */
14280 
14281 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
14282 }
14283 
14284 void
imdi_k41_tab(tabspec * t)14285 imdi_k41_tab(
14286 tabspec *t			/* structure to be initialised */
14287 ) {
14288 	static unsigned char data[] = {
14289 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14290 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14291 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14292 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
14293 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
14294 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
14295 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14296 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
14297 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
14298 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14299 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
14300 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
14301 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
14302 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
14303 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
14304 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14305 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14306 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
14307 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
14308 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14309 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14310 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
14311 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
14312 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
14313 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14314 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14315 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14316 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14317 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14318 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14319 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14320 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14321 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
14322 	};	/* Structure image */
14323 
14324 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
14325 }
14326 
14327 
14328 
14329 
14330 
14331 
14332 /* Integer Multi-Dimensional Interpolation */
14333 /* Interpolation Kernel Code */
14334 /* Generated by cgen */
14335 /* Copyright 2000 - 2002 Graeme W. Gill */
14336 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
14337 
14338 /* see the Licence.txt file for licencing details.*/
14339 
14340 
14341 /*
14342    Interpolation kernel specs:
14343 
14344    Input channels per pixel = 8
14345    Input channel 0 bits = 8
14346    Input channel 0 increment = 8
14347    Input channel 1 bits = 8
14348    Input channel 1 increment = 8
14349    Input channel 2 bits = 8
14350    Input channel 2 increment = 8
14351    Input channel 3 bits = 8
14352    Input channel 3 increment = 8
14353    Input channel 4 bits = 8
14354    Input channel 4 increment = 8
14355    Input channel 5 bits = 8
14356    Input channel 5 increment = 8
14357    Input channel 6 bits = 8
14358    Input channel 6 increment = 8
14359    Input channel 7 bits = 8
14360    Input channel 7 increment = 8
14361    Input is channel interleaved
14362    Input channels are separate words
14363    Input value extraction is done in input table lookup
14364 
14365    Output channels per pixel = 7
14366    Output channel 0 bits = 8
14367    Output channel 0 increment = 7
14368    Output channel 1 bits = 8
14369    Output channel 1 increment = 7
14370    Output channel 2 bits = 8
14371    Output channel 2 increment = 7
14372    Output channel 3 bits = 8
14373    Output channel 3 increment = 7
14374    Output channel 4 bits = 8
14375    Output channel 4 increment = 7
14376    Output channel 5 bits = 8
14377    Output channel 5 increment = 7
14378    Output channel 6 bits = 8
14379    Output channel 6 increment = 7
14380    Output is channel interleaved
14381 
14382    Output channels are separate words
14383    Weight+voffset bits       = 32
14384    Interpolation table index bits = 32
14385    Interpolation table max resolution = 8
14386  */
14387 
14388 /*
14389    Machine architecture specs:
14390 
14391    Little endian
14392    Reading and writing pixel values separately
14393    Pointer size = 32 bits
14394 
14395    Ordinal size  8 bits is known as 'unsigned char'
14396    Ordinal size 16 bits is known as 'unsigned short'
14397    Ordinal size 32 bits is known as 'unsigned int'
14398    Natural ordinal is 'unsigned int'
14399 
14400    Integer size  8 bits is known as 'signed char'
14401    Integer size 16 bits is known as 'short'
14402    Integer size 32 bits is known as 'int'
14403    Natural integer is 'int'
14404 
14405  */
14406 
14407 #ifndef  IMDI_INCLUDED
14408 #include <memory.h>
14409 #include "imdi_imp.h"
14410 #define  IMDI_INCLUDED
14411 #endif  /* IMDI_INCLUDED */
14412 
14413 #ifndef DEFINED_pointer
14414 #define DEFINED_pointer
14415 typedef unsigned char * pointer;
14416 #endif
14417 
14418 /* Input table interp. index */
14419 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
14420 
14421 /* Input table input weighting/offset value enty */
14422 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
14423 
14424 /* Conditional exchange for sorting */
14425 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
14426 
14427 /* Interpolation multi-dim. table access */
14428 #define IM_O(off) ((off) * 16)
14429 
14430 /* Interpolation table - get vertex values */
14431 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
14432 #define IM_PE(p, v) *((unsigned int *)((p) + 12 + (v) * 8))
14433 
14434 /* Output table indexes */
14435 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
14436 
14437 void
imdi_k42(imdi * s,void ** outp,void ** inp,unsigned int npix)14438 imdi_k42(
14439 imdi *s,			/* imdi context */
14440 void **outp,		/* pointer to output pointers */
14441 void **inp,		/* pointer to input pointers */
14442 unsigned int npix	/* Number of pixels to process */
14443 ) {
14444 	imdi_imp *p = (imdi_imp *)(s->impl);
14445 	unsigned char *ip0 = (unsigned char *)inp[0];
14446 	unsigned char *op0 = (unsigned char *)outp[0];
14447 	unsigned char *ep = ip0 + npix * 8 ;
14448 	pointer it0 = (pointer)p->in_tables[0];
14449 	pointer it1 = (pointer)p->in_tables[1];
14450 	pointer it2 = (pointer)p->in_tables[2];
14451 	pointer it3 = (pointer)p->in_tables[3];
14452 	pointer it4 = (pointer)p->in_tables[4];
14453 	pointer it5 = (pointer)p->in_tables[5];
14454 	pointer it6 = (pointer)p->in_tables[6];
14455 	pointer it7 = (pointer)p->in_tables[7];
14456 	pointer ot0 = (pointer)p->out_tables[0];
14457 	pointer ot1 = (pointer)p->out_tables[1];
14458 	pointer ot2 = (pointer)p->out_tables[2];
14459 	pointer ot3 = (pointer)p->out_tables[3];
14460 	pointer ot4 = (pointer)p->out_tables[4];
14461 	pointer ot5 = (pointer)p->out_tables[5];
14462 	pointer ot6 = (pointer)p->out_tables[6];
14463 	pointer im_base = (pointer)p->im_table;
14464 
14465 	for(;ip0 < ep; ip0 += 8, op0 += 7) {
14466 		unsigned int ova0;	/* Output value accumulator */
14467 		unsigned int ova1;	/* Output value accumulator */
14468 		unsigned int ova2;	/* Output value accumulator */
14469 		unsigned int ova3;	/* Output value partial accumulator */
14470 		{
14471 			pointer imp;
14472 			unsigned int wo0;	/* Weighting value and vertex offset variable */
14473 			unsigned int wo1;	/* Weighting value and vertex offset variable */
14474 			unsigned int wo2;	/* Weighting value and vertex offset variable */
14475 			unsigned int wo3;	/* Weighting value and vertex offset variable */
14476 			unsigned int wo4;	/* Weighting value and vertex offset variable */
14477 			unsigned int wo5;	/* Weighting value and vertex offset variable */
14478 			unsigned int wo6;	/* Weighting value and vertex offset variable */
14479 			unsigned int wo7;	/* Weighting value and vertex offset variable */
14480 			{
14481 				unsigned int ti_i;	/* Interpolation index variable */
14482 
14483 				ti_i  = IT_IX(it0, ip0[0]);
14484 				wo0   = IT_WO(it0, ip0[0]);
14485 				ti_i += IT_IX(it1, ip0[1]);
14486 				wo1   = IT_WO(it1, ip0[1]);
14487 				ti_i += IT_IX(it2, ip0[2]);
14488 				wo2   = IT_WO(it2, ip0[2]);
14489 				ti_i += IT_IX(it3, ip0[3]);
14490 				wo3   = IT_WO(it3, ip0[3]);
14491 				ti_i += IT_IX(it4, ip0[4]);
14492 				wo4   = IT_WO(it4, ip0[4]);
14493 				ti_i += IT_IX(it5, ip0[5]);
14494 				wo5   = IT_WO(it5, ip0[5]);
14495 				ti_i += IT_IX(it6, ip0[6]);
14496 				wo6   = IT_WO(it6, ip0[6]);
14497 				ti_i += IT_IX(it7, ip0[7]);
14498 				wo7   = IT_WO(it7, ip0[7]);
14499 
14500 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
14501 
14502 				/* Sort weighting values and vertex offset values */
14503 				CEX(wo0, wo1);
14504 				CEX(wo0, wo2);
14505 				CEX(wo0, wo3);
14506 				CEX(wo0, wo4);
14507 				CEX(wo0, wo5);
14508 				CEX(wo0, wo6);
14509 				CEX(wo0, wo7);
14510 				CEX(wo1, wo2);
14511 				CEX(wo1, wo3);
14512 				CEX(wo1, wo4);
14513 				CEX(wo1, wo5);
14514 				CEX(wo1, wo6);
14515 				CEX(wo1, wo7);
14516 				CEX(wo2, wo3);
14517 				CEX(wo2, wo4);
14518 				CEX(wo2, wo5);
14519 				CEX(wo2, wo6);
14520 				CEX(wo2, wo7);
14521 				CEX(wo3, wo4);
14522 				CEX(wo3, wo5);
14523 				CEX(wo3, wo6);
14524 				CEX(wo3, wo7);
14525 				CEX(wo4, wo5);
14526 				CEX(wo4, wo6);
14527 				CEX(wo4, wo7);
14528 				CEX(wo5, wo6);
14529 				CEX(wo5, wo7);
14530 				CEX(wo6, wo7);
14531 			}
14532 			{
14533 				unsigned int nvof;	/* Next vertex offset value */
14534 				unsigned int vof;	/* Vertex offset value */
14535 				unsigned int vwe;	/* Vertex weighting */
14536 
14537 				vof = 0;				/* First vertex offset is 0 */
14538 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
14539 				wo0 = (wo0 >> 23);		/* Extract weighting value */
14540 				vwe = 256 - wo0;		/* Baricentric weighting */
14541 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
14542 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
14543 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
14544 				ova3  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
14545 				vof += nvof;			/* Move to next vertex */
14546 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
14547 				wo1 = (wo1 >> 23);		/* Extract weighting value */
14548 				vwe = wo0 - wo1;		/* Baricentric weighting */
14549 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
14550 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
14551 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
14552 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
14553 				vof += nvof;			/* Move to next vertex */
14554 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
14555 				wo2 = (wo2 >> 23);		/* Extract weighting value */
14556 				vwe = wo1 - wo2;		/* Baricentric weighting */
14557 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
14558 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
14559 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
14560 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
14561 				vof += nvof;			/* Move to next vertex */
14562 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
14563 				wo3 = (wo3 >> 23);		/* Extract weighting value */
14564 				vwe = wo2 - wo3;		/* Baricentric weighting */
14565 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
14566 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
14567 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
14568 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
14569 				vof += nvof;			/* Move to next vertex */
14570 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
14571 				wo4 = (wo4 >> 23);		/* Extract weighting value */
14572 				vwe = wo3 - wo4;		/* Baricentric weighting */
14573 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
14574 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
14575 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
14576 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
14577 				vof += nvof;			/* Move to next vertex */
14578 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
14579 				wo5 = (wo5 >> 23);		/* Extract weighting value */
14580 				vwe = wo4 - wo5;		/* Baricentric weighting */
14581 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
14582 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
14583 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
14584 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
14585 				vof += nvof;			/* Move to next vertex */
14586 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
14587 				wo6 = (wo6 >> 23);		/* Extract weighting value */
14588 				vwe = wo5 - wo6;		/* Baricentric weighting */
14589 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
14590 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
14591 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
14592 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
14593 				vof += nvof;			/* Move to next vertex */
14594 				nvof = (wo7 & 0x7fffff);	/* Extract offset value */
14595 				wo7 = (wo7 >> 23);		/* Extract weighting value */
14596 				vwe = wo6 - wo7;		/* Baricentric weighting */
14597 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
14598 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
14599 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
14600 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
14601 				vof += nvof;			/* Move to next vertex */
14602 				vwe = wo7;				/* Baricentric weighting */
14603 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
14604 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
14605 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
14606 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
14607 			}
14608 		}
14609 		{
14610 			unsigned int oti;	/* Vertex offset value */
14611 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
14612 			op0[0] = OT_E(ot0, oti);	/* Write result */
14613 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
14614 			op0[1] = OT_E(ot1, oti);	/* Write result */
14615 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
14616 			op0[2] = OT_E(ot2, oti);	/* Write result */
14617 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
14618 			op0[3] = OT_E(ot3, oti);	/* Write result */
14619 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
14620 			op0[4] = OT_E(ot4, oti);	/* Write result */
14621 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
14622 			op0[5] = OT_E(ot5, oti);	/* Write result */
14623 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
14624 			op0[6] = OT_E(ot6, oti);	/* Write result */
14625 		}
14626 	}
14627 }
14628 #undef IT_WO
14629 #undef IT_IX
14630 #undef CEX
14631 #undef IM_O
14632 #undef IM_FE
14633 #undef IM_PE
14634 #undef OT_E
14635 
14636 void
imdi_k42_gen(genspec * g)14637 imdi_k42_gen(
14638 genspec *g			/* structure to be initialised */
14639 ) {
14640 	static unsigned char data[] = {
14641 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14642 		0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14643 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14644 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14645 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14646 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14647 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14648 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14649 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14650 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14651 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14652 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14653 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14654 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14655 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14656 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14657 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14658 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14659 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14660 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14661 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14662 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14663 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14664 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14665 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
14666 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
14667 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
14668 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
14669 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14670 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14671 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14672 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14673 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14674 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14675 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14676 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14677 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14678 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14679 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14680 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
14681 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
14682 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
14683 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
14684 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
14685 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
14686 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
14687 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
14688 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
14689 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14690 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
14691 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
14692 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x37, 0x5f,
14693 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
14694 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
14695 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
14696 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
14697 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
14698 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
14699 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
14700 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14701 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14702 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14703 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14704 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
14705 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x34, 0x32,
14706 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14707 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14708 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
14709 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
14710 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
14711 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
14712 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
14713 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
14714 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
14715 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
14716 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
14717 		0x00, 0xf0, 0x04, 0x08
14718 	};	/* Structure image */
14719 
14720 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
14721 }
14722 
14723 void
imdi_k42_tab(tabspec * t)14724 imdi_k42_tab(
14725 tabspec *t			/* structure to be initialised */
14726 ) {
14727 	static unsigned char data[] = {
14728 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14729 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14730 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14731 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
14732 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
14733 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
14734 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14735 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
14736 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
14737 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14738 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
14739 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
14740 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
14741 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
14742 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
14743 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14744 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14745 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
14746 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
14747 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14748 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14749 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
14750 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
14751 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
14752 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14753 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14754 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14755 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14756 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14757 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14758 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14759 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14760 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
14761 	};	/* Structure image */
14762 
14763 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
14764 }
14765 
14766 
14767 
14768 
14769 
14770 
14771 /* Integer Multi-Dimensional Interpolation */
14772 /* Interpolation Kernel Code */
14773 /* Generated by cgen */
14774 /* Copyright 2000 - 2002 Graeme W. Gill */
14775 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
14776 
14777 /* see the Licence.txt file for licencing details.*/
14778 
14779 
14780 /*
14781    Interpolation kernel specs:
14782 
14783    Input channels per pixel = 1
14784    Input channel 0 bits = 8
14785    Input channel 0 increment = 1
14786    Input is channel interleaved
14787    Input channels are separate words
14788    Input value extraction is done in input table lookup
14789 
14790    Output channels per pixel = 8
14791    Output channel 0 bits = 8
14792    Output channel 0 increment = 8
14793    Output channel 1 bits = 8
14794    Output channel 1 increment = 8
14795    Output channel 2 bits = 8
14796    Output channel 2 increment = 8
14797    Output channel 3 bits = 8
14798    Output channel 3 increment = 8
14799    Output channel 4 bits = 8
14800    Output channel 4 increment = 8
14801    Output channel 5 bits = 8
14802    Output channel 5 increment = 8
14803    Output channel 6 bits = 8
14804    Output channel 6 increment = 8
14805    Output channel 7 bits = 8
14806    Output channel 7 increment = 8
14807    Output is channel interleaved
14808 
14809    Output channels are separate words
14810    Simplex table index bits       = 0
14811    Interpolation table index bits = 8
14812    Simplex table max resolution = 1
14813    Interpolation table max resolution = 255
14814  */
14815 
14816 /*
14817    Machine architecture specs:
14818 
14819    Little endian
14820    Reading and writing pixel values separately
14821    Pointer size = 32 bits
14822 
14823    Ordinal size  8 bits is known as 'unsigned char'
14824    Ordinal size 16 bits is known as 'unsigned short'
14825    Ordinal size 32 bits is known as 'unsigned int'
14826    Natural ordinal is 'unsigned int'
14827 
14828    Integer size  8 bits is known as 'signed char'
14829    Integer size 16 bits is known as 'short'
14830    Integer size 32 bits is known as 'int'
14831    Natural integer is 'int'
14832 
14833  */
14834 
14835 #ifndef  IMDI_INCLUDED
14836 #include <memory.h>
14837 #include "imdi_imp.h"
14838 #define  IMDI_INCLUDED
14839 #endif  /* IMDI_INCLUDED */
14840 
14841 #ifndef DEFINED_pointer
14842 #define DEFINED_pointer
14843 typedef unsigned char * pointer;
14844 #endif
14845 
14846 /* Input table inter & simplex indexes */
14847 #define IT_IT(p, off) *((unsigned char *)((p) + 0 + (off) * 1))
14848 
14849 /* Simplex weighting table access */
14850 #define SW_O(off) ((off) * 4)
14851 
14852 /* Simplex table - get weighting/offset value */
14853 #define SX_WO(p, v) *((unsigned short *)((p) + (v) * 2))
14854 
14855 /* Interpolation multi-dim. table access */
14856 #define IM_O(off) ((off) * 16)
14857 
14858 /* Interpolation table - get vertex values */
14859 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
14860 
14861 /* Output table indexes */
14862 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
14863 
14864 void
imdi_k43(imdi * s,void ** outp,void ** inp,unsigned int npix)14865 imdi_k43(
14866 imdi *s,			/* imdi context */
14867 void **outp,		/* pointer to output pointers */
14868 void **inp,		/* pointer to input pointers */
14869 unsigned int npix	/* Number of pixels to process */
14870 ) {
14871 	imdi_imp *p = (imdi_imp *)(s->impl);
14872 	unsigned char *ip0 = (unsigned char *)inp[0];
14873 	unsigned char *op0 = (unsigned char *)outp[0];
14874 	unsigned char *ep = ip0 + npix * 1 ;
14875 	pointer it0 = (pointer)p->in_tables[0];
14876 	pointer ot0 = (pointer)p->out_tables[0];
14877 	pointer ot1 = (pointer)p->out_tables[1];
14878 	pointer ot2 = (pointer)p->out_tables[2];
14879 	pointer ot3 = (pointer)p->out_tables[3];
14880 	pointer ot4 = (pointer)p->out_tables[4];
14881 	pointer ot5 = (pointer)p->out_tables[5];
14882 	pointer ot6 = (pointer)p->out_tables[6];
14883 	pointer ot7 = (pointer)p->out_tables[7];
14884 	pointer sw_base = (pointer)p->sw_table;
14885 	pointer im_base = (pointer)p->im_table;
14886 
14887 	for(;ip0 < ep; ip0 += 1, op0 += 8) {
14888 		unsigned int ova0;	/* Output value accumulator */
14889 		unsigned int ova1;	/* Output value accumulator */
14890 		unsigned int ova2;	/* Output value accumulator */
14891 		unsigned int ova3;	/* Output value accumulator */
14892 		{
14893 			pointer swp;
14894 			pointer imp;
14895 			{
14896 				unsigned int ti;	/* Simplex+Interpolation index variable */
14897 
14898 				ti  = IT_IT(it0, ip0[0]);
14899 
14900 				imp = im_base + IM_O(ti >> 0);		/* Extract interp. index and comp. entry */
14901 				swp = sw_base + SW_O(ti & 0x0);	/* Extract simplex index and comp. entry */
14902 			}
14903 			{
14904 				unsigned int vowr;	/* Vertex offset/weight value */
14905 				unsigned int vof;	/* Vertex offset value */
14906 				unsigned int vwe;	/* Vertex weighting */
14907 
14908 				vowr = SX_WO(swp, 0);	/* Read vertex offset+weighting values */
14909 				vof = (vowr & 0x7f);	/* Extract offset value */
14910 				vwe = (vowr >> 7);	/* Extract weighting value */
14911 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
14912 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
14913 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
14914 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
14915 				vowr = SX_WO(swp, 1);	/* Read vertex offset+weighting values */
14916 				vof = (vowr & 0x7f);	/* Extract offset value */
14917 				vwe = (vowr >> 7);	/* Extract weighting value */
14918 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
14919 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
14920 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
14921 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
14922 			}
14923 		}
14924 		{
14925 			unsigned int oti;	/* Vertex offset value */
14926 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
14927 			op0[0] = OT_E(ot0, oti);	/* Write result */
14928 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
14929 			op0[1] = OT_E(ot1, oti);	/* Write result */
14930 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
14931 			op0[2] = OT_E(ot2, oti);	/* Write result */
14932 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
14933 			op0[3] = OT_E(ot3, oti);	/* Write result */
14934 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
14935 			op0[4] = OT_E(ot4, oti);	/* Write result */
14936 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
14937 			op0[5] = OT_E(ot5, oti);	/* Write result */
14938 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
14939 			op0[6] = OT_E(ot6, oti);	/* Write result */
14940 			oti = ((ova3 >> 24) & 0xff);	/* Extract integer part of result */
14941 			op0[7] = OT_E(ot7, oti);	/* Write result */
14942 		}
14943 	}
14944 }
14945 #undef IT_IT
14946 #undef SW_O
14947 #undef SX_WO
14948 #undef IM_O
14949 #undef IM_FE
14950 #undef OT_E
14951 
14952 void
imdi_k43_gen(genspec * g)14953 imdi_k43_gen(
14954 genspec *g			/* structure to be initialised */
14955 ) {
14956 	static unsigned char data[] = {
14957 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14958 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14959 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14960 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14961 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14962 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14963 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14964 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14965 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14966 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14967 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14968 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14969 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14970 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14971 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14972 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14973 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14974 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14975 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14976 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14977 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14978 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14979 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14980 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14981 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14982 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14983 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14984 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14985 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14986 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14987 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14988 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14989 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14990 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14991 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14992 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
14993 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14994 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14995 		0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
14996 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
14997 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
14998 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
14999 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
15000 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
15001 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
15002 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
15003 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
15004 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
15005 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15006 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
15007 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
15008 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x38, 0x5f,
15009 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
15010 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
15011 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
15012 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
15013 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
15014 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
15015 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
15016 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15017 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15018 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15019 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15020 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
15021 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x34, 0x33,
15022 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15023 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15024 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
15025 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
15026 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
15027 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
15028 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
15029 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
15030 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
15031 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
15032 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
15033 		0x00, 0xf0, 0x04, 0x08
15034 	};	/* Structure image */
15035 
15036 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
15037 }
15038 
15039 void
imdi_k43_tab(tabspec * t)15040 imdi_k43_tab(
15041 tabspec *t			/* structure to be initialised */
15042 ) {
15043 	static unsigned char data[] = {
15044 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15045 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15046 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15047 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
15048 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
15049 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
15050 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15051 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
15052 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15053 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15054 		0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
15055 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15056 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
15057 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
15058 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
15059 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15060 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15061 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
15062 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15063 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15064 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15065 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
15066 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
15067 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
15068 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15069 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15070 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15071 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15072 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15073 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15074 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15075 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15076 		0x08, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
15077 	};	/* Structure image */
15078 
15079 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
15080 }
15081 
15082 
15083 
15084 
15085 
15086 
15087 /* Integer Multi-Dimensional Interpolation */
15088 /* Interpolation Kernel Code */
15089 /* Generated by cgen */
15090 /* Copyright 2000 - 2002 Graeme W. Gill */
15091 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
15092 
15093 /* see the Licence.txt file for licencing details.*/
15094 
15095 
15096 /*
15097    Interpolation kernel specs:
15098 
15099    Input channels per pixel = 3
15100    Input channel 0 bits = 8
15101    Input channel 0 increment = 3
15102    Input channel 1 bits = 8
15103    Input channel 1 increment = 3
15104    Input channel 2 bits = 8
15105    Input channel 2 increment = 3
15106    Input is channel interleaved
15107    Input channels are separate words
15108    Input value extraction is done in input table lookup
15109 
15110    Output channels per pixel = 8
15111    Output channel 0 bits = 8
15112    Output channel 0 increment = 8
15113    Output channel 1 bits = 8
15114    Output channel 1 increment = 8
15115    Output channel 2 bits = 8
15116    Output channel 2 increment = 8
15117    Output channel 3 bits = 8
15118    Output channel 3 increment = 8
15119    Output channel 4 bits = 8
15120    Output channel 4 increment = 8
15121    Output channel 5 bits = 8
15122    Output channel 5 increment = 8
15123    Output channel 6 bits = 8
15124    Output channel 6 increment = 8
15125    Output channel 7 bits = 8
15126    Output channel 7 increment = 8
15127    Output is channel interleaved
15128 
15129    Output channels are separate words
15130    Simplex table index bits       = 12
15131    Interpolation table index bits = 20
15132    Simplex table max resolution = 16
15133    Interpolation table max resolution = 101
15134  */
15135 
15136 /*
15137    Machine architecture specs:
15138 
15139    Little endian
15140    Reading and writing pixel values separately
15141    Pointer size = 32 bits
15142 
15143    Ordinal size  8 bits is known as 'unsigned char'
15144    Ordinal size 16 bits is known as 'unsigned short'
15145    Ordinal size 32 bits is known as 'unsigned int'
15146    Natural ordinal is 'unsigned int'
15147 
15148    Integer size  8 bits is known as 'signed char'
15149    Integer size 16 bits is known as 'short'
15150    Integer size 32 bits is known as 'int'
15151    Natural integer is 'int'
15152 
15153  */
15154 
15155 #ifndef  IMDI_INCLUDED
15156 #include <memory.h>
15157 #include "imdi_imp.h"
15158 #define  IMDI_INCLUDED
15159 #endif  /* IMDI_INCLUDED */
15160 
15161 #ifndef DEFINED_pointer
15162 #define DEFINED_pointer
15163 typedef unsigned char * pointer;
15164 #endif
15165 
15166 /* Input table inter & simplex indexes */
15167 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
15168 
15169 /* Simplex weighting table access */
15170 #define SW_O(off) ((off) * 16)
15171 
15172 /* Simplex table - get weighting value */
15173 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
15174 
15175 /* Simplex table - get offset value */
15176 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
15177 
15178 /* Interpolation multi-dim. table access */
15179 #define IM_O(off) ((off) * 16)
15180 
15181 /* Interpolation table - get vertex values */
15182 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
15183 
15184 /* Output table indexes */
15185 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
15186 
15187 void
imdi_k44(imdi * s,void ** outp,void ** inp,unsigned int npix)15188 imdi_k44(
15189 imdi *s,			/* imdi context */
15190 void **outp,		/* pointer to output pointers */
15191 void **inp,		/* pointer to input pointers */
15192 unsigned int npix	/* Number of pixels to process */
15193 ) {
15194 	imdi_imp *p = (imdi_imp *)(s->impl);
15195 	unsigned char *ip0 = (unsigned char *)inp[0];
15196 	unsigned char *op0 = (unsigned char *)outp[0];
15197 	unsigned char *ep = ip0 + npix * 3 ;
15198 	pointer it0 = (pointer)p->in_tables[0];
15199 	pointer it1 = (pointer)p->in_tables[1];
15200 	pointer it2 = (pointer)p->in_tables[2];
15201 	pointer ot0 = (pointer)p->out_tables[0];
15202 	pointer ot1 = (pointer)p->out_tables[1];
15203 	pointer ot2 = (pointer)p->out_tables[2];
15204 	pointer ot3 = (pointer)p->out_tables[3];
15205 	pointer ot4 = (pointer)p->out_tables[4];
15206 	pointer ot5 = (pointer)p->out_tables[5];
15207 	pointer ot6 = (pointer)p->out_tables[6];
15208 	pointer ot7 = (pointer)p->out_tables[7];
15209 	pointer sw_base = (pointer)p->sw_table;
15210 	pointer im_base = (pointer)p->im_table;
15211 
15212 	for(;ip0 < ep; ip0 += 3, op0 += 8) {
15213 		unsigned int ova0;	/* Output value accumulator */
15214 		unsigned int ova1;	/* Output value accumulator */
15215 		unsigned int ova2;	/* Output value accumulator */
15216 		unsigned int ova3;	/* Output value accumulator */
15217 		{
15218 			pointer swp;
15219 			pointer imp;
15220 			{
15221 				unsigned int ti;	/* Simplex+Interpolation index variable */
15222 
15223 				ti  = IT_IT(it0, ip0[0]);
15224 				ti += IT_IT(it1, ip0[1]);
15225 				ti += IT_IT(it2, ip0[2]);
15226 
15227 				imp = im_base + IM_O(ti >> 12);		/* Extract interp. index and comp. entry */
15228 				swp = sw_base + SW_O(ti & 0xfff);	/* Extract simplex index and comp. entry */
15229 			}
15230 			{
15231 				unsigned int vof;	/* Vertex offset value */
15232 				unsigned int vwe;	/* Vertex weighting */
15233 
15234 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
15235 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
15236 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
15237 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
15238 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
15239 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
15240 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
15241 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
15242 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
15243 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
15244 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
15245 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
15246 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
15247 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
15248 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
15249 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
15250 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
15251 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
15252 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
15253 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
15254 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
15255 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
15256 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
15257 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
15258 			}
15259 		}
15260 		{
15261 			unsigned int oti;	/* Vertex offset value */
15262 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
15263 			op0[0] = OT_E(ot0, oti);	/* Write result */
15264 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
15265 			op0[1] = OT_E(ot1, oti);	/* Write result */
15266 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
15267 			op0[2] = OT_E(ot2, oti);	/* Write result */
15268 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
15269 			op0[3] = OT_E(ot3, oti);	/* Write result */
15270 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
15271 			op0[4] = OT_E(ot4, oti);	/* Write result */
15272 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
15273 			op0[5] = OT_E(ot5, oti);	/* Write result */
15274 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
15275 			op0[6] = OT_E(ot6, oti);	/* Write result */
15276 			oti = ((ova3 >> 24) & 0xff);	/* Extract integer part of result */
15277 			op0[7] = OT_E(ot7, oti);	/* Write result */
15278 		}
15279 	}
15280 }
15281 #undef IT_IT
15282 #undef SW_O
15283 #undef SX_WE
15284 #undef SX_VO
15285 #undef IM_O
15286 #undef IM_FE
15287 #undef OT_E
15288 
15289 void
imdi_k44_gen(genspec * g)15290 imdi_k44_gen(
15291 genspec *g			/* structure to be initialised */
15292 ) {
15293 	static unsigned char data[] = {
15294 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
15295 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15296 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15297 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15298 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15299 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15300 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15301 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
15302 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
15303 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15304 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15305 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15306 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15307 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15308 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15309 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15310 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15311 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15312 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15313 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15314 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15315 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15316 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15317 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15318 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15319 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15320 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15321 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15322 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15323 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15324 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15325 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15326 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15327 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15328 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15329 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15330 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15331 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15332 		0x65, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
15333 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
15334 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
15335 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
15336 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
15337 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
15338 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
15339 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
15340 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
15341 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
15342 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15343 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
15344 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
15345 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x38, 0x5f,
15346 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
15347 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
15348 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
15349 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
15350 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
15351 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
15352 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
15353 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15354 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15355 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15356 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15357 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
15358 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x34, 0x34,
15359 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15360 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15361 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
15362 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
15363 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
15364 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
15365 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
15366 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
15367 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
15368 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
15369 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
15370 		0x00, 0xf0, 0x04, 0x08
15371 	};	/* Structure image */
15372 
15373 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
15374 }
15375 
15376 void
imdi_k44_tab(tabspec * t)15377 imdi_k44_tab(
15378 tabspec *t			/* structure to be initialised */
15379 ) {
15380 	static unsigned char data[] = {
15381 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15382 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15383 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15384 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
15385 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
15386 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
15387 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
15388 		0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
15389 		0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
15390 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15391 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
15392 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15393 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
15394 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
15395 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
15396 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15397 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15398 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
15399 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15400 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15401 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15402 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
15403 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
15404 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
15405 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15406 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15407 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15408 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15409 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15410 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15411 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15412 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15413 		0x08, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
15414 	};	/* Structure image */
15415 
15416 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
15417 }
15418 
15419 
15420 
15421 
15422 
15423 
15424 /* Integer Multi-Dimensional Interpolation */
15425 /* Interpolation Kernel Code */
15426 /* Generated by cgen */
15427 /* Copyright 2000 - 2002 Graeme W. Gill */
15428 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
15429 
15430 /* see the Licence.txt file for licencing details.*/
15431 
15432 
15433 /*
15434    Interpolation kernel specs:
15435 
15436    Input channels per pixel = 4
15437    Input channel 0 bits = 8
15438    Input channel 0 increment = 4
15439    Input channel 1 bits = 8
15440    Input channel 1 increment = 4
15441    Input channel 2 bits = 8
15442    Input channel 2 increment = 4
15443    Input channel 3 bits = 8
15444    Input channel 3 increment = 4
15445    Input is channel interleaved
15446    Input channels are separate words
15447    Input value extraction is done in input table lookup
15448 
15449    Output channels per pixel = 8
15450    Output channel 0 bits = 8
15451    Output channel 0 increment = 8
15452    Output channel 1 bits = 8
15453    Output channel 1 increment = 8
15454    Output channel 2 bits = 8
15455    Output channel 2 increment = 8
15456    Output channel 3 bits = 8
15457    Output channel 3 increment = 8
15458    Output channel 4 bits = 8
15459    Output channel 4 increment = 8
15460    Output channel 5 bits = 8
15461    Output channel 5 increment = 8
15462    Output channel 6 bits = 8
15463    Output channel 6 increment = 8
15464    Output channel 7 bits = 8
15465    Output channel 7 increment = 8
15466    Output is channel interleaved
15467 
15468    Output channels are separate words
15469    Simplex table index bits       = 32
15470    Interpolation table index bits = 32
15471    Simplex table max resolution = 255
15472    Interpolation table max resolution = 31
15473  */
15474 
15475 /*
15476    Machine architecture specs:
15477 
15478    Little endian
15479    Reading and writing pixel values separately
15480    Pointer size = 32 bits
15481 
15482    Ordinal size  8 bits is known as 'unsigned char'
15483    Ordinal size 16 bits is known as 'unsigned short'
15484    Ordinal size 32 bits is known as 'unsigned int'
15485    Natural ordinal is 'unsigned int'
15486 
15487    Integer size  8 bits is known as 'signed char'
15488    Integer size 16 bits is known as 'short'
15489    Integer size 32 bits is known as 'int'
15490    Natural integer is 'int'
15491 
15492  */
15493 
15494 #ifndef  IMDI_INCLUDED
15495 #include <memory.h>
15496 #include "imdi_imp.h"
15497 #define  IMDI_INCLUDED
15498 #endif  /* IMDI_INCLUDED */
15499 
15500 #ifndef DEFINED_pointer
15501 #define DEFINED_pointer
15502 typedef unsigned char * pointer;
15503 #endif
15504 
15505 /* Input table interp. index */
15506 #define IT_IX(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
15507 
15508 /* Input table simplex index enty */
15509 #define IT_SX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
15510 
15511 /* Simplex weighting table access */
15512 #define SW_O(off) ((off) * 20)
15513 
15514 /* Simplex table - get weighting value */
15515 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
15516 
15517 /* Simplex table - get offset value */
15518 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
15519 
15520 /* Interpolation multi-dim. table access */
15521 #define IM_O(off) ((off) * 16)
15522 
15523 /* Interpolation table - get vertex values */
15524 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
15525 
15526 /* Output table indexes */
15527 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
15528 
15529 void
imdi_k45(imdi * s,void ** outp,void ** inp,unsigned int npix)15530 imdi_k45(
15531 imdi *s,			/* imdi context */
15532 void **outp,		/* pointer to output pointers */
15533 void **inp,		/* pointer to input pointers */
15534 unsigned int npix	/* Number of pixels to process */
15535 ) {
15536 	imdi_imp *p = (imdi_imp *)(s->impl);
15537 	unsigned char *ip0 = (unsigned char *)inp[0];
15538 	unsigned char *op0 = (unsigned char *)outp[0];
15539 	unsigned char *ep = ip0 + npix * 4 ;
15540 	pointer it0 = (pointer)p->in_tables[0];
15541 	pointer it1 = (pointer)p->in_tables[1];
15542 	pointer it2 = (pointer)p->in_tables[2];
15543 	pointer it3 = (pointer)p->in_tables[3];
15544 	pointer ot0 = (pointer)p->out_tables[0];
15545 	pointer ot1 = (pointer)p->out_tables[1];
15546 	pointer ot2 = (pointer)p->out_tables[2];
15547 	pointer ot3 = (pointer)p->out_tables[3];
15548 	pointer ot4 = (pointer)p->out_tables[4];
15549 	pointer ot5 = (pointer)p->out_tables[5];
15550 	pointer ot6 = (pointer)p->out_tables[6];
15551 	pointer ot7 = (pointer)p->out_tables[7];
15552 	pointer sw_base = (pointer)p->sw_table;
15553 	pointer im_base = (pointer)p->im_table;
15554 
15555 	for(;ip0 < ep; ip0 += 4, op0 += 8) {
15556 		unsigned int ova0;	/* Output value accumulator */
15557 		unsigned int ova1;	/* Output value accumulator */
15558 		unsigned int ova2;	/* Output value accumulator */
15559 		unsigned int ova3;	/* Output value accumulator */
15560 		{
15561 			pointer swp;
15562 			pointer imp;
15563 			{
15564 				unsigned int ti_s;	/* Simplex index variable */
15565 				unsigned int ti_i;	/* Interpolation index variable */
15566 
15567 				ti_i  = IT_IX(it0, ip0[0]);
15568 				ti_s  = IT_SX(it0, ip0[0]);
15569 				ti_i += IT_IX(it1, ip0[1]);
15570 				ti_s += IT_SX(it1, ip0[1]);
15571 				ti_i += IT_IX(it2, ip0[2]);
15572 				ti_s += IT_SX(it2, ip0[2]);
15573 				ti_i += IT_IX(it3, ip0[3]);
15574 				ti_s += IT_SX(it3, ip0[3]);
15575 
15576 				swp = sw_base + SW_O(ti_s);		/* Compute simplex table entry pointer */
15577 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
15578 			}
15579 			{
15580 				unsigned int vof;	/* Vertex offset value */
15581 				unsigned int vwe;	/* Vertex weighting */
15582 
15583 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
15584 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
15585 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
15586 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
15587 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
15588 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
15589 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
15590 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
15591 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
15592 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
15593 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
15594 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
15595 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
15596 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
15597 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
15598 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
15599 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
15600 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
15601 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
15602 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
15603 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
15604 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
15605 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
15606 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
15607 				vof = SX_VO(swp, 4);	/* Read vertex offset value */
15608 				vwe = SX_WE(swp, 4);	/* Read vertex weighting value */
15609 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
15610 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
15611 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
15612 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
15613 			}
15614 		}
15615 		{
15616 			unsigned int oti;	/* Vertex offset value */
15617 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
15618 			op0[0] = OT_E(ot0, oti);	/* Write result */
15619 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
15620 			op0[1] = OT_E(ot1, oti);	/* Write result */
15621 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
15622 			op0[2] = OT_E(ot2, oti);	/* Write result */
15623 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
15624 			op0[3] = OT_E(ot3, oti);	/* Write result */
15625 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
15626 			op0[4] = OT_E(ot4, oti);	/* Write result */
15627 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
15628 			op0[5] = OT_E(ot5, oti);	/* Write result */
15629 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
15630 			op0[6] = OT_E(ot6, oti);	/* Write result */
15631 			oti = ((ova3 >> 24) & 0xff);	/* Extract integer part of result */
15632 			op0[7] = OT_E(ot7, oti);	/* Write result */
15633 		}
15634 	}
15635 }
15636 #undef IT_IX
15637 #undef IT_SX
15638 #undef SW_O
15639 #undef SX_WE
15640 #undef SX_VO
15641 #undef IM_O
15642 #undef IM_FE
15643 #undef OT_E
15644 
15645 void
imdi_k45_gen(genspec * g)15646 imdi_k45_gen(
15647 genspec *g			/* structure to be initialised */
15648 ) {
15649 	static unsigned char data[] = {
15650 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
15651 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15652 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15653 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15654 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15655 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15656 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15657 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
15658 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
15659 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15660 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15661 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15662 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15663 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15664 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15665 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15666 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15667 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15668 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15669 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15670 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15671 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15672 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15673 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15674 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15675 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15676 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15677 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15678 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15679 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15680 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15681 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15682 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15683 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15684 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15685 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15686 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15687 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15688 		0x1f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
15689 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
15690 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
15691 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
15692 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
15693 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
15694 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
15695 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
15696 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
15697 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
15698 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15699 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
15700 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
15701 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x38, 0x5f,
15702 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
15703 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
15704 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
15705 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
15706 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
15707 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
15708 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
15709 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15710 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15711 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15712 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15713 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
15714 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x34, 0x35,
15715 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15716 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15717 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
15718 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
15719 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
15720 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
15721 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
15722 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
15723 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
15724 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
15725 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
15726 		0x00, 0xf0, 0x04, 0x08
15727 	};	/* Structure image */
15728 
15729 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
15730 }
15731 
15732 void
imdi_k45_tab(tabspec * t)15733 imdi_k45_tab(
15734 tabspec *t			/* structure to be initialised */
15735 ) {
15736 	static unsigned char data[] = {
15737 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15738 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15739 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15740 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
15741 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
15742 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
15743 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15744 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
15745 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
15746 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15747 		0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
15748 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15749 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
15750 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
15751 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
15752 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15753 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15754 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
15755 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15756 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15757 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15758 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
15759 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
15760 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
15761 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15762 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15763 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15764 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15765 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15766 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15767 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15768 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
15769 		0x08, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
15770 	};	/* Structure image */
15771 
15772 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
15773 }
15774 
15775 
15776 
15777 
15778 
15779 
15780 /* Integer Multi-Dimensional Interpolation */
15781 /* Interpolation Kernel Code */
15782 /* Generated by cgen */
15783 /* Copyright 2000 - 2002 Graeme W. Gill */
15784 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
15785 
15786 /* see the Licence.txt file for licencing details.*/
15787 
15788 
15789 /*
15790    Interpolation kernel specs:
15791 
15792    Input channels per pixel = 5
15793    Input channel 0 bits = 8
15794    Input channel 0 increment = 5
15795    Input channel 1 bits = 8
15796    Input channel 1 increment = 5
15797    Input channel 2 bits = 8
15798    Input channel 2 increment = 5
15799    Input channel 3 bits = 8
15800    Input channel 3 increment = 5
15801    Input channel 4 bits = 8
15802    Input channel 4 increment = 5
15803    Input is channel interleaved
15804    Input channels are separate words
15805    Input value extraction is done in input table lookup
15806 
15807    Output channels per pixel = 8
15808    Output channel 0 bits = 8
15809    Output channel 0 increment = 8
15810    Output channel 1 bits = 8
15811    Output channel 1 increment = 8
15812    Output channel 2 bits = 8
15813    Output channel 2 increment = 8
15814    Output channel 3 bits = 8
15815    Output channel 3 increment = 8
15816    Output channel 4 bits = 8
15817    Output channel 4 increment = 8
15818    Output channel 5 bits = 8
15819    Output channel 5 increment = 8
15820    Output channel 6 bits = 8
15821    Output channel 6 increment = 8
15822    Output channel 7 bits = 8
15823    Output channel 7 increment = 8
15824    Output is channel interleaved
15825 
15826    Output channels are separate words
15827    Weight+voffset bits       = 32
15828    Interpolation table index bits = 32
15829    Interpolation table max resolution = 45
15830  */
15831 
15832 /*
15833    Machine architecture specs:
15834 
15835    Little endian
15836    Reading and writing pixel values separately
15837    Pointer size = 32 bits
15838 
15839    Ordinal size  8 bits is known as 'unsigned char'
15840    Ordinal size 16 bits is known as 'unsigned short'
15841    Ordinal size 32 bits is known as 'unsigned int'
15842    Natural ordinal is 'unsigned int'
15843 
15844    Integer size  8 bits is known as 'signed char'
15845    Integer size 16 bits is known as 'short'
15846    Integer size 32 bits is known as 'int'
15847    Natural integer is 'int'
15848 
15849  */
15850 
15851 #ifndef  IMDI_INCLUDED
15852 #include <memory.h>
15853 #include "imdi_imp.h"
15854 #define  IMDI_INCLUDED
15855 #endif  /* IMDI_INCLUDED */
15856 
15857 #ifndef DEFINED_pointer
15858 #define DEFINED_pointer
15859 typedef unsigned char * pointer;
15860 #endif
15861 
15862 /* Input table interp. index */
15863 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
15864 
15865 /* Input table input weighting/offset value enty */
15866 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
15867 
15868 /* Conditional exchange for sorting */
15869 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
15870 
15871 /* Interpolation multi-dim. table access */
15872 #define IM_O(off) ((off) * 16)
15873 
15874 /* Interpolation table - get vertex values */
15875 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
15876 
15877 /* Output table indexes */
15878 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
15879 
15880 void
imdi_k46(imdi * s,void ** outp,void ** inp,unsigned int npix)15881 imdi_k46(
15882 imdi *s,			/* imdi context */
15883 void **outp,		/* pointer to output pointers */
15884 void **inp,		/* pointer to input pointers */
15885 unsigned int npix	/* Number of pixels to process */
15886 ) {
15887 	imdi_imp *p = (imdi_imp *)(s->impl);
15888 	unsigned char *ip0 = (unsigned char *)inp[0];
15889 	unsigned char *op0 = (unsigned char *)outp[0];
15890 	unsigned char *ep = ip0 + npix * 5 ;
15891 	pointer it0 = (pointer)p->in_tables[0];
15892 	pointer it1 = (pointer)p->in_tables[1];
15893 	pointer it2 = (pointer)p->in_tables[2];
15894 	pointer it3 = (pointer)p->in_tables[3];
15895 	pointer it4 = (pointer)p->in_tables[4];
15896 	pointer ot0 = (pointer)p->out_tables[0];
15897 	pointer ot1 = (pointer)p->out_tables[1];
15898 	pointer ot2 = (pointer)p->out_tables[2];
15899 	pointer ot3 = (pointer)p->out_tables[3];
15900 	pointer ot4 = (pointer)p->out_tables[4];
15901 	pointer ot5 = (pointer)p->out_tables[5];
15902 	pointer ot6 = (pointer)p->out_tables[6];
15903 	pointer ot7 = (pointer)p->out_tables[7];
15904 	pointer im_base = (pointer)p->im_table;
15905 
15906 	for(;ip0 < ep; ip0 += 5, op0 += 8) {
15907 		unsigned int ova0;	/* Output value accumulator */
15908 		unsigned int ova1;	/* Output value accumulator */
15909 		unsigned int ova2;	/* Output value accumulator */
15910 		unsigned int ova3;	/* Output value accumulator */
15911 		{
15912 			pointer imp;
15913 			unsigned int wo0;	/* Weighting value and vertex offset variable */
15914 			unsigned int wo1;	/* Weighting value and vertex offset variable */
15915 			unsigned int wo2;	/* Weighting value and vertex offset variable */
15916 			unsigned int wo3;	/* Weighting value and vertex offset variable */
15917 			unsigned int wo4;	/* Weighting value and vertex offset variable */
15918 			{
15919 				unsigned int ti_i;	/* Interpolation index variable */
15920 
15921 				ti_i  = IT_IX(it0, ip0[0]);
15922 				wo0   = IT_WO(it0, ip0[0]);
15923 				ti_i += IT_IX(it1, ip0[1]);
15924 				wo1   = IT_WO(it1, ip0[1]);
15925 				ti_i += IT_IX(it2, ip0[2]);
15926 				wo2   = IT_WO(it2, ip0[2]);
15927 				ti_i += IT_IX(it3, ip0[3]);
15928 				wo3   = IT_WO(it3, ip0[3]);
15929 				ti_i += IT_IX(it4, ip0[4]);
15930 				wo4   = IT_WO(it4, ip0[4]);
15931 
15932 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
15933 
15934 				/* Sort weighting values and vertex offset values */
15935 				CEX(wo0, wo1);
15936 				CEX(wo0, wo2);
15937 				CEX(wo0, wo3);
15938 				CEX(wo0, wo4);
15939 				CEX(wo1, wo2);
15940 				CEX(wo1, wo3);
15941 				CEX(wo1, wo4);
15942 				CEX(wo2, wo3);
15943 				CEX(wo2, wo4);
15944 				CEX(wo3, wo4);
15945 			}
15946 			{
15947 				unsigned int nvof;	/* Next vertex offset value */
15948 				unsigned int vof;	/* Vertex offset value */
15949 				unsigned int vwe;	/* Vertex weighting */
15950 
15951 				vof = 0;				/* First vertex offset is 0 */
15952 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
15953 				wo0 = (wo0 >> 23);		/* Extract weighting value */
15954 				vwe = 256 - wo0;		/* Baricentric weighting */
15955 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
15956 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
15957 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
15958 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
15959 				vof += nvof;			/* Move to next vertex */
15960 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
15961 				wo1 = (wo1 >> 23);		/* Extract weighting value */
15962 				vwe = wo0 - wo1;		/* Baricentric weighting */
15963 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
15964 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
15965 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
15966 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
15967 				vof += nvof;			/* Move to next vertex */
15968 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
15969 				wo2 = (wo2 >> 23);		/* Extract weighting value */
15970 				vwe = wo1 - wo2;		/* Baricentric weighting */
15971 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
15972 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
15973 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
15974 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
15975 				vof += nvof;			/* Move to next vertex */
15976 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
15977 				wo3 = (wo3 >> 23);		/* Extract weighting value */
15978 				vwe = wo2 - wo3;		/* Baricentric weighting */
15979 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
15980 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
15981 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
15982 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
15983 				vof += nvof;			/* Move to next vertex */
15984 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
15985 				wo4 = (wo4 >> 23);		/* Extract weighting value */
15986 				vwe = wo3 - wo4;		/* Baricentric weighting */
15987 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
15988 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
15989 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
15990 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
15991 				vof += nvof;			/* Move to next vertex */
15992 				vwe = wo4;				/* Baricentric weighting */
15993 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
15994 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
15995 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
15996 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
15997 			}
15998 		}
15999 		{
16000 			unsigned int oti;	/* Vertex offset value */
16001 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
16002 			op0[0] = OT_E(ot0, oti);	/* Write result */
16003 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
16004 			op0[1] = OT_E(ot1, oti);	/* Write result */
16005 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
16006 			op0[2] = OT_E(ot2, oti);	/* Write result */
16007 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
16008 			op0[3] = OT_E(ot3, oti);	/* Write result */
16009 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
16010 			op0[4] = OT_E(ot4, oti);	/* Write result */
16011 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
16012 			op0[5] = OT_E(ot5, oti);	/* Write result */
16013 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
16014 			op0[6] = OT_E(ot6, oti);	/* Write result */
16015 			oti = ((ova3 >> 24) & 0xff);	/* Extract integer part of result */
16016 			op0[7] = OT_E(ot7, oti);	/* Write result */
16017 		}
16018 	}
16019 }
16020 #undef IT_WO
16021 #undef IT_IX
16022 #undef CEX
16023 #undef IM_O
16024 #undef IM_FE
16025 #undef OT_E
16026 
16027 void
imdi_k46_gen(genspec * g)16028 imdi_k46_gen(
16029 genspec *g			/* structure to be initialised */
16030 ) {
16031 	static unsigned char data[] = {
16032 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
16033 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16034 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16035 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16036 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16037 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16038 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16039 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
16040 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
16041 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
16042 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16043 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16044 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16045 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16046 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16047 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16048 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16049 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16050 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16051 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16052 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16053 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16054 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16055 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16056 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16057 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16058 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16059 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16060 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16061 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16062 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16063 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16064 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16065 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16066 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16067 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16068 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16069 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16070 		0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16071 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
16072 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
16073 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
16074 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
16075 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
16076 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
16077 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
16078 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
16079 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
16080 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16081 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
16082 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
16083 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x38, 0x5f,
16084 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
16085 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
16086 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
16087 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
16088 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
16089 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
16090 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
16091 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16092 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16093 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16094 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16095 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
16096 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x34, 0x36,
16097 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16098 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16099 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
16100 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
16101 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
16102 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
16103 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
16104 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
16105 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
16106 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
16107 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
16108 		0x00, 0xf0, 0x04, 0x08
16109 	};	/* Structure image */
16110 
16111 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
16112 }
16113 
16114 void
imdi_k46_tab(tabspec * t)16115 imdi_k46_tab(
16116 tabspec *t			/* structure to be initialised */
16117 ) {
16118 	static unsigned char data[] = {
16119 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16120 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16121 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16122 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
16123 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
16124 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
16125 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16126 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
16127 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
16128 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16129 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
16130 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
16131 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
16132 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
16133 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
16134 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16135 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16136 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
16137 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16138 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16139 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16140 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
16141 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
16142 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
16143 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16144 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16145 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16146 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16147 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16148 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16149 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16150 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16151 		0x08, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
16152 	};	/* Structure image */
16153 
16154 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
16155 }
16156 
16157 
16158 
16159 
16160 
16161 
16162 /* Integer Multi-Dimensional Interpolation */
16163 /* Interpolation Kernel Code */
16164 /* Generated by cgen */
16165 /* Copyright 2000 - 2002 Graeme W. Gill */
16166 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
16167 
16168 /* see the Licence.txt file for licencing details.*/
16169 
16170 
16171 /*
16172    Interpolation kernel specs:
16173 
16174    Input channels per pixel = 6
16175    Input channel 0 bits = 8
16176    Input channel 0 increment = 6
16177    Input channel 1 bits = 8
16178    Input channel 1 increment = 6
16179    Input channel 2 bits = 8
16180    Input channel 2 increment = 6
16181    Input channel 3 bits = 8
16182    Input channel 3 increment = 6
16183    Input channel 4 bits = 8
16184    Input channel 4 increment = 6
16185    Input channel 5 bits = 8
16186    Input channel 5 increment = 6
16187    Input is channel interleaved
16188    Input channels are separate words
16189    Input value extraction is done in input table lookup
16190 
16191    Output channels per pixel = 8
16192    Output channel 0 bits = 8
16193    Output channel 0 increment = 8
16194    Output channel 1 bits = 8
16195    Output channel 1 increment = 8
16196    Output channel 2 bits = 8
16197    Output channel 2 increment = 8
16198    Output channel 3 bits = 8
16199    Output channel 3 increment = 8
16200    Output channel 4 bits = 8
16201    Output channel 4 increment = 8
16202    Output channel 5 bits = 8
16203    Output channel 5 increment = 8
16204    Output channel 6 bits = 8
16205    Output channel 6 increment = 8
16206    Output channel 7 bits = 8
16207    Output channel 7 increment = 8
16208    Output is channel interleaved
16209 
16210    Output channels are separate words
16211    Weight+voffset bits       = 32
16212    Interpolation table index bits = 32
16213    Interpolation table max resolution = 20
16214  */
16215 
16216 /*
16217    Machine architecture specs:
16218 
16219    Little endian
16220    Reading and writing pixel values separately
16221    Pointer size = 32 bits
16222 
16223    Ordinal size  8 bits is known as 'unsigned char'
16224    Ordinal size 16 bits is known as 'unsigned short'
16225    Ordinal size 32 bits is known as 'unsigned int'
16226    Natural ordinal is 'unsigned int'
16227 
16228    Integer size  8 bits is known as 'signed char'
16229    Integer size 16 bits is known as 'short'
16230    Integer size 32 bits is known as 'int'
16231    Natural integer is 'int'
16232 
16233  */
16234 
16235 #ifndef  IMDI_INCLUDED
16236 #include <memory.h>
16237 #include "imdi_imp.h"
16238 #define  IMDI_INCLUDED
16239 #endif  /* IMDI_INCLUDED */
16240 
16241 #ifndef DEFINED_pointer
16242 #define DEFINED_pointer
16243 typedef unsigned char * pointer;
16244 #endif
16245 
16246 /* Input table interp. index */
16247 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
16248 
16249 /* Input table input weighting/offset value enty */
16250 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
16251 
16252 /* Conditional exchange for sorting */
16253 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
16254 
16255 /* Interpolation multi-dim. table access */
16256 #define IM_O(off) ((off) * 16)
16257 
16258 /* Interpolation table - get vertex values */
16259 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
16260 
16261 /* Output table indexes */
16262 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
16263 
16264 void
imdi_k47(imdi * s,void ** outp,void ** inp,unsigned int npix)16265 imdi_k47(
16266 imdi *s,			/* imdi context */
16267 void **outp,		/* pointer to output pointers */
16268 void **inp,		/* pointer to input pointers */
16269 unsigned int npix	/* Number of pixels to process */
16270 ) {
16271 	imdi_imp *p = (imdi_imp *)(s->impl);
16272 	unsigned char *ip0 = (unsigned char *)inp[0];
16273 	unsigned char *op0 = (unsigned char *)outp[0];
16274 	unsigned char *ep = ip0 + npix * 6 ;
16275 	pointer it0 = (pointer)p->in_tables[0];
16276 	pointer it1 = (pointer)p->in_tables[1];
16277 	pointer it2 = (pointer)p->in_tables[2];
16278 	pointer it3 = (pointer)p->in_tables[3];
16279 	pointer it4 = (pointer)p->in_tables[4];
16280 	pointer it5 = (pointer)p->in_tables[5];
16281 	pointer ot0 = (pointer)p->out_tables[0];
16282 	pointer ot1 = (pointer)p->out_tables[1];
16283 	pointer ot2 = (pointer)p->out_tables[2];
16284 	pointer ot3 = (pointer)p->out_tables[3];
16285 	pointer ot4 = (pointer)p->out_tables[4];
16286 	pointer ot5 = (pointer)p->out_tables[5];
16287 	pointer ot6 = (pointer)p->out_tables[6];
16288 	pointer ot7 = (pointer)p->out_tables[7];
16289 	pointer im_base = (pointer)p->im_table;
16290 
16291 	for(;ip0 < ep; ip0 += 6, op0 += 8) {
16292 		unsigned int ova0;	/* Output value accumulator */
16293 		unsigned int ova1;	/* Output value accumulator */
16294 		unsigned int ova2;	/* Output value accumulator */
16295 		unsigned int ova3;	/* Output value accumulator */
16296 		{
16297 			pointer imp;
16298 			unsigned int wo0;	/* Weighting value and vertex offset variable */
16299 			unsigned int wo1;	/* Weighting value and vertex offset variable */
16300 			unsigned int wo2;	/* Weighting value and vertex offset variable */
16301 			unsigned int wo3;	/* Weighting value and vertex offset variable */
16302 			unsigned int wo4;	/* Weighting value and vertex offset variable */
16303 			unsigned int wo5;	/* Weighting value and vertex offset variable */
16304 			{
16305 				unsigned int ti_i;	/* Interpolation index variable */
16306 
16307 				ti_i  = IT_IX(it0, ip0[0]);
16308 				wo0   = IT_WO(it0, ip0[0]);
16309 				ti_i += IT_IX(it1, ip0[1]);
16310 				wo1   = IT_WO(it1, ip0[1]);
16311 				ti_i += IT_IX(it2, ip0[2]);
16312 				wo2   = IT_WO(it2, ip0[2]);
16313 				ti_i += IT_IX(it3, ip0[3]);
16314 				wo3   = IT_WO(it3, ip0[3]);
16315 				ti_i += IT_IX(it4, ip0[4]);
16316 				wo4   = IT_WO(it4, ip0[4]);
16317 				ti_i += IT_IX(it5, ip0[5]);
16318 				wo5   = IT_WO(it5, ip0[5]);
16319 
16320 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
16321 
16322 				/* Sort weighting values and vertex offset values */
16323 				CEX(wo0, wo1);
16324 				CEX(wo0, wo2);
16325 				CEX(wo0, wo3);
16326 				CEX(wo0, wo4);
16327 				CEX(wo0, wo5);
16328 				CEX(wo1, wo2);
16329 				CEX(wo1, wo3);
16330 				CEX(wo1, wo4);
16331 				CEX(wo1, wo5);
16332 				CEX(wo2, wo3);
16333 				CEX(wo2, wo4);
16334 				CEX(wo2, wo5);
16335 				CEX(wo3, wo4);
16336 				CEX(wo3, wo5);
16337 				CEX(wo4, wo5);
16338 			}
16339 			{
16340 				unsigned int nvof;	/* Next vertex offset value */
16341 				unsigned int vof;	/* Vertex offset value */
16342 				unsigned int vwe;	/* Vertex weighting */
16343 
16344 				vof = 0;				/* First vertex offset is 0 */
16345 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
16346 				wo0 = (wo0 >> 23);		/* Extract weighting value */
16347 				vwe = 256 - wo0;		/* Baricentric weighting */
16348 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
16349 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
16350 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
16351 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
16352 				vof += nvof;			/* Move to next vertex */
16353 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
16354 				wo1 = (wo1 >> 23);		/* Extract weighting value */
16355 				vwe = wo0 - wo1;		/* Baricentric weighting */
16356 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
16357 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
16358 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
16359 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
16360 				vof += nvof;			/* Move to next vertex */
16361 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
16362 				wo2 = (wo2 >> 23);		/* Extract weighting value */
16363 				vwe = wo1 - wo2;		/* Baricentric weighting */
16364 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
16365 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
16366 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
16367 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
16368 				vof += nvof;			/* Move to next vertex */
16369 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
16370 				wo3 = (wo3 >> 23);		/* Extract weighting value */
16371 				vwe = wo2 - wo3;		/* Baricentric weighting */
16372 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
16373 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
16374 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
16375 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
16376 				vof += nvof;			/* Move to next vertex */
16377 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
16378 				wo4 = (wo4 >> 23);		/* Extract weighting value */
16379 				vwe = wo3 - wo4;		/* Baricentric weighting */
16380 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
16381 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
16382 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
16383 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
16384 				vof += nvof;			/* Move to next vertex */
16385 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
16386 				wo5 = (wo5 >> 23);		/* Extract weighting value */
16387 				vwe = wo4 - wo5;		/* Baricentric weighting */
16388 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
16389 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
16390 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
16391 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
16392 				vof += nvof;			/* Move to next vertex */
16393 				vwe = wo5;				/* Baricentric weighting */
16394 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
16395 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
16396 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
16397 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
16398 			}
16399 		}
16400 		{
16401 			unsigned int oti;	/* Vertex offset value */
16402 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
16403 			op0[0] = OT_E(ot0, oti);	/* Write result */
16404 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
16405 			op0[1] = OT_E(ot1, oti);	/* Write result */
16406 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
16407 			op0[2] = OT_E(ot2, oti);	/* Write result */
16408 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
16409 			op0[3] = OT_E(ot3, oti);	/* Write result */
16410 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
16411 			op0[4] = OT_E(ot4, oti);	/* Write result */
16412 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
16413 			op0[5] = OT_E(ot5, oti);	/* Write result */
16414 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
16415 			op0[6] = OT_E(ot6, oti);	/* Write result */
16416 			oti = ((ova3 >> 24) & 0xff);	/* Extract integer part of result */
16417 			op0[7] = OT_E(ot7, oti);	/* Write result */
16418 		}
16419 	}
16420 }
16421 #undef IT_WO
16422 #undef IT_IX
16423 #undef CEX
16424 #undef IM_O
16425 #undef IM_FE
16426 #undef OT_E
16427 
16428 void
imdi_k47_gen(genspec * g)16429 imdi_k47_gen(
16430 genspec *g			/* structure to be initialised */
16431 ) {
16432 	static unsigned char data[] = {
16433 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
16434 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16435 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16436 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16437 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16438 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16439 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16440 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
16441 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
16442 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
16443 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16444 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16445 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16446 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16447 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16448 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16449 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16450 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16451 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16452 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16453 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16454 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16455 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16456 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16457 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16458 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16459 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16460 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16461 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16462 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16463 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16464 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16465 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16466 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16467 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16468 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16469 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16470 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16471 		0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16472 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
16473 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
16474 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
16475 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
16476 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
16477 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
16478 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
16479 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
16480 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
16481 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16482 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
16483 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
16484 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x38, 0x5f,
16485 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
16486 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
16487 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
16488 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
16489 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
16490 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
16491 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
16492 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16493 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16494 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16495 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16496 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
16497 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x34, 0x37,
16498 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16499 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16500 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
16501 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
16502 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
16503 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
16504 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
16505 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
16506 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
16507 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
16508 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
16509 		0x00, 0xf0, 0x04, 0x08
16510 	};	/* Structure image */
16511 
16512 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
16513 }
16514 
16515 void
imdi_k47_tab(tabspec * t)16516 imdi_k47_tab(
16517 tabspec *t			/* structure to be initialised */
16518 ) {
16519 	static unsigned char data[] = {
16520 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16521 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16522 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16523 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
16524 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
16525 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
16526 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16527 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
16528 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
16529 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16530 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
16531 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
16532 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
16533 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
16534 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
16535 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16536 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16537 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
16538 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16539 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16540 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16541 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
16542 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
16543 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
16544 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16545 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16546 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16547 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16548 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16549 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16550 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16551 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16552 		0x08, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
16553 	};	/* Structure image */
16554 
16555 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
16556 }
16557 
16558 
16559 
16560 
16561 
16562 
16563 /* Integer Multi-Dimensional Interpolation */
16564 /* Interpolation Kernel Code */
16565 /* Generated by cgen */
16566 /* Copyright 2000 - 2002 Graeme W. Gill */
16567 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
16568 
16569 /* see the Licence.txt file for licencing details.*/
16570 
16571 
16572 /*
16573    Interpolation kernel specs:
16574 
16575    Input channels per pixel = 7
16576    Input channel 0 bits = 8
16577    Input channel 0 increment = 7
16578    Input channel 1 bits = 8
16579    Input channel 1 increment = 7
16580    Input channel 2 bits = 8
16581    Input channel 2 increment = 7
16582    Input channel 3 bits = 8
16583    Input channel 3 increment = 7
16584    Input channel 4 bits = 8
16585    Input channel 4 increment = 7
16586    Input channel 5 bits = 8
16587    Input channel 5 increment = 7
16588    Input channel 6 bits = 8
16589    Input channel 6 increment = 7
16590    Input is channel interleaved
16591    Input channels are separate words
16592    Input value extraction is done in input table lookup
16593 
16594    Output channels per pixel = 8
16595    Output channel 0 bits = 8
16596    Output channel 0 increment = 8
16597    Output channel 1 bits = 8
16598    Output channel 1 increment = 8
16599    Output channel 2 bits = 8
16600    Output channel 2 increment = 8
16601    Output channel 3 bits = 8
16602    Output channel 3 increment = 8
16603    Output channel 4 bits = 8
16604    Output channel 4 increment = 8
16605    Output channel 5 bits = 8
16606    Output channel 5 increment = 8
16607    Output channel 6 bits = 8
16608    Output channel 6 increment = 8
16609    Output channel 7 bits = 8
16610    Output channel 7 increment = 8
16611    Output is channel interleaved
16612 
16613    Output channels are separate words
16614    Weight+voffset bits       = 32
16615    Interpolation table index bits = 32
16616    Interpolation table max resolution = 12
16617  */
16618 
16619 /*
16620    Machine architecture specs:
16621 
16622    Little endian
16623    Reading and writing pixel values separately
16624    Pointer size = 32 bits
16625 
16626    Ordinal size  8 bits is known as 'unsigned char'
16627    Ordinal size 16 bits is known as 'unsigned short'
16628    Ordinal size 32 bits is known as 'unsigned int'
16629    Natural ordinal is 'unsigned int'
16630 
16631    Integer size  8 bits is known as 'signed char'
16632    Integer size 16 bits is known as 'short'
16633    Integer size 32 bits is known as 'int'
16634    Natural integer is 'int'
16635 
16636  */
16637 
16638 #ifndef  IMDI_INCLUDED
16639 #include <memory.h>
16640 #include "imdi_imp.h"
16641 #define  IMDI_INCLUDED
16642 #endif  /* IMDI_INCLUDED */
16643 
16644 #ifndef DEFINED_pointer
16645 #define DEFINED_pointer
16646 typedef unsigned char * pointer;
16647 #endif
16648 
16649 /* Input table interp. index */
16650 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
16651 
16652 /* Input table input weighting/offset value enty */
16653 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
16654 
16655 /* Conditional exchange for sorting */
16656 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
16657 
16658 /* Interpolation multi-dim. table access */
16659 #define IM_O(off) ((off) * 16)
16660 
16661 /* Interpolation table - get vertex values */
16662 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
16663 
16664 /* Output table indexes */
16665 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
16666 
16667 void
imdi_k48(imdi * s,void ** outp,void ** inp,unsigned int npix)16668 imdi_k48(
16669 imdi *s,			/* imdi context */
16670 void **outp,		/* pointer to output pointers */
16671 void **inp,		/* pointer to input pointers */
16672 unsigned int npix	/* Number of pixels to process */
16673 ) {
16674 	imdi_imp *p = (imdi_imp *)(s->impl);
16675 	unsigned char *ip0 = (unsigned char *)inp[0];
16676 	unsigned char *op0 = (unsigned char *)outp[0];
16677 	unsigned char *ep = ip0 + npix * 7 ;
16678 	pointer it0 = (pointer)p->in_tables[0];
16679 	pointer it1 = (pointer)p->in_tables[1];
16680 	pointer it2 = (pointer)p->in_tables[2];
16681 	pointer it3 = (pointer)p->in_tables[3];
16682 	pointer it4 = (pointer)p->in_tables[4];
16683 	pointer it5 = (pointer)p->in_tables[5];
16684 	pointer it6 = (pointer)p->in_tables[6];
16685 	pointer ot0 = (pointer)p->out_tables[0];
16686 	pointer ot1 = (pointer)p->out_tables[1];
16687 	pointer ot2 = (pointer)p->out_tables[2];
16688 	pointer ot3 = (pointer)p->out_tables[3];
16689 	pointer ot4 = (pointer)p->out_tables[4];
16690 	pointer ot5 = (pointer)p->out_tables[5];
16691 	pointer ot6 = (pointer)p->out_tables[6];
16692 	pointer ot7 = (pointer)p->out_tables[7];
16693 	pointer im_base = (pointer)p->im_table;
16694 
16695 	for(;ip0 < ep; ip0 += 7, op0 += 8) {
16696 		unsigned int ova0;	/* Output value accumulator */
16697 		unsigned int ova1;	/* Output value accumulator */
16698 		unsigned int ova2;	/* Output value accumulator */
16699 		unsigned int ova3;	/* Output value accumulator */
16700 		{
16701 			pointer imp;
16702 			unsigned int wo0;	/* Weighting value and vertex offset variable */
16703 			unsigned int wo1;	/* Weighting value and vertex offset variable */
16704 			unsigned int wo2;	/* Weighting value and vertex offset variable */
16705 			unsigned int wo3;	/* Weighting value and vertex offset variable */
16706 			unsigned int wo4;	/* Weighting value and vertex offset variable */
16707 			unsigned int wo5;	/* Weighting value and vertex offset variable */
16708 			unsigned int wo6;	/* Weighting value and vertex offset variable */
16709 			{
16710 				unsigned int ti_i;	/* Interpolation index variable */
16711 
16712 				ti_i  = IT_IX(it0, ip0[0]);
16713 				wo0   = IT_WO(it0, ip0[0]);
16714 				ti_i += IT_IX(it1, ip0[1]);
16715 				wo1   = IT_WO(it1, ip0[1]);
16716 				ti_i += IT_IX(it2, ip0[2]);
16717 				wo2   = IT_WO(it2, ip0[2]);
16718 				ti_i += IT_IX(it3, ip0[3]);
16719 				wo3   = IT_WO(it3, ip0[3]);
16720 				ti_i += IT_IX(it4, ip0[4]);
16721 				wo4   = IT_WO(it4, ip0[4]);
16722 				ti_i += IT_IX(it5, ip0[5]);
16723 				wo5   = IT_WO(it5, ip0[5]);
16724 				ti_i += IT_IX(it6, ip0[6]);
16725 				wo6   = IT_WO(it6, ip0[6]);
16726 
16727 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
16728 
16729 				/* Sort weighting values and vertex offset values */
16730 				CEX(wo0, wo1);
16731 				CEX(wo0, wo2);
16732 				CEX(wo0, wo3);
16733 				CEX(wo0, wo4);
16734 				CEX(wo0, wo5);
16735 				CEX(wo0, wo6);
16736 				CEX(wo1, wo2);
16737 				CEX(wo1, wo3);
16738 				CEX(wo1, wo4);
16739 				CEX(wo1, wo5);
16740 				CEX(wo1, wo6);
16741 				CEX(wo2, wo3);
16742 				CEX(wo2, wo4);
16743 				CEX(wo2, wo5);
16744 				CEX(wo2, wo6);
16745 				CEX(wo3, wo4);
16746 				CEX(wo3, wo5);
16747 				CEX(wo3, wo6);
16748 				CEX(wo4, wo5);
16749 				CEX(wo4, wo6);
16750 				CEX(wo5, wo6);
16751 			}
16752 			{
16753 				unsigned int nvof;	/* Next vertex offset value */
16754 				unsigned int vof;	/* Vertex offset value */
16755 				unsigned int vwe;	/* Vertex weighting */
16756 
16757 				vof = 0;				/* First vertex offset is 0 */
16758 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
16759 				wo0 = (wo0 >> 23);		/* Extract weighting value */
16760 				vwe = 256 - wo0;		/* Baricentric weighting */
16761 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
16762 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
16763 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
16764 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
16765 				vof += nvof;			/* Move to next vertex */
16766 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
16767 				wo1 = (wo1 >> 23);		/* Extract weighting value */
16768 				vwe = wo0 - wo1;		/* Baricentric weighting */
16769 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
16770 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
16771 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
16772 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
16773 				vof += nvof;			/* Move to next vertex */
16774 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
16775 				wo2 = (wo2 >> 23);		/* Extract weighting value */
16776 				vwe = wo1 - wo2;		/* Baricentric weighting */
16777 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
16778 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
16779 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
16780 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
16781 				vof += nvof;			/* Move to next vertex */
16782 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
16783 				wo3 = (wo3 >> 23);		/* Extract weighting value */
16784 				vwe = wo2 - wo3;		/* Baricentric weighting */
16785 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
16786 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
16787 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
16788 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
16789 				vof += nvof;			/* Move to next vertex */
16790 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
16791 				wo4 = (wo4 >> 23);		/* Extract weighting value */
16792 				vwe = wo3 - wo4;		/* Baricentric weighting */
16793 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
16794 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
16795 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
16796 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
16797 				vof += nvof;			/* Move to next vertex */
16798 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
16799 				wo5 = (wo5 >> 23);		/* Extract weighting value */
16800 				vwe = wo4 - wo5;		/* Baricentric weighting */
16801 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
16802 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
16803 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
16804 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
16805 				vof += nvof;			/* Move to next vertex */
16806 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
16807 				wo6 = (wo6 >> 23);		/* Extract weighting value */
16808 				vwe = wo5 - wo6;		/* Baricentric weighting */
16809 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
16810 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
16811 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
16812 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
16813 				vof += nvof;			/* Move to next vertex */
16814 				vwe = wo6;				/* Baricentric weighting */
16815 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
16816 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
16817 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
16818 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
16819 			}
16820 		}
16821 		{
16822 			unsigned int oti;	/* Vertex offset value */
16823 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
16824 			op0[0] = OT_E(ot0, oti);	/* Write result */
16825 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
16826 			op0[1] = OT_E(ot1, oti);	/* Write result */
16827 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
16828 			op0[2] = OT_E(ot2, oti);	/* Write result */
16829 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
16830 			op0[3] = OT_E(ot3, oti);	/* Write result */
16831 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
16832 			op0[4] = OT_E(ot4, oti);	/* Write result */
16833 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
16834 			op0[5] = OT_E(ot5, oti);	/* Write result */
16835 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
16836 			op0[6] = OT_E(ot6, oti);	/* Write result */
16837 			oti = ((ova3 >> 24) & 0xff);	/* Extract integer part of result */
16838 			op0[7] = OT_E(ot7, oti);	/* Write result */
16839 		}
16840 	}
16841 }
16842 #undef IT_WO
16843 #undef IT_IX
16844 #undef CEX
16845 #undef IM_O
16846 #undef IM_FE
16847 #undef OT_E
16848 
16849 void
imdi_k48_gen(genspec * g)16850 imdi_k48_gen(
16851 genspec *g			/* structure to be initialised */
16852 ) {
16853 	static unsigned char data[] = {
16854 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
16855 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16856 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16857 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16858 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16859 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16860 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16861 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
16862 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
16863 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
16864 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
16865 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16866 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16867 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16868 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16869 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16870 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16871 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16872 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16873 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16874 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16875 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16876 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16877 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16878 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16879 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16880 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16881 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16882 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16883 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16884 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16885 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16886 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16887 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16888 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16889 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16890 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16891 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16892 		0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16893 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
16894 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
16895 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
16896 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
16897 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
16898 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
16899 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
16900 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
16901 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
16902 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16903 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
16904 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
16905 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x38, 0x5f,
16906 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
16907 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
16908 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
16909 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
16910 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
16911 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
16912 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
16913 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16914 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16915 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16916 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16917 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
16918 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x34, 0x38,
16919 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16920 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16921 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
16922 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
16923 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
16924 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
16925 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
16926 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
16927 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
16928 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
16929 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
16930 		0x00, 0xf0, 0x04, 0x08
16931 	};	/* Structure image */
16932 
16933 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
16934 }
16935 
16936 void
imdi_k48_tab(tabspec * t)16937 imdi_k48_tab(
16938 tabspec *t			/* structure to be initialised */
16939 ) {
16940 	static unsigned char data[] = {
16941 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16942 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16943 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16944 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
16945 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
16946 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
16947 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16948 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
16949 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
16950 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16951 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
16952 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
16953 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
16954 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
16955 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
16956 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16957 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16958 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
16959 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16960 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16961 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
16962 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
16963 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
16964 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
16965 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16966 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16967 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16968 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16969 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16970 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16971 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16972 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
16973 		0x08, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
16974 	};	/* Structure image */
16975 
16976 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
16977 }
16978 
16979 
16980 
16981 
16982 
16983 
16984 /* Integer Multi-Dimensional Interpolation */
16985 /* Interpolation Kernel Code */
16986 /* Generated by cgen */
16987 /* Copyright 2000 - 2002 Graeme W. Gill */
16988 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
16989 
16990 /* see the Licence.txt file for licencing details.*/
16991 
16992 
16993 /*
16994    Interpolation kernel specs:
16995 
16996    Input channels per pixel = 8
16997    Input channel 0 bits = 8
16998    Input channel 0 increment = 8
16999    Input channel 1 bits = 8
17000    Input channel 1 increment = 8
17001    Input channel 2 bits = 8
17002    Input channel 2 increment = 8
17003    Input channel 3 bits = 8
17004    Input channel 3 increment = 8
17005    Input channel 4 bits = 8
17006    Input channel 4 increment = 8
17007    Input channel 5 bits = 8
17008    Input channel 5 increment = 8
17009    Input channel 6 bits = 8
17010    Input channel 6 increment = 8
17011    Input channel 7 bits = 8
17012    Input channel 7 increment = 8
17013    Input is channel interleaved
17014    Input channels are separate words
17015    Input value extraction is done in input table lookup
17016 
17017    Output channels per pixel = 8
17018    Output channel 0 bits = 8
17019    Output channel 0 increment = 8
17020    Output channel 1 bits = 8
17021    Output channel 1 increment = 8
17022    Output channel 2 bits = 8
17023    Output channel 2 increment = 8
17024    Output channel 3 bits = 8
17025    Output channel 3 increment = 8
17026    Output channel 4 bits = 8
17027    Output channel 4 increment = 8
17028    Output channel 5 bits = 8
17029    Output channel 5 increment = 8
17030    Output channel 6 bits = 8
17031    Output channel 6 increment = 8
17032    Output channel 7 bits = 8
17033    Output channel 7 increment = 8
17034    Output is channel interleaved
17035 
17036    Output channels are separate words
17037    Weight+voffset bits       = 32
17038    Interpolation table index bits = 32
17039    Interpolation table max resolution = 8
17040  */
17041 
17042 /*
17043    Machine architecture specs:
17044 
17045    Little endian
17046    Reading and writing pixel values separately
17047    Pointer size = 32 bits
17048 
17049    Ordinal size  8 bits is known as 'unsigned char'
17050    Ordinal size 16 bits is known as 'unsigned short'
17051    Ordinal size 32 bits is known as 'unsigned int'
17052    Natural ordinal is 'unsigned int'
17053 
17054    Integer size  8 bits is known as 'signed char'
17055    Integer size 16 bits is known as 'short'
17056    Integer size 32 bits is known as 'int'
17057    Natural integer is 'int'
17058 
17059  */
17060 
17061 #ifndef  IMDI_INCLUDED
17062 #include <memory.h>
17063 #include "imdi_imp.h"
17064 #define  IMDI_INCLUDED
17065 #endif  /* IMDI_INCLUDED */
17066 
17067 #ifndef DEFINED_pointer
17068 #define DEFINED_pointer
17069 typedef unsigned char * pointer;
17070 #endif
17071 
17072 /* Input table interp. index */
17073 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
17074 
17075 /* Input table input weighting/offset value enty */
17076 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
17077 
17078 /* Conditional exchange for sorting */
17079 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
17080 
17081 /* Interpolation multi-dim. table access */
17082 #define IM_O(off) ((off) * 16)
17083 
17084 /* Interpolation table - get vertex values */
17085 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
17086 
17087 /* Output table indexes */
17088 #define OT_E(p, off) *((unsigned char *)((p) + (off) * 1))
17089 
17090 void
imdi_k49(imdi * s,void ** outp,void ** inp,unsigned int npix)17091 imdi_k49(
17092 imdi *s,			/* imdi context */
17093 void **outp,		/* pointer to output pointers */
17094 void **inp,		/* pointer to input pointers */
17095 unsigned int npix	/* Number of pixels to process */
17096 ) {
17097 	imdi_imp *p = (imdi_imp *)(s->impl);
17098 	unsigned char *ip0 = (unsigned char *)inp[0];
17099 	unsigned char *op0 = (unsigned char *)outp[0];
17100 	unsigned char *ep = ip0 + npix * 8 ;
17101 	pointer it0 = (pointer)p->in_tables[0];
17102 	pointer it1 = (pointer)p->in_tables[1];
17103 	pointer it2 = (pointer)p->in_tables[2];
17104 	pointer it3 = (pointer)p->in_tables[3];
17105 	pointer it4 = (pointer)p->in_tables[4];
17106 	pointer it5 = (pointer)p->in_tables[5];
17107 	pointer it6 = (pointer)p->in_tables[6];
17108 	pointer it7 = (pointer)p->in_tables[7];
17109 	pointer ot0 = (pointer)p->out_tables[0];
17110 	pointer ot1 = (pointer)p->out_tables[1];
17111 	pointer ot2 = (pointer)p->out_tables[2];
17112 	pointer ot3 = (pointer)p->out_tables[3];
17113 	pointer ot4 = (pointer)p->out_tables[4];
17114 	pointer ot5 = (pointer)p->out_tables[5];
17115 	pointer ot6 = (pointer)p->out_tables[6];
17116 	pointer ot7 = (pointer)p->out_tables[7];
17117 	pointer im_base = (pointer)p->im_table;
17118 
17119 	for(;ip0 < ep; ip0 += 8, op0 += 8) {
17120 		unsigned int ova0;	/* Output value accumulator */
17121 		unsigned int ova1;	/* Output value accumulator */
17122 		unsigned int ova2;	/* Output value accumulator */
17123 		unsigned int ova3;	/* Output value accumulator */
17124 		{
17125 			pointer imp;
17126 			unsigned int wo0;	/* Weighting value and vertex offset variable */
17127 			unsigned int wo1;	/* Weighting value and vertex offset variable */
17128 			unsigned int wo2;	/* Weighting value and vertex offset variable */
17129 			unsigned int wo3;	/* Weighting value and vertex offset variable */
17130 			unsigned int wo4;	/* Weighting value and vertex offset variable */
17131 			unsigned int wo5;	/* Weighting value and vertex offset variable */
17132 			unsigned int wo6;	/* Weighting value and vertex offset variable */
17133 			unsigned int wo7;	/* Weighting value and vertex offset variable */
17134 			{
17135 				unsigned int ti_i;	/* Interpolation index variable */
17136 
17137 				ti_i  = IT_IX(it0, ip0[0]);
17138 				wo0   = IT_WO(it0, ip0[0]);
17139 				ti_i += IT_IX(it1, ip0[1]);
17140 				wo1   = IT_WO(it1, ip0[1]);
17141 				ti_i += IT_IX(it2, ip0[2]);
17142 				wo2   = IT_WO(it2, ip0[2]);
17143 				ti_i += IT_IX(it3, ip0[3]);
17144 				wo3   = IT_WO(it3, ip0[3]);
17145 				ti_i += IT_IX(it4, ip0[4]);
17146 				wo4   = IT_WO(it4, ip0[4]);
17147 				ti_i += IT_IX(it5, ip0[5]);
17148 				wo5   = IT_WO(it5, ip0[5]);
17149 				ti_i += IT_IX(it6, ip0[6]);
17150 				wo6   = IT_WO(it6, ip0[6]);
17151 				ti_i += IT_IX(it7, ip0[7]);
17152 				wo7   = IT_WO(it7, ip0[7]);
17153 
17154 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
17155 
17156 				/* Sort weighting values and vertex offset values */
17157 				CEX(wo0, wo1);
17158 				CEX(wo0, wo2);
17159 				CEX(wo0, wo3);
17160 				CEX(wo0, wo4);
17161 				CEX(wo0, wo5);
17162 				CEX(wo0, wo6);
17163 				CEX(wo0, wo7);
17164 				CEX(wo1, wo2);
17165 				CEX(wo1, wo3);
17166 				CEX(wo1, wo4);
17167 				CEX(wo1, wo5);
17168 				CEX(wo1, wo6);
17169 				CEX(wo1, wo7);
17170 				CEX(wo2, wo3);
17171 				CEX(wo2, wo4);
17172 				CEX(wo2, wo5);
17173 				CEX(wo2, wo6);
17174 				CEX(wo2, wo7);
17175 				CEX(wo3, wo4);
17176 				CEX(wo3, wo5);
17177 				CEX(wo3, wo6);
17178 				CEX(wo3, wo7);
17179 				CEX(wo4, wo5);
17180 				CEX(wo4, wo6);
17181 				CEX(wo4, wo7);
17182 				CEX(wo5, wo6);
17183 				CEX(wo5, wo7);
17184 				CEX(wo6, wo7);
17185 			}
17186 			{
17187 				unsigned int nvof;	/* Next vertex offset value */
17188 				unsigned int vof;	/* Vertex offset value */
17189 				unsigned int vwe;	/* Vertex weighting */
17190 
17191 				vof = 0;				/* First vertex offset is 0 */
17192 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
17193 				wo0 = (wo0 >> 23);		/* Extract weighting value */
17194 				vwe = 256 - wo0;		/* Baricentric weighting */
17195 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
17196 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
17197 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
17198 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
17199 				vof += nvof;			/* Move to next vertex */
17200 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
17201 				wo1 = (wo1 >> 23);		/* Extract weighting value */
17202 				vwe = wo0 - wo1;		/* Baricentric weighting */
17203 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
17204 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
17205 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
17206 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
17207 				vof += nvof;			/* Move to next vertex */
17208 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
17209 				wo2 = (wo2 >> 23);		/* Extract weighting value */
17210 				vwe = wo1 - wo2;		/* Baricentric weighting */
17211 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
17212 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
17213 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
17214 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
17215 				vof += nvof;			/* Move to next vertex */
17216 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
17217 				wo3 = (wo3 >> 23);		/* Extract weighting value */
17218 				vwe = wo2 - wo3;		/* Baricentric weighting */
17219 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
17220 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
17221 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
17222 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
17223 				vof += nvof;			/* Move to next vertex */
17224 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
17225 				wo4 = (wo4 >> 23);		/* Extract weighting value */
17226 				vwe = wo3 - wo4;		/* Baricentric weighting */
17227 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
17228 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
17229 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
17230 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
17231 				vof += nvof;			/* Move to next vertex */
17232 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
17233 				wo5 = (wo5 >> 23);		/* Extract weighting value */
17234 				vwe = wo4 - wo5;		/* Baricentric weighting */
17235 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
17236 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
17237 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
17238 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
17239 				vof += nvof;			/* Move to next vertex */
17240 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
17241 				wo6 = (wo6 >> 23);		/* Extract weighting value */
17242 				vwe = wo5 - wo6;		/* Baricentric weighting */
17243 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
17244 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
17245 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
17246 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
17247 				vof += nvof;			/* Move to next vertex */
17248 				nvof = (wo7 & 0x7fffff);	/* Extract offset value */
17249 				wo7 = (wo7 >> 23);		/* Extract weighting value */
17250 				vwe = wo6 - wo7;		/* Baricentric weighting */
17251 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
17252 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
17253 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
17254 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
17255 				vof += nvof;			/* Move to next vertex */
17256 				vwe = wo7;				/* Baricentric weighting */
17257 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
17258 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
17259 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
17260 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
17261 			}
17262 		}
17263 		{
17264 			unsigned int oti;	/* Vertex offset value */
17265 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
17266 			op0[0] = OT_E(ot0, oti);	/* Write result */
17267 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
17268 			op0[1] = OT_E(ot1, oti);	/* Write result */
17269 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
17270 			op0[2] = OT_E(ot2, oti);	/* Write result */
17271 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
17272 			op0[3] = OT_E(ot3, oti);	/* Write result */
17273 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
17274 			op0[4] = OT_E(ot4, oti);	/* Write result */
17275 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
17276 			op0[5] = OT_E(ot5, oti);	/* Write result */
17277 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
17278 			op0[6] = OT_E(ot6, oti);	/* Write result */
17279 			oti = ((ova3 >> 24) & 0xff);	/* Extract integer part of result */
17280 			op0[7] = OT_E(ot7, oti);	/* Write result */
17281 		}
17282 	}
17283 }
17284 #undef IT_WO
17285 #undef IT_IX
17286 #undef CEX
17287 #undef IM_O
17288 #undef IM_FE
17289 #undef OT_E
17290 
17291 void
imdi_k49_gen(genspec * g)17292 imdi_k49_gen(
17293 genspec *g			/* structure to be initialised */
17294 ) {
17295 	static unsigned char data[] = {
17296 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17297 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17298 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17299 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17300 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17301 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17302 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17303 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17304 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17305 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17306 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17307 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17308 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17309 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17310 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17311 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17312 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17313 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17314 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17315 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17316 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17317 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17318 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17319 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17320 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17321 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17322 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17323 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17324 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17325 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17326 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17327 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17328 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17329 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17330 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17331 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17332 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17333 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17334 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17335 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
17336 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
17337 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
17338 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
17339 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
17340 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
17341 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
17342 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
17343 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
17344 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17345 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
17346 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
17347 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x38, 0x5f,
17348 		0x69, 0x38, 0x5f, 0x69, 0x38, 0x5f, 0x66, 0x00,
17349 		0x8e, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
17350 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
17351 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
17352 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
17353 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
17354 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
17355 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17356 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17357 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17358 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17359 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
17360 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x34, 0x39,
17361 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17362 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17363 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
17364 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
17365 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
17366 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
17367 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
17368 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
17369 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
17370 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
17371 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
17372 		0x00, 0xf0, 0x04, 0x08
17373 	};	/* Structure image */
17374 
17375 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
17376 }
17377 
17378 void
imdi_k49_tab(tabspec * t)17379 imdi_k49_tab(
17380 tabspec *t			/* structure to be initialised */
17381 ) {
17382 	static unsigned char data[] = {
17383 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17384 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17385 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17386 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
17387 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
17388 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
17389 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17390 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
17391 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
17392 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17393 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
17394 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
17395 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
17396 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
17397 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
17398 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17399 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17400 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
17401 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17402 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17403 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17404 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
17405 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
17406 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
17407 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17408 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17409 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17410 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17411 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17412 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17413 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17414 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17415 		0x08, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
17416 	};	/* Structure image */
17417 
17418 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
17419 }
17420 
17421 
17422 
17423 
17424 
17425 
17426 /* Integer Multi-Dimensional Interpolation */
17427 /* Interpolation Kernel Code */
17428 /* Generated by cgen */
17429 /* Copyright 2000 - 2002 Graeme W. Gill */
17430 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
17431 
17432 /* see the Licence.txt file for licencing details.*/
17433 
17434 
17435 /*
17436    Interpolation kernel specs:
17437 
17438    Input channels per pixel = 1
17439    Input channel 0 bits = 8
17440    Input channel 0 increment = 1
17441    Input is channel interleaved
17442    Input channels are separate words
17443    Input value extraction is done in input table lookup
17444 
17445    Output channels per pixel = 1
17446    Output channel 0 bits = 16
17447    Output channel 0 increment = 1
17448    Output is channel interleaved
17449 
17450    Output channels are separate words
17451    Simplex table index bits       = 0
17452    Interpolation table index bits = 8
17453    Simplex table max resolution = 1
17454    Interpolation table max resolution = 255
17455  */
17456 
17457 /*
17458    Machine architecture specs:
17459 
17460    Little endian
17461    Reading and writing pixel values separately
17462    Pointer size = 32 bits
17463 
17464    Ordinal size  8 bits is known as 'unsigned char'
17465    Ordinal size 16 bits is known as 'unsigned short'
17466    Ordinal size 32 bits is known as 'unsigned int'
17467    Natural ordinal is 'unsigned int'
17468 
17469    Integer size  8 bits is known as 'signed char'
17470    Integer size 16 bits is known as 'short'
17471    Integer size 32 bits is known as 'int'
17472    Natural integer is 'int'
17473 
17474  */
17475 
17476 #ifndef  IMDI_INCLUDED
17477 #include <memory.h>
17478 #include "imdi_imp.h"
17479 #define  IMDI_INCLUDED
17480 #endif  /* IMDI_INCLUDED */
17481 
17482 #ifndef DEFINED_pointer
17483 #define DEFINED_pointer
17484 typedef unsigned char * pointer;
17485 #endif
17486 
17487 /* Input table inter & simplex indexes */
17488 #define IT_IT(p, off) *((unsigned char *)((p) + 0 + (off) * 1))
17489 
17490 /* Simplex weighting table access */
17491 #define SW_O(off) ((off) * 4)
17492 
17493 /* Simplex table - get weighting/offset value */
17494 #define SX_WO(p, v) *((unsigned short *)((p) + (v) * 2))
17495 
17496 /* Interpolation multi-dim. table access */
17497 #define IM_O(off) ((off) * 4)
17498 
17499 /* Interpolation table - get vertex values */
17500 #define IM_PE(p, v) *((unsigned int *)((p) + 0 + (v) * 4))
17501 
17502 /* Output table indexes */
17503 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
17504 
17505 void
imdi_k50(imdi * s,void ** outp,void ** inp,unsigned int npix)17506 imdi_k50(
17507 imdi *s,			/* imdi context */
17508 void **outp,		/* pointer to output pointers */
17509 void **inp,		/* pointer to input pointers */
17510 unsigned int npix	/* Number of pixels to process */
17511 ) {
17512 	imdi_imp *p = (imdi_imp *)(s->impl);
17513 	unsigned char *ip0 = (unsigned char *)inp[0];
17514 	unsigned short *op0 = (unsigned short *)outp[0];
17515 	unsigned char *ep = ip0 + npix * 1 ;
17516 	pointer it0 = (pointer)p->in_tables[0];
17517 	pointer ot0 = (pointer)p->out_tables[0];
17518 	pointer sw_base = (pointer)p->sw_table;
17519 	pointer im_base = (pointer)p->im_table;
17520 
17521 	for(;ip0 < ep; ip0 += 1, op0 += 1) {
17522 		unsigned int ova0;	/* Output value partial accumulator */
17523 		{
17524 			pointer swp;
17525 			pointer imp;
17526 			{
17527 				unsigned int ti;	/* Simplex+Interpolation index variable */
17528 
17529 				ti  = IT_IT(it0, ip0[0]);
17530 
17531 				imp = im_base + IM_O(ti >> 0);		/* Extract interp. index and comp. entry */
17532 				swp = sw_base + SW_O(ti & 0x0);	/* Extract simplex index and comp. entry */
17533 			}
17534 			{
17535 				unsigned int vowr;	/* Vertex offset/weight value */
17536 				unsigned int vof;	/* Vertex offset value */
17537 				unsigned int vwe;	/* Vertex weighting */
17538 
17539 				vowr = SX_WO(swp, 0);	/* Read vertex offset+weighting values */
17540 				vof = (vowr & 0x7f);	/* Extract offset value */
17541 				vwe = (vowr >> 7);	/* Extract weighting value */
17542 				ova0  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
17543 				vowr = SX_WO(swp, 1);	/* Read vertex offset+weighting values */
17544 				vof = (vowr & 0x7f);	/* Extract offset value */
17545 				vwe = (vowr >> 7);	/* Extract weighting value */
17546 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
17547 			}
17548 		}
17549 		{
17550 			unsigned int oti;	/* Vertex offset value */
17551 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
17552 			op0[0] = OT_E(ot0, oti);	/* Write result */
17553 		}
17554 	}
17555 }
17556 #undef IT_IT
17557 #undef SW_O
17558 #undef SX_WO
17559 #undef IM_O
17560 #undef IM_PE
17561 #undef OT_E
17562 
17563 void
imdi_k50_gen(genspec * g)17564 imdi_k50_gen(
17565 genspec *g			/* structure to be initialised */
17566 ) {
17567 	static unsigned char data[] = {
17568 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17569 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17570 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17571 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17572 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17573 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17574 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17575 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17576 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17577 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17578 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17579 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17580 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17581 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17582 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17583 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17584 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17585 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17586 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17587 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17588 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
17589 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17590 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17591 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17592 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17593 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17594 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17595 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17596 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17597 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17598 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17599 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17600 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
17601 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17602 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17603 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17604 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17605 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17606 		0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17607 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
17608 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
17609 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
17610 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
17611 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
17612 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
17613 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
17614 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
17615 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
17616 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17617 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
17618 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
17619 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x31, 0x5f,
17620 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
17621 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
17622 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
17623 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
17624 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
17625 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
17626 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
17627 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17628 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17629 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17630 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17631 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
17632 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x35, 0x30,
17633 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17634 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17635 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
17636 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
17637 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
17638 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
17639 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
17640 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
17641 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
17642 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
17643 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
17644 		0x00, 0xf0, 0x04, 0x08
17645 	};	/* Structure image */
17646 
17647 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
17648 }
17649 
17650 void
imdi_k50_tab(tabspec * t)17651 imdi_k50_tab(
17652 tabspec *t			/* structure to be initialised */
17653 ) {
17654 	static unsigned char data[] = {
17655 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17656 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17657 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17658 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
17659 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
17660 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
17661 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17662 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
17663 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17664 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17665 		0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
17666 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17667 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
17668 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
17669 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
17670 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17671 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
17672 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17673 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
17674 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17675 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
17676 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
17677 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
17678 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
17679 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17680 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
17681 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
17682 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
17683 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
17684 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
17685 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
17686 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
17687 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
17688 	};	/* Structure image */
17689 
17690 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
17691 }
17692 
17693 
17694 
17695 
17696 
17697 
17698 /* Integer Multi-Dimensional Interpolation */
17699 /* Interpolation Kernel Code */
17700 /* Generated by cgen */
17701 /* Copyright 2000 - 2002 Graeme W. Gill */
17702 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
17703 
17704 /* see the Licence.txt file for licencing details.*/
17705 
17706 
17707 /*
17708    Interpolation kernel specs:
17709 
17710    Input channels per pixel = 3
17711    Input channel 0 bits = 8
17712    Input channel 0 increment = 3
17713    Input channel 1 bits = 8
17714    Input channel 1 increment = 3
17715    Input channel 2 bits = 8
17716    Input channel 2 increment = 3
17717    Input is channel interleaved
17718    Input channels are separate words
17719    Input value extraction is done in input table lookup
17720 
17721    Output channels per pixel = 1
17722    Output channel 0 bits = 16
17723    Output channel 0 increment = 1
17724    Output is channel interleaved
17725 
17726    Output channels are separate words
17727    Simplex table index bits       = 12
17728    Interpolation table index bits = 20
17729    Simplex table max resolution = 16
17730    Interpolation table max resolution = 101
17731  */
17732 
17733 /*
17734    Machine architecture specs:
17735 
17736    Little endian
17737    Reading and writing pixel values separately
17738    Pointer size = 32 bits
17739 
17740    Ordinal size  8 bits is known as 'unsigned char'
17741    Ordinal size 16 bits is known as 'unsigned short'
17742    Ordinal size 32 bits is known as 'unsigned int'
17743    Natural ordinal is 'unsigned int'
17744 
17745    Integer size  8 bits is known as 'signed char'
17746    Integer size 16 bits is known as 'short'
17747    Integer size 32 bits is known as 'int'
17748    Natural integer is 'int'
17749 
17750  */
17751 
17752 #ifndef  IMDI_INCLUDED
17753 #include <memory.h>
17754 #include "imdi_imp.h"
17755 #define  IMDI_INCLUDED
17756 #endif  /* IMDI_INCLUDED */
17757 
17758 #ifndef DEFINED_pointer
17759 #define DEFINED_pointer
17760 typedef unsigned char * pointer;
17761 #endif
17762 
17763 /* Input table inter & simplex indexes */
17764 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
17765 
17766 /* Simplex weighting table access */
17767 #define SW_O(off) ((off) * 16)
17768 
17769 /* Simplex table - get weighting value */
17770 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
17771 
17772 /* Simplex table - get offset value */
17773 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
17774 
17775 /* Interpolation multi-dim. table access */
17776 #define IM_O(off) ((off) * 4)
17777 
17778 /* Interpolation table - get vertex values */
17779 #define IM_PE(p, v) *((unsigned int *)((p) + 0 + (v) * 4))
17780 
17781 /* Output table indexes */
17782 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
17783 
17784 void
imdi_k51(imdi * s,void ** outp,void ** inp,unsigned int npix)17785 imdi_k51(
17786 imdi *s,			/* imdi context */
17787 void **outp,		/* pointer to output pointers */
17788 void **inp,		/* pointer to input pointers */
17789 unsigned int npix	/* Number of pixels to process */
17790 ) {
17791 	imdi_imp *p = (imdi_imp *)(s->impl);
17792 	unsigned char *ip0 = (unsigned char *)inp[0];
17793 	unsigned short *op0 = (unsigned short *)outp[0];
17794 	unsigned char *ep = ip0 + npix * 3 ;
17795 	pointer it0 = (pointer)p->in_tables[0];
17796 	pointer it1 = (pointer)p->in_tables[1];
17797 	pointer it2 = (pointer)p->in_tables[2];
17798 	pointer ot0 = (pointer)p->out_tables[0];
17799 	pointer sw_base = (pointer)p->sw_table;
17800 	pointer im_base = (pointer)p->im_table;
17801 
17802 	for(;ip0 < ep; ip0 += 3, op0 += 1) {
17803 		unsigned int ova0;	/* Output value partial accumulator */
17804 		{
17805 			pointer swp;
17806 			pointer imp;
17807 			{
17808 				unsigned int ti;	/* Simplex+Interpolation index variable */
17809 
17810 				ti  = IT_IT(it0, ip0[0]);
17811 				ti += IT_IT(it1, ip0[1]);
17812 				ti += IT_IT(it2, ip0[2]);
17813 
17814 				imp = im_base + IM_O(ti >> 12);		/* Extract interp. index and comp. entry */
17815 				swp = sw_base + SW_O(ti & 0xfff);	/* Extract simplex index and comp. entry */
17816 			}
17817 			{
17818 				unsigned int vof;	/* Vertex offset value */
17819 				unsigned int vwe;	/* Vertex weighting */
17820 
17821 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
17822 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
17823 				ova0  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
17824 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
17825 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
17826 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
17827 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
17828 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
17829 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
17830 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
17831 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
17832 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
17833 			}
17834 		}
17835 		{
17836 			unsigned int oti;	/* Vertex offset value */
17837 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
17838 			op0[0] = OT_E(ot0, oti);	/* Write result */
17839 		}
17840 	}
17841 }
17842 #undef IT_IT
17843 #undef SW_O
17844 #undef SX_WE
17845 #undef SX_VO
17846 #undef IM_O
17847 #undef IM_PE
17848 #undef OT_E
17849 
17850 void
imdi_k51_gen(genspec * g)17851 imdi_k51_gen(
17852 genspec *g			/* structure to be initialised */
17853 ) {
17854 	static unsigned char data[] = {
17855 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
17856 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17857 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17858 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17859 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17860 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17861 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17862 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
17863 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
17864 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17865 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17866 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17867 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17868 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17869 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17870 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17871 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17872 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17873 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17874 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17875 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
17876 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17877 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17878 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17879 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17880 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17881 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17882 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17883 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17884 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17885 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17886 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17887 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
17888 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17889 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17890 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
17891 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17892 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17893 		0x65, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
17894 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
17895 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
17896 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
17897 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
17898 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
17899 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
17900 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
17901 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
17902 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
17903 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17904 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
17905 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
17906 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x31, 0x5f,
17907 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
17908 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
17909 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
17910 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
17911 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
17912 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
17913 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
17914 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17915 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17916 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17917 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17918 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
17919 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x35, 0x31,
17920 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17921 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17922 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
17923 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
17924 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
17925 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
17926 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
17927 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
17928 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
17929 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
17930 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
17931 		0x00, 0xf0, 0x04, 0x08
17932 	};	/* Structure image */
17933 
17934 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
17935 }
17936 
17937 void
imdi_k51_tab(tabspec * t)17938 imdi_k51_tab(
17939 tabspec *t			/* structure to be initialised */
17940 ) {
17941 	static unsigned char data[] = {
17942 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17943 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17944 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17945 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
17946 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
17947 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
17948 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
17949 		0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
17950 		0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
17951 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17952 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
17953 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17954 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
17955 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
17956 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
17957 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17958 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
17959 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17960 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
17961 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
17962 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
17963 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
17964 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
17965 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
17966 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17967 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
17968 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
17969 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
17970 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
17971 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
17972 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
17973 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
17974 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
17975 	};	/* Structure image */
17976 
17977 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
17978 }
17979 
17980 
17981 
17982 
17983 
17984 
17985 /* Integer Multi-Dimensional Interpolation */
17986 /* Interpolation Kernel Code */
17987 /* Generated by cgen */
17988 /* Copyright 2000 - 2002 Graeme W. Gill */
17989 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
17990 
17991 /* see the Licence.txt file for licencing details.*/
17992 
17993 
17994 /*
17995    Interpolation kernel specs:
17996 
17997    Input channels per pixel = 4
17998    Input channel 0 bits = 8
17999    Input channel 0 increment = 4
18000    Input channel 1 bits = 8
18001    Input channel 1 increment = 4
18002    Input channel 2 bits = 8
18003    Input channel 2 increment = 4
18004    Input channel 3 bits = 8
18005    Input channel 3 increment = 4
18006    Input is channel interleaved
18007    Input channels are separate words
18008    Input value extraction is done in input table lookup
18009 
18010    Output channels per pixel = 1
18011    Output channel 0 bits = 16
18012    Output channel 0 increment = 1
18013    Output is channel interleaved
18014 
18015    Output channels are separate words
18016    Simplex table index bits       = 32
18017    Interpolation table index bits = 32
18018    Simplex table max resolution = 255
18019    Interpolation table max resolution = 39
18020  */
18021 
18022 /*
18023    Machine architecture specs:
18024 
18025    Little endian
18026    Reading and writing pixel values separately
18027    Pointer size = 32 bits
18028 
18029    Ordinal size  8 bits is known as 'unsigned char'
18030    Ordinal size 16 bits is known as 'unsigned short'
18031    Ordinal size 32 bits is known as 'unsigned int'
18032    Natural ordinal is 'unsigned int'
18033 
18034    Integer size  8 bits is known as 'signed char'
18035    Integer size 16 bits is known as 'short'
18036    Integer size 32 bits is known as 'int'
18037    Natural integer is 'int'
18038 
18039  */
18040 
18041 #ifndef  IMDI_INCLUDED
18042 #include <memory.h>
18043 #include "imdi_imp.h"
18044 #define  IMDI_INCLUDED
18045 #endif  /* IMDI_INCLUDED */
18046 
18047 #ifndef DEFINED_pointer
18048 #define DEFINED_pointer
18049 typedef unsigned char * pointer;
18050 #endif
18051 
18052 /* Input table interp. index */
18053 #define IT_IX(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
18054 
18055 /* Input table simplex index enty */
18056 #define IT_SX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
18057 
18058 /* Simplex weighting table access */
18059 #define SW_O(off) ((off) * 20)
18060 
18061 /* Simplex table - get weighting value */
18062 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
18063 
18064 /* Simplex table - get offset value */
18065 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
18066 
18067 /* Interpolation multi-dim. table access */
18068 #define IM_O(off) ((off) * 4)
18069 
18070 /* Interpolation table - get vertex values */
18071 #define IM_PE(p, v) *((unsigned int *)((p) + 0 + (v) * 4))
18072 
18073 /* Output table indexes */
18074 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
18075 
18076 void
imdi_k52(imdi * s,void ** outp,void ** inp,unsigned int npix)18077 imdi_k52(
18078 imdi *s,			/* imdi context */
18079 void **outp,		/* pointer to output pointers */
18080 void **inp,		/* pointer to input pointers */
18081 unsigned int npix	/* Number of pixels to process */
18082 ) {
18083 	imdi_imp *p = (imdi_imp *)(s->impl);
18084 	unsigned char *ip0 = (unsigned char *)inp[0];
18085 	unsigned short *op0 = (unsigned short *)outp[0];
18086 	unsigned char *ep = ip0 + npix * 4 ;
18087 	pointer it0 = (pointer)p->in_tables[0];
18088 	pointer it1 = (pointer)p->in_tables[1];
18089 	pointer it2 = (pointer)p->in_tables[2];
18090 	pointer it3 = (pointer)p->in_tables[3];
18091 	pointer ot0 = (pointer)p->out_tables[0];
18092 	pointer sw_base = (pointer)p->sw_table;
18093 	pointer im_base = (pointer)p->im_table;
18094 
18095 	for(;ip0 < ep; ip0 += 4, op0 += 1) {
18096 		unsigned int ova0;	/* Output value partial accumulator */
18097 		{
18098 			pointer swp;
18099 			pointer imp;
18100 			{
18101 				unsigned int ti_s;	/* Simplex index variable */
18102 				unsigned int ti_i;	/* Interpolation index variable */
18103 
18104 				ti_i  = IT_IX(it0, ip0[0]);
18105 				ti_s  = IT_SX(it0, ip0[0]);
18106 				ti_i += IT_IX(it1, ip0[1]);
18107 				ti_s += IT_SX(it1, ip0[1]);
18108 				ti_i += IT_IX(it2, ip0[2]);
18109 				ti_s += IT_SX(it2, ip0[2]);
18110 				ti_i += IT_IX(it3, ip0[3]);
18111 				ti_s += IT_SX(it3, ip0[3]);
18112 
18113 				swp = sw_base + SW_O(ti_s);		/* Compute simplex table entry pointer */
18114 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
18115 			}
18116 			{
18117 				unsigned int vof;	/* Vertex offset value */
18118 				unsigned int vwe;	/* Vertex weighting */
18119 
18120 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
18121 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
18122 				ova0  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
18123 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
18124 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
18125 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
18126 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
18127 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
18128 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
18129 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
18130 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
18131 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
18132 				vof = SX_VO(swp, 4);	/* Read vertex offset value */
18133 				vwe = SX_WE(swp, 4);	/* Read vertex weighting value */
18134 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
18135 			}
18136 		}
18137 		{
18138 			unsigned int oti;	/* Vertex offset value */
18139 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
18140 			op0[0] = OT_E(ot0, oti);	/* Write result */
18141 		}
18142 	}
18143 }
18144 #undef IT_IX
18145 #undef IT_SX
18146 #undef SW_O
18147 #undef SX_WE
18148 #undef SX_VO
18149 #undef IM_O
18150 #undef IM_PE
18151 #undef OT_E
18152 
18153 void
imdi_k52_gen(genspec * g)18154 imdi_k52_gen(
18155 genspec *g			/* structure to be initialised */
18156 ) {
18157 	static unsigned char data[] = {
18158 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
18159 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18160 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18161 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18162 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18163 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18164 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18165 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
18166 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
18167 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18168 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18169 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18170 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18171 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18172 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18173 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18174 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18175 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18176 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18177 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18178 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
18179 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18180 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18181 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18182 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18183 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18184 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18185 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18186 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18187 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18188 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18189 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18190 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
18191 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18192 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18193 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18194 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18195 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18196 		0x27, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
18197 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
18198 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
18199 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
18200 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
18201 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
18202 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
18203 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
18204 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
18205 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
18206 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18207 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
18208 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
18209 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x31, 0x5f,
18210 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
18211 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
18212 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
18213 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
18214 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
18215 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
18216 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
18217 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18218 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18219 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18220 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18221 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
18222 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x35, 0x32,
18223 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18224 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18225 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
18226 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
18227 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
18228 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
18229 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
18230 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
18231 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
18232 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
18233 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
18234 		0x00, 0xf0, 0x04, 0x08
18235 	};	/* Structure image */
18236 
18237 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
18238 }
18239 
18240 void
imdi_k52_tab(tabspec * t)18241 imdi_k52_tab(
18242 tabspec *t			/* structure to be initialised */
18243 ) {
18244 	static unsigned char data[] = {
18245 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18246 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18247 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18248 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
18249 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
18250 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
18251 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18252 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
18253 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
18254 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18255 		0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
18256 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18257 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
18258 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
18259 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
18260 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18261 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
18262 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18263 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
18264 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18265 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
18266 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
18267 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
18268 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
18269 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18270 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
18271 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
18272 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
18273 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
18274 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
18275 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
18276 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
18277 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
18278 	};	/* Structure image */
18279 
18280 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
18281 }
18282 
18283 
18284 
18285 
18286 
18287 
18288 /* Integer Multi-Dimensional Interpolation */
18289 /* Interpolation Kernel Code */
18290 /* Generated by cgen */
18291 /* Copyright 2000 - 2002 Graeme W. Gill */
18292 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
18293 
18294 /* see the Licence.txt file for licencing details.*/
18295 
18296 
18297 /*
18298    Interpolation kernel specs:
18299 
18300    Input channels per pixel = 5
18301    Input channel 0 bits = 8
18302    Input channel 0 increment = 5
18303    Input channel 1 bits = 8
18304    Input channel 1 increment = 5
18305    Input channel 2 bits = 8
18306    Input channel 2 increment = 5
18307    Input channel 3 bits = 8
18308    Input channel 3 increment = 5
18309    Input channel 4 bits = 8
18310    Input channel 4 increment = 5
18311    Input is channel interleaved
18312    Input channels are separate words
18313    Input value extraction is done in input table lookup
18314 
18315    Output channels per pixel = 1
18316    Output channel 0 bits = 16
18317    Output channel 0 increment = 1
18318    Output is channel interleaved
18319 
18320    Output channels are separate words
18321    Weight+voffset bits       = 32
18322    Interpolation table index bits = 32
18323    Interpolation table max resolution = 53
18324  */
18325 
18326 /*
18327    Machine architecture specs:
18328 
18329    Little endian
18330    Reading and writing pixel values separately
18331    Pointer size = 32 bits
18332 
18333    Ordinal size  8 bits is known as 'unsigned char'
18334    Ordinal size 16 bits is known as 'unsigned short'
18335    Ordinal size 32 bits is known as 'unsigned int'
18336    Natural ordinal is 'unsigned int'
18337 
18338    Integer size  8 bits is known as 'signed char'
18339    Integer size 16 bits is known as 'short'
18340    Integer size 32 bits is known as 'int'
18341    Natural integer is 'int'
18342 
18343  */
18344 
18345 #ifndef  IMDI_INCLUDED
18346 #include <memory.h>
18347 #include "imdi_imp.h"
18348 #define  IMDI_INCLUDED
18349 #endif  /* IMDI_INCLUDED */
18350 
18351 #ifndef DEFINED_pointer
18352 #define DEFINED_pointer
18353 typedef unsigned char * pointer;
18354 #endif
18355 
18356 /* Input table interp. index */
18357 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
18358 
18359 /* Input table input weighting/offset value enty */
18360 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
18361 
18362 /* Conditional exchange for sorting */
18363 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
18364 
18365 /* Interpolation multi-dim. table access */
18366 #define IM_O(off) ((off) * 4)
18367 
18368 /* Interpolation table - get vertex values */
18369 #define IM_PE(p, v) *((unsigned int *)((p) + 0 + (v) * 4))
18370 
18371 /* Output table indexes */
18372 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
18373 
18374 void
imdi_k53(imdi * s,void ** outp,void ** inp,unsigned int npix)18375 imdi_k53(
18376 imdi *s,			/* imdi context */
18377 void **outp,		/* pointer to output pointers */
18378 void **inp,		/* pointer to input pointers */
18379 unsigned int npix	/* Number of pixels to process */
18380 ) {
18381 	imdi_imp *p = (imdi_imp *)(s->impl);
18382 	unsigned char *ip0 = (unsigned char *)inp[0];
18383 	unsigned short *op0 = (unsigned short *)outp[0];
18384 	unsigned char *ep = ip0 + npix * 5 ;
18385 	pointer it0 = (pointer)p->in_tables[0];
18386 	pointer it1 = (pointer)p->in_tables[1];
18387 	pointer it2 = (pointer)p->in_tables[2];
18388 	pointer it3 = (pointer)p->in_tables[3];
18389 	pointer it4 = (pointer)p->in_tables[4];
18390 	pointer ot0 = (pointer)p->out_tables[0];
18391 	pointer im_base = (pointer)p->im_table;
18392 
18393 	for(;ip0 < ep; ip0 += 5, op0 += 1) {
18394 		unsigned int ova0;	/* Output value partial accumulator */
18395 		{
18396 			pointer imp;
18397 			unsigned int wo0;	/* Weighting value and vertex offset variable */
18398 			unsigned int wo1;	/* Weighting value and vertex offset variable */
18399 			unsigned int wo2;	/* Weighting value and vertex offset variable */
18400 			unsigned int wo3;	/* Weighting value and vertex offset variable */
18401 			unsigned int wo4;	/* Weighting value and vertex offset variable */
18402 			{
18403 				unsigned int ti_i;	/* Interpolation index variable */
18404 
18405 				ti_i  = IT_IX(it0, ip0[0]);
18406 				wo0   = IT_WO(it0, ip0[0]);
18407 				ti_i += IT_IX(it1, ip0[1]);
18408 				wo1   = IT_WO(it1, ip0[1]);
18409 				ti_i += IT_IX(it2, ip0[2]);
18410 				wo2   = IT_WO(it2, ip0[2]);
18411 				ti_i += IT_IX(it3, ip0[3]);
18412 				wo3   = IT_WO(it3, ip0[3]);
18413 				ti_i += IT_IX(it4, ip0[4]);
18414 				wo4   = IT_WO(it4, ip0[4]);
18415 
18416 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
18417 
18418 				/* Sort weighting values and vertex offset values */
18419 				CEX(wo0, wo1);
18420 				CEX(wo0, wo2);
18421 				CEX(wo0, wo3);
18422 				CEX(wo0, wo4);
18423 				CEX(wo1, wo2);
18424 				CEX(wo1, wo3);
18425 				CEX(wo1, wo4);
18426 				CEX(wo2, wo3);
18427 				CEX(wo2, wo4);
18428 				CEX(wo3, wo4);
18429 			}
18430 			{
18431 				unsigned int nvof;	/* Next vertex offset value */
18432 				unsigned int vof;	/* Vertex offset value */
18433 				unsigned int vwe;	/* Vertex weighting */
18434 
18435 				vof = 0;				/* First vertex offset is 0 */
18436 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
18437 				wo0 = (wo0 >> 23);		/* Extract weighting value */
18438 				vwe = 256 - wo0;		/* Baricentric weighting */
18439 				ova0  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
18440 				vof += nvof;			/* Move to next vertex */
18441 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
18442 				wo1 = (wo1 >> 23);		/* Extract weighting value */
18443 				vwe = wo0 - wo1;		/* Baricentric weighting */
18444 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
18445 				vof += nvof;			/* Move to next vertex */
18446 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
18447 				wo2 = (wo2 >> 23);		/* Extract weighting value */
18448 				vwe = wo1 - wo2;		/* Baricentric weighting */
18449 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
18450 				vof += nvof;			/* Move to next vertex */
18451 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
18452 				wo3 = (wo3 >> 23);		/* Extract weighting value */
18453 				vwe = wo2 - wo3;		/* Baricentric weighting */
18454 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
18455 				vof += nvof;			/* Move to next vertex */
18456 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
18457 				wo4 = (wo4 >> 23);		/* Extract weighting value */
18458 				vwe = wo3 - wo4;		/* Baricentric weighting */
18459 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
18460 				vof += nvof;			/* Move to next vertex */
18461 				vwe = wo4;				/* Baricentric weighting */
18462 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
18463 			}
18464 		}
18465 		{
18466 			unsigned int oti;	/* Vertex offset value */
18467 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
18468 			op0[0] = OT_E(ot0, oti);	/* Write result */
18469 		}
18470 	}
18471 }
18472 #undef IT_WO
18473 #undef IT_IX
18474 #undef CEX
18475 #undef IM_O
18476 #undef IM_PE
18477 #undef OT_E
18478 
18479 void
imdi_k53_gen(genspec * g)18480 imdi_k53_gen(
18481 genspec *g			/* structure to be initialised */
18482 ) {
18483 	static unsigned char data[] = {
18484 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
18485 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18486 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18487 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18488 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18489 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18490 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18491 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
18492 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
18493 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
18494 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18495 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18496 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18497 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18498 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18499 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18500 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18501 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18502 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18503 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18504 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
18505 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18506 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18507 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18508 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18509 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18510 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18511 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18512 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18513 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18514 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18515 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18516 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
18517 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18518 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18519 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18520 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18521 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18522 		0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18523 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
18524 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
18525 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
18526 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
18527 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
18528 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
18529 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
18530 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
18531 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
18532 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18533 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
18534 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
18535 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x31, 0x5f,
18536 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
18537 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
18538 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
18539 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
18540 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
18541 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
18542 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
18543 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18544 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18545 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18546 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18547 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
18548 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x35, 0x33,
18549 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18550 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18551 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
18552 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
18553 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
18554 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
18555 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
18556 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
18557 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
18558 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
18559 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
18560 		0x00, 0xf0, 0x04, 0x08
18561 	};	/* Structure image */
18562 
18563 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
18564 }
18565 
18566 void
imdi_k53_tab(tabspec * t)18567 imdi_k53_tab(
18568 tabspec *t			/* structure to be initialised */
18569 ) {
18570 	static unsigned char data[] = {
18571 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18572 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18573 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18574 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
18575 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
18576 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
18577 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18578 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
18579 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
18580 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18581 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
18582 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
18583 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
18584 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
18585 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
18586 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18587 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
18588 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18589 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
18590 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18591 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
18592 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
18593 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
18594 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
18595 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18596 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
18597 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
18598 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
18599 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
18600 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
18601 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
18602 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
18603 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
18604 	};	/* Structure image */
18605 
18606 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
18607 }
18608 
18609 
18610 
18611 
18612 
18613 
18614 /* Integer Multi-Dimensional Interpolation */
18615 /* Interpolation Kernel Code */
18616 /* Generated by cgen */
18617 /* Copyright 2000 - 2002 Graeme W. Gill */
18618 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
18619 
18620 /* see the Licence.txt file for licencing details.*/
18621 
18622 
18623 /*
18624    Interpolation kernel specs:
18625 
18626    Input channels per pixel = 6
18627    Input channel 0 bits = 8
18628    Input channel 0 increment = 6
18629    Input channel 1 bits = 8
18630    Input channel 1 increment = 6
18631    Input channel 2 bits = 8
18632    Input channel 2 increment = 6
18633    Input channel 3 bits = 8
18634    Input channel 3 increment = 6
18635    Input channel 4 bits = 8
18636    Input channel 4 increment = 6
18637    Input channel 5 bits = 8
18638    Input channel 5 increment = 6
18639    Input is channel interleaved
18640    Input channels are separate words
18641    Input value extraction is done in input table lookup
18642 
18643    Output channels per pixel = 1
18644    Output channel 0 bits = 16
18645    Output channel 0 increment = 1
18646    Output is channel interleaved
18647 
18648    Output channels are separate words
18649    Weight+voffset bits       = 32
18650    Interpolation table index bits = 32
18651    Interpolation table max resolution = 24
18652  */
18653 
18654 /*
18655    Machine architecture specs:
18656 
18657    Little endian
18658    Reading and writing pixel values separately
18659    Pointer size = 32 bits
18660 
18661    Ordinal size  8 bits is known as 'unsigned char'
18662    Ordinal size 16 bits is known as 'unsigned short'
18663    Ordinal size 32 bits is known as 'unsigned int'
18664    Natural ordinal is 'unsigned int'
18665 
18666    Integer size  8 bits is known as 'signed char'
18667    Integer size 16 bits is known as 'short'
18668    Integer size 32 bits is known as 'int'
18669    Natural integer is 'int'
18670 
18671  */
18672 
18673 #ifndef  IMDI_INCLUDED
18674 #include <memory.h>
18675 #include "imdi_imp.h"
18676 #define  IMDI_INCLUDED
18677 #endif  /* IMDI_INCLUDED */
18678 
18679 #ifndef DEFINED_pointer
18680 #define DEFINED_pointer
18681 typedef unsigned char * pointer;
18682 #endif
18683 
18684 /* Input table interp. index */
18685 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
18686 
18687 /* Input table input weighting/offset value enty */
18688 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
18689 
18690 /* Conditional exchange for sorting */
18691 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
18692 
18693 /* Interpolation multi-dim. table access */
18694 #define IM_O(off) ((off) * 4)
18695 
18696 /* Interpolation table - get vertex values */
18697 #define IM_PE(p, v) *((unsigned int *)((p) + 0 + (v) * 4))
18698 
18699 /* Output table indexes */
18700 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
18701 
18702 void
imdi_k54(imdi * s,void ** outp,void ** inp,unsigned int npix)18703 imdi_k54(
18704 imdi *s,			/* imdi context */
18705 void **outp,		/* pointer to output pointers */
18706 void **inp,		/* pointer to input pointers */
18707 unsigned int npix	/* Number of pixels to process */
18708 ) {
18709 	imdi_imp *p = (imdi_imp *)(s->impl);
18710 	unsigned char *ip0 = (unsigned char *)inp[0];
18711 	unsigned short *op0 = (unsigned short *)outp[0];
18712 	unsigned char *ep = ip0 + npix * 6 ;
18713 	pointer it0 = (pointer)p->in_tables[0];
18714 	pointer it1 = (pointer)p->in_tables[1];
18715 	pointer it2 = (pointer)p->in_tables[2];
18716 	pointer it3 = (pointer)p->in_tables[3];
18717 	pointer it4 = (pointer)p->in_tables[4];
18718 	pointer it5 = (pointer)p->in_tables[5];
18719 	pointer ot0 = (pointer)p->out_tables[0];
18720 	pointer im_base = (pointer)p->im_table;
18721 
18722 	for(;ip0 < ep; ip0 += 6, op0 += 1) {
18723 		unsigned int ova0;	/* Output value partial accumulator */
18724 		{
18725 			pointer imp;
18726 			unsigned int wo0;	/* Weighting value and vertex offset variable */
18727 			unsigned int wo1;	/* Weighting value and vertex offset variable */
18728 			unsigned int wo2;	/* Weighting value and vertex offset variable */
18729 			unsigned int wo3;	/* Weighting value and vertex offset variable */
18730 			unsigned int wo4;	/* Weighting value and vertex offset variable */
18731 			unsigned int wo5;	/* Weighting value and vertex offset variable */
18732 			{
18733 				unsigned int ti_i;	/* Interpolation index variable */
18734 
18735 				ti_i  = IT_IX(it0, ip0[0]);
18736 				wo0   = IT_WO(it0, ip0[0]);
18737 				ti_i += IT_IX(it1, ip0[1]);
18738 				wo1   = IT_WO(it1, ip0[1]);
18739 				ti_i += IT_IX(it2, ip0[2]);
18740 				wo2   = IT_WO(it2, ip0[2]);
18741 				ti_i += IT_IX(it3, ip0[3]);
18742 				wo3   = IT_WO(it3, ip0[3]);
18743 				ti_i += IT_IX(it4, ip0[4]);
18744 				wo4   = IT_WO(it4, ip0[4]);
18745 				ti_i += IT_IX(it5, ip0[5]);
18746 				wo5   = IT_WO(it5, ip0[5]);
18747 
18748 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
18749 
18750 				/* Sort weighting values and vertex offset values */
18751 				CEX(wo0, wo1);
18752 				CEX(wo0, wo2);
18753 				CEX(wo0, wo3);
18754 				CEX(wo0, wo4);
18755 				CEX(wo0, wo5);
18756 				CEX(wo1, wo2);
18757 				CEX(wo1, wo3);
18758 				CEX(wo1, wo4);
18759 				CEX(wo1, wo5);
18760 				CEX(wo2, wo3);
18761 				CEX(wo2, wo4);
18762 				CEX(wo2, wo5);
18763 				CEX(wo3, wo4);
18764 				CEX(wo3, wo5);
18765 				CEX(wo4, wo5);
18766 			}
18767 			{
18768 				unsigned int nvof;	/* Next vertex offset value */
18769 				unsigned int vof;	/* Vertex offset value */
18770 				unsigned int vwe;	/* Vertex weighting */
18771 
18772 				vof = 0;				/* First vertex offset is 0 */
18773 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
18774 				wo0 = (wo0 >> 23);		/* Extract weighting value */
18775 				vwe = 256 - wo0;		/* Baricentric weighting */
18776 				ova0  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
18777 				vof += nvof;			/* Move to next vertex */
18778 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
18779 				wo1 = (wo1 >> 23);		/* Extract weighting value */
18780 				vwe = wo0 - wo1;		/* Baricentric weighting */
18781 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
18782 				vof += nvof;			/* Move to next vertex */
18783 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
18784 				wo2 = (wo2 >> 23);		/* Extract weighting value */
18785 				vwe = wo1 - wo2;		/* Baricentric weighting */
18786 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
18787 				vof += nvof;			/* Move to next vertex */
18788 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
18789 				wo3 = (wo3 >> 23);		/* Extract weighting value */
18790 				vwe = wo2 - wo3;		/* Baricentric weighting */
18791 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
18792 				vof += nvof;			/* Move to next vertex */
18793 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
18794 				wo4 = (wo4 >> 23);		/* Extract weighting value */
18795 				vwe = wo3 - wo4;		/* Baricentric weighting */
18796 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
18797 				vof += nvof;			/* Move to next vertex */
18798 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
18799 				wo5 = (wo5 >> 23);		/* Extract weighting value */
18800 				vwe = wo4 - wo5;		/* Baricentric weighting */
18801 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
18802 				vof += nvof;			/* Move to next vertex */
18803 				vwe = wo5;				/* Baricentric weighting */
18804 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
18805 			}
18806 		}
18807 		{
18808 			unsigned int oti;	/* Vertex offset value */
18809 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
18810 			op0[0] = OT_E(ot0, oti);	/* Write result */
18811 		}
18812 	}
18813 }
18814 #undef IT_WO
18815 #undef IT_IX
18816 #undef CEX
18817 #undef IM_O
18818 #undef IM_PE
18819 #undef OT_E
18820 
18821 void
imdi_k54_gen(genspec * g)18822 imdi_k54_gen(
18823 genspec *g			/* structure to be initialised */
18824 ) {
18825 	static unsigned char data[] = {
18826 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
18827 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18828 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18829 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18830 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18831 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18832 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18833 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
18834 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
18835 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
18836 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18837 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18838 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18839 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18840 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18841 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18842 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18843 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18844 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18845 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18846 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
18847 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18848 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18849 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18850 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18851 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18852 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18853 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18854 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18855 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18856 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18857 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18858 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
18859 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18860 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18861 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18862 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18863 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18864 		0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18865 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
18866 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
18867 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
18868 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
18869 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
18870 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
18871 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
18872 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
18873 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
18874 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18875 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
18876 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
18877 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x31, 0x5f,
18878 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
18879 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
18880 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
18881 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
18882 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
18883 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
18884 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
18885 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18886 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18887 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18888 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18889 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
18890 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x35, 0x34,
18891 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18892 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18893 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
18894 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
18895 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
18896 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
18897 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
18898 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
18899 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
18900 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
18901 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
18902 		0x00, 0xf0, 0x04, 0x08
18903 	};	/* Structure image */
18904 
18905 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
18906 }
18907 
18908 void
imdi_k54_tab(tabspec * t)18909 imdi_k54_tab(
18910 tabspec *t			/* structure to be initialised */
18911 ) {
18912 	static unsigned char data[] = {
18913 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18914 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18915 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18916 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
18917 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
18918 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
18919 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
18920 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
18921 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
18922 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18923 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
18924 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
18925 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
18926 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
18927 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
18928 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18929 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
18930 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18931 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
18932 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
18933 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
18934 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
18935 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
18936 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
18937 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18938 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
18939 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
18940 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
18941 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
18942 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
18943 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
18944 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
18945 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
18946 	};	/* Structure image */
18947 
18948 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
18949 }
18950 
18951 
18952 
18953 
18954 
18955 
18956 /* Integer Multi-Dimensional Interpolation */
18957 /* Interpolation Kernel Code */
18958 /* Generated by cgen */
18959 /* Copyright 2000 - 2002 Graeme W. Gill */
18960 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
18961 
18962 /* see the Licence.txt file for licencing details.*/
18963 
18964 
18965 /*
18966    Interpolation kernel specs:
18967 
18968    Input channels per pixel = 7
18969    Input channel 0 bits = 8
18970    Input channel 0 increment = 7
18971    Input channel 1 bits = 8
18972    Input channel 1 increment = 7
18973    Input channel 2 bits = 8
18974    Input channel 2 increment = 7
18975    Input channel 3 bits = 8
18976    Input channel 3 increment = 7
18977    Input channel 4 bits = 8
18978    Input channel 4 increment = 7
18979    Input channel 5 bits = 8
18980    Input channel 5 increment = 7
18981    Input channel 6 bits = 8
18982    Input channel 6 increment = 7
18983    Input is channel interleaved
18984    Input channels are separate words
18985    Input value extraction is done in input table lookup
18986 
18987    Output channels per pixel = 1
18988    Output channel 0 bits = 16
18989    Output channel 0 increment = 1
18990    Output is channel interleaved
18991 
18992    Output channels are separate words
18993    Weight+voffset bits       = 32
18994    Interpolation table index bits = 32
18995    Interpolation table max resolution = 14
18996  */
18997 
18998 /*
18999    Machine architecture specs:
19000 
19001    Little endian
19002    Reading and writing pixel values separately
19003    Pointer size = 32 bits
19004 
19005    Ordinal size  8 bits is known as 'unsigned char'
19006    Ordinal size 16 bits is known as 'unsigned short'
19007    Ordinal size 32 bits is known as 'unsigned int'
19008    Natural ordinal is 'unsigned int'
19009 
19010    Integer size  8 bits is known as 'signed char'
19011    Integer size 16 bits is known as 'short'
19012    Integer size 32 bits is known as 'int'
19013    Natural integer is 'int'
19014 
19015  */
19016 
19017 #ifndef  IMDI_INCLUDED
19018 #include <memory.h>
19019 #include "imdi_imp.h"
19020 #define  IMDI_INCLUDED
19021 #endif  /* IMDI_INCLUDED */
19022 
19023 #ifndef DEFINED_pointer
19024 #define DEFINED_pointer
19025 typedef unsigned char * pointer;
19026 #endif
19027 
19028 /* Input table interp. index */
19029 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
19030 
19031 /* Input table input weighting/offset value enty */
19032 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
19033 
19034 /* Conditional exchange for sorting */
19035 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
19036 
19037 /* Interpolation multi-dim. table access */
19038 #define IM_O(off) ((off) * 4)
19039 
19040 /* Interpolation table - get vertex values */
19041 #define IM_PE(p, v) *((unsigned int *)((p) + 0 + (v) * 4))
19042 
19043 /* Output table indexes */
19044 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
19045 
19046 void
imdi_k55(imdi * s,void ** outp,void ** inp,unsigned int npix)19047 imdi_k55(
19048 imdi *s,			/* imdi context */
19049 void **outp,		/* pointer to output pointers */
19050 void **inp,		/* pointer to input pointers */
19051 unsigned int npix	/* Number of pixels to process */
19052 ) {
19053 	imdi_imp *p = (imdi_imp *)(s->impl);
19054 	unsigned char *ip0 = (unsigned char *)inp[0];
19055 	unsigned short *op0 = (unsigned short *)outp[0];
19056 	unsigned char *ep = ip0 + npix * 7 ;
19057 	pointer it0 = (pointer)p->in_tables[0];
19058 	pointer it1 = (pointer)p->in_tables[1];
19059 	pointer it2 = (pointer)p->in_tables[2];
19060 	pointer it3 = (pointer)p->in_tables[3];
19061 	pointer it4 = (pointer)p->in_tables[4];
19062 	pointer it5 = (pointer)p->in_tables[5];
19063 	pointer it6 = (pointer)p->in_tables[6];
19064 	pointer ot0 = (pointer)p->out_tables[0];
19065 	pointer im_base = (pointer)p->im_table;
19066 
19067 	for(;ip0 < ep; ip0 += 7, op0 += 1) {
19068 		unsigned int ova0;	/* Output value partial accumulator */
19069 		{
19070 			pointer imp;
19071 			unsigned int wo0;	/* Weighting value and vertex offset variable */
19072 			unsigned int wo1;	/* Weighting value and vertex offset variable */
19073 			unsigned int wo2;	/* Weighting value and vertex offset variable */
19074 			unsigned int wo3;	/* Weighting value and vertex offset variable */
19075 			unsigned int wo4;	/* Weighting value and vertex offset variable */
19076 			unsigned int wo5;	/* Weighting value and vertex offset variable */
19077 			unsigned int wo6;	/* Weighting value and vertex offset variable */
19078 			{
19079 				unsigned int ti_i;	/* Interpolation index variable */
19080 
19081 				ti_i  = IT_IX(it0, ip0[0]);
19082 				wo0   = IT_WO(it0, ip0[0]);
19083 				ti_i += IT_IX(it1, ip0[1]);
19084 				wo1   = IT_WO(it1, ip0[1]);
19085 				ti_i += IT_IX(it2, ip0[2]);
19086 				wo2   = IT_WO(it2, ip0[2]);
19087 				ti_i += IT_IX(it3, ip0[3]);
19088 				wo3   = IT_WO(it3, ip0[3]);
19089 				ti_i += IT_IX(it4, ip0[4]);
19090 				wo4   = IT_WO(it4, ip0[4]);
19091 				ti_i += IT_IX(it5, ip0[5]);
19092 				wo5   = IT_WO(it5, ip0[5]);
19093 				ti_i += IT_IX(it6, ip0[6]);
19094 				wo6   = IT_WO(it6, ip0[6]);
19095 
19096 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
19097 
19098 				/* Sort weighting values and vertex offset values */
19099 				CEX(wo0, wo1);
19100 				CEX(wo0, wo2);
19101 				CEX(wo0, wo3);
19102 				CEX(wo0, wo4);
19103 				CEX(wo0, wo5);
19104 				CEX(wo0, wo6);
19105 				CEX(wo1, wo2);
19106 				CEX(wo1, wo3);
19107 				CEX(wo1, wo4);
19108 				CEX(wo1, wo5);
19109 				CEX(wo1, wo6);
19110 				CEX(wo2, wo3);
19111 				CEX(wo2, wo4);
19112 				CEX(wo2, wo5);
19113 				CEX(wo2, wo6);
19114 				CEX(wo3, wo4);
19115 				CEX(wo3, wo5);
19116 				CEX(wo3, wo6);
19117 				CEX(wo4, wo5);
19118 				CEX(wo4, wo6);
19119 				CEX(wo5, wo6);
19120 			}
19121 			{
19122 				unsigned int nvof;	/* Next vertex offset value */
19123 				unsigned int vof;	/* Vertex offset value */
19124 				unsigned int vwe;	/* Vertex weighting */
19125 
19126 				vof = 0;				/* First vertex offset is 0 */
19127 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
19128 				wo0 = (wo0 >> 23);		/* Extract weighting value */
19129 				vwe = 256 - wo0;		/* Baricentric weighting */
19130 				ova0  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
19131 				vof += nvof;			/* Move to next vertex */
19132 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
19133 				wo1 = (wo1 >> 23);		/* Extract weighting value */
19134 				vwe = wo0 - wo1;		/* Baricentric weighting */
19135 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
19136 				vof += nvof;			/* Move to next vertex */
19137 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
19138 				wo2 = (wo2 >> 23);		/* Extract weighting value */
19139 				vwe = wo1 - wo2;		/* Baricentric weighting */
19140 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
19141 				vof += nvof;			/* Move to next vertex */
19142 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
19143 				wo3 = (wo3 >> 23);		/* Extract weighting value */
19144 				vwe = wo2 - wo3;		/* Baricentric weighting */
19145 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
19146 				vof += nvof;			/* Move to next vertex */
19147 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
19148 				wo4 = (wo4 >> 23);		/* Extract weighting value */
19149 				vwe = wo3 - wo4;		/* Baricentric weighting */
19150 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
19151 				vof += nvof;			/* Move to next vertex */
19152 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
19153 				wo5 = (wo5 >> 23);		/* Extract weighting value */
19154 				vwe = wo4 - wo5;		/* Baricentric weighting */
19155 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
19156 				vof += nvof;			/* Move to next vertex */
19157 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
19158 				wo6 = (wo6 >> 23);		/* Extract weighting value */
19159 				vwe = wo5 - wo6;		/* Baricentric weighting */
19160 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
19161 				vof += nvof;			/* Move to next vertex */
19162 				vwe = wo6;				/* Baricentric weighting */
19163 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
19164 			}
19165 		}
19166 		{
19167 			unsigned int oti;	/* Vertex offset value */
19168 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
19169 			op0[0] = OT_E(ot0, oti);	/* Write result */
19170 		}
19171 	}
19172 }
19173 #undef IT_WO
19174 #undef IT_IX
19175 #undef CEX
19176 #undef IM_O
19177 #undef IM_PE
19178 #undef OT_E
19179 
19180 void
imdi_k55_gen(genspec * g)19181 imdi_k55_gen(
19182 genspec *g			/* structure to be initialised */
19183 ) {
19184 	static unsigned char data[] = {
19185 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
19186 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19187 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19188 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19189 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19190 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19191 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19192 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
19193 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
19194 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
19195 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
19196 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19197 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19198 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19199 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19200 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19201 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19202 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19203 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19204 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19205 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
19206 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19207 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19208 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19209 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19210 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19211 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19212 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19213 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19214 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19215 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19216 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19217 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
19218 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19219 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19220 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19221 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19222 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19223 		0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19224 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
19225 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
19226 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
19227 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
19228 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
19229 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
19230 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
19231 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
19232 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
19233 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19234 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
19235 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
19236 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x31, 0x5f,
19237 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
19238 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
19239 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
19240 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
19241 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
19242 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
19243 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
19244 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19245 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19246 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19247 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19248 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
19249 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x35, 0x35,
19250 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19251 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19252 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
19253 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
19254 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
19255 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
19256 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
19257 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
19258 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
19259 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
19260 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
19261 		0x00, 0xf0, 0x04, 0x08
19262 	};	/* Structure image */
19263 
19264 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
19265 }
19266 
19267 void
imdi_k55_tab(tabspec * t)19268 imdi_k55_tab(
19269 tabspec *t			/* structure to be initialised */
19270 ) {
19271 	static unsigned char data[] = {
19272 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19273 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19274 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19275 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
19276 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
19277 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
19278 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19279 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
19280 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
19281 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19282 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
19283 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
19284 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
19285 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
19286 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
19287 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19288 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
19289 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19290 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
19291 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19292 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
19293 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
19294 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
19295 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
19296 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19297 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
19298 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
19299 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
19300 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
19301 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
19302 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
19303 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
19304 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
19305 	};	/* Structure image */
19306 
19307 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
19308 }
19309 
19310 
19311 
19312 
19313 
19314 
19315 /* Integer Multi-Dimensional Interpolation */
19316 /* Interpolation Kernel Code */
19317 /* Generated by cgen */
19318 /* Copyright 2000 - 2002 Graeme W. Gill */
19319 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
19320 
19321 /* see the Licence.txt file for licencing details.*/
19322 
19323 
19324 /*
19325    Interpolation kernel specs:
19326 
19327    Input channels per pixel = 8
19328    Input channel 0 bits = 8
19329    Input channel 0 increment = 8
19330    Input channel 1 bits = 8
19331    Input channel 1 increment = 8
19332    Input channel 2 bits = 8
19333    Input channel 2 increment = 8
19334    Input channel 3 bits = 8
19335    Input channel 3 increment = 8
19336    Input channel 4 bits = 8
19337    Input channel 4 increment = 8
19338    Input channel 5 bits = 8
19339    Input channel 5 increment = 8
19340    Input channel 6 bits = 8
19341    Input channel 6 increment = 8
19342    Input channel 7 bits = 8
19343    Input channel 7 increment = 8
19344    Input is channel interleaved
19345    Input channels are separate words
19346    Input value extraction is done in input table lookup
19347 
19348    Output channels per pixel = 1
19349    Output channel 0 bits = 16
19350    Output channel 0 increment = 1
19351    Output is channel interleaved
19352 
19353    Output channels are separate words
19354    Weight+voffset bits       = 32
19355    Interpolation table index bits = 32
19356    Interpolation table max resolution = 9
19357  */
19358 
19359 /*
19360    Machine architecture specs:
19361 
19362    Little endian
19363    Reading and writing pixel values separately
19364    Pointer size = 32 bits
19365 
19366    Ordinal size  8 bits is known as 'unsigned char'
19367    Ordinal size 16 bits is known as 'unsigned short'
19368    Ordinal size 32 bits is known as 'unsigned int'
19369    Natural ordinal is 'unsigned int'
19370 
19371    Integer size  8 bits is known as 'signed char'
19372    Integer size 16 bits is known as 'short'
19373    Integer size 32 bits is known as 'int'
19374    Natural integer is 'int'
19375 
19376  */
19377 
19378 #ifndef  IMDI_INCLUDED
19379 #include <memory.h>
19380 #include "imdi_imp.h"
19381 #define  IMDI_INCLUDED
19382 #endif  /* IMDI_INCLUDED */
19383 
19384 #ifndef DEFINED_pointer
19385 #define DEFINED_pointer
19386 typedef unsigned char * pointer;
19387 #endif
19388 
19389 /* Input table interp. index */
19390 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
19391 
19392 /* Input table input weighting/offset value enty */
19393 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
19394 
19395 /* Conditional exchange for sorting */
19396 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
19397 
19398 /* Interpolation multi-dim. table access */
19399 #define IM_O(off) ((off) * 4)
19400 
19401 /* Interpolation table - get vertex values */
19402 #define IM_PE(p, v) *((unsigned int *)((p) + 0 + (v) * 4))
19403 
19404 /* Output table indexes */
19405 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
19406 
19407 void
imdi_k56(imdi * s,void ** outp,void ** inp,unsigned int npix)19408 imdi_k56(
19409 imdi *s,			/* imdi context */
19410 void **outp,		/* pointer to output pointers */
19411 void **inp,		/* pointer to input pointers */
19412 unsigned int npix	/* Number of pixels to process */
19413 ) {
19414 	imdi_imp *p = (imdi_imp *)(s->impl);
19415 	unsigned char *ip0 = (unsigned char *)inp[0];
19416 	unsigned short *op0 = (unsigned short *)outp[0];
19417 	unsigned char *ep = ip0 + npix * 8 ;
19418 	pointer it0 = (pointer)p->in_tables[0];
19419 	pointer it1 = (pointer)p->in_tables[1];
19420 	pointer it2 = (pointer)p->in_tables[2];
19421 	pointer it3 = (pointer)p->in_tables[3];
19422 	pointer it4 = (pointer)p->in_tables[4];
19423 	pointer it5 = (pointer)p->in_tables[5];
19424 	pointer it6 = (pointer)p->in_tables[6];
19425 	pointer it7 = (pointer)p->in_tables[7];
19426 	pointer ot0 = (pointer)p->out_tables[0];
19427 	pointer im_base = (pointer)p->im_table;
19428 
19429 	for(;ip0 < ep; ip0 += 8, op0 += 1) {
19430 		unsigned int ova0;	/* Output value partial accumulator */
19431 		{
19432 			pointer imp;
19433 			unsigned int wo0;	/* Weighting value and vertex offset variable */
19434 			unsigned int wo1;	/* Weighting value and vertex offset variable */
19435 			unsigned int wo2;	/* Weighting value and vertex offset variable */
19436 			unsigned int wo3;	/* Weighting value and vertex offset variable */
19437 			unsigned int wo4;	/* Weighting value and vertex offset variable */
19438 			unsigned int wo5;	/* Weighting value and vertex offset variable */
19439 			unsigned int wo6;	/* Weighting value and vertex offset variable */
19440 			unsigned int wo7;	/* Weighting value and vertex offset variable */
19441 			{
19442 				unsigned int ti_i;	/* Interpolation index variable */
19443 
19444 				ti_i  = IT_IX(it0, ip0[0]);
19445 				wo0   = IT_WO(it0, ip0[0]);
19446 				ti_i += IT_IX(it1, ip0[1]);
19447 				wo1   = IT_WO(it1, ip0[1]);
19448 				ti_i += IT_IX(it2, ip0[2]);
19449 				wo2   = IT_WO(it2, ip0[2]);
19450 				ti_i += IT_IX(it3, ip0[3]);
19451 				wo3   = IT_WO(it3, ip0[3]);
19452 				ti_i += IT_IX(it4, ip0[4]);
19453 				wo4   = IT_WO(it4, ip0[4]);
19454 				ti_i += IT_IX(it5, ip0[5]);
19455 				wo5   = IT_WO(it5, ip0[5]);
19456 				ti_i += IT_IX(it6, ip0[6]);
19457 				wo6   = IT_WO(it6, ip0[6]);
19458 				ti_i += IT_IX(it7, ip0[7]);
19459 				wo7   = IT_WO(it7, ip0[7]);
19460 
19461 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
19462 
19463 				/* Sort weighting values and vertex offset values */
19464 				CEX(wo0, wo1);
19465 				CEX(wo0, wo2);
19466 				CEX(wo0, wo3);
19467 				CEX(wo0, wo4);
19468 				CEX(wo0, wo5);
19469 				CEX(wo0, wo6);
19470 				CEX(wo0, wo7);
19471 				CEX(wo1, wo2);
19472 				CEX(wo1, wo3);
19473 				CEX(wo1, wo4);
19474 				CEX(wo1, wo5);
19475 				CEX(wo1, wo6);
19476 				CEX(wo1, wo7);
19477 				CEX(wo2, wo3);
19478 				CEX(wo2, wo4);
19479 				CEX(wo2, wo5);
19480 				CEX(wo2, wo6);
19481 				CEX(wo2, wo7);
19482 				CEX(wo3, wo4);
19483 				CEX(wo3, wo5);
19484 				CEX(wo3, wo6);
19485 				CEX(wo3, wo7);
19486 				CEX(wo4, wo5);
19487 				CEX(wo4, wo6);
19488 				CEX(wo4, wo7);
19489 				CEX(wo5, wo6);
19490 				CEX(wo5, wo7);
19491 				CEX(wo6, wo7);
19492 			}
19493 			{
19494 				unsigned int nvof;	/* Next vertex offset value */
19495 				unsigned int vof;	/* Vertex offset value */
19496 				unsigned int vwe;	/* Vertex weighting */
19497 
19498 				vof = 0;				/* First vertex offset is 0 */
19499 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
19500 				wo0 = (wo0 >> 23);		/* Extract weighting value */
19501 				vwe = 256 - wo0;		/* Baricentric weighting */
19502 				ova0  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
19503 				vof += nvof;			/* Move to next vertex */
19504 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
19505 				wo1 = (wo1 >> 23);		/* Extract weighting value */
19506 				vwe = wo0 - wo1;		/* Baricentric weighting */
19507 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
19508 				vof += nvof;			/* Move to next vertex */
19509 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
19510 				wo2 = (wo2 >> 23);		/* Extract weighting value */
19511 				vwe = wo1 - wo2;		/* Baricentric weighting */
19512 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
19513 				vof += nvof;			/* Move to next vertex */
19514 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
19515 				wo3 = (wo3 >> 23);		/* Extract weighting value */
19516 				vwe = wo2 - wo3;		/* Baricentric weighting */
19517 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
19518 				vof += nvof;			/* Move to next vertex */
19519 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
19520 				wo4 = (wo4 >> 23);		/* Extract weighting value */
19521 				vwe = wo3 - wo4;		/* Baricentric weighting */
19522 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
19523 				vof += nvof;			/* Move to next vertex */
19524 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
19525 				wo5 = (wo5 >> 23);		/* Extract weighting value */
19526 				vwe = wo4 - wo5;		/* Baricentric weighting */
19527 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
19528 				vof += nvof;			/* Move to next vertex */
19529 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
19530 				wo6 = (wo6 >> 23);		/* Extract weighting value */
19531 				vwe = wo5 - wo6;		/* Baricentric weighting */
19532 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
19533 				vof += nvof;			/* Move to next vertex */
19534 				nvof = (wo7 & 0x7fffff);	/* Extract offset value */
19535 				wo7 = (wo7 >> 23);		/* Extract weighting value */
19536 				vwe = wo6 - wo7;		/* Baricentric weighting */
19537 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
19538 				vof += nvof;			/* Move to next vertex */
19539 				vwe = wo7;				/* Baricentric weighting */
19540 				ova0 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
19541 			}
19542 		}
19543 		{
19544 			unsigned int oti;	/* Vertex offset value */
19545 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
19546 			op0[0] = OT_E(ot0, oti);	/* Write result */
19547 		}
19548 	}
19549 }
19550 #undef IT_WO
19551 #undef IT_IX
19552 #undef CEX
19553 #undef IM_O
19554 #undef IM_PE
19555 #undef OT_E
19556 
19557 void
imdi_k56_gen(genspec * g)19558 imdi_k56_gen(
19559 genspec *g			/* structure to be initialised */
19560 ) {
19561 	static unsigned char data[] = {
19562 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19563 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19564 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19565 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19566 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19567 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19568 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19569 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19570 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19571 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19572 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19573 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19574 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19575 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19576 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19577 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19578 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19579 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19580 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19581 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19582 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
19583 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19584 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19585 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19586 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19587 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19588 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19589 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19590 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19591 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19592 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19593 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19594 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
19595 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19596 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19597 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19598 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19599 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19600 		0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19601 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
19602 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
19603 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
19604 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
19605 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
19606 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
19607 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
19608 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
19609 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
19610 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19611 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
19612 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
19613 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x31, 0x5f,
19614 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
19615 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
19616 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
19617 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
19618 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
19619 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
19620 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
19621 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19622 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19623 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19624 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19625 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
19626 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x35, 0x36,
19627 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19628 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19629 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
19630 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
19631 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
19632 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
19633 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
19634 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
19635 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
19636 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
19637 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
19638 		0x00, 0xf0, 0x04, 0x08
19639 	};	/* Structure image */
19640 
19641 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
19642 }
19643 
19644 void
imdi_k56_tab(tabspec * t)19645 imdi_k56_tab(
19646 tabspec *t			/* structure to be initialised */
19647 ) {
19648 	static unsigned char data[] = {
19649 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19650 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19651 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19652 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
19653 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
19654 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
19655 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19656 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
19657 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
19658 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19659 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
19660 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
19661 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
19662 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
19663 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
19664 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19665 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
19666 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19667 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
19668 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19669 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
19670 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
19671 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
19672 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
19673 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19674 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
19675 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
19676 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
19677 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
19678 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
19679 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
19680 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
19681 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
19682 	};	/* Structure image */
19683 
19684 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
19685 }
19686 
19687 
19688 
19689 
19690 
19691 
19692 /* Integer Multi-Dimensional Interpolation */
19693 /* Interpolation Kernel Code */
19694 /* Generated by cgen */
19695 /* Copyright 2000 - 2002 Graeme W. Gill */
19696 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
19697 
19698 /* see the Licence.txt file for licencing details.*/
19699 
19700 
19701 /*
19702    Interpolation kernel specs:
19703 
19704    Input channels per pixel = 1
19705    Input channel 0 bits = 8
19706    Input channel 0 increment = 1
19707    Input is channel interleaved
19708    Input channels are separate words
19709    Input value extraction is done in input table lookup
19710 
19711    Output channels per pixel = 3
19712    Output channel 0 bits = 16
19713    Output channel 0 increment = 3
19714    Output channel 1 bits = 16
19715    Output channel 1 increment = 3
19716    Output channel 2 bits = 16
19717    Output channel 2 increment = 3
19718    Output is channel interleaved
19719 
19720    Output channels are separate words
19721    Simplex table index bits       = 0
19722    Interpolation table index bits = 8
19723    Simplex table max resolution = 1
19724    Interpolation table max resolution = 255
19725  */
19726 
19727 /*
19728    Machine architecture specs:
19729 
19730    Little endian
19731    Reading and writing pixel values separately
19732    Pointer size = 32 bits
19733 
19734    Ordinal size  8 bits is known as 'unsigned char'
19735    Ordinal size 16 bits is known as 'unsigned short'
19736    Ordinal size 32 bits is known as 'unsigned int'
19737    Natural ordinal is 'unsigned int'
19738 
19739    Integer size  8 bits is known as 'signed char'
19740    Integer size 16 bits is known as 'short'
19741    Integer size 32 bits is known as 'int'
19742    Natural integer is 'int'
19743 
19744  */
19745 
19746 #ifndef  IMDI_INCLUDED
19747 #include <memory.h>
19748 #include "imdi_imp.h"
19749 #define  IMDI_INCLUDED
19750 #endif  /* IMDI_INCLUDED */
19751 
19752 #ifndef DEFINED_pointer
19753 #define DEFINED_pointer
19754 typedef unsigned char * pointer;
19755 #endif
19756 
19757 /* Input table inter & simplex indexes */
19758 #define IT_IT(p, off) *((unsigned char *)((p) + 0 + (off) * 1))
19759 
19760 /* Simplex weighting table access */
19761 #define SW_O(off) ((off) * 4)
19762 
19763 /* Simplex table - get weighting/offset value */
19764 #define SX_WO(p, v) *((unsigned short *)((p) + (v) * 2))
19765 
19766 /* Interpolation multi-dim. table access */
19767 #define IM_O(off) ((off) * 8)
19768 
19769 /* Interpolation table - get vertex values */
19770 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
19771 #define IM_PE(p, v) *((unsigned int *)((p) + 4 + (v) * 8))
19772 
19773 /* Output table indexes */
19774 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
19775 
19776 void
imdi_k57(imdi * s,void ** outp,void ** inp,unsigned int npix)19777 imdi_k57(
19778 imdi *s,			/* imdi context */
19779 void **outp,		/* pointer to output pointers */
19780 void **inp,		/* pointer to input pointers */
19781 unsigned int npix	/* Number of pixels to process */
19782 ) {
19783 	imdi_imp *p = (imdi_imp *)(s->impl);
19784 	unsigned char *ip0 = (unsigned char *)inp[0];
19785 	unsigned short *op0 = (unsigned short *)outp[0];
19786 	unsigned char *ep = ip0 + npix * 1 ;
19787 	pointer it0 = (pointer)p->in_tables[0];
19788 	pointer ot0 = (pointer)p->out_tables[0];
19789 	pointer ot1 = (pointer)p->out_tables[1];
19790 	pointer ot2 = (pointer)p->out_tables[2];
19791 	pointer sw_base = (pointer)p->sw_table;
19792 	pointer im_base = (pointer)p->im_table;
19793 
19794 	for(;ip0 < ep; ip0 += 1, op0 += 3) {
19795 		unsigned int ova0;	/* Output value accumulator */
19796 		unsigned int ova1;	/* Output value partial accumulator */
19797 		{
19798 			pointer swp;
19799 			pointer imp;
19800 			{
19801 				unsigned int ti;	/* Simplex+Interpolation index variable */
19802 
19803 				ti  = IT_IT(it0, ip0[0]);
19804 
19805 				imp = im_base + IM_O(ti >> 0);		/* Extract interp. index and comp. entry */
19806 				swp = sw_base + SW_O(ti & 0x0);	/* Extract simplex index and comp. entry */
19807 			}
19808 			{
19809 				unsigned int vowr;	/* Vertex offset/weight value */
19810 				unsigned int vof;	/* Vertex offset value */
19811 				unsigned int vwe;	/* Vertex weighting */
19812 
19813 				vowr = SX_WO(swp, 0);	/* Read vertex offset+weighting values */
19814 				vof = (vowr & 0x7f);	/* Extract offset value */
19815 				vwe = (vowr >> 7);	/* Extract weighting value */
19816 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
19817 				ova1  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
19818 				vowr = SX_WO(swp, 1);	/* Read vertex offset+weighting values */
19819 				vof = (vowr & 0x7f);	/* Extract offset value */
19820 				vwe = (vowr >> 7);	/* Extract weighting value */
19821 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
19822 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
19823 			}
19824 		}
19825 		{
19826 			unsigned int oti;	/* Vertex offset value */
19827 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
19828 			op0[0] = OT_E(ot0, oti);	/* Write result */
19829 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
19830 			op0[1] = OT_E(ot1, oti);	/* Write result */
19831 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
19832 			op0[2] = OT_E(ot2, oti);	/* Write result */
19833 		}
19834 	}
19835 }
19836 #undef IT_IT
19837 #undef SW_O
19838 #undef SX_WO
19839 #undef IM_O
19840 #undef IM_FE
19841 #undef IM_PE
19842 #undef OT_E
19843 
19844 void
imdi_k57_gen(genspec * g)19845 imdi_k57_gen(
19846 genspec *g			/* structure to be initialised */
19847 ) {
19848 	static unsigned char data[] = {
19849 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19850 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19851 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19852 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19853 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19854 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19855 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19856 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19857 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19858 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19859 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19860 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19861 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19862 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19863 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19864 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19865 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19866 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19867 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19868 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19869 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
19870 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
19871 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19872 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19873 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
19874 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
19875 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19876 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19877 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19878 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19879 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19880 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19881 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
19882 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
19883 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19884 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19885 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19886 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19887 		0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19888 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
19889 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
19890 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
19891 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
19892 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
19893 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
19894 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
19895 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
19896 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
19897 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19898 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
19899 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
19900 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x33, 0x5f,
19901 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
19902 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
19903 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
19904 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
19905 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
19906 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
19907 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
19908 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19909 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19910 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19911 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19912 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
19913 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x35, 0x37,
19914 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19915 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19916 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
19917 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
19918 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
19919 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
19920 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
19921 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
19922 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
19923 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
19924 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
19925 		0x00, 0xf0, 0x04, 0x08
19926 	};	/* Structure image */
19927 
19928 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
19929 }
19930 
19931 void
imdi_k57_tab(tabspec * t)19932 imdi_k57_tab(
19933 tabspec *t			/* structure to be initialised */
19934 ) {
19935 	static unsigned char data[] = {
19936 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19937 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19938 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19939 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
19940 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
19941 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
19942 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19943 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
19944 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19945 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19946 		0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
19947 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19948 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
19949 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
19950 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
19951 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19952 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19953 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19954 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
19955 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19956 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
19957 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
19958 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
19959 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
19960 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19961 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19962 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
19963 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
19964 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
19965 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
19966 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
19967 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
19968 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
19969 	};	/* Structure image */
19970 
19971 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
19972 }
19973 
19974 
19975 
19976 
19977 
19978 
19979 /* Integer Multi-Dimensional Interpolation */
19980 /* Interpolation Kernel Code */
19981 /* Generated by cgen */
19982 /* Copyright 2000 - 2002 Graeme W. Gill */
19983 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
19984 
19985 /* see the Licence.txt file for licencing details.*/
19986 
19987 
19988 /*
19989    Interpolation kernel specs:
19990 
19991    Input channels per pixel = 3
19992    Input channel 0 bits = 8
19993    Input channel 0 increment = 3
19994    Input channel 1 bits = 8
19995    Input channel 1 increment = 3
19996    Input channel 2 bits = 8
19997    Input channel 2 increment = 3
19998    Input is channel interleaved
19999    Input channels are separate words
20000    Input value extraction is done in input table lookup
20001 
20002    Output channels per pixel = 3
20003    Output channel 0 bits = 16
20004    Output channel 0 increment = 3
20005    Output channel 1 bits = 16
20006    Output channel 1 increment = 3
20007    Output channel 2 bits = 16
20008    Output channel 2 increment = 3
20009    Output is channel interleaved
20010 
20011    Output channels are separate words
20012    Simplex table index bits       = 12
20013    Interpolation table index bits = 20
20014    Simplex table max resolution = 16
20015    Interpolation table max resolution = 101
20016  */
20017 
20018 /*
20019    Machine architecture specs:
20020 
20021    Little endian
20022    Reading and writing pixel values separately
20023    Pointer size = 32 bits
20024 
20025    Ordinal size  8 bits is known as 'unsigned char'
20026    Ordinal size 16 bits is known as 'unsigned short'
20027    Ordinal size 32 bits is known as 'unsigned int'
20028    Natural ordinal is 'unsigned int'
20029 
20030    Integer size  8 bits is known as 'signed char'
20031    Integer size 16 bits is known as 'short'
20032    Integer size 32 bits is known as 'int'
20033    Natural integer is 'int'
20034 
20035  */
20036 
20037 #ifndef  IMDI_INCLUDED
20038 #include <memory.h>
20039 #include "imdi_imp.h"
20040 #define  IMDI_INCLUDED
20041 #endif  /* IMDI_INCLUDED */
20042 
20043 #ifndef DEFINED_pointer
20044 #define DEFINED_pointer
20045 typedef unsigned char * pointer;
20046 #endif
20047 
20048 /* Input table inter & simplex indexes */
20049 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
20050 
20051 /* Simplex weighting table access */
20052 #define SW_O(off) ((off) * 16)
20053 
20054 /* Simplex table - get weighting value */
20055 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
20056 
20057 /* Simplex table - get offset value */
20058 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
20059 
20060 /* Interpolation multi-dim. table access */
20061 #define IM_O(off) ((off) * 8)
20062 
20063 /* Interpolation table - get vertex values */
20064 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
20065 #define IM_PE(p, v) *((unsigned int *)((p) + 4 + (v) * 8))
20066 
20067 /* Output table indexes */
20068 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
20069 
20070 void
imdi_k58(imdi * s,void ** outp,void ** inp,unsigned int npix)20071 imdi_k58(
20072 imdi *s,			/* imdi context */
20073 void **outp,		/* pointer to output pointers */
20074 void **inp,		/* pointer to input pointers */
20075 unsigned int npix	/* Number of pixels to process */
20076 ) {
20077 	imdi_imp *p = (imdi_imp *)(s->impl);
20078 	unsigned char *ip0 = (unsigned char *)inp[0];
20079 	unsigned short *op0 = (unsigned short *)outp[0];
20080 	unsigned char *ep = ip0 + npix * 3 ;
20081 	pointer it0 = (pointer)p->in_tables[0];
20082 	pointer it1 = (pointer)p->in_tables[1];
20083 	pointer it2 = (pointer)p->in_tables[2];
20084 	pointer ot0 = (pointer)p->out_tables[0];
20085 	pointer ot1 = (pointer)p->out_tables[1];
20086 	pointer ot2 = (pointer)p->out_tables[2];
20087 	pointer sw_base = (pointer)p->sw_table;
20088 	pointer im_base = (pointer)p->im_table;
20089 
20090 	for(;ip0 < ep; ip0 += 3, op0 += 3) {
20091 		unsigned int ova0;	/* Output value accumulator */
20092 		unsigned int ova1;	/* Output value partial accumulator */
20093 		{
20094 			pointer swp;
20095 			pointer imp;
20096 			{
20097 				unsigned int ti;	/* Simplex+Interpolation index variable */
20098 
20099 				ti  = IT_IT(it0, ip0[0]);
20100 				ti += IT_IT(it1, ip0[1]);
20101 				ti += IT_IT(it2, ip0[2]);
20102 
20103 				imp = im_base + IM_O(ti >> 12);		/* Extract interp. index and comp. entry */
20104 				swp = sw_base + SW_O(ti & 0xfff);	/* Extract simplex index and comp. entry */
20105 			}
20106 			{
20107 				unsigned int vof;	/* Vertex offset value */
20108 				unsigned int vwe;	/* Vertex weighting */
20109 
20110 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
20111 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
20112 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
20113 				ova1  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
20114 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
20115 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
20116 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
20117 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
20118 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
20119 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
20120 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
20121 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
20122 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
20123 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
20124 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
20125 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
20126 			}
20127 		}
20128 		{
20129 			unsigned int oti;	/* Vertex offset value */
20130 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
20131 			op0[0] = OT_E(ot0, oti);	/* Write result */
20132 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
20133 			op0[1] = OT_E(ot1, oti);	/* Write result */
20134 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
20135 			op0[2] = OT_E(ot2, oti);	/* Write result */
20136 		}
20137 	}
20138 }
20139 #undef IT_IT
20140 #undef SW_O
20141 #undef SX_WE
20142 #undef SX_VO
20143 #undef IM_O
20144 #undef IM_FE
20145 #undef IM_PE
20146 #undef OT_E
20147 
20148 void
imdi_k58_gen(genspec * g)20149 imdi_k58_gen(
20150 genspec *g			/* structure to be initialised */
20151 ) {
20152 	static unsigned char data[] = {
20153 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
20154 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20155 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20156 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20157 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20158 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20159 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20160 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
20161 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
20162 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20163 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20164 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20165 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20166 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20167 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20168 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20169 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20170 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20171 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20172 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20173 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20174 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20175 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20176 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20177 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
20178 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
20179 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20180 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20181 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20182 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20183 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20184 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20185 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20186 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20187 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20188 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20189 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20190 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20191 		0x65, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20192 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
20193 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
20194 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
20195 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
20196 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
20197 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
20198 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
20199 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
20200 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
20201 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20202 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
20203 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
20204 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x33, 0x5f,
20205 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
20206 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
20207 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
20208 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
20209 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
20210 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
20211 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
20212 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20213 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20214 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20215 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20216 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
20217 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x35, 0x38,
20218 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20219 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20220 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
20221 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
20222 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
20223 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
20224 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
20225 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
20226 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
20227 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
20228 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
20229 		0x00, 0xf0, 0x04, 0x08
20230 	};	/* Structure image */
20231 
20232 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
20233 }
20234 
20235 void
imdi_k58_tab(tabspec * t)20236 imdi_k58_tab(
20237 tabspec *t			/* structure to be initialised */
20238 ) {
20239 	static unsigned char data[] = {
20240 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20241 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20242 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20243 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
20244 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
20245 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
20246 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
20247 		0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
20248 		0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
20249 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20250 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20251 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20252 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
20253 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20254 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
20255 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20256 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20257 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20258 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
20259 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20260 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20261 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
20262 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
20263 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
20264 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20265 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20266 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
20267 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
20268 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20269 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20270 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
20271 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
20272 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
20273 	};	/* Structure image */
20274 
20275 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
20276 }
20277 
20278 
20279 
20280 
20281 
20282 
20283 /* Integer Multi-Dimensional Interpolation */
20284 /* Interpolation Kernel Code */
20285 /* Generated by cgen */
20286 /* Copyright 2000 - 2002 Graeme W. Gill */
20287 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
20288 
20289 /* see the Licence.txt file for licencing details.*/
20290 
20291 
20292 /*
20293    Interpolation kernel specs:
20294 
20295    Input channels per pixel = 4
20296    Input channel 0 bits = 8
20297    Input channel 0 increment = 4
20298    Input channel 1 bits = 8
20299    Input channel 1 increment = 4
20300    Input channel 2 bits = 8
20301    Input channel 2 increment = 4
20302    Input channel 3 bits = 8
20303    Input channel 3 increment = 4
20304    Input is channel interleaved
20305    Input channels are separate words
20306    Input value extraction is done in input table lookup
20307 
20308    Output channels per pixel = 3
20309    Output channel 0 bits = 16
20310    Output channel 0 increment = 3
20311    Output channel 1 bits = 16
20312    Output channel 1 increment = 3
20313    Output channel 2 bits = 16
20314    Output channel 2 increment = 3
20315    Output is channel interleaved
20316 
20317    Output channels are separate words
20318    Simplex table index bits       = 32
20319    Interpolation table index bits = 32
20320    Simplex table max resolution = 255
20321    Interpolation table max resolution = 39
20322  */
20323 
20324 /*
20325    Machine architecture specs:
20326 
20327    Little endian
20328    Reading and writing pixel values separately
20329    Pointer size = 32 bits
20330 
20331    Ordinal size  8 bits is known as 'unsigned char'
20332    Ordinal size 16 bits is known as 'unsigned short'
20333    Ordinal size 32 bits is known as 'unsigned int'
20334    Natural ordinal is 'unsigned int'
20335 
20336    Integer size  8 bits is known as 'signed char'
20337    Integer size 16 bits is known as 'short'
20338    Integer size 32 bits is known as 'int'
20339    Natural integer is 'int'
20340 
20341  */
20342 
20343 #ifndef  IMDI_INCLUDED
20344 #include <memory.h>
20345 #include "imdi_imp.h"
20346 #define  IMDI_INCLUDED
20347 #endif  /* IMDI_INCLUDED */
20348 
20349 #ifndef DEFINED_pointer
20350 #define DEFINED_pointer
20351 typedef unsigned char * pointer;
20352 #endif
20353 
20354 /* Input table interp. index */
20355 #define IT_IX(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
20356 
20357 /* Input table simplex index enty */
20358 #define IT_SX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
20359 
20360 /* Simplex weighting table access */
20361 #define SW_O(off) ((off) * 20)
20362 
20363 /* Simplex table - get weighting value */
20364 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
20365 
20366 /* Simplex table - get offset value */
20367 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
20368 
20369 /* Interpolation multi-dim. table access */
20370 #define IM_O(off) ((off) * 8)
20371 
20372 /* Interpolation table - get vertex values */
20373 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
20374 #define IM_PE(p, v) *((unsigned int *)((p) + 4 + (v) * 8))
20375 
20376 /* Output table indexes */
20377 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
20378 
20379 void
imdi_k59(imdi * s,void ** outp,void ** inp,unsigned int npix)20380 imdi_k59(
20381 imdi *s,			/* imdi context */
20382 void **outp,		/* pointer to output pointers */
20383 void **inp,		/* pointer to input pointers */
20384 unsigned int npix	/* Number of pixels to process */
20385 ) {
20386 	imdi_imp *p = (imdi_imp *)(s->impl);
20387 	unsigned char *ip0 = (unsigned char *)inp[0];
20388 	unsigned short *op0 = (unsigned short *)outp[0];
20389 	unsigned char *ep = ip0 + npix * 4 ;
20390 	pointer it0 = (pointer)p->in_tables[0];
20391 	pointer it1 = (pointer)p->in_tables[1];
20392 	pointer it2 = (pointer)p->in_tables[2];
20393 	pointer it3 = (pointer)p->in_tables[3];
20394 	pointer ot0 = (pointer)p->out_tables[0];
20395 	pointer ot1 = (pointer)p->out_tables[1];
20396 	pointer ot2 = (pointer)p->out_tables[2];
20397 	pointer sw_base = (pointer)p->sw_table;
20398 	pointer im_base = (pointer)p->im_table;
20399 
20400 	for(;ip0 < ep; ip0 += 4, op0 += 3) {
20401 		unsigned int ova0;	/* Output value accumulator */
20402 		unsigned int ova1;	/* Output value partial accumulator */
20403 		{
20404 			pointer swp;
20405 			pointer imp;
20406 			{
20407 				unsigned int ti_s;	/* Simplex index variable */
20408 				unsigned int ti_i;	/* Interpolation index variable */
20409 
20410 				ti_i  = IT_IX(it0, ip0[0]);
20411 				ti_s  = IT_SX(it0, ip0[0]);
20412 				ti_i += IT_IX(it1, ip0[1]);
20413 				ti_s += IT_SX(it1, ip0[1]);
20414 				ti_i += IT_IX(it2, ip0[2]);
20415 				ti_s += IT_SX(it2, ip0[2]);
20416 				ti_i += IT_IX(it3, ip0[3]);
20417 				ti_s += IT_SX(it3, ip0[3]);
20418 
20419 				swp = sw_base + SW_O(ti_s);		/* Compute simplex table entry pointer */
20420 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
20421 			}
20422 			{
20423 				unsigned int vof;	/* Vertex offset value */
20424 				unsigned int vwe;	/* Vertex weighting */
20425 
20426 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
20427 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
20428 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
20429 				ova1  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
20430 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
20431 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
20432 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
20433 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
20434 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
20435 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
20436 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
20437 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
20438 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
20439 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
20440 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
20441 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
20442 				vof = SX_VO(swp, 4);	/* Read vertex offset value */
20443 				vwe = SX_WE(swp, 4);	/* Read vertex weighting value */
20444 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
20445 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
20446 			}
20447 		}
20448 		{
20449 			unsigned int oti;	/* Vertex offset value */
20450 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
20451 			op0[0] = OT_E(ot0, oti);	/* Write result */
20452 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
20453 			op0[1] = OT_E(ot1, oti);	/* Write result */
20454 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
20455 			op0[2] = OT_E(ot2, oti);	/* Write result */
20456 		}
20457 	}
20458 }
20459 #undef IT_IX
20460 #undef IT_SX
20461 #undef SW_O
20462 #undef SX_WE
20463 #undef SX_VO
20464 #undef IM_O
20465 #undef IM_FE
20466 #undef IM_PE
20467 #undef OT_E
20468 
20469 void
imdi_k59_gen(genspec * g)20470 imdi_k59_gen(
20471 genspec *g			/* structure to be initialised */
20472 ) {
20473 	static unsigned char data[] = {
20474 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
20475 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20476 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20477 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20478 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20479 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20480 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20481 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
20482 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
20483 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20484 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20485 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20486 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20487 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20488 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20489 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20490 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20491 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20492 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20493 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20494 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20495 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20496 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20497 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20498 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
20499 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
20500 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20501 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20502 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20503 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20504 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20505 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20506 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20507 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20508 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20509 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20510 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20511 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20512 		0x27, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
20513 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
20514 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
20515 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
20516 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
20517 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
20518 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
20519 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
20520 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
20521 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
20522 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20523 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
20524 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
20525 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x33, 0x5f,
20526 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
20527 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
20528 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
20529 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
20530 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
20531 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
20532 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
20533 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20534 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20535 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20536 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20537 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
20538 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x35, 0x39,
20539 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20540 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20541 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
20542 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
20543 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
20544 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
20545 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
20546 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
20547 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
20548 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
20549 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
20550 		0x00, 0xf0, 0x04, 0x08
20551 	};	/* Structure image */
20552 
20553 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
20554 }
20555 
20556 void
imdi_k59_tab(tabspec * t)20557 imdi_k59_tab(
20558 tabspec *t			/* structure to be initialised */
20559 ) {
20560 	static unsigned char data[] = {
20561 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20562 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20563 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20564 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
20565 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
20566 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
20567 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20568 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
20569 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
20570 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20571 		0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20572 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20573 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
20574 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20575 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
20576 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20577 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20578 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20579 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
20580 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20581 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20582 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
20583 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
20584 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
20585 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20586 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20587 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
20588 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
20589 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20590 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20591 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
20592 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
20593 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
20594 	};	/* Structure image */
20595 
20596 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
20597 }
20598 
20599 
20600 
20601 
20602 
20603 
20604 /* Integer Multi-Dimensional Interpolation */
20605 /* Interpolation Kernel Code */
20606 /* Generated by cgen */
20607 /* Copyright 2000 - 2002 Graeme W. Gill */
20608 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
20609 
20610 /* see the Licence.txt file for licencing details.*/
20611 
20612 
20613 /*
20614    Interpolation kernel specs:
20615 
20616    Input channels per pixel = 5
20617    Input channel 0 bits = 8
20618    Input channel 0 increment = 5
20619    Input channel 1 bits = 8
20620    Input channel 1 increment = 5
20621    Input channel 2 bits = 8
20622    Input channel 2 increment = 5
20623    Input channel 3 bits = 8
20624    Input channel 3 increment = 5
20625    Input channel 4 bits = 8
20626    Input channel 4 increment = 5
20627    Input is channel interleaved
20628    Input channels are separate words
20629    Input value extraction is done in input table lookup
20630 
20631    Output channels per pixel = 3
20632    Output channel 0 bits = 16
20633    Output channel 0 increment = 3
20634    Output channel 1 bits = 16
20635    Output channel 1 increment = 3
20636    Output channel 2 bits = 16
20637    Output channel 2 increment = 3
20638    Output is channel interleaved
20639 
20640    Output channels are separate words
20641    Weight+voffset bits       = 32
20642    Interpolation table index bits = 32
20643    Interpolation table max resolution = 53
20644  */
20645 
20646 /*
20647    Machine architecture specs:
20648 
20649    Little endian
20650    Reading and writing pixel values separately
20651    Pointer size = 32 bits
20652 
20653    Ordinal size  8 bits is known as 'unsigned char'
20654    Ordinal size 16 bits is known as 'unsigned short'
20655    Ordinal size 32 bits is known as 'unsigned int'
20656    Natural ordinal is 'unsigned int'
20657 
20658    Integer size  8 bits is known as 'signed char'
20659    Integer size 16 bits is known as 'short'
20660    Integer size 32 bits is known as 'int'
20661    Natural integer is 'int'
20662 
20663  */
20664 
20665 #ifndef  IMDI_INCLUDED
20666 #include <memory.h>
20667 #include "imdi_imp.h"
20668 #define  IMDI_INCLUDED
20669 #endif  /* IMDI_INCLUDED */
20670 
20671 #ifndef DEFINED_pointer
20672 #define DEFINED_pointer
20673 typedef unsigned char * pointer;
20674 #endif
20675 
20676 /* Input table interp. index */
20677 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
20678 
20679 /* Input table input weighting/offset value enty */
20680 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
20681 
20682 /* Conditional exchange for sorting */
20683 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
20684 
20685 /* Interpolation multi-dim. table access */
20686 #define IM_O(off) ((off) * 8)
20687 
20688 /* Interpolation table - get vertex values */
20689 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
20690 #define IM_PE(p, v) *((unsigned int *)((p) + 4 + (v) * 8))
20691 
20692 /* Output table indexes */
20693 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
20694 
20695 void
imdi_k60(imdi * s,void ** outp,void ** inp,unsigned int npix)20696 imdi_k60(
20697 imdi *s,			/* imdi context */
20698 void **outp,		/* pointer to output pointers */
20699 void **inp,		/* pointer to input pointers */
20700 unsigned int npix	/* Number of pixels to process */
20701 ) {
20702 	imdi_imp *p = (imdi_imp *)(s->impl);
20703 	unsigned char *ip0 = (unsigned char *)inp[0];
20704 	unsigned short *op0 = (unsigned short *)outp[0];
20705 	unsigned char *ep = ip0 + npix * 5 ;
20706 	pointer it0 = (pointer)p->in_tables[0];
20707 	pointer it1 = (pointer)p->in_tables[1];
20708 	pointer it2 = (pointer)p->in_tables[2];
20709 	pointer it3 = (pointer)p->in_tables[3];
20710 	pointer it4 = (pointer)p->in_tables[4];
20711 	pointer ot0 = (pointer)p->out_tables[0];
20712 	pointer ot1 = (pointer)p->out_tables[1];
20713 	pointer ot2 = (pointer)p->out_tables[2];
20714 	pointer im_base = (pointer)p->im_table;
20715 
20716 	for(;ip0 < ep; ip0 += 5, op0 += 3) {
20717 		unsigned int ova0;	/* Output value accumulator */
20718 		unsigned int ova1;	/* Output value partial accumulator */
20719 		{
20720 			pointer imp;
20721 			unsigned int wo0;	/* Weighting value and vertex offset variable */
20722 			unsigned int wo1;	/* Weighting value and vertex offset variable */
20723 			unsigned int wo2;	/* Weighting value and vertex offset variable */
20724 			unsigned int wo3;	/* Weighting value and vertex offset variable */
20725 			unsigned int wo4;	/* Weighting value and vertex offset variable */
20726 			{
20727 				unsigned int ti_i;	/* Interpolation index variable */
20728 
20729 				ti_i  = IT_IX(it0, ip0[0]);
20730 				wo0   = IT_WO(it0, ip0[0]);
20731 				ti_i += IT_IX(it1, ip0[1]);
20732 				wo1   = IT_WO(it1, ip0[1]);
20733 				ti_i += IT_IX(it2, ip0[2]);
20734 				wo2   = IT_WO(it2, ip0[2]);
20735 				ti_i += IT_IX(it3, ip0[3]);
20736 				wo3   = IT_WO(it3, ip0[3]);
20737 				ti_i += IT_IX(it4, ip0[4]);
20738 				wo4   = IT_WO(it4, ip0[4]);
20739 
20740 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
20741 
20742 				/* Sort weighting values and vertex offset values */
20743 				CEX(wo0, wo1);
20744 				CEX(wo0, wo2);
20745 				CEX(wo0, wo3);
20746 				CEX(wo0, wo4);
20747 				CEX(wo1, wo2);
20748 				CEX(wo1, wo3);
20749 				CEX(wo1, wo4);
20750 				CEX(wo2, wo3);
20751 				CEX(wo2, wo4);
20752 				CEX(wo3, wo4);
20753 			}
20754 			{
20755 				unsigned int nvof;	/* Next vertex offset value */
20756 				unsigned int vof;	/* Vertex offset value */
20757 				unsigned int vwe;	/* Vertex weighting */
20758 
20759 				vof = 0;				/* First vertex offset is 0 */
20760 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
20761 				wo0 = (wo0 >> 23);		/* Extract weighting value */
20762 				vwe = 256 - wo0;		/* Baricentric weighting */
20763 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
20764 				ova1  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
20765 				vof += nvof;			/* Move to next vertex */
20766 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
20767 				wo1 = (wo1 >> 23);		/* Extract weighting value */
20768 				vwe = wo0 - wo1;		/* Baricentric weighting */
20769 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
20770 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
20771 				vof += nvof;			/* Move to next vertex */
20772 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
20773 				wo2 = (wo2 >> 23);		/* Extract weighting value */
20774 				vwe = wo1 - wo2;		/* Baricentric weighting */
20775 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
20776 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
20777 				vof += nvof;			/* Move to next vertex */
20778 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
20779 				wo3 = (wo3 >> 23);		/* Extract weighting value */
20780 				vwe = wo2 - wo3;		/* Baricentric weighting */
20781 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
20782 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
20783 				vof += nvof;			/* Move to next vertex */
20784 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
20785 				wo4 = (wo4 >> 23);		/* Extract weighting value */
20786 				vwe = wo3 - wo4;		/* Baricentric weighting */
20787 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
20788 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
20789 				vof += nvof;			/* Move to next vertex */
20790 				vwe = wo4;				/* Baricentric weighting */
20791 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
20792 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
20793 			}
20794 		}
20795 		{
20796 			unsigned int oti;	/* Vertex offset value */
20797 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
20798 			op0[0] = OT_E(ot0, oti);	/* Write result */
20799 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
20800 			op0[1] = OT_E(ot1, oti);	/* Write result */
20801 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
20802 			op0[2] = OT_E(ot2, oti);	/* Write result */
20803 		}
20804 	}
20805 }
20806 #undef IT_WO
20807 #undef IT_IX
20808 #undef CEX
20809 #undef IM_O
20810 #undef IM_FE
20811 #undef IM_PE
20812 #undef OT_E
20813 
20814 void
imdi_k60_gen(genspec * g)20815 imdi_k60_gen(
20816 genspec *g			/* structure to be initialised */
20817 ) {
20818 	static unsigned char data[] = {
20819 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
20820 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20821 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20822 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20823 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20824 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20825 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20826 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
20827 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
20828 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
20829 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20830 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20831 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20832 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20833 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20834 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20835 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20836 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20837 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20838 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20839 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20840 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20841 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20842 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20843 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
20844 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
20845 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20846 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20847 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20848 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20849 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20850 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20851 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20852 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20853 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20854 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20855 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20856 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20857 		0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20858 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
20859 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
20860 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
20861 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
20862 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
20863 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
20864 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
20865 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
20866 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
20867 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20868 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
20869 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
20870 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x33, 0x5f,
20871 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
20872 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
20873 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
20874 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
20875 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
20876 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
20877 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
20878 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20879 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20880 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20881 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20882 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
20883 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x36, 0x30,
20884 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20885 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20886 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
20887 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
20888 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
20889 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
20890 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
20891 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
20892 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
20893 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
20894 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
20895 		0x00, 0xf0, 0x04, 0x08
20896 	};	/* Structure image */
20897 
20898 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
20899 }
20900 
20901 void
imdi_k60_tab(tabspec * t)20902 imdi_k60_tab(
20903 tabspec *t			/* structure to be initialised */
20904 ) {
20905 	static unsigned char data[] = {
20906 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20907 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20908 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20909 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
20910 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
20911 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
20912 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20913 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
20914 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
20915 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20916 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
20917 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
20918 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
20919 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
20920 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
20921 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20922 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
20923 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20924 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
20925 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20926 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
20927 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
20928 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
20929 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
20930 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20931 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20932 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
20933 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
20934 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20935 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
20936 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
20937 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
20938 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
20939 	};	/* Structure image */
20940 
20941 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
20942 }
20943 
20944 
20945 
20946 
20947 
20948 
20949 /* Integer Multi-Dimensional Interpolation */
20950 /* Interpolation Kernel Code */
20951 /* Generated by cgen */
20952 /* Copyright 2000 - 2002 Graeme W. Gill */
20953 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
20954 
20955 /* see the Licence.txt file for licencing details.*/
20956 
20957 
20958 /*
20959    Interpolation kernel specs:
20960 
20961    Input channels per pixel = 6
20962    Input channel 0 bits = 8
20963    Input channel 0 increment = 6
20964    Input channel 1 bits = 8
20965    Input channel 1 increment = 6
20966    Input channel 2 bits = 8
20967    Input channel 2 increment = 6
20968    Input channel 3 bits = 8
20969    Input channel 3 increment = 6
20970    Input channel 4 bits = 8
20971    Input channel 4 increment = 6
20972    Input channel 5 bits = 8
20973    Input channel 5 increment = 6
20974    Input is channel interleaved
20975    Input channels are separate words
20976    Input value extraction is done in input table lookup
20977 
20978    Output channels per pixel = 3
20979    Output channel 0 bits = 16
20980    Output channel 0 increment = 3
20981    Output channel 1 bits = 16
20982    Output channel 1 increment = 3
20983    Output channel 2 bits = 16
20984    Output channel 2 increment = 3
20985    Output is channel interleaved
20986 
20987    Output channels are separate words
20988    Weight+voffset bits       = 32
20989    Interpolation table index bits = 32
20990    Interpolation table max resolution = 24
20991  */
20992 
20993 /*
20994    Machine architecture specs:
20995 
20996    Little endian
20997    Reading and writing pixel values separately
20998    Pointer size = 32 bits
20999 
21000    Ordinal size  8 bits is known as 'unsigned char'
21001    Ordinal size 16 bits is known as 'unsigned short'
21002    Ordinal size 32 bits is known as 'unsigned int'
21003    Natural ordinal is 'unsigned int'
21004 
21005    Integer size  8 bits is known as 'signed char'
21006    Integer size 16 bits is known as 'short'
21007    Integer size 32 bits is known as 'int'
21008    Natural integer is 'int'
21009 
21010  */
21011 
21012 #ifndef  IMDI_INCLUDED
21013 #include <memory.h>
21014 #include "imdi_imp.h"
21015 #define  IMDI_INCLUDED
21016 #endif  /* IMDI_INCLUDED */
21017 
21018 #ifndef DEFINED_pointer
21019 #define DEFINED_pointer
21020 typedef unsigned char * pointer;
21021 #endif
21022 
21023 /* Input table interp. index */
21024 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
21025 
21026 /* Input table input weighting/offset value enty */
21027 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
21028 
21029 /* Conditional exchange for sorting */
21030 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
21031 
21032 /* Interpolation multi-dim. table access */
21033 #define IM_O(off) ((off) * 8)
21034 
21035 /* Interpolation table - get vertex values */
21036 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
21037 #define IM_PE(p, v) *((unsigned int *)((p) + 4 + (v) * 8))
21038 
21039 /* Output table indexes */
21040 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
21041 
21042 void
imdi_k61(imdi * s,void ** outp,void ** inp,unsigned int npix)21043 imdi_k61(
21044 imdi *s,			/* imdi context */
21045 void **outp,		/* pointer to output pointers */
21046 void **inp,		/* pointer to input pointers */
21047 unsigned int npix	/* Number of pixels to process */
21048 ) {
21049 	imdi_imp *p = (imdi_imp *)(s->impl);
21050 	unsigned char *ip0 = (unsigned char *)inp[0];
21051 	unsigned short *op0 = (unsigned short *)outp[0];
21052 	unsigned char *ep = ip0 + npix * 6 ;
21053 	pointer it0 = (pointer)p->in_tables[0];
21054 	pointer it1 = (pointer)p->in_tables[1];
21055 	pointer it2 = (pointer)p->in_tables[2];
21056 	pointer it3 = (pointer)p->in_tables[3];
21057 	pointer it4 = (pointer)p->in_tables[4];
21058 	pointer it5 = (pointer)p->in_tables[5];
21059 	pointer ot0 = (pointer)p->out_tables[0];
21060 	pointer ot1 = (pointer)p->out_tables[1];
21061 	pointer ot2 = (pointer)p->out_tables[2];
21062 	pointer im_base = (pointer)p->im_table;
21063 
21064 	for(;ip0 < ep; ip0 += 6, op0 += 3) {
21065 		unsigned int ova0;	/* Output value accumulator */
21066 		unsigned int ova1;	/* Output value partial accumulator */
21067 		{
21068 			pointer imp;
21069 			unsigned int wo0;	/* Weighting value and vertex offset variable */
21070 			unsigned int wo1;	/* Weighting value and vertex offset variable */
21071 			unsigned int wo2;	/* Weighting value and vertex offset variable */
21072 			unsigned int wo3;	/* Weighting value and vertex offset variable */
21073 			unsigned int wo4;	/* Weighting value and vertex offset variable */
21074 			unsigned int wo5;	/* Weighting value and vertex offset variable */
21075 			{
21076 				unsigned int ti_i;	/* Interpolation index variable */
21077 
21078 				ti_i  = IT_IX(it0, ip0[0]);
21079 				wo0   = IT_WO(it0, ip0[0]);
21080 				ti_i += IT_IX(it1, ip0[1]);
21081 				wo1   = IT_WO(it1, ip0[1]);
21082 				ti_i += IT_IX(it2, ip0[2]);
21083 				wo2   = IT_WO(it2, ip0[2]);
21084 				ti_i += IT_IX(it3, ip0[3]);
21085 				wo3   = IT_WO(it3, ip0[3]);
21086 				ti_i += IT_IX(it4, ip0[4]);
21087 				wo4   = IT_WO(it4, ip0[4]);
21088 				ti_i += IT_IX(it5, ip0[5]);
21089 				wo5   = IT_WO(it5, ip0[5]);
21090 
21091 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
21092 
21093 				/* Sort weighting values and vertex offset values */
21094 				CEX(wo0, wo1);
21095 				CEX(wo0, wo2);
21096 				CEX(wo0, wo3);
21097 				CEX(wo0, wo4);
21098 				CEX(wo0, wo5);
21099 				CEX(wo1, wo2);
21100 				CEX(wo1, wo3);
21101 				CEX(wo1, wo4);
21102 				CEX(wo1, wo5);
21103 				CEX(wo2, wo3);
21104 				CEX(wo2, wo4);
21105 				CEX(wo2, wo5);
21106 				CEX(wo3, wo4);
21107 				CEX(wo3, wo5);
21108 				CEX(wo4, wo5);
21109 			}
21110 			{
21111 				unsigned int nvof;	/* Next vertex offset value */
21112 				unsigned int vof;	/* Vertex offset value */
21113 				unsigned int vwe;	/* Vertex weighting */
21114 
21115 				vof = 0;				/* First vertex offset is 0 */
21116 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
21117 				wo0 = (wo0 >> 23);		/* Extract weighting value */
21118 				vwe = 256 - wo0;		/* Baricentric weighting */
21119 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21120 				ova1  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21121 				vof += nvof;			/* Move to next vertex */
21122 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
21123 				wo1 = (wo1 >> 23);		/* Extract weighting value */
21124 				vwe = wo0 - wo1;		/* Baricentric weighting */
21125 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21126 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21127 				vof += nvof;			/* Move to next vertex */
21128 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
21129 				wo2 = (wo2 >> 23);		/* Extract weighting value */
21130 				vwe = wo1 - wo2;		/* Baricentric weighting */
21131 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21132 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21133 				vof += nvof;			/* Move to next vertex */
21134 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
21135 				wo3 = (wo3 >> 23);		/* Extract weighting value */
21136 				vwe = wo2 - wo3;		/* Baricentric weighting */
21137 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21138 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21139 				vof += nvof;			/* Move to next vertex */
21140 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
21141 				wo4 = (wo4 >> 23);		/* Extract weighting value */
21142 				vwe = wo3 - wo4;		/* Baricentric weighting */
21143 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21144 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21145 				vof += nvof;			/* Move to next vertex */
21146 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
21147 				wo5 = (wo5 >> 23);		/* Extract weighting value */
21148 				vwe = wo4 - wo5;		/* Baricentric weighting */
21149 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21150 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21151 				vof += nvof;			/* Move to next vertex */
21152 				vwe = wo5;				/* Baricentric weighting */
21153 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21154 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21155 			}
21156 		}
21157 		{
21158 			unsigned int oti;	/* Vertex offset value */
21159 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
21160 			op0[0] = OT_E(ot0, oti);	/* Write result */
21161 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
21162 			op0[1] = OT_E(ot1, oti);	/* Write result */
21163 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
21164 			op0[2] = OT_E(ot2, oti);	/* Write result */
21165 		}
21166 	}
21167 }
21168 #undef IT_WO
21169 #undef IT_IX
21170 #undef CEX
21171 #undef IM_O
21172 #undef IM_FE
21173 #undef IM_PE
21174 #undef OT_E
21175 
21176 void
imdi_k61_gen(genspec * g)21177 imdi_k61_gen(
21178 genspec *g			/* structure to be initialised */
21179 ) {
21180 	static unsigned char data[] = {
21181 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
21182 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21183 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21184 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21185 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21186 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21187 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21188 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
21189 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
21190 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
21191 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21192 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21193 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21194 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21195 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21196 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21197 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21198 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21199 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21200 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21201 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
21202 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
21203 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21204 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21205 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
21206 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
21207 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21208 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21209 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21210 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21211 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21212 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21213 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
21214 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
21215 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21216 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21217 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21218 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21219 		0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21220 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
21221 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
21222 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
21223 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
21224 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
21225 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
21226 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
21227 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
21228 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
21229 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21230 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
21231 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
21232 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x33, 0x5f,
21233 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
21234 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
21235 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
21236 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
21237 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
21238 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
21239 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
21240 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21241 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21242 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21243 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21244 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
21245 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x36, 0x31,
21246 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21247 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21248 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
21249 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
21250 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
21251 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
21252 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
21253 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
21254 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
21255 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
21256 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
21257 		0x00, 0xf0, 0x04, 0x08
21258 	};	/* Structure image */
21259 
21260 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
21261 }
21262 
21263 void
imdi_k61_tab(tabspec * t)21264 imdi_k61_tab(
21265 tabspec *t			/* structure to be initialised */
21266 ) {
21267 	static unsigned char data[] = {
21268 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21269 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21270 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21271 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
21272 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
21273 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
21274 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21275 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
21276 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
21277 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21278 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
21279 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
21280 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
21281 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
21282 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
21283 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21284 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21285 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21286 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
21287 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21288 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21289 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
21290 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
21291 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
21292 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21293 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21294 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
21295 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
21296 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
21297 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
21298 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
21299 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
21300 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
21301 	};	/* Structure image */
21302 
21303 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
21304 }
21305 
21306 
21307 
21308 
21309 
21310 
21311 /* Integer Multi-Dimensional Interpolation */
21312 /* Interpolation Kernel Code */
21313 /* Generated by cgen */
21314 /* Copyright 2000 - 2002 Graeme W. Gill */
21315 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
21316 
21317 /* see the Licence.txt file for licencing details.*/
21318 
21319 
21320 /*
21321    Interpolation kernel specs:
21322 
21323    Input channels per pixel = 7
21324    Input channel 0 bits = 8
21325    Input channel 0 increment = 7
21326    Input channel 1 bits = 8
21327    Input channel 1 increment = 7
21328    Input channel 2 bits = 8
21329    Input channel 2 increment = 7
21330    Input channel 3 bits = 8
21331    Input channel 3 increment = 7
21332    Input channel 4 bits = 8
21333    Input channel 4 increment = 7
21334    Input channel 5 bits = 8
21335    Input channel 5 increment = 7
21336    Input channel 6 bits = 8
21337    Input channel 6 increment = 7
21338    Input is channel interleaved
21339    Input channels are separate words
21340    Input value extraction is done in input table lookup
21341 
21342    Output channels per pixel = 3
21343    Output channel 0 bits = 16
21344    Output channel 0 increment = 3
21345    Output channel 1 bits = 16
21346    Output channel 1 increment = 3
21347    Output channel 2 bits = 16
21348    Output channel 2 increment = 3
21349    Output is channel interleaved
21350 
21351    Output channels are separate words
21352    Weight+voffset bits       = 32
21353    Interpolation table index bits = 32
21354    Interpolation table max resolution = 14
21355  */
21356 
21357 /*
21358    Machine architecture specs:
21359 
21360    Little endian
21361    Reading and writing pixel values separately
21362    Pointer size = 32 bits
21363 
21364    Ordinal size  8 bits is known as 'unsigned char'
21365    Ordinal size 16 bits is known as 'unsigned short'
21366    Ordinal size 32 bits is known as 'unsigned int'
21367    Natural ordinal is 'unsigned int'
21368 
21369    Integer size  8 bits is known as 'signed char'
21370    Integer size 16 bits is known as 'short'
21371    Integer size 32 bits is known as 'int'
21372    Natural integer is 'int'
21373 
21374  */
21375 
21376 #ifndef  IMDI_INCLUDED
21377 #include <memory.h>
21378 #include "imdi_imp.h"
21379 #define  IMDI_INCLUDED
21380 #endif  /* IMDI_INCLUDED */
21381 
21382 #ifndef DEFINED_pointer
21383 #define DEFINED_pointer
21384 typedef unsigned char * pointer;
21385 #endif
21386 
21387 /* Input table interp. index */
21388 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
21389 
21390 /* Input table input weighting/offset value enty */
21391 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
21392 
21393 /* Conditional exchange for sorting */
21394 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
21395 
21396 /* Interpolation multi-dim. table access */
21397 #define IM_O(off) ((off) * 8)
21398 
21399 /* Interpolation table - get vertex values */
21400 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
21401 #define IM_PE(p, v) *((unsigned int *)((p) + 4 + (v) * 8))
21402 
21403 /* Output table indexes */
21404 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
21405 
21406 void
imdi_k62(imdi * s,void ** outp,void ** inp,unsigned int npix)21407 imdi_k62(
21408 imdi *s,			/* imdi context */
21409 void **outp,		/* pointer to output pointers */
21410 void **inp,		/* pointer to input pointers */
21411 unsigned int npix	/* Number of pixels to process */
21412 ) {
21413 	imdi_imp *p = (imdi_imp *)(s->impl);
21414 	unsigned char *ip0 = (unsigned char *)inp[0];
21415 	unsigned short *op0 = (unsigned short *)outp[0];
21416 	unsigned char *ep = ip0 + npix * 7 ;
21417 	pointer it0 = (pointer)p->in_tables[0];
21418 	pointer it1 = (pointer)p->in_tables[1];
21419 	pointer it2 = (pointer)p->in_tables[2];
21420 	pointer it3 = (pointer)p->in_tables[3];
21421 	pointer it4 = (pointer)p->in_tables[4];
21422 	pointer it5 = (pointer)p->in_tables[5];
21423 	pointer it6 = (pointer)p->in_tables[6];
21424 	pointer ot0 = (pointer)p->out_tables[0];
21425 	pointer ot1 = (pointer)p->out_tables[1];
21426 	pointer ot2 = (pointer)p->out_tables[2];
21427 	pointer im_base = (pointer)p->im_table;
21428 
21429 	for(;ip0 < ep; ip0 += 7, op0 += 3) {
21430 		unsigned int ova0;	/* Output value accumulator */
21431 		unsigned int ova1;	/* Output value partial accumulator */
21432 		{
21433 			pointer imp;
21434 			unsigned int wo0;	/* Weighting value and vertex offset variable */
21435 			unsigned int wo1;	/* Weighting value and vertex offset variable */
21436 			unsigned int wo2;	/* Weighting value and vertex offset variable */
21437 			unsigned int wo3;	/* Weighting value and vertex offset variable */
21438 			unsigned int wo4;	/* Weighting value and vertex offset variable */
21439 			unsigned int wo5;	/* Weighting value and vertex offset variable */
21440 			unsigned int wo6;	/* Weighting value and vertex offset variable */
21441 			{
21442 				unsigned int ti_i;	/* Interpolation index variable */
21443 
21444 				ti_i  = IT_IX(it0, ip0[0]);
21445 				wo0   = IT_WO(it0, ip0[0]);
21446 				ti_i += IT_IX(it1, ip0[1]);
21447 				wo1   = IT_WO(it1, ip0[1]);
21448 				ti_i += IT_IX(it2, ip0[2]);
21449 				wo2   = IT_WO(it2, ip0[2]);
21450 				ti_i += IT_IX(it3, ip0[3]);
21451 				wo3   = IT_WO(it3, ip0[3]);
21452 				ti_i += IT_IX(it4, ip0[4]);
21453 				wo4   = IT_WO(it4, ip0[4]);
21454 				ti_i += IT_IX(it5, ip0[5]);
21455 				wo5   = IT_WO(it5, ip0[5]);
21456 				ti_i += IT_IX(it6, ip0[6]);
21457 				wo6   = IT_WO(it6, ip0[6]);
21458 
21459 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
21460 
21461 				/* Sort weighting values and vertex offset values */
21462 				CEX(wo0, wo1);
21463 				CEX(wo0, wo2);
21464 				CEX(wo0, wo3);
21465 				CEX(wo0, wo4);
21466 				CEX(wo0, wo5);
21467 				CEX(wo0, wo6);
21468 				CEX(wo1, wo2);
21469 				CEX(wo1, wo3);
21470 				CEX(wo1, wo4);
21471 				CEX(wo1, wo5);
21472 				CEX(wo1, wo6);
21473 				CEX(wo2, wo3);
21474 				CEX(wo2, wo4);
21475 				CEX(wo2, wo5);
21476 				CEX(wo2, wo6);
21477 				CEX(wo3, wo4);
21478 				CEX(wo3, wo5);
21479 				CEX(wo3, wo6);
21480 				CEX(wo4, wo5);
21481 				CEX(wo4, wo6);
21482 				CEX(wo5, wo6);
21483 			}
21484 			{
21485 				unsigned int nvof;	/* Next vertex offset value */
21486 				unsigned int vof;	/* Vertex offset value */
21487 				unsigned int vwe;	/* Vertex weighting */
21488 
21489 				vof = 0;				/* First vertex offset is 0 */
21490 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
21491 				wo0 = (wo0 >> 23);		/* Extract weighting value */
21492 				vwe = 256 - wo0;		/* Baricentric weighting */
21493 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21494 				ova1  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21495 				vof += nvof;			/* Move to next vertex */
21496 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
21497 				wo1 = (wo1 >> 23);		/* Extract weighting value */
21498 				vwe = wo0 - wo1;		/* Baricentric weighting */
21499 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21500 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21501 				vof += nvof;			/* Move to next vertex */
21502 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
21503 				wo2 = (wo2 >> 23);		/* Extract weighting value */
21504 				vwe = wo1 - wo2;		/* Baricentric weighting */
21505 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21506 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21507 				vof += nvof;			/* Move to next vertex */
21508 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
21509 				wo3 = (wo3 >> 23);		/* Extract weighting value */
21510 				vwe = wo2 - wo3;		/* Baricentric weighting */
21511 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21512 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21513 				vof += nvof;			/* Move to next vertex */
21514 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
21515 				wo4 = (wo4 >> 23);		/* Extract weighting value */
21516 				vwe = wo3 - wo4;		/* Baricentric weighting */
21517 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21518 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21519 				vof += nvof;			/* Move to next vertex */
21520 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
21521 				wo5 = (wo5 >> 23);		/* Extract weighting value */
21522 				vwe = wo4 - wo5;		/* Baricentric weighting */
21523 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21524 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21525 				vof += nvof;			/* Move to next vertex */
21526 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
21527 				wo6 = (wo6 >> 23);		/* Extract weighting value */
21528 				vwe = wo5 - wo6;		/* Baricentric weighting */
21529 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21530 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21531 				vof += nvof;			/* Move to next vertex */
21532 				vwe = wo6;				/* Baricentric weighting */
21533 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21534 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21535 			}
21536 		}
21537 		{
21538 			unsigned int oti;	/* Vertex offset value */
21539 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
21540 			op0[0] = OT_E(ot0, oti);	/* Write result */
21541 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
21542 			op0[1] = OT_E(ot1, oti);	/* Write result */
21543 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
21544 			op0[2] = OT_E(ot2, oti);	/* Write result */
21545 		}
21546 	}
21547 }
21548 #undef IT_WO
21549 #undef IT_IX
21550 #undef CEX
21551 #undef IM_O
21552 #undef IM_FE
21553 #undef IM_PE
21554 #undef OT_E
21555 
21556 void
imdi_k62_gen(genspec * g)21557 imdi_k62_gen(
21558 genspec *g			/* structure to be initialised */
21559 ) {
21560 	static unsigned char data[] = {
21561 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
21562 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21563 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21564 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21565 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21566 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21567 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21568 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
21569 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
21570 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
21571 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
21572 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21573 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21574 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21575 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21576 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21577 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21578 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21579 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21580 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21581 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
21582 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
21583 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21584 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21585 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
21586 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
21587 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21588 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21589 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21590 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21591 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21592 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21593 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
21594 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
21595 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21596 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21597 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21598 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21599 		0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21600 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
21601 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
21602 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
21603 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
21604 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
21605 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
21606 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
21607 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
21608 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
21609 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21610 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
21611 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
21612 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x33, 0x5f,
21613 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
21614 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
21615 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
21616 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
21617 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
21618 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
21619 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
21620 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21621 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21622 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21623 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21624 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
21625 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x36, 0x32,
21626 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21627 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21628 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
21629 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
21630 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
21631 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
21632 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
21633 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
21634 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
21635 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
21636 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
21637 		0x00, 0xf0, 0x04, 0x08
21638 	};	/* Structure image */
21639 
21640 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
21641 }
21642 
21643 void
imdi_k62_tab(tabspec * t)21644 imdi_k62_tab(
21645 tabspec *t			/* structure to be initialised */
21646 ) {
21647 	static unsigned char data[] = {
21648 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21649 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21650 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21651 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
21652 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
21653 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
21654 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21655 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
21656 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
21657 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21658 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
21659 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
21660 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
21661 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
21662 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
21663 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21664 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21665 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21666 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
21667 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21668 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21669 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
21670 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
21671 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
21672 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21673 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21674 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
21675 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
21676 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
21677 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
21678 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
21679 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
21680 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
21681 	};	/* Structure image */
21682 
21683 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
21684 }
21685 
21686 
21687 
21688 
21689 
21690 
21691 /* Integer Multi-Dimensional Interpolation */
21692 /* Interpolation Kernel Code */
21693 /* Generated by cgen */
21694 /* Copyright 2000 - 2002 Graeme W. Gill */
21695 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
21696 
21697 /* see the Licence.txt file for licencing details.*/
21698 
21699 
21700 /*
21701    Interpolation kernel specs:
21702 
21703    Input channels per pixel = 8
21704    Input channel 0 bits = 8
21705    Input channel 0 increment = 8
21706    Input channel 1 bits = 8
21707    Input channel 1 increment = 8
21708    Input channel 2 bits = 8
21709    Input channel 2 increment = 8
21710    Input channel 3 bits = 8
21711    Input channel 3 increment = 8
21712    Input channel 4 bits = 8
21713    Input channel 4 increment = 8
21714    Input channel 5 bits = 8
21715    Input channel 5 increment = 8
21716    Input channel 6 bits = 8
21717    Input channel 6 increment = 8
21718    Input channel 7 bits = 8
21719    Input channel 7 increment = 8
21720    Input is channel interleaved
21721    Input channels are separate words
21722    Input value extraction is done in input table lookup
21723 
21724    Output channels per pixel = 3
21725    Output channel 0 bits = 16
21726    Output channel 0 increment = 3
21727    Output channel 1 bits = 16
21728    Output channel 1 increment = 3
21729    Output channel 2 bits = 16
21730    Output channel 2 increment = 3
21731    Output is channel interleaved
21732 
21733    Output channels are separate words
21734    Weight+voffset bits       = 32
21735    Interpolation table index bits = 32
21736    Interpolation table max resolution = 9
21737  */
21738 
21739 /*
21740    Machine architecture specs:
21741 
21742    Little endian
21743    Reading and writing pixel values separately
21744    Pointer size = 32 bits
21745 
21746    Ordinal size  8 bits is known as 'unsigned char'
21747    Ordinal size 16 bits is known as 'unsigned short'
21748    Ordinal size 32 bits is known as 'unsigned int'
21749    Natural ordinal is 'unsigned int'
21750 
21751    Integer size  8 bits is known as 'signed char'
21752    Integer size 16 bits is known as 'short'
21753    Integer size 32 bits is known as 'int'
21754    Natural integer is 'int'
21755 
21756  */
21757 
21758 #ifndef  IMDI_INCLUDED
21759 #include <memory.h>
21760 #include "imdi_imp.h"
21761 #define  IMDI_INCLUDED
21762 #endif  /* IMDI_INCLUDED */
21763 
21764 #ifndef DEFINED_pointer
21765 #define DEFINED_pointer
21766 typedef unsigned char * pointer;
21767 #endif
21768 
21769 /* Input table interp. index */
21770 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
21771 
21772 /* Input table input weighting/offset value enty */
21773 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
21774 
21775 /* Conditional exchange for sorting */
21776 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
21777 
21778 /* Interpolation multi-dim. table access */
21779 #define IM_O(off) ((off) * 8)
21780 
21781 /* Interpolation table - get vertex values */
21782 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
21783 #define IM_PE(p, v) *((unsigned int *)((p) + 4 + (v) * 8))
21784 
21785 /* Output table indexes */
21786 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
21787 
21788 void
imdi_k63(imdi * s,void ** outp,void ** inp,unsigned int npix)21789 imdi_k63(
21790 imdi *s,			/* imdi context */
21791 void **outp,		/* pointer to output pointers */
21792 void **inp,		/* pointer to input pointers */
21793 unsigned int npix	/* Number of pixels to process */
21794 ) {
21795 	imdi_imp *p = (imdi_imp *)(s->impl);
21796 	unsigned char *ip0 = (unsigned char *)inp[0];
21797 	unsigned short *op0 = (unsigned short *)outp[0];
21798 	unsigned char *ep = ip0 + npix * 8 ;
21799 	pointer it0 = (pointer)p->in_tables[0];
21800 	pointer it1 = (pointer)p->in_tables[1];
21801 	pointer it2 = (pointer)p->in_tables[2];
21802 	pointer it3 = (pointer)p->in_tables[3];
21803 	pointer it4 = (pointer)p->in_tables[4];
21804 	pointer it5 = (pointer)p->in_tables[5];
21805 	pointer it6 = (pointer)p->in_tables[6];
21806 	pointer it7 = (pointer)p->in_tables[7];
21807 	pointer ot0 = (pointer)p->out_tables[0];
21808 	pointer ot1 = (pointer)p->out_tables[1];
21809 	pointer ot2 = (pointer)p->out_tables[2];
21810 	pointer im_base = (pointer)p->im_table;
21811 
21812 	for(;ip0 < ep; ip0 += 8, op0 += 3) {
21813 		unsigned int ova0;	/* Output value accumulator */
21814 		unsigned int ova1;	/* Output value partial accumulator */
21815 		{
21816 			pointer imp;
21817 			unsigned int wo0;	/* Weighting value and vertex offset variable */
21818 			unsigned int wo1;	/* Weighting value and vertex offset variable */
21819 			unsigned int wo2;	/* Weighting value and vertex offset variable */
21820 			unsigned int wo3;	/* Weighting value and vertex offset variable */
21821 			unsigned int wo4;	/* Weighting value and vertex offset variable */
21822 			unsigned int wo5;	/* Weighting value and vertex offset variable */
21823 			unsigned int wo6;	/* Weighting value and vertex offset variable */
21824 			unsigned int wo7;	/* Weighting value and vertex offset variable */
21825 			{
21826 				unsigned int ti_i;	/* Interpolation index variable */
21827 
21828 				ti_i  = IT_IX(it0, ip0[0]);
21829 				wo0   = IT_WO(it0, ip0[0]);
21830 				ti_i += IT_IX(it1, ip0[1]);
21831 				wo1   = IT_WO(it1, ip0[1]);
21832 				ti_i += IT_IX(it2, ip0[2]);
21833 				wo2   = IT_WO(it2, ip0[2]);
21834 				ti_i += IT_IX(it3, ip0[3]);
21835 				wo3   = IT_WO(it3, ip0[3]);
21836 				ti_i += IT_IX(it4, ip0[4]);
21837 				wo4   = IT_WO(it4, ip0[4]);
21838 				ti_i += IT_IX(it5, ip0[5]);
21839 				wo5   = IT_WO(it5, ip0[5]);
21840 				ti_i += IT_IX(it6, ip0[6]);
21841 				wo6   = IT_WO(it6, ip0[6]);
21842 				ti_i += IT_IX(it7, ip0[7]);
21843 				wo7   = IT_WO(it7, ip0[7]);
21844 
21845 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
21846 
21847 				/* Sort weighting values and vertex offset values */
21848 				CEX(wo0, wo1);
21849 				CEX(wo0, wo2);
21850 				CEX(wo0, wo3);
21851 				CEX(wo0, wo4);
21852 				CEX(wo0, wo5);
21853 				CEX(wo0, wo6);
21854 				CEX(wo0, wo7);
21855 				CEX(wo1, wo2);
21856 				CEX(wo1, wo3);
21857 				CEX(wo1, wo4);
21858 				CEX(wo1, wo5);
21859 				CEX(wo1, wo6);
21860 				CEX(wo1, wo7);
21861 				CEX(wo2, wo3);
21862 				CEX(wo2, wo4);
21863 				CEX(wo2, wo5);
21864 				CEX(wo2, wo6);
21865 				CEX(wo2, wo7);
21866 				CEX(wo3, wo4);
21867 				CEX(wo3, wo5);
21868 				CEX(wo3, wo6);
21869 				CEX(wo3, wo7);
21870 				CEX(wo4, wo5);
21871 				CEX(wo4, wo6);
21872 				CEX(wo4, wo7);
21873 				CEX(wo5, wo6);
21874 				CEX(wo5, wo7);
21875 				CEX(wo6, wo7);
21876 			}
21877 			{
21878 				unsigned int nvof;	/* Next vertex offset value */
21879 				unsigned int vof;	/* Vertex offset value */
21880 				unsigned int vwe;	/* Vertex weighting */
21881 
21882 				vof = 0;				/* First vertex offset is 0 */
21883 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
21884 				wo0 = (wo0 >> 23);		/* Extract weighting value */
21885 				vwe = 256 - wo0;		/* Baricentric weighting */
21886 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21887 				ova1  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21888 				vof += nvof;			/* Move to next vertex */
21889 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
21890 				wo1 = (wo1 >> 23);		/* Extract weighting value */
21891 				vwe = wo0 - wo1;		/* Baricentric weighting */
21892 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21893 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21894 				vof += nvof;			/* Move to next vertex */
21895 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
21896 				wo2 = (wo2 >> 23);		/* Extract weighting value */
21897 				vwe = wo1 - wo2;		/* Baricentric weighting */
21898 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21899 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21900 				vof += nvof;			/* Move to next vertex */
21901 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
21902 				wo3 = (wo3 >> 23);		/* Extract weighting value */
21903 				vwe = wo2 - wo3;		/* Baricentric weighting */
21904 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21905 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21906 				vof += nvof;			/* Move to next vertex */
21907 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
21908 				wo4 = (wo4 >> 23);		/* Extract weighting value */
21909 				vwe = wo3 - wo4;		/* Baricentric weighting */
21910 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21911 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21912 				vof += nvof;			/* Move to next vertex */
21913 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
21914 				wo5 = (wo5 >> 23);		/* Extract weighting value */
21915 				vwe = wo4 - wo5;		/* Baricentric weighting */
21916 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21917 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21918 				vof += nvof;			/* Move to next vertex */
21919 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
21920 				wo6 = (wo6 >> 23);		/* Extract weighting value */
21921 				vwe = wo5 - wo6;		/* Baricentric weighting */
21922 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21923 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21924 				vof += nvof;			/* Move to next vertex */
21925 				nvof = (wo7 & 0x7fffff);	/* Extract offset value */
21926 				wo7 = (wo7 >> 23);		/* Extract weighting value */
21927 				vwe = wo6 - wo7;		/* Baricentric weighting */
21928 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21929 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21930 				vof += nvof;			/* Move to next vertex */
21931 				vwe = wo7;				/* Baricentric weighting */
21932 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
21933 				ova1 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
21934 			}
21935 		}
21936 		{
21937 			unsigned int oti;	/* Vertex offset value */
21938 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
21939 			op0[0] = OT_E(ot0, oti);	/* Write result */
21940 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
21941 			op0[1] = OT_E(ot1, oti);	/* Write result */
21942 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
21943 			op0[2] = OT_E(ot2, oti);	/* Write result */
21944 		}
21945 	}
21946 }
21947 #undef IT_WO
21948 #undef IT_IX
21949 #undef CEX
21950 #undef IM_O
21951 #undef IM_FE
21952 #undef IM_PE
21953 #undef OT_E
21954 
21955 void
imdi_k63_gen(genspec * g)21956 imdi_k63_gen(
21957 genspec *g			/* structure to be initialised */
21958 ) {
21959 	static unsigned char data[] = {
21960 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21961 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21962 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21963 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21964 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21965 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21966 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21967 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21968 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21969 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21970 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21971 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21972 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21973 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21974 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21975 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21976 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21977 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21978 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21979 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21980 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
21981 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
21982 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21983 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21984 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
21985 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
21986 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21987 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21988 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21989 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21990 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21991 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21992 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
21993 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
21994 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21995 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21996 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21997 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
21998 		0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21999 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
22000 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
22001 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
22002 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
22003 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
22004 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
22005 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
22006 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
22007 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
22008 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22009 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
22010 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
22011 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x33, 0x5f,
22012 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
22013 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
22014 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
22015 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
22016 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
22017 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
22018 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
22019 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22020 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22021 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22022 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22023 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
22024 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x36, 0x33,
22025 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22026 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22027 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
22028 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
22029 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
22030 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
22031 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
22032 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
22033 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
22034 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
22035 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
22036 		0x00, 0xf0, 0x04, 0x08
22037 	};	/* Structure image */
22038 
22039 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
22040 }
22041 
22042 void
imdi_k63_tab(tabspec * t)22043 imdi_k63_tab(
22044 tabspec *t			/* structure to be initialised */
22045 ) {
22046 	static unsigned char data[] = {
22047 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22048 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22049 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22050 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
22051 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
22052 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
22053 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22054 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
22055 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
22056 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22057 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
22058 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
22059 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
22060 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
22061 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
22062 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22063 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22064 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22065 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
22066 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22067 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22068 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
22069 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
22070 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
22071 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22072 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22073 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
22074 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
22075 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22076 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22077 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
22078 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
22079 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
22080 	};	/* Structure image */
22081 
22082 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
22083 }
22084 
22085 
22086 
22087 
22088 
22089 
22090 /* Integer Multi-Dimensional Interpolation */
22091 /* Interpolation Kernel Code */
22092 /* Generated by cgen */
22093 /* Copyright 2000 - 2002 Graeme W. Gill */
22094 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
22095 
22096 /* see the Licence.txt file for licencing details.*/
22097 
22098 
22099 /*
22100    Interpolation kernel specs:
22101 
22102    Input channels per pixel = 1
22103    Input channel 0 bits = 8
22104    Input channel 0 increment = 1
22105    Input is channel interleaved
22106    Input channels are separate words
22107    Input value extraction is done in input table lookup
22108 
22109    Output channels per pixel = 4
22110    Output channel 0 bits = 16
22111    Output channel 0 increment = 4
22112    Output channel 1 bits = 16
22113    Output channel 1 increment = 4
22114    Output channel 2 bits = 16
22115    Output channel 2 increment = 4
22116    Output channel 3 bits = 16
22117    Output channel 3 increment = 4
22118    Output is channel interleaved
22119 
22120    Output channels are separate words
22121    Simplex table index bits       = 0
22122    Interpolation table index bits = 8
22123    Simplex table max resolution = 1
22124    Interpolation table max resolution = 255
22125  */
22126 
22127 /*
22128    Machine architecture specs:
22129 
22130    Little endian
22131    Reading and writing pixel values separately
22132    Pointer size = 32 bits
22133 
22134    Ordinal size  8 bits is known as 'unsigned char'
22135    Ordinal size 16 bits is known as 'unsigned short'
22136    Ordinal size 32 bits is known as 'unsigned int'
22137    Natural ordinal is 'unsigned int'
22138 
22139    Integer size  8 bits is known as 'signed char'
22140    Integer size 16 bits is known as 'short'
22141    Integer size 32 bits is known as 'int'
22142    Natural integer is 'int'
22143 
22144  */
22145 
22146 #ifndef  IMDI_INCLUDED
22147 #include <memory.h>
22148 #include "imdi_imp.h"
22149 #define  IMDI_INCLUDED
22150 #endif  /* IMDI_INCLUDED */
22151 
22152 #ifndef DEFINED_pointer
22153 #define DEFINED_pointer
22154 typedef unsigned char * pointer;
22155 #endif
22156 
22157 /* Input table inter & simplex indexes */
22158 #define IT_IT(p, off) *((unsigned char *)((p) + 0 + (off) * 1))
22159 
22160 /* Simplex weighting table access */
22161 #define SW_O(off) ((off) * 4)
22162 
22163 /* Simplex table - get weighting/offset value */
22164 #define SX_WO(p, v) *((unsigned short *)((p) + (v) * 2))
22165 
22166 /* Interpolation multi-dim. table access */
22167 #define IM_O(off) ((off) * 8)
22168 
22169 /* Interpolation table - get vertex values */
22170 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
22171 
22172 /* Output table indexes */
22173 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
22174 
22175 void
imdi_k64(imdi * s,void ** outp,void ** inp,unsigned int npix)22176 imdi_k64(
22177 imdi *s,			/* imdi context */
22178 void **outp,		/* pointer to output pointers */
22179 void **inp,		/* pointer to input pointers */
22180 unsigned int npix	/* Number of pixels to process */
22181 ) {
22182 	imdi_imp *p = (imdi_imp *)(s->impl);
22183 	unsigned char *ip0 = (unsigned char *)inp[0];
22184 	unsigned short *op0 = (unsigned short *)outp[0];
22185 	unsigned char *ep = ip0 + npix * 1 ;
22186 	pointer it0 = (pointer)p->in_tables[0];
22187 	pointer ot0 = (pointer)p->out_tables[0];
22188 	pointer ot1 = (pointer)p->out_tables[1];
22189 	pointer ot2 = (pointer)p->out_tables[2];
22190 	pointer ot3 = (pointer)p->out_tables[3];
22191 	pointer sw_base = (pointer)p->sw_table;
22192 	pointer im_base = (pointer)p->im_table;
22193 
22194 	for(;ip0 < ep; ip0 += 1, op0 += 4) {
22195 		unsigned int ova0;	/* Output value accumulator */
22196 		unsigned int ova1;	/* Output value accumulator */
22197 		{
22198 			pointer swp;
22199 			pointer imp;
22200 			{
22201 				unsigned int ti;	/* Simplex+Interpolation index variable */
22202 
22203 				ti  = IT_IT(it0, ip0[0]);
22204 
22205 				imp = im_base + IM_O(ti >> 0);		/* Extract interp. index and comp. entry */
22206 				swp = sw_base + SW_O(ti & 0x0);	/* Extract simplex index and comp. entry */
22207 			}
22208 			{
22209 				unsigned int vowr;	/* Vertex offset/weight value */
22210 				unsigned int vof;	/* Vertex offset value */
22211 				unsigned int vwe;	/* Vertex weighting */
22212 
22213 				vowr = SX_WO(swp, 0);	/* Read vertex offset+weighting values */
22214 				vof = (vowr & 0x7f);	/* Extract offset value */
22215 				vwe = (vowr >> 7);	/* Extract weighting value */
22216 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
22217 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
22218 				vowr = SX_WO(swp, 1);	/* Read vertex offset+weighting values */
22219 				vof = (vowr & 0x7f);	/* Extract offset value */
22220 				vwe = (vowr >> 7);	/* Extract weighting value */
22221 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
22222 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
22223 			}
22224 		}
22225 		{
22226 			unsigned int oti;	/* Vertex offset value */
22227 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
22228 			op0[0] = OT_E(ot0, oti);	/* Write result */
22229 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
22230 			op0[1] = OT_E(ot1, oti);	/* Write result */
22231 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
22232 			op0[2] = OT_E(ot2, oti);	/* Write result */
22233 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
22234 			op0[3] = OT_E(ot3, oti);	/* Write result */
22235 		}
22236 	}
22237 }
22238 #undef IT_IT
22239 #undef SW_O
22240 #undef SX_WO
22241 #undef IM_O
22242 #undef IM_FE
22243 #undef OT_E
22244 
22245 void
imdi_k64_gen(genspec * g)22246 imdi_k64_gen(
22247 genspec *g			/* structure to be initialised */
22248 ) {
22249 	static unsigned char data[] = {
22250 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22251 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22252 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22253 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22254 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22255 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22256 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22257 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22258 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22259 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22260 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22261 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22262 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22263 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22264 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22265 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22266 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22267 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22268 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22269 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22270 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22271 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22272 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22273 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22274 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
22275 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
22276 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22277 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22278 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22279 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22280 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22281 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22282 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22283 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22284 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22285 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22286 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22287 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22288 		0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22289 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
22290 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
22291 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
22292 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
22293 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
22294 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
22295 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
22296 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
22297 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
22298 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22299 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
22300 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
22301 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x34, 0x5f,
22302 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
22303 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
22304 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
22305 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
22306 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
22307 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
22308 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
22309 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22310 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22311 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22312 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22313 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
22314 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x36, 0x34,
22315 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22316 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22317 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
22318 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
22319 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
22320 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
22321 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
22322 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
22323 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
22324 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
22325 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
22326 		0x00, 0xf0, 0x04, 0x08
22327 	};	/* Structure image */
22328 
22329 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
22330 }
22331 
22332 void
imdi_k64_tab(tabspec * t)22333 imdi_k64_tab(
22334 tabspec *t			/* structure to be initialised */
22335 ) {
22336 	static unsigned char data[] = {
22337 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22338 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22339 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22340 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
22341 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
22342 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
22343 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22344 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
22345 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22346 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22347 		0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22348 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22349 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
22350 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
22351 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
22352 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22353 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22354 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
22355 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22356 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22357 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22358 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
22359 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
22360 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
22361 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22362 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22363 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
22364 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
22365 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22366 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22367 		0x10, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
22368 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
22369 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
22370 	};	/* Structure image */
22371 
22372 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
22373 }
22374 
22375 
22376 
22377 
22378 
22379 
22380 /* Integer Multi-Dimensional Interpolation */
22381 /* Interpolation Kernel Code */
22382 /* Generated by cgen */
22383 /* Copyright 2000 - 2002 Graeme W. Gill */
22384 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
22385 
22386 /* see the Licence.txt file for licencing details.*/
22387 
22388 
22389 /*
22390    Interpolation kernel specs:
22391 
22392    Input channels per pixel = 3
22393    Input channel 0 bits = 8
22394    Input channel 0 increment = 3
22395    Input channel 1 bits = 8
22396    Input channel 1 increment = 3
22397    Input channel 2 bits = 8
22398    Input channel 2 increment = 3
22399    Input is channel interleaved
22400    Input channels are separate words
22401    Input value extraction is done in input table lookup
22402 
22403    Output channels per pixel = 4
22404    Output channel 0 bits = 16
22405    Output channel 0 increment = 4
22406    Output channel 1 bits = 16
22407    Output channel 1 increment = 4
22408    Output channel 2 bits = 16
22409    Output channel 2 increment = 4
22410    Output channel 3 bits = 16
22411    Output channel 3 increment = 4
22412    Output is channel interleaved
22413 
22414    Output channels are separate words
22415    Simplex table index bits       = 12
22416    Interpolation table index bits = 20
22417    Simplex table max resolution = 16
22418    Interpolation table max resolution = 101
22419  */
22420 
22421 /*
22422    Machine architecture specs:
22423 
22424    Little endian
22425    Reading and writing pixel values separately
22426    Pointer size = 32 bits
22427 
22428    Ordinal size  8 bits is known as 'unsigned char'
22429    Ordinal size 16 bits is known as 'unsigned short'
22430    Ordinal size 32 bits is known as 'unsigned int'
22431    Natural ordinal is 'unsigned int'
22432 
22433    Integer size  8 bits is known as 'signed char'
22434    Integer size 16 bits is known as 'short'
22435    Integer size 32 bits is known as 'int'
22436    Natural integer is 'int'
22437 
22438  */
22439 
22440 #ifndef  IMDI_INCLUDED
22441 #include <memory.h>
22442 #include "imdi_imp.h"
22443 #define  IMDI_INCLUDED
22444 #endif  /* IMDI_INCLUDED */
22445 
22446 #ifndef DEFINED_pointer
22447 #define DEFINED_pointer
22448 typedef unsigned char * pointer;
22449 #endif
22450 
22451 /* Input table inter & simplex indexes */
22452 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
22453 
22454 /* Simplex weighting table access */
22455 #define SW_O(off) ((off) * 16)
22456 
22457 /* Simplex table - get weighting value */
22458 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
22459 
22460 /* Simplex table - get offset value */
22461 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
22462 
22463 /* Interpolation multi-dim. table access */
22464 #define IM_O(off) ((off) * 8)
22465 
22466 /* Interpolation table - get vertex values */
22467 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
22468 
22469 /* Output table indexes */
22470 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
22471 
22472 void
imdi_k65(imdi * s,void ** outp,void ** inp,unsigned int npix)22473 imdi_k65(
22474 imdi *s,			/* imdi context */
22475 void **outp,		/* pointer to output pointers */
22476 void **inp,		/* pointer to input pointers */
22477 unsigned int npix	/* Number of pixels to process */
22478 ) {
22479 	imdi_imp *p = (imdi_imp *)(s->impl);
22480 	unsigned char *ip0 = (unsigned char *)inp[0];
22481 	unsigned short *op0 = (unsigned short *)outp[0];
22482 	unsigned char *ep = ip0 + npix * 3 ;
22483 	pointer it0 = (pointer)p->in_tables[0];
22484 	pointer it1 = (pointer)p->in_tables[1];
22485 	pointer it2 = (pointer)p->in_tables[2];
22486 	pointer ot0 = (pointer)p->out_tables[0];
22487 	pointer ot1 = (pointer)p->out_tables[1];
22488 	pointer ot2 = (pointer)p->out_tables[2];
22489 	pointer ot3 = (pointer)p->out_tables[3];
22490 	pointer sw_base = (pointer)p->sw_table;
22491 	pointer im_base = (pointer)p->im_table;
22492 
22493 	for(;ip0 < ep; ip0 += 3, op0 += 4) {
22494 		unsigned int ova0;	/* Output value accumulator */
22495 		unsigned int ova1;	/* Output value accumulator */
22496 		{
22497 			pointer swp;
22498 			pointer imp;
22499 			{
22500 				unsigned int ti;	/* Simplex+Interpolation index variable */
22501 
22502 				ti  = IT_IT(it0, ip0[0]);
22503 				ti += IT_IT(it1, ip0[1]);
22504 				ti += IT_IT(it2, ip0[2]);
22505 
22506 				imp = im_base + IM_O(ti >> 12);		/* Extract interp. index and comp. entry */
22507 				swp = sw_base + SW_O(ti & 0xfff);	/* Extract simplex index and comp. entry */
22508 			}
22509 			{
22510 				unsigned int vof;	/* Vertex offset value */
22511 				unsigned int vwe;	/* Vertex weighting */
22512 
22513 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
22514 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
22515 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
22516 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
22517 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
22518 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
22519 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
22520 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
22521 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
22522 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
22523 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
22524 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
22525 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
22526 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
22527 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
22528 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
22529 			}
22530 		}
22531 		{
22532 			unsigned int oti;	/* Vertex offset value */
22533 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
22534 			op0[0] = OT_E(ot0, oti);	/* Write result */
22535 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
22536 			op0[1] = OT_E(ot1, oti);	/* Write result */
22537 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
22538 			op0[2] = OT_E(ot2, oti);	/* Write result */
22539 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
22540 			op0[3] = OT_E(ot3, oti);	/* Write result */
22541 		}
22542 	}
22543 }
22544 #undef IT_IT
22545 #undef SW_O
22546 #undef SX_WE
22547 #undef SX_VO
22548 #undef IM_O
22549 #undef IM_FE
22550 #undef OT_E
22551 
22552 void
imdi_k65_gen(genspec * g)22553 imdi_k65_gen(
22554 genspec *g			/* structure to be initialised */
22555 ) {
22556 	static unsigned char data[] = {
22557 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
22558 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22559 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22560 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22561 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22562 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22563 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22564 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
22565 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
22566 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22567 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22568 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22569 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22570 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22571 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22572 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22573 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22574 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22575 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22576 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22577 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22578 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22579 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22580 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22581 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
22582 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
22583 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22584 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22585 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22586 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22587 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22588 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22589 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22590 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22591 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22592 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22593 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22594 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22595 		0x65, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22596 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
22597 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
22598 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
22599 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
22600 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
22601 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
22602 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
22603 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
22604 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
22605 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22606 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
22607 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
22608 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x34, 0x5f,
22609 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
22610 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
22611 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
22612 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
22613 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
22614 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
22615 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
22616 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22617 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22618 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22619 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22620 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
22621 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x36, 0x35,
22622 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22623 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22624 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
22625 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
22626 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
22627 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
22628 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
22629 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
22630 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
22631 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
22632 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
22633 		0x00, 0xf0, 0x04, 0x08
22634 	};	/* Structure image */
22635 
22636 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
22637 }
22638 
22639 void
imdi_k65_tab(tabspec * t)22640 imdi_k65_tab(
22641 tabspec *t			/* structure to be initialised */
22642 ) {
22643 	static unsigned char data[] = {
22644 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22645 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22646 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22647 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
22648 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
22649 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
22650 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
22651 		0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
22652 		0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
22653 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22654 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22655 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22656 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
22657 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22658 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
22659 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22660 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22661 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
22662 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22663 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22664 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22665 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
22666 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
22667 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
22668 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22669 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22670 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
22671 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
22672 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22673 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22674 		0x10, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
22675 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
22676 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
22677 	};	/* Structure image */
22678 
22679 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
22680 }
22681 
22682 
22683 
22684 
22685 
22686 
22687 /* Integer Multi-Dimensional Interpolation */
22688 /* Interpolation Kernel Code */
22689 /* Generated by cgen */
22690 /* Copyright 2000 - 2002 Graeme W. Gill */
22691 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
22692 
22693 /* see the Licence.txt file for licencing details.*/
22694 
22695 
22696 /*
22697    Interpolation kernel specs:
22698 
22699    Input channels per pixel = 4
22700    Input channel 0 bits = 8
22701    Input channel 0 increment = 4
22702    Input channel 1 bits = 8
22703    Input channel 1 increment = 4
22704    Input channel 2 bits = 8
22705    Input channel 2 increment = 4
22706    Input channel 3 bits = 8
22707    Input channel 3 increment = 4
22708    Input is channel interleaved
22709    Input channels are separate words
22710    Input value extraction is done in input table lookup
22711 
22712    Output channels per pixel = 4
22713    Output channel 0 bits = 16
22714    Output channel 0 increment = 4
22715    Output channel 1 bits = 16
22716    Output channel 1 increment = 4
22717    Output channel 2 bits = 16
22718    Output channel 2 increment = 4
22719    Output channel 3 bits = 16
22720    Output channel 3 increment = 4
22721    Output is channel interleaved
22722 
22723    Output channels are separate words
22724    Simplex table index bits       = 32
22725    Interpolation table index bits = 32
22726    Simplex table max resolution = 255
22727    Interpolation table max resolution = 39
22728  */
22729 
22730 /*
22731    Machine architecture specs:
22732 
22733    Little endian
22734    Reading and writing pixel values separately
22735    Pointer size = 32 bits
22736 
22737    Ordinal size  8 bits is known as 'unsigned char'
22738    Ordinal size 16 bits is known as 'unsigned short'
22739    Ordinal size 32 bits is known as 'unsigned int'
22740    Natural ordinal is 'unsigned int'
22741 
22742    Integer size  8 bits is known as 'signed char'
22743    Integer size 16 bits is known as 'short'
22744    Integer size 32 bits is known as 'int'
22745    Natural integer is 'int'
22746 
22747  */
22748 
22749 #ifndef  IMDI_INCLUDED
22750 #include <memory.h>
22751 #include "imdi_imp.h"
22752 #define  IMDI_INCLUDED
22753 #endif  /* IMDI_INCLUDED */
22754 
22755 #ifndef DEFINED_pointer
22756 #define DEFINED_pointer
22757 typedef unsigned char * pointer;
22758 #endif
22759 
22760 /* Input table interp. index */
22761 #define IT_IX(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
22762 
22763 /* Input table simplex index enty */
22764 #define IT_SX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
22765 
22766 /* Simplex weighting table access */
22767 #define SW_O(off) ((off) * 20)
22768 
22769 /* Simplex table - get weighting value */
22770 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
22771 
22772 /* Simplex table - get offset value */
22773 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
22774 
22775 /* Interpolation multi-dim. table access */
22776 #define IM_O(off) ((off) * 8)
22777 
22778 /* Interpolation table - get vertex values */
22779 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
22780 
22781 /* Output table indexes */
22782 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
22783 
22784 void
imdi_k66(imdi * s,void ** outp,void ** inp,unsigned int npix)22785 imdi_k66(
22786 imdi *s,			/* imdi context */
22787 void **outp,		/* pointer to output pointers */
22788 void **inp,		/* pointer to input pointers */
22789 unsigned int npix	/* Number of pixels to process */
22790 ) {
22791 	imdi_imp *p = (imdi_imp *)(s->impl);
22792 	unsigned char *ip0 = (unsigned char *)inp[0];
22793 	unsigned short *op0 = (unsigned short *)outp[0];
22794 	unsigned char *ep = ip0 + npix * 4 ;
22795 	pointer it0 = (pointer)p->in_tables[0];
22796 	pointer it1 = (pointer)p->in_tables[1];
22797 	pointer it2 = (pointer)p->in_tables[2];
22798 	pointer it3 = (pointer)p->in_tables[3];
22799 	pointer ot0 = (pointer)p->out_tables[0];
22800 	pointer ot1 = (pointer)p->out_tables[1];
22801 	pointer ot2 = (pointer)p->out_tables[2];
22802 	pointer ot3 = (pointer)p->out_tables[3];
22803 	pointer sw_base = (pointer)p->sw_table;
22804 	pointer im_base = (pointer)p->im_table;
22805 
22806 	for(;ip0 < ep; ip0 += 4, op0 += 4) {
22807 		unsigned int ova0;	/* Output value accumulator */
22808 		unsigned int ova1;	/* Output value accumulator */
22809 		{
22810 			pointer swp;
22811 			pointer imp;
22812 			{
22813 				unsigned int ti_s;	/* Simplex index variable */
22814 				unsigned int ti_i;	/* Interpolation index variable */
22815 
22816 				ti_i  = IT_IX(it0, ip0[0]);
22817 				ti_s  = IT_SX(it0, ip0[0]);
22818 				ti_i += IT_IX(it1, ip0[1]);
22819 				ti_s += IT_SX(it1, ip0[1]);
22820 				ti_i += IT_IX(it2, ip0[2]);
22821 				ti_s += IT_SX(it2, ip0[2]);
22822 				ti_i += IT_IX(it3, ip0[3]);
22823 				ti_s += IT_SX(it3, ip0[3]);
22824 
22825 				swp = sw_base + SW_O(ti_s);		/* Compute simplex table entry pointer */
22826 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
22827 			}
22828 			{
22829 				unsigned int vof;	/* Vertex offset value */
22830 				unsigned int vwe;	/* Vertex weighting */
22831 
22832 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
22833 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
22834 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
22835 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
22836 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
22837 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
22838 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
22839 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
22840 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
22841 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
22842 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
22843 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
22844 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
22845 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
22846 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
22847 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
22848 				vof = SX_VO(swp, 4);	/* Read vertex offset value */
22849 				vwe = SX_WE(swp, 4);	/* Read vertex weighting value */
22850 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
22851 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
22852 			}
22853 		}
22854 		{
22855 			unsigned int oti;	/* Vertex offset value */
22856 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
22857 			op0[0] = OT_E(ot0, oti);	/* Write result */
22858 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
22859 			op0[1] = OT_E(ot1, oti);	/* Write result */
22860 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
22861 			op0[2] = OT_E(ot2, oti);	/* Write result */
22862 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
22863 			op0[3] = OT_E(ot3, oti);	/* Write result */
22864 		}
22865 	}
22866 }
22867 #undef IT_IX
22868 #undef IT_SX
22869 #undef SW_O
22870 #undef SX_WE
22871 #undef SX_VO
22872 #undef IM_O
22873 #undef IM_FE
22874 #undef OT_E
22875 
22876 void
imdi_k66_gen(genspec * g)22877 imdi_k66_gen(
22878 genspec *g			/* structure to be initialised */
22879 ) {
22880 	static unsigned char data[] = {
22881 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
22882 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22883 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22884 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22885 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22886 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22887 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22888 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
22889 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
22890 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22891 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22892 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22893 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22894 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22895 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22896 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22897 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22898 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22899 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22900 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22901 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22902 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22903 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22904 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22905 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
22906 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
22907 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22908 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22909 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22910 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22911 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22912 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22913 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22914 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22915 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22916 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22917 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22918 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22919 		0x27, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
22920 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
22921 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
22922 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
22923 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
22924 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
22925 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
22926 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
22927 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
22928 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
22929 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22930 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
22931 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
22932 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x34, 0x5f,
22933 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
22934 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
22935 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
22936 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
22937 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
22938 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
22939 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
22940 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22941 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22942 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22943 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22944 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
22945 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x36, 0x36,
22946 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22947 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22948 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
22949 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
22950 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
22951 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
22952 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
22953 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
22954 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
22955 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
22956 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
22957 		0x00, 0xf0, 0x04, 0x08
22958 	};	/* Structure image */
22959 
22960 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
22961 }
22962 
22963 void
imdi_k66_tab(tabspec * t)22964 imdi_k66_tab(
22965 tabspec *t			/* structure to be initialised */
22966 ) {
22967 	static unsigned char data[] = {
22968 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22969 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22970 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22971 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
22972 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
22973 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
22974 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22975 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
22976 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
22977 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22978 		0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22979 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22980 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
22981 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22982 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
22983 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22984 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
22985 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
22986 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22987 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22988 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
22989 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
22990 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
22991 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
22992 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22993 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22994 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
22995 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
22996 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22997 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
22998 		0x10, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
22999 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
23000 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
23001 	};	/* Structure image */
23002 
23003 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
23004 }
23005 
23006 
23007 
23008 
23009 
23010 
23011 /* Integer Multi-Dimensional Interpolation */
23012 /* Interpolation Kernel Code */
23013 /* Generated by cgen */
23014 /* Copyright 2000 - 2002 Graeme W. Gill */
23015 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
23016 
23017 /* see the Licence.txt file for licencing details.*/
23018 
23019 
23020 /*
23021    Interpolation kernel specs:
23022 
23023    Input channels per pixel = 5
23024    Input channel 0 bits = 8
23025    Input channel 0 increment = 5
23026    Input channel 1 bits = 8
23027    Input channel 1 increment = 5
23028    Input channel 2 bits = 8
23029    Input channel 2 increment = 5
23030    Input channel 3 bits = 8
23031    Input channel 3 increment = 5
23032    Input channel 4 bits = 8
23033    Input channel 4 increment = 5
23034    Input is channel interleaved
23035    Input channels are separate words
23036    Input value extraction is done in input table lookup
23037 
23038    Output channels per pixel = 4
23039    Output channel 0 bits = 16
23040    Output channel 0 increment = 4
23041    Output channel 1 bits = 16
23042    Output channel 1 increment = 4
23043    Output channel 2 bits = 16
23044    Output channel 2 increment = 4
23045    Output channel 3 bits = 16
23046    Output channel 3 increment = 4
23047    Output is channel interleaved
23048 
23049    Output channels are separate words
23050    Weight+voffset bits       = 32
23051    Interpolation table index bits = 32
23052    Interpolation table max resolution = 53
23053  */
23054 
23055 /*
23056    Machine architecture specs:
23057 
23058    Little endian
23059    Reading and writing pixel values separately
23060    Pointer size = 32 bits
23061 
23062    Ordinal size  8 bits is known as 'unsigned char'
23063    Ordinal size 16 bits is known as 'unsigned short'
23064    Ordinal size 32 bits is known as 'unsigned int'
23065    Natural ordinal is 'unsigned int'
23066 
23067    Integer size  8 bits is known as 'signed char'
23068    Integer size 16 bits is known as 'short'
23069    Integer size 32 bits is known as 'int'
23070    Natural integer is 'int'
23071 
23072  */
23073 
23074 #ifndef  IMDI_INCLUDED
23075 #include <memory.h>
23076 #include "imdi_imp.h"
23077 #define  IMDI_INCLUDED
23078 #endif  /* IMDI_INCLUDED */
23079 
23080 #ifndef DEFINED_pointer
23081 #define DEFINED_pointer
23082 typedef unsigned char * pointer;
23083 #endif
23084 
23085 /* Input table interp. index */
23086 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
23087 
23088 /* Input table input weighting/offset value enty */
23089 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
23090 
23091 /* Conditional exchange for sorting */
23092 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
23093 
23094 /* Interpolation multi-dim. table access */
23095 #define IM_O(off) ((off) * 8)
23096 
23097 /* Interpolation table - get vertex values */
23098 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
23099 
23100 /* Output table indexes */
23101 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
23102 
23103 void
imdi_k67(imdi * s,void ** outp,void ** inp,unsigned int npix)23104 imdi_k67(
23105 imdi *s,			/* imdi context */
23106 void **outp,		/* pointer to output pointers */
23107 void **inp,		/* pointer to input pointers */
23108 unsigned int npix	/* Number of pixels to process */
23109 ) {
23110 	imdi_imp *p = (imdi_imp *)(s->impl);
23111 	unsigned char *ip0 = (unsigned char *)inp[0];
23112 	unsigned short *op0 = (unsigned short *)outp[0];
23113 	unsigned char *ep = ip0 + npix * 5 ;
23114 	pointer it0 = (pointer)p->in_tables[0];
23115 	pointer it1 = (pointer)p->in_tables[1];
23116 	pointer it2 = (pointer)p->in_tables[2];
23117 	pointer it3 = (pointer)p->in_tables[3];
23118 	pointer it4 = (pointer)p->in_tables[4];
23119 	pointer ot0 = (pointer)p->out_tables[0];
23120 	pointer ot1 = (pointer)p->out_tables[1];
23121 	pointer ot2 = (pointer)p->out_tables[2];
23122 	pointer ot3 = (pointer)p->out_tables[3];
23123 	pointer im_base = (pointer)p->im_table;
23124 
23125 	for(;ip0 < ep; ip0 += 5, op0 += 4) {
23126 		unsigned int ova0;	/* Output value accumulator */
23127 		unsigned int ova1;	/* Output value accumulator */
23128 		{
23129 			pointer imp;
23130 			unsigned int wo0;	/* Weighting value and vertex offset variable */
23131 			unsigned int wo1;	/* Weighting value and vertex offset variable */
23132 			unsigned int wo2;	/* Weighting value and vertex offset variable */
23133 			unsigned int wo3;	/* Weighting value and vertex offset variable */
23134 			unsigned int wo4;	/* Weighting value and vertex offset variable */
23135 			{
23136 				unsigned int ti_i;	/* Interpolation index variable */
23137 
23138 				ti_i  = IT_IX(it0, ip0[0]);
23139 				wo0   = IT_WO(it0, ip0[0]);
23140 				ti_i += IT_IX(it1, ip0[1]);
23141 				wo1   = IT_WO(it1, ip0[1]);
23142 				ti_i += IT_IX(it2, ip0[2]);
23143 				wo2   = IT_WO(it2, ip0[2]);
23144 				ti_i += IT_IX(it3, ip0[3]);
23145 				wo3   = IT_WO(it3, ip0[3]);
23146 				ti_i += IT_IX(it4, ip0[4]);
23147 				wo4   = IT_WO(it4, ip0[4]);
23148 
23149 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
23150 
23151 				/* Sort weighting values and vertex offset values */
23152 				CEX(wo0, wo1);
23153 				CEX(wo0, wo2);
23154 				CEX(wo0, wo3);
23155 				CEX(wo0, wo4);
23156 				CEX(wo1, wo2);
23157 				CEX(wo1, wo3);
23158 				CEX(wo1, wo4);
23159 				CEX(wo2, wo3);
23160 				CEX(wo2, wo4);
23161 				CEX(wo3, wo4);
23162 			}
23163 			{
23164 				unsigned int nvof;	/* Next vertex offset value */
23165 				unsigned int vof;	/* Vertex offset value */
23166 				unsigned int vwe;	/* Vertex weighting */
23167 
23168 				vof = 0;				/* First vertex offset is 0 */
23169 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
23170 				wo0 = (wo0 >> 23);		/* Extract weighting value */
23171 				vwe = 256 - wo0;		/* Baricentric weighting */
23172 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23173 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23174 				vof += nvof;			/* Move to next vertex */
23175 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
23176 				wo1 = (wo1 >> 23);		/* Extract weighting value */
23177 				vwe = wo0 - wo1;		/* Baricentric weighting */
23178 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23179 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23180 				vof += nvof;			/* Move to next vertex */
23181 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
23182 				wo2 = (wo2 >> 23);		/* Extract weighting value */
23183 				vwe = wo1 - wo2;		/* Baricentric weighting */
23184 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23185 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23186 				vof += nvof;			/* Move to next vertex */
23187 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
23188 				wo3 = (wo3 >> 23);		/* Extract weighting value */
23189 				vwe = wo2 - wo3;		/* Baricentric weighting */
23190 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23191 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23192 				vof += nvof;			/* Move to next vertex */
23193 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
23194 				wo4 = (wo4 >> 23);		/* Extract weighting value */
23195 				vwe = wo3 - wo4;		/* Baricentric weighting */
23196 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23197 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23198 				vof += nvof;			/* Move to next vertex */
23199 				vwe = wo4;				/* Baricentric weighting */
23200 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23201 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23202 			}
23203 		}
23204 		{
23205 			unsigned int oti;	/* Vertex offset value */
23206 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
23207 			op0[0] = OT_E(ot0, oti);	/* Write result */
23208 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
23209 			op0[1] = OT_E(ot1, oti);	/* Write result */
23210 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
23211 			op0[2] = OT_E(ot2, oti);	/* Write result */
23212 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
23213 			op0[3] = OT_E(ot3, oti);	/* Write result */
23214 		}
23215 	}
23216 }
23217 #undef IT_WO
23218 #undef IT_IX
23219 #undef CEX
23220 #undef IM_O
23221 #undef IM_FE
23222 #undef OT_E
23223 
23224 void
imdi_k67_gen(genspec * g)23225 imdi_k67_gen(
23226 genspec *g			/* structure to be initialised */
23227 ) {
23228 	static unsigned char data[] = {
23229 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
23230 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23231 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23232 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23233 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23234 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23235 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23236 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
23237 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
23238 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
23239 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23240 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23241 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23242 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23243 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23244 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23245 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23246 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23247 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23248 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23249 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
23250 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
23251 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23252 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23253 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
23254 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
23255 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23256 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23257 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23258 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23259 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23260 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23261 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
23262 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
23263 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23264 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23265 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23266 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23267 		0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23268 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
23269 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
23270 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
23271 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
23272 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
23273 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
23274 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
23275 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
23276 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
23277 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23278 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
23279 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
23280 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x34, 0x5f,
23281 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
23282 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
23283 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
23284 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
23285 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
23286 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
23287 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
23288 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23289 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23290 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23291 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23292 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
23293 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x36, 0x37,
23294 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23295 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23296 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
23297 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
23298 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
23299 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
23300 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
23301 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
23302 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
23303 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
23304 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
23305 		0x00, 0xf0, 0x04, 0x08
23306 	};	/* Structure image */
23307 
23308 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
23309 }
23310 
23311 void
imdi_k67_tab(tabspec * t)23312 imdi_k67_tab(
23313 tabspec *t			/* structure to be initialised */
23314 ) {
23315 	static unsigned char data[] = {
23316 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23317 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23318 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23319 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
23320 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
23321 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
23322 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23323 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
23324 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
23325 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23326 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
23327 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
23328 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
23329 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
23330 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
23331 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23332 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23333 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
23334 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23335 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23336 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23337 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
23338 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
23339 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
23340 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23341 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23342 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
23343 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
23344 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
23345 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
23346 		0x10, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
23347 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
23348 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
23349 	};	/* Structure image */
23350 
23351 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
23352 }
23353 
23354 
23355 
23356 
23357 
23358 
23359 /* Integer Multi-Dimensional Interpolation */
23360 /* Interpolation Kernel Code */
23361 /* Generated by cgen */
23362 /* Copyright 2000 - 2002 Graeme W. Gill */
23363 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
23364 
23365 /* see the Licence.txt file for licencing details.*/
23366 
23367 
23368 /*
23369    Interpolation kernel specs:
23370 
23371    Input channels per pixel = 6
23372    Input channel 0 bits = 8
23373    Input channel 0 increment = 6
23374    Input channel 1 bits = 8
23375    Input channel 1 increment = 6
23376    Input channel 2 bits = 8
23377    Input channel 2 increment = 6
23378    Input channel 3 bits = 8
23379    Input channel 3 increment = 6
23380    Input channel 4 bits = 8
23381    Input channel 4 increment = 6
23382    Input channel 5 bits = 8
23383    Input channel 5 increment = 6
23384    Input is channel interleaved
23385    Input channels are separate words
23386    Input value extraction is done in input table lookup
23387 
23388    Output channels per pixel = 4
23389    Output channel 0 bits = 16
23390    Output channel 0 increment = 4
23391    Output channel 1 bits = 16
23392    Output channel 1 increment = 4
23393    Output channel 2 bits = 16
23394    Output channel 2 increment = 4
23395    Output channel 3 bits = 16
23396    Output channel 3 increment = 4
23397    Output is channel interleaved
23398 
23399    Output channels are separate words
23400    Weight+voffset bits       = 32
23401    Interpolation table index bits = 32
23402    Interpolation table max resolution = 24
23403  */
23404 
23405 /*
23406    Machine architecture specs:
23407 
23408    Little endian
23409    Reading and writing pixel values separately
23410    Pointer size = 32 bits
23411 
23412    Ordinal size  8 bits is known as 'unsigned char'
23413    Ordinal size 16 bits is known as 'unsigned short'
23414    Ordinal size 32 bits is known as 'unsigned int'
23415    Natural ordinal is 'unsigned int'
23416 
23417    Integer size  8 bits is known as 'signed char'
23418    Integer size 16 bits is known as 'short'
23419    Integer size 32 bits is known as 'int'
23420    Natural integer is 'int'
23421 
23422  */
23423 
23424 #ifndef  IMDI_INCLUDED
23425 #include <memory.h>
23426 #include "imdi_imp.h"
23427 #define  IMDI_INCLUDED
23428 #endif  /* IMDI_INCLUDED */
23429 
23430 #ifndef DEFINED_pointer
23431 #define DEFINED_pointer
23432 typedef unsigned char * pointer;
23433 #endif
23434 
23435 /* Input table interp. index */
23436 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
23437 
23438 /* Input table input weighting/offset value enty */
23439 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
23440 
23441 /* Conditional exchange for sorting */
23442 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
23443 
23444 /* Interpolation multi-dim. table access */
23445 #define IM_O(off) ((off) * 8)
23446 
23447 /* Interpolation table - get vertex values */
23448 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
23449 
23450 /* Output table indexes */
23451 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
23452 
23453 void
imdi_k68(imdi * s,void ** outp,void ** inp,unsigned int npix)23454 imdi_k68(
23455 imdi *s,			/* imdi context */
23456 void **outp,		/* pointer to output pointers */
23457 void **inp,		/* pointer to input pointers */
23458 unsigned int npix	/* Number of pixels to process */
23459 ) {
23460 	imdi_imp *p = (imdi_imp *)(s->impl);
23461 	unsigned char *ip0 = (unsigned char *)inp[0];
23462 	unsigned short *op0 = (unsigned short *)outp[0];
23463 	unsigned char *ep = ip0 + npix * 6 ;
23464 	pointer it0 = (pointer)p->in_tables[0];
23465 	pointer it1 = (pointer)p->in_tables[1];
23466 	pointer it2 = (pointer)p->in_tables[2];
23467 	pointer it3 = (pointer)p->in_tables[3];
23468 	pointer it4 = (pointer)p->in_tables[4];
23469 	pointer it5 = (pointer)p->in_tables[5];
23470 	pointer ot0 = (pointer)p->out_tables[0];
23471 	pointer ot1 = (pointer)p->out_tables[1];
23472 	pointer ot2 = (pointer)p->out_tables[2];
23473 	pointer ot3 = (pointer)p->out_tables[3];
23474 	pointer im_base = (pointer)p->im_table;
23475 
23476 	for(;ip0 < ep; ip0 += 6, op0 += 4) {
23477 		unsigned int ova0;	/* Output value accumulator */
23478 		unsigned int ova1;	/* Output value accumulator */
23479 		{
23480 			pointer imp;
23481 			unsigned int wo0;	/* Weighting value and vertex offset variable */
23482 			unsigned int wo1;	/* Weighting value and vertex offset variable */
23483 			unsigned int wo2;	/* Weighting value and vertex offset variable */
23484 			unsigned int wo3;	/* Weighting value and vertex offset variable */
23485 			unsigned int wo4;	/* Weighting value and vertex offset variable */
23486 			unsigned int wo5;	/* Weighting value and vertex offset variable */
23487 			{
23488 				unsigned int ti_i;	/* Interpolation index variable */
23489 
23490 				ti_i  = IT_IX(it0, ip0[0]);
23491 				wo0   = IT_WO(it0, ip0[0]);
23492 				ti_i += IT_IX(it1, ip0[1]);
23493 				wo1   = IT_WO(it1, ip0[1]);
23494 				ti_i += IT_IX(it2, ip0[2]);
23495 				wo2   = IT_WO(it2, ip0[2]);
23496 				ti_i += IT_IX(it3, ip0[3]);
23497 				wo3   = IT_WO(it3, ip0[3]);
23498 				ti_i += IT_IX(it4, ip0[4]);
23499 				wo4   = IT_WO(it4, ip0[4]);
23500 				ti_i += IT_IX(it5, ip0[5]);
23501 				wo5   = IT_WO(it5, ip0[5]);
23502 
23503 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
23504 
23505 				/* Sort weighting values and vertex offset values */
23506 				CEX(wo0, wo1);
23507 				CEX(wo0, wo2);
23508 				CEX(wo0, wo3);
23509 				CEX(wo0, wo4);
23510 				CEX(wo0, wo5);
23511 				CEX(wo1, wo2);
23512 				CEX(wo1, wo3);
23513 				CEX(wo1, wo4);
23514 				CEX(wo1, wo5);
23515 				CEX(wo2, wo3);
23516 				CEX(wo2, wo4);
23517 				CEX(wo2, wo5);
23518 				CEX(wo3, wo4);
23519 				CEX(wo3, wo5);
23520 				CEX(wo4, wo5);
23521 			}
23522 			{
23523 				unsigned int nvof;	/* Next vertex offset value */
23524 				unsigned int vof;	/* Vertex offset value */
23525 				unsigned int vwe;	/* Vertex weighting */
23526 
23527 				vof = 0;				/* First vertex offset is 0 */
23528 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
23529 				wo0 = (wo0 >> 23);		/* Extract weighting value */
23530 				vwe = 256 - wo0;		/* Baricentric weighting */
23531 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23532 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23533 				vof += nvof;			/* Move to next vertex */
23534 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
23535 				wo1 = (wo1 >> 23);		/* Extract weighting value */
23536 				vwe = wo0 - wo1;		/* Baricentric weighting */
23537 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23538 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23539 				vof += nvof;			/* Move to next vertex */
23540 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
23541 				wo2 = (wo2 >> 23);		/* Extract weighting value */
23542 				vwe = wo1 - wo2;		/* Baricentric weighting */
23543 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23544 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23545 				vof += nvof;			/* Move to next vertex */
23546 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
23547 				wo3 = (wo3 >> 23);		/* Extract weighting value */
23548 				vwe = wo2 - wo3;		/* Baricentric weighting */
23549 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23550 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23551 				vof += nvof;			/* Move to next vertex */
23552 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
23553 				wo4 = (wo4 >> 23);		/* Extract weighting value */
23554 				vwe = wo3 - wo4;		/* Baricentric weighting */
23555 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23556 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23557 				vof += nvof;			/* Move to next vertex */
23558 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
23559 				wo5 = (wo5 >> 23);		/* Extract weighting value */
23560 				vwe = wo4 - wo5;		/* Baricentric weighting */
23561 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23562 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23563 				vof += nvof;			/* Move to next vertex */
23564 				vwe = wo5;				/* Baricentric weighting */
23565 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23566 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23567 			}
23568 		}
23569 		{
23570 			unsigned int oti;	/* Vertex offset value */
23571 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
23572 			op0[0] = OT_E(ot0, oti);	/* Write result */
23573 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
23574 			op0[1] = OT_E(ot1, oti);	/* Write result */
23575 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
23576 			op0[2] = OT_E(ot2, oti);	/* Write result */
23577 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
23578 			op0[3] = OT_E(ot3, oti);	/* Write result */
23579 		}
23580 	}
23581 }
23582 #undef IT_WO
23583 #undef IT_IX
23584 #undef CEX
23585 #undef IM_O
23586 #undef IM_FE
23587 #undef OT_E
23588 
23589 void
imdi_k68_gen(genspec * g)23590 imdi_k68_gen(
23591 genspec *g			/* structure to be initialised */
23592 ) {
23593 	static unsigned char data[] = {
23594 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
23595 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23596 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23597 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23598 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23599 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23600 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23601 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
23602 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
23603 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
23604 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23605 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23606 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23607 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23608 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23609 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23610 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23611 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23612 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23613 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23614 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
23615 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
23616 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23617 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23618 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
23619 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
23620 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23621 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23622 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23623 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23624 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23625 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23626 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
23627 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
23628 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23629 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23630 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23631 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23632 		0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23633 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
23634 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
23635 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
23636 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
23637 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
23638 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
23639 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
23640 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
23641 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
23642 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23643 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
23644 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
23645 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x34, 0x5f,
23646 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
23647 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
23648 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
23649 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
23650 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
23651 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
23652 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
23653 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23654 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23655 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23656 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23657 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
23658 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x36, 0x38,
23659 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23660 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23661 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
23662 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
23663 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
23664 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
23665 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
23666 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
23667 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
23668 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
23669 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
23670 		0x00, 0xf0, 0x04, 0x08
23671 	};	/* Structure image */
23672 
23673 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
23674 }
23675 
23676 void
imdi_k68_tab(tabspec * t)23677 imdi_k68_tab(
23678 tabspec *t			/* structure to be initialised */
23679 ) {
23680 	static unsigned char data[] = {
23681 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23682 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23683 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23684 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
23685 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
23686 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
23687 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23688 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
23689 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
23690 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23691 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
23692 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
23693 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
23694 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
23695 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
23696 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23697 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23698 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
23699 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23700 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23701 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23702 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
23703 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
23704 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
23705 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23706 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23707 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
23708 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
23709 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
23710 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
23711 		0x10, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
23712 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
23713 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
23714 	};	/* Structure image */
23715 
23716 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
23717 }
23718 
23719 
23720 
23721 
23722 
23723 
23724 /* Integer Multi-Dimensional Interpolation */
23725 /* Interpolation Kernel Code */
23726 /* Generated by cgen */
23727 /* Copyright 2000 - 2002 Graeme W. Gill */
23728 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
23729 
23730 /* see the Licence.txt file for licencing details.*/
23731 
23732 
23733 /*
23734    Interpolation kernel specs:
23735 
23736    Input channels per pixel = 7
23737    Input channel 0 bits = 8
23738    Input channel 0 increment = 7
23739    Input channel 1 bits = 8
23740    Input channel 1 increment = 7
23741    Input channel 2 bits = 8
23742    Input channel 2 increment = 7
23743    Input channel 3 bits = 8
23744    Input channel 3 increment = 7
23745    Input channel 4 bits = 8
23746    Input channel 4 increment = 7
23747    Input channel 5 bits = 8
23748    Input channel 5 increment = 7
23749    Input channel 6 bits = 8
23750    Input channel 6 increment = 7
23751    Input is channel interleaved
23752    Input channels are separate words
23753    Input value extraction is done in input table lookup
23754 
23755    Output channels per pixel = 4
23756    Output channel 0 bits = 16
23757    Output channel 0 increment = 4
23758    Output channel 1 bits = 16
23759    Output channel 1 increment = 4
23760    Output channel 2 bits = 16
23761    Output channel 2 increment = 4
23762    Output channel 3 bits = 16
23763    Output channel 3 increment = 4
23764    Output is channel interleaved
23765 
23766    Output channels are separate words
23767    Weight+voffset bits       = 32
23768    Interpolation table index bits = 32
23769    Interpolation table max resolution = 14
23770  */
23771 
23772 /*
23773    Machine architecture specs:
23774 
23775    Little endian
23776    Reading and writing pixel values separately
23777    Pointer size = 32 bits
23778 
23779    Ordinal size  8 bits is known as 'unsigned char'
23780    Ordinal size 16 bits is known as 'unsigned short'
23781    Ordinal size 32 bits is known as 'unsigned int'
23782    Natural ordinal is 'unsigned int'
23783 
23784    Integer size  8 bits is known as 'signed char'
23785    Integer size 16 bits is known as 'short'
23786    Integer size 32 bits is known as 'int'
23787    Natural integer is 'int'
23788 
23789  */
23790 
23791 #ifndef  IMDI_INCLUDED
23792 #include <memory.h>
23793 #include "imdi_imp.h"
23794 #define  IMDI_INCLUDED
23795 #endif  /* IMDI_INCLUDED */
23796 
23797 #ifndef DEFINED_pointer
23798 #define DEFINED_pointer
23799 typedef unsigned char * pointer;
23800 #endif
23801 
23802 /* Input table interp. index */
23803 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
23804 
23805 /* Input table input weighting/offset value enty */
23806 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
23807 
23808 /* Conditional exchange for sorting */
23809 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
23810 
23811 /* Interpolation multi-dim. table access */
23812 #define IM_O(off) ((off) * 8)
23813 
23814 /* Interpolation table - get vertex values */
23815 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
23816 
23817 /* Output table indexes */
23818 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
23819 
23820 void
imdi_k69(imdi * s,void ** outp,void ** inp,unsigned int npix)23821 imdi_k69(
23822 imdi *s,			/* imdi context */
23823 void **outp,		/* pointer to output pointers */
23824 void **inp,		/* pointer to input pointers */
23825 unsigned int npix	/* Number of pixels to process */
23826 ) {
23827 	imdi_imp *p = (imdi_imp *)(s->impl);
23828 	unsigned char *ip0 = (unsigned char *)inp[0];
23829 	unsigned short *op0 = (unsigned short *)outp[0];
23830 	unsigned char *ep = ip0 + npix * 7 ;
23831 	pointer it0 = (pointer)p->in_tables[0];
23832 	pointer it1 = (pointer)p->in_tables[1];
23833 	pointer it2 = (pointer)p->in_tables[2];
23834 	pointer it3 = (pointer)p->in_tables[3];
23835 	pointer it4 = (pointer)p->in_tables[4];
23836 	pointer it5 = (pointer)p->in_tables[5];
23837 	pointer it6 = (pointer)p->in_tables[6];
23838 	pointer ot0 = (pointer)p->out_tables[0];
23839 	pointer ot1 = (pointer)p->out_tables[1];
23840 	pointer ot2 = (pointer)p->out_tables[2];
23841 	pointer ot3 = (pointer)p->out_tables[3];
23842 	pointer im_base = (pointer)p->im_table;
23843 
23844 	for(;ip0 < ep; ip0 += 7, op0 += 4) {
23845 		unsigned int ova0;	/* Output value accumulator */
23846 		unsigned int ova1;	/* Output value accumulator */
23847 		{
23848 			pointer imp;
23849 			unsigned int wo0;	/* Weighting value and vertex offset variable */
23850 			unsigned int wo1;	/* Weighting value and vertex offset variable */
23851 			unsigned int wo2;	/* Weighting value and vertex offset variable */
23852 			unsigned int wo3;	/* Weighting value and vertex offset variable */
23853 			unsigned int wo4;	/* Weighting value and vertex offset variable */
23854 			unsigned int wo5;	/* Weighting value and vertex offset variable */
23855 			unsigned int wo6;	/* Weighting value and vertex offset variable */
23856 			{
23857 				unsigned int ti_i;	/* Interpolation index variable */
23858 
23859 				ti_i  = IT_IX(it0, ip0[0]);
23860 				wo0   = IT_WO(it0, ip0[0]);
23861 				ti_i += IT_IX(it1, ip0[1]);
23862 				wo1   = IT_WO(it1, ip0[1]);
23863 				ti_i += IT_IX(it2, ip0[2]);
23864 				wo2   = IT_WO(it2, ip0[2]);
23865 				ti_i += IT_IX(it3, ip0[3]);
23866 				wo3   = IT_WO(it3, ip0[3]);
23867 				ti_i += IT_IX(it4, ip0[4]);
23868 				wo4   = IT_WO(it4, ip0[4]);
23869 				ti_i += IT_IX(it5, ip0[5]);
23870 				wo5   = IT_WO(it5, ip0[5]);
23871 				ti_i += IT_IX(it6, ip0[6]);
23872 				wo6   = IT_WO(it6, ip0[6]);
23873 
23874 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
23875 
23876 				/* Sort weighting values and vertex offset values */
23877 				CEX(wo0, wo1);
23878 				CEX(wo0, wo2);
23879 				CEX(wo0, wo3);
23880 				CEX(wo0, wo4);
23881 				CEX(wo0, wo5);
23882 				CEX(wo0, wo6);
23883 				CEX(wo1, wo2);
23884 				CEX(wo1, wo3);
23885 				CEX(wo1, wo4);
23886 				CEX(wo1, wo5);
23887 				CEX(wo1, wo6);
23888 				CEX(wo2, wo3);
23889 				CEX(wo2, wo4);
23890 				CEX(wo2, wo5);
23891 				CEX(wo2, wo6);
23892 				CEX(wo3, wo4);
23893 				CEX(wo3, wo5);
23894 				CEX(wo3, wo6);
23895 				CEX(wo4, wo5);
23896 				CEX(wo4, wo6);
23897 				CEX(wo5, wo6);
23898 			}
23899 			{
23900 				unsigned int nvof;	/* Next vertex offset value */
23901 				unsigned int vof;	/* Vertex offset value */
23902 				unsigned int vwe;	/* Vertex weighting */
23903 
23904 				vof = 0;				/* First vertex offset is 0 */
23905 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
23906 				wo0 = (wo0 >> 23);		/* Extract weighting value */
23907 				vwe = 256 - wo0;		/* Baricentric weighting */
23908 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23909 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23910 				vof += nvof;			/* Move to next vertex */
23911 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
23912 				wo1 = (wo1 >> 23);		/* Extract weighting value */
23913 				vwe = wo0 - wo1;		/* Baricentric weighting */
23914 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23915 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23916 				vof += nvof;			/* Move to next vertex */
23917 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
23918 				wo2 = (wo2 >> 23);		/* Extract weighting value */
23919 				vwe = wo1 - wo2;		/* Baricentric weighting */
23920 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23921 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23922 				vof += nvof;			/* Move to next vertex */
23923 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
23924 				wo3 = (wo3 >> 23);		/* Extract weighting value */
23925 				vwe = wo2 - wo3;		/* Baricentric weighting */
23926 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23927 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23928 				vof += nvof;			/* Move to next vertex */
23929 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
23930 				wo4 = (wo4 >> 23);		/* Extract weighting value */
23931 				vwe = wo3 - wo4;		/* Baricentric weighting */
23932 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23933 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23934 				vof += nvof;			/* Move to next vertex */
23935 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
23936 				wo5 = (wo5 >> 23);		/* Extract weighting value */
23937 				vwe = wo4 - wo5;		/* Baricentric weighting */
23938 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23939 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23940 				vof += nvof;			/* Move to next vertex */
23941 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
23942 				wo6 = (wo6 >> 23);		/* Extract weighting value */
23943 				vwe = wo5 - wo6;		/* Baricentric weighting */
23944 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23945 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23946 				vof += nvof;			/* Move to next vertex */
23947 				vwe = wo6;				/* Baricentric weighting */
23948 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
23949 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
23950 			}
23951 		}
23952 		{
23953 			unsigned int oti;	/* Vertex offset value */
23954 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
23955 			op0[0] = OT_E(ot0, oti);	/* Write result */
23956 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
23957 			op0[1] = OT_E(ot1, oti);	/* Write result */
23958 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
23959 			op0[2] = OT_E(ot2, oti);	/* Write result */
23960 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
23961 			op0[3] = OT_E(ot3, oti);	/* Write result */
23962 		}
23963 	}
23964 }
23965 #undef IT_WO
23966 #undef IT_IX
23967 #undef CEX
23968 #undef IM_O
23969 #undef IM_FE
23970 #undef OT_E
23971 
23972 void
imdi_k69_gen(genspec * g)23973 imdi_k69_gen(
23974 genspec *g			/* structure to be initialised */
23975 ) {
23976 	static unsigned char data[] = {
23977 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
23978 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23979 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23980 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23981 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23982 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23983 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23984 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
23985 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
23986 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
23987 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
23988 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23989 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23990 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23991 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23992 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23993 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23994 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23995 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
23996 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
23997 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
23998 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
23999 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24000 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24001 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
24002 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
24003 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24004 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24005 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24006 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24007 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24008 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24009 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24010 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24011 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24012 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24013 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24014 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24015 		0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24016 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
24017 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
24018 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
24019 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
24020 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
24021 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
24022 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
24023 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
24024 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
24025 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24026 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
24027 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
24028 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x34, 0x5f,
24029 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
24030 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
24031 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
24032 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
24033 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
24034 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
24035 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
24036 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24037 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24038 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24039 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24040 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
24041 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x36, 0x39,
24042 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24043 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24044 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
24045 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
24046 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
24047 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
24048 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
24049 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
24050 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
24051 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
24052 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
24053 		0x00, 0xf0, 0x04, 0x08
24054 	};	/* Structure image */
24055 
24056 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
24057 }
24058 
24059 void
imdi_k69_tab(tabspec * t)24060 imdi_k69_tab(
24061 tabspec *t			/* structure to be initialised */
24062 ) {
24063 	static unsigned char data[] = {
24064 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24065 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24066 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24067 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
24068 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
24069 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
24070 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24071 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
24072 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
24073 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24074 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
24075 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
24076 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
24077 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
24078 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
24079 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24080 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24081 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
24082 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24083 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24084 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24085 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
24086 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
24087 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
24088 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24089 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24090 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
24091 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
24092 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24093 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24094 		0x10, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
24095 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
24096 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
24097 	};	/* Structure image */
24098 
24099 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
24100 }
24101 
24102 
24103 
24104 
24105 
24106 
24107 /* Integer Multi-Dimensional Interpolation */
24108 /* Interpolation Kernel Code */
24109 /* Generated by cgen */
24110 /* Copyright 2000 - 2002 Graeme W. Gill */
24111 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
24112 
24113 /* see the Licence.txt file for licencing details.*/
24114 
24115 
24116 /*
24117    Interpolation kernel specs:
24118 
24119    Input channels per pixel = 8
24120    Input channel 0 bits = 8
24121    Input channel 0 increment = 8
24122    Input channel 1 bits = 8
24123    Input channel 1 increment = 8
24124    Input channel 2 bits = 8
24125    Input channel 2 increment = 8
24126    Input channel 3 bits = 8
24127    Input channel 3 increment = 8
24128    Input channel 4 bits = 8
24129    Input channel 4 increment = 8
24130    Input channel 5 bits = 8
24131    Input channel 5 increment = 8
24132    Input channel 6 bits = 8
24133    Input channel 6 increment = 8
24134    Input channel 7 bits = 8
24135    Input channel 7 increment = 8
24136    Input is channel interleaved
24137    Input channels are separate words
24138    Input value extraction is done in input table lookup
24139 
24140    Output channels per pixel = 4
24141    Output channel 0 bits = 16
24142    Output channel 0 increment = 4
24143    Output channel 1 bits = 16
24144    Output channel 1 increment = 4
24145    Output channel 2 bits = 16
24146    Output channel 2 increment = 4
24147    Output channel 3 bits = 16
24148    Output channel 3 increment = 4
24149    Output is channel interleaved
24150 
24151    Output channels are separate words
24152    Weight+voffset bits       = 32
24153    Interpolation table index bits = 32
24154    Interpolation table max resolution = 9
24155  */
24156 
24157 /*
24158    Machine architecture specs:
24159 
24160    Little endian
24161    Reading and writing pixel values separately
24162    Pointer size = 32 bits
24163 
24164    Ordinal size  8 bits is known as 'unsigned char'
24165    Ordinal size 16 bits is known as 'unsigned short'
24166    Ordinal size 32 bits is known as 'unsigned int'
24167    Natural ordinal is 'unsigned int'
24168 
24169    Integer size  8 bits is known as 'signed char'
24170    Integer size 16 bits is known as 'short'
24171    Integer size 32 bits is known as 'int'
24172    Natural integer is 'int'
24173 
24174  */
24175 
24176 #ifndef  IMDI_INCLUDED
24177 #include <memory.h>
24178 #include "imdi_imp.h"
24179 #define  IMDI_INCLUDED
24180 #endif  /* IMDI_INCLUDED */
24181 
24182 #ifndef DEFINED_pointer
24183 #define DEFINED_pointer
24184 typedef unsigned char * pointer;
24185 #endif
24186 
24187 /* Input table interp. index */
24188 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
24189 
24190 /* Input table input weighting/offset value enty */
24191 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
24192 
24193 /* Conditional exchange for sorting */
24194 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
24195 
24196 /* Interpolation multi-dim. table access */
24197 #define IM_O(off) ((off) * 8)
24198 
24199 /* Interpolation table - get vertex values */
24200 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
24201 
24202 /* Output table indexes */
24203 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
24204 
24205 void
imdi_k70(imdi * s,void ** outp,void ** inp,unsigned int npix)24206 imdi_k70(
24207 imdi *s,			/* imdi context */
24208 void **outp,		/* pointer to output pointers */
24209 void **inp,		/* pointer to input pointers */
24210 unsigned int npix	/* Number of pixels to process */
24211 ) {
24212 	imdi_imp *p = (imdi_imp *)(s->impl);
24213 	unsigned char *ip0 = (unsigned char *)inp[0];
24214 	unsigned short *op0 = (unsigned short *)outp[0];
24215 	unsigned char *ep = ip0 + npix * 8 ;
24216 	pointer it0 = (pointer)p->in_tables[0];
24217 	pointer it1 = (pointer)p->in_tables[1];
24218 	pointer it2 = (pointer)p->in_tables[2];
24219 	pointer it3 = (pointer)p->in_tables[3];
24220 	pointer it4 = (pointer)p->in_tables[4];
24221 	pointer it5 = (pointer)p->in_tables[5];
24222 	pointer it6 = (pointer)p->in_tables[6];
24223 	pointer it7 = (pointer)p->in_tables[7];
24224 	pointer ot0 = (pointer)p->out_tables[0];
24225 	pointer ot1 = (pointer)p->out_tables[1];
24226 	pointer ot2 = (pointer)p->out_tables[2];
24227 	pointer ot3 = (pointer)p->out_tables[3];
24228 	pointer im_base = (pointer)p->im_table;
24229 
24230 	for(;ip0 < ep; ip0 += 8, op0 += 4) {
24231 		unsigned int ova0;	/* Output value accumulator */
24232 		unsigned int ova1;	/* Output value accumulator */
24233 		{
24234 			pointer imp;
24235 			unsigned int wo0;	/* Weighting value and vertex offset variable */
24236 			unsigned int wo1;	/* Weighting value and vertex offset variable */
24237 			unsigned int wo2;	/* Weighting value and vertex offset variable */
24238 			unsigned int wo3;	/* Weighting value and vertex offset variable */
24239 			unsigned int wo4;	/* Weighting value and vertex offset variable */
24240 			unsigned int wo5;	/* Weighting value and vertex offset variable */
24241 			unsigned int wo6;	/* Weighting value and vertex offset variable */
24242 			unsigned int wo7;	/* Weighting value and vertex offset variable */
24243 			{
24244 				unsigned int ti_i;	/* Interpolation index variable */
24245 
24246 				ti_i  = IT_IX(it0, ip0[0]);
24247 				wo0   = IT_WO(it0, ip0[0]);
24248 				ti_i += IT_IX(it1, ip0[1]);
24249 				wo1   = IT_WO(it1, ip0[1]);
24250 				ti_i += IT_IX(it2, ip0[2]);
24251 				wo2   = IT_WO(it2, ip0[2]);
24252 				ti_i += IT_IX(it3, ip0[3]);
24253 				wo3   = IT_WO(it3, ip0[3]);
24254 				ti_i += IT_IX(it4, ip0[4]);
24255 				wo4   = IT_WO(it4, ip0[4]);
24256 				ti_i += IT_IX(it5, ip0[5]);
24257 				wo5   = IT_WO(it5, ip0[5]);
24258 				ti_i += IT_IX(it6, ip0[6]);
24259 				wo6   = IT_WO(it6, ip0[6]);
24260 				ti_i += IT_IX(it7, ip0[7]);
24261 				wo7   = IT_WO(it7, ip0[7]);
24262 
24263 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
24264 
24265 				/* Sort weighting values and vertex offset values */
24266 				CEX(wo0, wo1);
24267 				CEX(wo0, wo2);
24268 				CEX(wo0, wo3);
24269 				CEX(wo0, wo4);
24270 				CEX(wo0, wo5);
24271 				CEX(wo0, wo6);
24272 				CEX(wo0, wo7);
24273 				CEX(wo1, wo2);
24274 				CEX(wo1, wo3);
24275 				CEX(wo1, wo4);
24276 				CEX(wo1, wo5);
24277 				CEX(wo1, wo6);
24278 				CEX(wo1, wo7);
24279 				CEX(wo2, wo3);
24280 				CEX(wo2, wo4);
24281 				CEX(wo2, wo5);
24282 				CEX(wo2, wo6);
24283 				CEX(wo2, wo7);
24284 				CEX(wo3, wo4);
24285 				CEX(wo3, wo5);
24286 				CEX(wo3, wo6);
24287 				CEX(wo3, wo7);
24288 				CEX(wo4, wo5);
24289 				CEX(wo4, wo6);
24290 				CEX(wo4, wo7);
24291 				CEX(wo5, wo6);
24292 				CEX(wo5, wo7);
24293 				CEX(wo6, wo7);
24294 			}
24295 			{
24296 				unsigned int nvof;	/* Next vertex offset value */
24297 				unsigned int vof;	/* Vertex offset value */
24298 				unsigned int vwe;	/* Vertex weighting */
24299 
24300 				vof = 0;				/* First vertex offset is 0 */
24301 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
24302 				wo0 = (wo0 >> 23);		/* Extract weighting value */
24303 				vwe = 256 - wo0;		/* Baricentric weighting */
24304 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
24305 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
24306 				vof += nvof;			/* Move to next vertex */
24307 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
24308 				wo1 = (wo1 >> 23);		/* Extract weighting value */
24309 				vwe = wo0 - wo1;		/* Baricentric weighting */
24310 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
24311 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
24312 				vof += nvof;			/* Move to next vertex */
24313 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
24314 				wo2 = (wo2 >> 23);		/* Extract weighting value */
24315 				vwe = wo1 - wo2;		/* Baricentric weighting */
24316 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
24317 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
24318 				vof += nvof;			/* Move to next vertex */
24319 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
24320 				wo3 = (wo3 >> 23);		/* Extract weighting value */
24321 				vwe = wo2 - wo3;		/* Baricentric weighting */
24322 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
24323 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
24324 				vof += nvof;			/* Move to next vertex */
24325 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
24326 				wo4 = (wo4 >> 23);		/* Extract weighting value */
24327 				vwe = wo3 - wo4;		/* Baricentric weighting */
24328 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
24329 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
24330 				vof += nvof;			/* Move to next vertex */
24331 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
24332 				wo5 = (wo5 >> 23);		/* Extract weighting value */
24333 				vwe = wo4 - wo5;		/* Baricentric weighting */
24334 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
24335 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
24336 				vof += nvof;			/* Move to next vertex */
24337 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
24338 				wo6 = (wo6 >> 23);		/* Extract weighting value */
24339 				vwe = wo5 - wo6;		/* Baricentric weighting */
24340 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
24341 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
24342 				vof += nvof;			/* Move to next vertex */
24343 				nvof = (wo7 & 0x7fffff);	/* Extract offset value */
24344 				wo7 = (wo7 >> 23);		/* Extract weighting value */
24345 				vwe = wo6 - wo7;		/* Baricentric weighting */
24346 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
24347 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
24348 				vof += nvof;			/* Move to next vertex */
24349 				vwe = wo7;				/* Baricentric weighting */
24350 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
24351 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
24352 			}
24353 		}
24354 		{
24355 			unsigned int oti;	/* Vertex offset value */
24356 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
24357 			op0[0] = OT_E(ot0, oti);	/* Write result */
24358 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
24359 			op0[1] = OT_E(ot1, oti);	/* Write result */
24360 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
24361 			op0[2] = OT_E(ot2, oti);	/* Write result */
24362 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
24363 			op0[3] = OT_E(ot3, oti);	/* Write result */
24364 		}
24365 	}
24366 }
24367 #undef IT_WO
24368 #undef IT_IX
24369 #undef CEX
24370 #undef IM_O
24371 #undef IM_FE
24372 #undef OT_E
24373 
24374 void
imdi_k70_gen(genspec * g)24375 imdi_k70_gen(
24376 genspec *g			/* structure to be initialised */
24377 ) {
24378 	static unsigned char data[] = {
24379 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24380 		0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24381 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24382 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24383 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24384 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24385 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24386 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24387 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24388 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24389 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24390 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24391 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24392 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24393 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24394 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24395 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24396 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24397 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24398 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24399 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24400 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24401 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24402 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24403 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
24404 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
24405 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24406 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24407 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24408 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24409 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24410 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24411 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24412 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24413 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24414 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24415 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24416 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24417 		0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24418 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
24419 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
24420 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
24421 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
24422 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
24423 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
24424 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
24425 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
24426 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
24427 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24428 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
24429 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
24430 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x34, 0x5f,
24431 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
24432 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
24433 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
24434 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
24435 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
24436 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
24437 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
24438 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24439 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24440 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24441 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24442 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
24443 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x37, 0x30,
24444 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24445 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24446 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
24447 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
24448 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
24449 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
24450 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
24451 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
24452 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
24453 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
24454 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
24455 		0x00, 0xf0, 0x04, 0x08
24456 	};	/* Structure image */
24457 
24458 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
24459 }
24460 
24461 void
imdi_k70_tab(tabspec * t)24462 imdi_k70_tab(
24463 tabspec *t			/* structure to be initialised */
24464 ) {
24465 	static unsigned char data[] = {
24466 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24467 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24468 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24469 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
24470 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
24471 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
24472 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24473 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
24474 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
24475 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24476 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
24477 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
24478 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
24479 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
24480 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
24481 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24482 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24483 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
24484 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24485 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24486 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24487 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
24488 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
24489 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
24490 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24491 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24492 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
24493 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
24494 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24495 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24496 		0x10, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
24497 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
24498 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
24499 	};	/* Structure image */
24500 
24501 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
24502 }
24503 
24504 
24505 
24506 
24507 
24508 
24509 /* Integer Multi-Dimensional Interpolation */
24510 /* Interpolation Kernel Code */
24511 /* Generated by cgen */
24512 /* Copyright 2000 - 2002 Graeme W. Gill */
24513 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
24514 
24515 /* see the Licence.txt file for licencing details.*/
24516 
24517 
24518 /*
24519    Interpolation kernel specs:
24520 
24521    Input channels per pixel = 1
24522    Input channel 0 bits = 8
24523    Input channel 0 increment = 1
24524    Input is channel interleaved
24525    Input channels are separate words
24526    Input value extraction is done in input table lookup
24527 
24528    Output channels per pixel = 5
24529    Output channel 0 bits = 16
24530    Output channel 0 increment = 5
24531    Output channel 1 bits = 16
24532    Output channel 1 increment = 5
24533    Output channel 2 bits = 16
24534    Output channel 2 increment = 5
24535    Output channel 3 bits = 16
24536    Output channel 3 increment = 5
24537    Output channel 4 bits = 16
24538    Output channel 4 increment = 5
24539    Output is channel interleaved
24540 
24541    Output channels are separate words
24542    Simplex table index bits       = 0
24543    Interpolation table index bits = 8
24544    Simplex table max resolution = 1
24545    Interpolation table max resolution = 255
24546  */
24547 
24548 /*
24549    Machine architecture specs:
24550 
24551    Little endian
24552    Reading and writing pixel values separately
24553    Pointer size = 32 bits
24554 
24555    Ordinal size  8 bits is known as 'unsigned char'
24556    Ordinal size 16 bits is known as 'unsigned short'
24557    Ordinal size 32 bits is known as 'unsigned int'
24558    Natural ordinal is 'unsigned int'
24559 
24560    Integer size  8 bits is known as 'signed char'
24561    Integer size 16 bits is known as 'short'
24562    Integer size 32 bits is known as 'int'
24563    Natural integer is 'int'
24564 
24565  */
24566 
24567 #ifndef  IMDI_INCLUDED
24568 #include <memory.h>
24569 #include "imdi_imp.h"
24570 #define  IMDI_INCLUDED
24571 #endif  /* IMDI_INCLUDED */
24572 
24573 #ifndef DEFINED_pointer
24574 #define DEFINED_pointer
24575 typedef unsigned char * pointer;
24576 #endif
24577 
24578 /* Input table inter & simplex indexes */
24579 #define IT_IT(p, off) *((unsigned char *)((p) + 0 + (off) * 1))
24580 
24581 /* Simplex weighting table access */
24582 #define SW_O(off) ((off) * 4)
24583 
24584 /* Simplex table - get weighting/offset value */
24585 #define SX_WO(p, v) *((unsigned short *)((p) + (v) * 2))
24586 
24587 /* Interpolation multi-dim. table access */
24588 #define IM_O(off) ((off) * 12)
24589 
24590 /* Interpolation table - get vertex values */
24591 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
24592 #define IM_PE(p, v) *((unsigned int *)((p) + 8 + (v) * 4))
24593 
24594 /* Output table indexes */
24595 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
24596 
24597 void
imdi_k71(imdi * s,void ** outp,void ** inp,unsigned int npix)24598 imdi_k71(
24599 imdi *s,			/* imdi context */
24600 void **outp,		/* pointer to output pointers */
24601 void **inp,		/* pointer to input pointers */
24602 unsigned int npix	/* Number of pixels to process */
24603 ) {
24604 	imdi_imp *p = (imdi_imp *)(s->impl);
24605 	unsigned char *ip0 = (unsigned char *)inp[0];
24606 	unsigned short *op0 = (unsigned short *)outp[0];
24607 	unsigned char *ep = ip0 + npix * 1 ;
24608 	pointer it0 = (pointer)p->in_tables[0];
24609 	pointer ot0 = (pointer)p->out_tables[0];
24610 	pointer ot1 = (pointer)p->out_tables[1];
24611 	pointer ot2 = (pointer)p->out_tables[2];
24612 	pointer ot3 = (pointer)p->out_tables[3];
24613 	pointer ot4 = (pointer)p->out_tables[4];
24614 	pointer sw_base = (pointer)p->sw_table;
24615 	pointer im_base = (pointer)p->im_table;
24616 
24617 	for(;ip0 < ep; ip0 += 1, op0 += 5) {
24618 		unsigned int ova0;	/* Output value accumulator */
24619 		unsigned int ova1;	/* Output value accumulator */
24620 		unsigned int ova2;	/* Output value partial accumulator */
24621 		{
24622 			pointer swp;
24623 			pointer imp;
24624 			{
24625 				unsigned int ti;	/* Simplex+Interpolation index variable */
24626 
24627 				ti  = IT_IT(it0, ip0[0]);
24628 
24629 				imp = im_base + IM_O(ti >> 0);		/* Extract interp. index and comp. entry */
24630 				swp = sw_base + SW_O(ti & 0x0);	/* Extract simplex index and comp. entry */
24631 			}
24632 			{
24633 				unsigned int vowr;	/* Vertex offset/weight value */
24634 				unsigned int vof;	/* Vertex offset value */
24635 				unsigned int vwe;	/* Vertex weighting */
24636 
24637 				vowr = SX_WO(swp, 0);	/* Read vertex offset+weighting values */
24638 				vof = (vowr & 0x7f);	/* Extract offset value */
24639 				vwe = (vowr >> 7);	/* Extract weighting value */
24640 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
24641 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
24642 				ova2  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
24643 				vowr = SX_WO(swp, 1);	/* Read vertex offset+weighting values */
24644 				vof = (vowr & 0x7f);	/* Extract offset value */
24645 				vwe = (vowr >> 7);	/* Extract weighting value */
24646 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
24647 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
24648 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
24649 			}
24650 		}
24651 		{
24652 			unsigned int oti;	/* Vertex offset value */
24653 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
24654 			op0[0] = OT_E(ot0, oti);	/* Write result */
24655 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
24656 			op0[1] = OT_E(ot1, oti);	/* Write result */
24657 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
24658 			op0[2] = OT_E(ot2, oti);	/* Write result */
24659 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
24660 			op0[3] = OT_E(ot3, oti);	/* Write result */
24661 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
24662 			op0[4] = OT_E(ot4, oti);	/* Write result */
24663 		}
24664 	}
24665 }
24666 #undef IT_IT
24667 #undef SW_O
24668 #undef SX_WO
24669 #undef IM_O
24670 #undef IM_FE
24671 #undef IM_PE
24672 #undef OT_E
24673 
24674 void
imdi_k71_gen(genspec * g)24675 imdi_k71_gen(
24676 genspec *g			/* structure to be initialised */
24677 ) {
24678 	static unsigned char data[] = {
24679 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24680 		0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24681 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24682 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24683 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24684 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24685 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24686 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24687 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24688 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24689 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24690 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24691 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24692 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24693 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24694 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24695 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24696 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24697 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24698 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24699 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24700 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24701 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24702 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24703 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
24704 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
24705 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
24706 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24707 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24708 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24709 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24710 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24711 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24712 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24713 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24714 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
24715 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24716 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24717 		0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24718 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
24719 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
24720 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
24721 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
24722 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
24723 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
24724 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
24725 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
24726 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
24727 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24728 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
24729 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
24730 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x35, 0x5f,
24731 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
24732 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
24733 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
24734 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
24735 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
24736 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
24737 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
24738 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24739 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24740 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24741 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24742 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
24743 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x37, 0x31,
24744 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24745 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24746 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
24747 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
24748 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
24749 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
24750 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
24751 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
24752 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
24753 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
24754 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
24755 		0x00, 0xf0, 0x04, 0x08
24756 	};	/* Structure image */
24757 
24758 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
24759 }
24760 
24761 void
imdi_k71_tab(tabspec * t)24762 imdi_k71_tab(
24763 tabspec *t			/* structure to be initialised */
24764 ) {
24765 	static unsigned char data[] = {
24766 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24767 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24768 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24769 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
24770 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
24771 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
24772 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24773 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
24774 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24775 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24776 		0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24777 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24778 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
24779 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
24780 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
24781 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24782 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
24783 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
24784 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
24785 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24786 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
24787 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
24788 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24789 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
24790 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24791 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24792 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24793 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
24794 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24795 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24796 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
24797 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
24798 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
24799 	};	/* Structure image */
24800 
24801 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
24802 }
24803 
24804 
24805 
24806 
24807 
24808 
24809 /* Integer Multi-Dimensional Interpolation */
24810 /* Interpolation Kernel Code */
24811 /* Generated by cgen */
24812 /* Copyright 2000 - 2002 Graeme W. Gill */
24813 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
24814 
24815 /* see the Licence.txt file for licencing details.*/
24816 
24817 
24818 /*
24819    Interpolation kernel specs:
24820 
24821    Input channels per pixel = 3
24822    Input channel 0 bits = 8
24823    Input channel 0 increment = 3
24824    Input channel 1 bits = 8
24825    Input channel 1 increment = 3
24826    Input channel 2 bits = 8
24827    Input channel 2 increment = 3
24828    Input is channel interleaved
24829    Input channels are separate words
24830    Input value extraction is done in input table lookup
24831 
24832    Output channels per pixel = 5
24833    Output channel 0 bits = 16
24834    Output channel 0 increment = 5
24835    Output channel 1 bits = 16
24836    Output channel 1 increment = 5
24837    Output channel 2 bits = 16
24838    Output channel 2 increment = 5
24839    Output channel 3 bits = 16
24840    Output channel 3 increment = 5
24841    Output channel 4 bits = 16
24842    Output channel 4 increment = 5
24843    Output is channel interleaved
24844 
24845    Output channels are separate words
24846    Simplex table index bits       = 12
24847    Interpolation table index bits = 20
24848    Simplex table max resolution = 16
24849    Interpolation table max resolution = 101
24850  */
24851 
24852 /*
24853    Machine architecture specs:
24854 
24855    Little endian
24856    Reading and writing pixel values separately
24857    Pointer size = 32 bits
24858 
24859    Ordinal size  8 bits is known as 'unsigned char'
24860    Ordinal size 16 bits is known as 'unsigned short'
24861    Ordinal size 32 bits is known as 'unsigned int'
24862    Natural ordinal is 'unsigned int'
24863 
24864    Integer size  8 bits is known as 'signed char'
24865    Integer size 16 bits is known as 'short'
24866    Integer size 32 bits is known as 'int'
24867    Natural integer is 'int'
24868 
24869  */
24870 
24871 #ifndef  IMDI_INCLUDED
24872 #include <memory.h>
24873 #include "imdi_imp.h"
24874 #define  IMDI_INCLUDED
24875 #endif  /* IMDI_INCLUDED */
24876 
24877 #ifndef DEFINED_pointer
24878 #define DEFINED_pointer
24879 typedef unsigned char * pointer;
24880 #endif
24881 
24882 /* Input table inter & simplex indexes */
24883 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
24884 
24885 /* Simplex weighting table access */
24886 #define SW_O(off) ((off) * 16)
24887 
24888 /* Simplex table - get weighting value */
24889 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
24890 
24891 /* Simplex table - get offset value */
24892 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
24893 
24894 /* Interpolation multi-dim. table access */
24895 #define IM_O(off) ((off) * 12)
24896 
24897 /* Interpolation table - get vertex values */
24898 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
24899 #define IM_PE(p, v) *((unsigned int *)((p) + 8 + (v) * 4))
24900 
24901 /* Output table indexes */
24902 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
24903 
24904 void
imdi_k72(imdi * s,void ** outp,void ** inp,unsigned int npix)24905 imdi_k72(
24906 imdi *s,			/* imdi context */
24907 void **outp,		/* pointer to output pointers */
24908 void **inp,		/* pointer to input pointers */
24909 unsigned int npix	/* Number of pixels to process */
24910 ) {
24911 	imdi_imp *p = (imdi_imp *)(s->impl);
24912 	unsigned char *ip0 = (unsigned char *)inp[0];
24913 	unsigned short *op0 = (unsigned short *)outp[0];
24914 	unsigned char *ep = ip0 + npix * 3 ;
24915 	pointer it0 = (pointer)p->in_tables[0];
24916 	pointer it1 = (pointer)p->in_tables[1];
24917 	pointer it2 = (pointer)p->in_tables[2];
24918 	pointer ot0 = (pointer)p->out_tables[0];
24919 	pointer ot1 = (pointer)p->out_tables[1];
24920 	pointer ot2 = (pointer)p->out_tables[2];
24921 	pointer ot3 = (pointer)p->out_tables[3];
24922 	pointer ot4 = (pointer)p->out_tables[4];
24923 	pointer sw_base = (pointer)p->sw_table;
24924 	pointer im_base = (pointer)p->im_table;
24925 
24926 	for(;ip0 < ep; ip0 += 3, op0 += 5) {
24927 		unsigned int ova0;	/* Output value accumulator */
24928 		unsigned int ova1;	/* Output value accumulator */
24929 		unsigned int ova2;	/* Output value partial accumulator */
24930 		{
24931 			pointer swp;
24932 			pointer imp;
24933 			{
24934 				unsigned int ti;	/* Simplex+Interpolation index variable */
24935 
24936 				ti  = IT_IT(it0, ip0[0]);
24937 				ti += IT_IT(it1, ip0[1]);
24938 				ti += IT_IT(it2, ip0[2]);
24939 
24940 				imp = im_base + IM_O(ti >> 12);		/* Extract interp. index and comp. entry */
24941 				swp = sw_base + SW_O(ti & 0xfff);	/* Extract simplex index and comp. entry */
24942 			}
24943 			{
24944 				unsigned int vof;	/* Vertex offset value */
24945 				unsigned int vwe;	/* Vertex weighting */
24946 
24947 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
24948 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
24949 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
24950 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
24951 				ova2  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
24952 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
24953 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
24954 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
24955 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
24956 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
24957 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
24958 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
24959 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
24960 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
24961 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
24962 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
24963 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
24964 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
24965 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
24966 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
24967 			}
24968 		}
24969 		{
24970 			unsigned int oti;	/* Vertex offset value */
24971 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
24972 			op0[0] = OT_E(ot0, oti);	/* Write result */
24973 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
24974 			op0[1] = OT_E(ot1, oti);	/* Write result */
24975 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
24976 			op0[2] = OT_E(ot2, oti);	/* Write result */
24977 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
24978 			op0[3] = OT_E(ot3, oti);	/* Write result */
24979 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
24980 			op0[4] = OT_E(ot4, oti);	/* Write result */
24981 		}
24982 	}
24983 }
24984 #undef IT_IT
24985 #undef SW_O
24986 #undef SX_WE
24987 #undef SX_VO
24988 #undef IM_O
24989 #undef IM_FE
24990 #undef IM_PE
24991 #undef OT_E
24992 
24993 void
imdi_k72_gen(genspec * g)24994 imdi_k72_gen(
24995 genspec *g			/* structure to be initialised */
24996 ) {
24997 	static unsigned char data[] = {
24998 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
24999 		0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25000 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25001 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25002 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25003 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25004 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25005 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
25006 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
25007 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25008 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25009 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25010 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25011 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25012 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25013 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25014 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25015 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25016 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25017 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25018 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25019 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25020 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25021 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25022 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
25023 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
25024 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
25025 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25026 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25027 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25028 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25029 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25030 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25031 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25032 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25033 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25034 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25035 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25036 		0x65, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25037 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
25038 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
25039 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
25040 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
25041 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
25042 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
25043 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
25044 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
25045 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
25046 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25047 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
25048 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
25049 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x35, 0x5f,
25050 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
25051 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
25052 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
25053 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
25054 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
25055 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
25056 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
25057 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25058 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25059 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25060 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25061 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
25062 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x37, 0x32,
25063 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25064 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25065 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
25066 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
25067 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
25068 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
25069 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
25070 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
25071 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
25072 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
25073 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
25074 		0x00, 0xf0, 0x04, 0x08
25075 	};	/* Structure image */
25076 
25077 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
25078 }
25079 
25080 void
imdi_k72_tab(tabspec * t)25081 imdi_k72_tab(
25082 tabspec *t			/* structure to be initialised */
25083 ) {
25084 	static unsigned char data[] = {
25085 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25086 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25087 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25088 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
25089 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
25090 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
25091 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
25092 		0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
25093 		0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
25094 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25095 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25096 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25097 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
25098 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25099 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
25100 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25101 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
25102 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
25103 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
25104 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25105 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25106 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
25107 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25108 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
25109 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25110 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25111 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25112 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
25113 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25114 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25115 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25116 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
25117 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
25118 	};	/* Structure image */
25119 
25120 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
25121 }
25122 
25123 
25124 
25125 
25126 
25127 
25128 /* Integer Multi-Dimensional Interpolation */
25129 /* Interpolation Kernel Code */
25130 /* Generated by cgen */
25131 /* Copyright 2000 - 2002 Graeme W. Gill */
25132 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
25133 
25134 /* see the Licence.txt file for licencing details.*/
25135 
25136 
25137 /*
25138    Interpolation kernel specs:
25139 
25140    Input channels per pixel = 4
25141    Input channel 0 bits = 8
25142    Input channel 0 increment = 4
25143    Input channel 1 bits = 8
25144    Input channel 1 increment = 4
25145    Input channel 2 bits = 8
25146    Input channel 2 increment = 4
25147    Input channel 3 bits = 8
25148    Input channel 3 increment = 4
25149    Input is channel interleaved
25150    Input channels are separate words
25151    Input value extraction is done in input table lookup
25152 
25153    Output channels per pixel = 5
25154    Output channel 0 bits = 16
25155    Output channel 0 increment = 5
25156    Output channel 1 bits = 16
25157    Output channel 1 increment = 5
25158    Output channel 2 bits = 16
25159    Output channel 2 increment = 5
25160    Output channel 3 bits = 16
25161    Output channel 3 increment = 5
25162    Output channel 4 bits = 16
25163    Output channel 4 increment = 5
25164    Output is channel interleaved
25165 
25166    Output channels are separate words
25167    Simplex table index bits       = 32
25168    Interpolation table index bits = 32
25169    Simplex table max resolution = 255
25170    Interpolation table max resolution = 27
25171  */
25172 
25173 /*
25174    Machine architecture specs:
25175 
25176    Little endian
25177    Reading and writing pixel values separately
25178    Pointer size = 32 bits
25179 
25180    Ordinal size  8 bits is known as 'unsigned char'
25181    Ordinal size 16 bits is known as 'unsigned short'
25182    Ordinal size 32 bits is known as 'unsigned int'
25183    Natural ordinal is 'unsigned int'
25184 
25185    Integer size  8 bits is known as 'signed char'
25186    Integer size 16 bits is known as 'short'
25187    Integer size 32 bits is known as 'int'
25188    Natural integer is 'int'
25189 
25190  */
25191 
25192 #ifndef  IMDI_INCLUDED
25193 #include <memory.h>
25194 #include "imdi_imp.h"
25195 #define  IMDI_INCLUDED
25196 #endif  /* IMDI_INCLUDED */
25197 
25198 #ifndef DEFINED_pointer
25199 #define DEFINED_pointer
25200 typedef unsigned char * pointer;
25201 #endif
25202 
25203 /* Input table interp. index */
25204 #define IT_IX(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
25205 
25206 /* Input table simplex index enty */
25207 #define IT_SX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
25208 
25209 /* Simplex weighting table access */
25210 #define SW_O(off) ((off) * 20)
25211 
25212 /* Simplex table - get weighting value */
25213 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
25214 
25215 /* Simplex table - get offset value */
25216 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
25217 
25218 /* Interpolation multi-dim. table access */
25219 #define IM_O(off) ((off) * 12)
25220 
25221 /* Interpolation table - get vertex values */
25222 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
25223 #define IM_PE(p, v) *((unsigned int *)((p) + 8 + (v) * 4))
25224 
25225 /* Output table indexes */
25226 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
25227 
25228 void
imdi_k73(imdi * s,void ** outp,void ** inp,unsigned int npix)25229 imdi_k73(
25230 imdi *s,			/* imdi context */
25231 void **outp,		/* pointer to output pointers */
25232 void **inp,		/* pointer to input pointers */
25233 unsigned int npix	/* Number of pixels to process */
25234 ) {
25235 	imdi_imp *p = (imdi_imp *)(s->impl);
25236 	unsigned char *ip0 = (unsigned char *)inp[0];
25237 	unsigned short *op0 = (unsigned short *)outp[0];
25238 	unsigned char *ep = ip0 + npix * 4 ;
25239 	pointer it0 = (pointer)p->in_tables[0];
25240 	pointer it1 = (pointer)p->in_tables[1];
25241 	pointer it2 = (pointer)p->in_tables[2];
25242 	pointer it3 = (pointer)p->in_tables[3];
25243 	pointer ot0 = (pointer)p->out_tables[0];
25244 	pointer ot1 = (pointer)p->out_tables[1];
25245 	pointer ot2 = (pointer)p->out_tables[2];
25246 	pointer ot3 = (pointer)p->out_tables[3];
25247 	pointer ot4 = (pointer)p->out_tables[4];
25248 	pointer sw_base = (pointer)p->sw_table;
25249 	pointer im_base = (pointer)p->im_table;
25250 
25251 	for(;ip0 < ep; ip0 += 4, op0 += 5) {
25252 		unsigned int ova0;	/* Output value accumulator */
25253 		unsigned int ova1;	/* Output value accumulator */
25254 		unsigned int ova2;	/* Output value partial accumulator */
25255 		{
25256 			pointer swp;
25257 			pointer imp;
25258 			{
25259 				unsigned int ti_s;	/* Simplex index variable */
25260 				unsigned int ti_i;	/* Interpolation index variable */
25261 
25262 				ti_i  = IT_IX(it0, ip0[0]);
25263 				ti_s  = IT_SX(it0, ip0[0]);
25264 				ti_i += IT_IX(it1, ip0[1]);
25265 				ti_s += IT_SX(it1, ip0[1]);
25266 				ti_i += IT_IX(it2, ip0[2]);
25267 				ti_s += IT_SX(it2, ip0[2]);
25268 				ti_i += IT_IX(it3, ip0[3]);
25269 				ti_s += IT_SX(it3, ip0[3]);
25270 
25271 				swp = sw_base + SW_O(ti_s);		/* Compute simplex table entry pointer */
25272 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
25273 			}
25274 			{
25275 				unsigned int vof;	/* Vertex offset value */
25276 				unsigned int vwe;	/* Vertex weighting */
25277 
25278 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
25279 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
25280 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
25281 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
25282 				ova2  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
25283 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
25284 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
25285 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
25286 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
25287 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
25288 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
25289 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
25290 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
25291 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
25292 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
25293 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
25294 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
25295 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
25296 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
25297 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
25298 				vof = SX_VO(swp, 4);	/* Read vertex offset value */
25299 				vwe = SX_WE(swp, 4);	/* Read vertex weighting value */
25300 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
25301 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
25302 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
25303 			}
25304 		}
25305 		{
25306 			unsigned int oti;	/* Vertex offset value */
25307 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
25308 			op0[0] = OT_E(ot0, oti);	/* Write result */
25309 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
25310 			op0[1] = OT_E(ot1, oti);	/* Write result */
25311 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
25312 			op0[2] = OT_E(ot2, oti);	/* Write result */
25313 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
25314 			op0[3] = OT_E(ot3, oti);	/* Write result */
25315 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
25316 			op0[4] = OT_E(ot4, oti);	/* Write result */
25317 		}
25318 	}
25319 }
25320 #undef IT_IX
25321 #undef IT_SX
25322 #undef SW_O
25323 #undef SX_WE
25324 #undef SX_VO
25325 #undef IM_O
25326 #undef IM_FE
25327 #undef IM_PE
25328 #undef OT_E
25329 
25330 void
imdi_k73_gen(genspec * g)25331 imdi_k73_gen(
25332 genspec *g			/* structure to be initialised */
25333 ) {
25334 	static unsigned char data[] = {
25335 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
25336 		0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25337 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25338 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25339 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25340 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25341 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25342 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
25343 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
25344 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25345 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25346 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25347 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25348 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25349 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25350 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25351 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25352 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25353 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25354 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25355 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25356 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25357 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25358 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25359 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
25360 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
25361 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
25362 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25363 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25364 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25365 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25366 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25367 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25368 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25369 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25370 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25371 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25372 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25373 		0x1b, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
25374 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
25375 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
25376 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
25377 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
25378 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
25379 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
25380 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
25381 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
25382 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
25383 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25384 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
25385 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
25386 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x35, 0x5f,
25387 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
25388 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
25389 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
25390 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
25391 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
25392 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
25393 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
25394 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25395 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25396 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25397 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25398 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
25399 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x37, 0x33,
25400 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25401 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25402 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
25403 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
25404 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
25405 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
25406 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
25407 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
25408 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
25409 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
25410 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
25411 		0x00, 0xf0, 0x04, 0x08
25412 	};	/* Structure image */
25413 
25414 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
25415 }
25416 
25417 void
imdi_k73_tab(tabspec * t)25418 imdi_k73_tab(
25419 tabspec *t			/* structure to be initialised */
25420 ) {
25421 	static unsigned char data[] = {
25422 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25423 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25424 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25425 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
25426 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
25427 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
25428 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25429 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
25430 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
25431 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25432 		0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25433 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25434 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
25435 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25436 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
25437 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25438 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
25439 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
25440 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
25441 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25442 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25443 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
25444 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25445 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
25446 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25447 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25448 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25449 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
25450 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25451 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25452 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25453 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
25454 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
25455 	};	/* Structure image */
25456 
25457 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
25458 }
25459 
25460 
25461 
25462 
25463 
25464 
25465 /* Integer Multi-Dimensional Interpolation */
25466 /* Interpolation Kernel Code */
25467 /* Generated by cgen */
25468 /* Copyright 2000 - 2002 Graeme W. Gill */
25469 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
25470 
25471 /* see the Licence.txt file for licencing details.*/
25472 
25473 
25474 /*
25475    Interpolation kernel specs:
25476 
25477    Input channels per pixel = 5
25478    Input channel 0 bits = 8
25479    Input channel 0 increment = 5
25480    Input channel 1 bits = 8
25481    Input channel 1 increment = 5
25482    Input channel 2 bits = 8
25483    Input channel 2 increment = 5
25484    Input channel 3 bits = 8
25485    Input channel 3 increment = 5
25486    Input channel 4 bits = 8
25487    Input channel 4 increment = 5
25488    Input is channel interleaved
25489    Input channels are separate words
25490    Input value extraction is done in input table lookup
25491 
25492    Output channels per pixel = 5
25493    Output channel 0 bits = 16
25494    Output channel 0 increment = 5
25495    Output channel 1 bits = 16
25496    Output channel 1 increment = 5
25497    Output channel 2 bits = 16
25498    Output channel 2 increment = 5
25499    Output channel 3 bits = 16
25500    Output channel 3 increment = 5
25501    Output channel 4 bits = 16
25502    Output channel 4 increment = 5
25503    Output is channel interleaved
25504 
25505    Output channels are separate words
25506    Weight+voffset bits       = 32
25507    Interpolation table index bits = 32
25508    Interpolation table max resolution = 40
25509  */
25510 
25511 /*
25512    Machine architecture specs:
25513 
25514    Little endian
25515    Reading and writing pixel values separately
25516    Pointer size = 32 bits
25517 
25518    Ordinal size  8 bits is known as 'unsigned char'
25519    Ordinal size 16 bits is known as 'unsigned short'
25520    Ordinal size 32 bits is known as 'unsigned int'
25521    Natural ordinal is 'unsigned int'
25522 
25523    Integer size  8 bits is known as 'signed char'
25524    Integer size 16 bits is known as 'short'
25525    Integer size 32 bits is known as 'int'
25526    Natural integer is 'int'
25527 
25528  */
25529 
25530 #ifndef  IMDI_INCLUDED
25531 #include <memory.h>
25532 #include "imdi_imp.h"
25533 #define  IMDI_INCLUDED
25534 #endif  /* IMDI_INCLUDED */
25535 
25536 #ifndef DEFINED_pointer
25537 #define DEFINED_pointer
25538 typedef unsigned char * pointer;
25539 #endif
25540 
25541 /* Input table interp. index */
25542 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
25543 
25544 /* Input table input weighting/offset value enty */
25545 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
25546 
25547 /* Conditional exchange for sorting */
25548 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
25549 
25550 /* Interpolation multi-dim. table access */
25551 #define IM_O(off) ((off) * 12)
25552 
25553 /* Interpolation table - get vertex values */
25554 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
25555 #define IM_PE(p, v) *((unsigned int *)((p) + 8 + (v) * 4))
25556 
25557 /* Output table indexes */
25558 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
25559 
25560 void
imdi_k74(imdi * s,void ** outp,void ** inp,unsigned int npix)25561 imdi_k74(
25562 imdi *s,			/* imdi context */
25563 void **outp,		/* pointer to output pointers */
25564 void **inp,		/* pointer to input pointers */
25565 unsigned int npix	/* Number of pixels to process */
25566 ) {
25567 	imdi_imp *p = (imdi_imp *)(s->impl);
25568 	unsigned char *ip0 = (unsigned char *)inp[0];
25569 	unsigned short *op0 = (unsigned short *)outp[0];
25570 	unsigned char *ep = ip0 + npix * 5 ;
25571 	pointer it0 = (pointer)p->in_tables[0];
25572 	pointer it1 = (pointer)p->in_tables[1];
25573 	pointer it2 = (pointer)p->in_tables[2];
25574 	pointer it3 = (pointer)p->in_tables[3];
25575 	pointer it4 = (pointer)p->in_tables[4];
25576 	pointer ot0 = (pointer)p->out_tables[0];
25577 	pointer ot1 = (pointer)p->out_tables[1];
25578 	pointer ot2 = (pointer)p->out_tables[2];
25579 	pointer ot3 = (pointer)p->out_tables[3];
25580 	pointer ot4 = (pointer)p->out_tables[4];
25581 	pointer im_base = (pointer)p->im_table;
25582 
25583 	for(;ip0 < ep; ip0 += 5, op0 += 5) {
25584 		unsigned int ova0;	/* Output value accumulator */
25585 		unsigned int ova1;	/* Output value accumulator */
25586 		unsigned int ova2;	/* Output value partial accumulator */
25587 		{
25588 			pointer imp;
25589 			unsigned int wo0;	/* Weighting value and vertex offset variable */
25590 			unsigned int wo1;	/* Weighting value and vertex offset variable */
25591 			unsigned int wo2;	/* Weighting value and vertex offset variable */
25592 			unsigned int wo3;	/* Weighting value and vertex offset variable */
25593 			unsigned int wo4;	/* Weighting value and vertex offset variable */
25594 			{
25595 				unsigned int ti_i;	/* Interpolation index variable */
25596 
25597 				ti_i  = IT_IX(it0, ip0[0]);
25598 				wo0   = IT_WO(it0, ip0[0]);
25599 				ti_i += IT_IX(it1, ip0[1]);
25600 				wo1   = IT_WO(it1, ip0[1]);
25601 				ti_i += IT_IX(it2, ip0[2]);
25602 				wo2   = IT_WO(it2, ip0[2]);
25603 				ti_i += IT_IX(it3, ip0[3]);
25604 				wo3   = IT_WO(it3, ip0[3]);
25605 				ti_i += IT_IX(it4, ip0[4]);
25606 				wo4   = IT_WO(it4, ip0[4]);
25607 
25608 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
25609 
25610 				/* Sort weighting values and vertex offset values */
25611 				CEX(wo0, wo1);
25612 				CEX(wo0, wo2);
25613 				CEX(wo0, wo3);
25614 				CEX(wo0, wo4);
25615 				CEX(wo1, wo2);
25616 				CEX(wo1, wo3);
25617 				CEX(wo1, wo4);
25618 				CEX(wo2, wo3);
25619 				CEX(wo2, wo4);
25620 				CEX(wo3, wo4);
25621 			}
25622 			{
25623 				unsigned int nvof;	/* Next vertex offset value */
25624 				unsigned int vof;	/* Vertex offset value */
25625 				unsigned int vwe;	/* Vertex weighting */
25626 
25627 				vof = 0;				/* First vertex offset is 0 */
25628 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
25629 				wo0 = (wo0 >> 23);		/* Extract weighting value */
25630 				vwe = 256 - wo0;		/* Baricentric weighting */
25631 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
25632 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
25633 				ova2  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
25634 				vof += nvof;			/* Move to next vertex */
25635 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
25636 				wo1 = (wo1 >> 23);		/* Extract weighting value */
25637 				vwe = wo0 - wo1;		/* Baricentric weighting */
25638 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
25639 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
25640 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
25641 				vof += nvof;			/* Move to next vertex */
25642 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
25643 				wo2 = (wo2 >> 23);		/* Extract weighting value */
25644 				vwe = wo1 - wo2;		/* Baricentric weighting */
25645 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
25646 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
25647 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
25648 				vof += nvof;			/* Move to next vertex */
25649 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
25650 				wo3 = (wo3 >> 23);		/* Extract weighting value */
25651 				vwe = wo2 - wo3;		/* Baricentric weighting */
25652 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
25653 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
25654 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
25655 				vof += nvof;			/* Move to next vertex */
25656 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
25657 				wo4 = (wo4 >> 23);		/* Extract weighting value */
25658 				vwe = wo3 - wo4;		/* Baricentric weighting */
25659 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
25660 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
25661 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
25662 				vof += nvof;			/* Move to next vertex */
25663 				vwe = wo4;				/* Baricentric weighting */
25664 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
25665 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
25666 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
25667 			}
25668 		}
25669 		{
25670 			unsigned int oti;	/* Vertex offset value */
25671 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
25672 			op0[0] = OT_E(ot0, oti);	/* Write result */
25673 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
25674 			op0[1] = OT_E(ot1, oti);	/* Write result */
25675 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
25676 			op0[2] = OT_E(ot2, oti);	/* Write result */
25677 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
25678 			op0[3] = OT_E(ot3, oti);	/* Write result */
25679 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
25680 			op0[4] = OT_E(ot4, oti);	/* Write result */
25681 		}
25682 	}
25683 }
25684 #undef IT_WO
25685 #undef IT_IX
25686 #undef CEX
25687 #undef IM_O
25688 #undef IM_FE
25689 #undef IM_PE
25690 #undef OT_E
25691 
25692 void
imdi_k74_gen(genspec * g)25693 imdi_k74_gen(
25694 genspec *g			/* structure to be initialised */
25695 ) {
25696 	static unsigned char data[] = {
25697 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
25698 		0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25699 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25700 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25701 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25702 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25703 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25704 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
25705 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
25706 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
25707 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25708 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25709 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25710 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25711 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25712 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25713 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25714 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25715 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25716 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25717 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25718 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25719 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25720 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25721 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
25722 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
25723 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
25724 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25725 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25726 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25727 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25728 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25729 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25730 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25731 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25732 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25733 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25734 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25735 		0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25736 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
25737 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
25738 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
25739 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
25740 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
25741 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
25742 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
25743 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
25744 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
25745 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25746 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
25747 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
25748 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x35, 0x5f,
25749 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
25750 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
25751 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
25752 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
25753 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
25754 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
25755 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
25756 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25757 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25758 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25759 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25760 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
25761 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x37, 0x34,
25762 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25763 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25764 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
25765 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
25766 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
25767 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
25768 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
25769 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
25770 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
25771 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
25772 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
25773 		0x00, 0xf0, 0x04, 0x08
25774 	};	/* Structure image */
25775 
25776 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
25777 }
25778 
25779 void
imdi_k74_tab(tabspec * t)25780 imdi_k74_tab(
25781 tabspec *t			/* structure to be initialised */
25782 ) {
25783 	static unsigned char data[] = {
25784 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25785 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25786 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25787 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
25788 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
25789 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
25790 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
25791 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
25792 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
25793 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25794 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
25795 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
25796 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
25797 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
25798 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
25799 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25800 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
25801 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
25802 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
25803 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25804 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
25805 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
25806 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25807 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
25808 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25809 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25810 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25811 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
25812 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25813 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25814 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
25815 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
25816 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
25817 	};	/* Structure image */
25818 
25819 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
25820 }
25821 
25822 
25823 
25824 
25825 
25826 
25827 /* Integer Multi-Dimensional Interpolation */
25828 /* Interpolation Kernel Code */
25829 /* Generated by cgen */
25830 /* Copyright 2000 - 2002 Graeme W. Gill */
25831 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
25832 
25833 /* see the Licence.txt file for licencing details.*/
25834 
25835 
25836 /*
25837    Interpolation kernel specs:
25838 
25839    Input channels per pixel = 6
25840    Input channel 0 bits = 8
25841    Input channel 0 increment = 6
25842    Input channel 1 bits = 8
25843    Input channel 1 increment = 6
25844    Input channel 2 bits = 8
25845    Input channel 2 increment = 6
25846    Input channel 3 bits = 8
25847    Input channel 3 increment = 6
25848    Input channel 4 bits = 8
25849    Input channel 4 increment = 6
25850    Input channel 5 bits = 8
25851    Input channel 5 increment = 6
25852    Input is channel interleaved
25853    Input channels are separate words
25854    Input value extraction is done in input table lookup
25855 
25856    Output channels per pixel = 5
25857    Output channel 0 bits = 16
25858    Output channel 0 increment = 5
25859    Output channel 1 bits = 16
25860    Output channel 1 increment = 5
25861    Output channel 2 bits = 16
25862    Output channel 2 increment = 5
25863    Output channel 3 bits = 16
25864    Output channel 3 increment = 5
25865    Output channel 4 bits = 16
25866    Output channel 4 increment = 5
25867    Output is channel interleaved
25868 
25869    Output channels are separate words
25870    Weight+voffset bits       = 32
25871    Interpolation table index bits = 32
25872    Interpolation table max resolution = 19
25873  */
25874 
25875 /*
25876    Machine architecture specs:
25877 
25878    Little endian
25879    Reading and writing pixel values separately
25880    Pointer size = 32 bits
25881 
25882    Ordinal size  8 bits is known as 'unsigned char'
25883    Ordinal size 16 bits is known as 'unsigned short'
25884    Ordinal size 32 bits is known as 'unsigned int'
25885    Natural ordinal is 'unsigned int'
25886 
25887    Integer size  8 bits is known as 'signed char'
25888    Integer size 16 bits is known as 'short'
25889    Integer size 32 bits is known as 'int'
25890    Natural integer is 'int'
25891 
25892  */
25893 
25894 #ifndef  IMDI_INCLUDED
25895 #include <memory.h>
25896 #include "imdi_imp.h"
25897 #define  IMDI_INCLUDED
25898 #endif  /* IMDI_INCLUDED */
25899 
25900 #ifndef DEFINED_pointer
25901 #define DEFINED_pointer
25902 typedef unsigned char * pointer;
25903 #endif
25904 
25905 /* Input table interp. index */
25906 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
25907 
25908 /* Input table input weighting/offset value enty */
25909 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
25910 
25911 /* Conditional exchange for sorting */
25912 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
25913 
25914 /* Interpolation multi-dim. table access */
25915 #define IM_O(off) ((off) * 12)
25916 
25917 /* Interpolation table - get vertex values */
25918 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
25919 #define IM_PE(p, v) *((unsigned int *)((p) + 8 + (v) * 4))
25920 
25921 /* Output table indexes */
25922 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
25923 
25924 void
imdi_k75(imdi * s,void ** outp,void ** inp,unsigned int npix)25925 imdi_k75(
25926 imdi *s,			/* imdi context */
25927 void **outp,		/* pointer to output pointers */
25928 void **inp,		/* pointer to input pointers */
25929 unsigned int npix	/* Number of pixels to process */
25930 ) {
25931 	imdi_imp *p = (imdi_imp *)(s->impl);
25932 	unsigned char *ip0 = (unsigned char *)inp[0];
25933 	unsigned short *op0 = (unsigned short *)outp[0];
25934 	unsigned char *ep = ip0 + npix * 6 ;
25935 	pointer it0 = (pointer)p->in_tables[0];
25936 	pointer it1 = (pointer)p->in_tables[1];
25937 	pointer it2 = (pointer)p->in_tables[2];
25938 	pointer it3 = (pointer)p->in_tables[3];
25939 	pointer it4 = (pointer)p->in_tables[4];
25940 	pointer it5 = (pointer)p->in_tables[5];
25941 	pointer ot0 = (pointer)p->out_tables[0];
25942 	pointer ot1 = (pointer)p->out_tables[1];
25943 	pointer ot2 = (pointer)p->out_tables[2];
25944 	pointer ot3 = (pointer)p->out_tables[3];
25945 	pointer ot4 = (pointer)p->out_tables[4];
25946 	pointer im_base = (pointer)p->im_table;
25947 
25948 	for(;ip0 < ep; ip0 += 6, op0 += 5) {
25949 		unsigned int ova0;	/* Output value accumulator */
25950 		unsigned int ova1;	/* Output value accumulator */
25951 		unsigned int ova2;	/* Output value partial accumulator */
25952 		{
25953 			pointer imp;
25954 			unsigned int wo0;	/* Weighting value and vertex offset variable */
25955 			unsigned int wo1;	/* Weighting value and vertex offset variable */
25956 			unsigned int wo2;	/* Weighting value and vertex offset variable */
25957 			unsigned int wo3;	/* Weighting value and vertex offset variable */
25958 			unsigned int wo4;	/* Weighting value and vertex offset variable */
25959 			unsigned int wo5;	/* Weighting value and vertex offset variable */
25960 			{
25961 				unsigned int ti_i;	/* Interpolation index variable */
25962 
25963 				ti_i  = IT_IX(it0, ip0[0]);
25964 				wo0   = IT_WO(it0, ip0[0]);
25965 				ti_i += IT_IX(it1, ip0[1]);
25966 				wo1   = IT_WO(it1, ip0[1]);
25967 				ti_i += IT_IX(it2, ip0[2]);
25968 				wo2   = IT_WO(it2, ip0[2]);
25969 				ti_i += IT_IX(it3, ip0[3]);
25970 				wo3   = IT_WO(it3, ip0[3]);
25971 				ti_i += IT_IX(it4, ip0[4]);
25972 				wo4   = IT_WO(it4, ip0[4]);
25973 				ti_i += IT_IX(it5, ip0[5]);
25974 				wo5   = IT_WO(it5, ip0[5]);
25975 
25976 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
25977 
25978 				/* Sort weighting values and vertex offset values */
25979 				CEX(wo0, wo1);
25980 				CEX(wo0, wo2);
25981 				CEX(wo0, wo3);
25982 				CEX(wo0, wo4);
25983 				CEX(wo0, wo5);
25984 				CEX(wo1, wo2);
25985 				CEX(wo1, wo3);
25986 				CEX(wo1, wo4);
25987 				CEX(wo1, wo5);
25988 				CEX(wo2, wo3);
25989 				CEX(wo2, wo4);
25990 				CEX(wo2, wo5);
25991 				CEX(wo3, wo4);
25992 				CEX(wo3, wo5);
25993 				CEX(wo4, wo5);
25994 			}
25995 			{
25996 				unsigned int nvof;	/* Next vertex offset value */
25997 				unsigned int vof;	/* Vertex offset value */
25998 				unsigned int vwe;	/* Vertex weighting */
25999 
26000 				vof = 0;				/* First vertex offset is 0 */
26001 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
26002 				wo0 = (wo0 >> 23);		/* Extract weighting value */
26003 				vwe = 256 - wo0;		/* Baricentric weighting */
26004 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26005 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26006 				ova2  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26007 				vof += nvof;			/* Move to next vertex */
26008 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
26009 				wo1 = (wo1 >> 23);		/* Extract weighting value */
26010 				vwe = wo0 - wo1;		/* Baricentric weighting */
26011 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26012 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26013 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26014 				vof += nvof;			/* Move to next vertex */
26015 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
26016 				wo2 = (wo2 >> 23);		/* Extract weighting value */
26017 				vwe = wo1 - wo2;		/* Baricentric weighting */
26018 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26019 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26020 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26021 				vof += nvof;			/* Move to next vertex */
26022 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
26023 				wo3 = (wo3 >> 23);		/* Extract weighting value */
26024 				vwe = wo2 - wo3;		/* Baricentric weighting */
26025 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26026 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26027 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26028 				vof += nvof;			/* Move to next vertex */
26029 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
26030 				wo4 = (wo4 >> 23);		/* Extract weighting value */
26031 				vwe = wo3 - wo4;		/* Baricentric weighting */
26032 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26033 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26034 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26035 				vof += nvof;			/* Move to next vertex */
26036 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
26037 				wo5 = (wo5 >> 23);		/* Extract weighting value */
26038 				vwe = wo4 - wo5;		/* Baricentric weighting */
26039 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26040 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26041 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26042 				vof += nvof;			/* Move to next vertex */
26043 				vwe = wo5;				/* Baricentric weighting */
26044 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26045 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26046 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26047 			}
26048 		}
26049 		{
26050 			unsigned int oti;	/* Vertex offset value */
26051 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
26052 			op0[0] = OT_E(ot0, oti);	/* Write result */
26053 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
26054 			op0[1] = OT_E(ot1, oti);	/* Write result */
26055 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
26056 			op0[2] = OT_E(ot2, oti);	/* Write result */
26057 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
26058 			op0[3] = OT_E(ot3, oti);	/* Write result */
26059 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
26060 			op0[4] = OT_E(ot4, oti);	/* Write result */
26061 		}
26062 	}
26063 }
26064 #undef IT_WO
26065 #undef IT_IX
26066 #undef CEX
26067 #undef IM_O
26068 #undef IM_FE
26069 #undef IM_PE
26070 #undef OT_E
26071 
26072 void
imdi_k75_gen(genspec * g)26073 imdi_k75_gen(
26074 genspec *g			/* structure to be initialised */
26075 ) {
26076 	static unsigned char data[] = {
26077 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
26078 		0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26079 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26080 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26081 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26082 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26083 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26084 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
26085 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
26086 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
26087 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26088 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26089 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26090 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26091 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26092 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26093 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26094 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26095 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26096 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26097 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26098 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26099 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26100 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26101 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
26102 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
26103 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
26104 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26105 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26106 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26107 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26108 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26109 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26110 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26111 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26112 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26113 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26114 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26115 		0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26116 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
26117 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
26118 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
26119 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
26120 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
26121 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
26122 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
26123 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
26124 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
26125 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26126 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
26127 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
26128 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x35, 0x5f,
26129 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
26130 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
26131 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
26132 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
26133 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
26134 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
26135 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
26136 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26137 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26138 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26139 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26140 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
26141 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x37, 0x35,
26142 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26143 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26144 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
26145 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
26146 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
26147 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
26148 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
26149 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
26150 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
26151 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
26152 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
26153 		0x00, 0xf0, 0x04, 0x08
26154 	};	/* Structure image */
26155 
26156 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
26157 }
26158 
26159 void
imdi_k75_tab(tabspec * t)26160 imdi_k75_tab(
26161 tabspec *t			/* structure to be initialised */
26162 ) {
26163 	static unsigned char data[] = {
26164 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26165 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26166 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26167 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
26168 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
26169 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
26170 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26171 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
26172 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
26173 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26174 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
26175 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
26176 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
26177 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
26178 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
26179 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26180 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
26181 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
26182 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
26183 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26184 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26185 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
26186 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26187 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
26188 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26189 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26190 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26191 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
26192 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26193 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26194 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26195 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
26196 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
26197 	};	/* Structure image */
26198 
26199 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
26200 }
26201 
26202 
26203 
26204 
26205 
26206 
26207 /* Integer Multi-Dimensional Interpolation */
26208 /* Interpolation Kernel Code */
26209 /* Generated by cgen */
26210 /* Copyright 2000 - 2002 Graeme W. Gill */
26211 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
26212 
26213 /* see the Licence.txt file for licencing details.*/
26214 
26215 
26216 /*
26217    Interpolation kernel specs:
26218 
26219    Input channels per pixel = 7
26220    Input channel 0 bits = 8
26221    Input channel 0 increment = 7
26222    Input channel 1 bits = 8
26223    Input channel 1 increment = 7
26224    Input channel 2 bits = 8
26225    Input channel 2 increment = 7
26226    Input channel 3 bits = 8
26227    Input channel 3 increment = 7
26228    Input channel 4 bits = 8
26229    Input channel 4 increment = 7
26230    Input channel 5 bits = 8
26231    Input channel 5 increment = 7
26232    Input channel 6 bits = 8
26233    Input channel 6 increment = 7
26234    Input is channel interleaved
26235    Input channels are separate words
26236    Input value extraction is done in input table lookup
26237 
26238    Output channels per pixel = 5
26239    Output channel 0 bits = 16
26240    Output channel 0 increment = 5
26241    Output channel 1 bits = 16
26242    Output channel 1 increment = 5
26243    Output channel 2 bits = 16
26244    Output channel 2 increment = 5
26245    Output channel 3 bits = 16
26246    Output channel 3 increment = 5
26247    Output channel 4 bits = 16
26248    Output channel 4 increment = 5
26249    Output is channel interleaved
26250 
26251    Output channels are separate words
26252    Weight+voffset bits       = 32
26253    Interpolation table index bits = 32
26254    Interpolation table max resolution = 11
26255  */
26256 
26257 /*
26258    Machine architecture specs:
26259 
26260    Little endian
26261    Reading and writing pixel values separately
26262    Pointer size = 32 bits
26263 
26264    Ordinal size  8 bits is known as 'unsigned char'
26265    Ordinal size 16 bits is known as 'unsigned short'
26266    Ordinal size 32 bits is known as 'unsigned int'
26267    Natural ordinal is 'unsigned int'
26268 
26269    Integer size  8 bits is known as 'signed char'
26270    Integer size 16 bits is known as 'short'
26271    Integer size 32 bits is known as 'int'
26272    Natural integer is 'int'
26273 
26274  */
26275 
26276 #ifndef  IMDI_INCLUDED
26277 #include <memory.h>
26278 #include "imdi_imp.h"
26279 #define  IMDI_INCLUDED
26280 #endif  /* IMDI_INCLUDED */
26281 
26282 #ifndef DEFINED_pointer
26283 #define DEFINED_pointer
26284 typedef unsigned char * pointer;
26285 #endif
26286 
26287 /* Input table interp. index */
26288 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
26289 
26290 /* Input table input weighting/offset value enty */
26291 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
26292 
26293 /* Conditional exchange for sorting */
26294 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
26295 
26296 /* Interpolation multi-dim. table access */
26297 #define IM_O(off) ((off) * 12)
26298 
26299 /* Interpolation table - get vertex values */
26300 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
26301 #define IM_PE(p, v) *((unsigned int *)((p) + 8 + (v) * 4))
26302 
26303 /* Output table indexes */
26304 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
26305 
26306 void
imdi_k76(imdi * s,void ** outp,void ** inp,unsigned int npix)26307 imdi_k76(
26308 imdi *s,			/* imdi context */
26309 void **outp,		/* pointer to output pointers */
26310 void **inp,		/* pointer to input pointers */
26311 unsigned int npix	/* Number of pixels to process */
26312 ) {
26313 	imdi_imp *p = (imdi_imp *)(s->impl);
26314 	unsigned char *ip0 = (unsigned char *)inp[0];
26315 	unsigned short *op0 = (unsigned short *)outp[0];
26316 	unsigned char *ep = ip0 + npix * 7 ;
26317 	pointer it0 = (pointer)p->in_tables[0];
26318 	pointer it1 = (pointer)p->in_tables[1];
26319 	pointer it2 = (pointer)p->in_tables[2];
26320 	pointer it3 = (pointer)p->in_tables[3];
26321 	pointer it4 = (pointer)p->in_tables[4];
26322 	pointer it5 = (pointer)p->in_tables[5];
26323 	pointer it6 = (pointer)p->in_tables[6];
26324 	pointer ot0 = (pointer)p->out_tables[0];
26325 	pointer ot1 = (pointer)p->out_tables[1];
26326 	pointer ot2 = (pointer)p->out_tables[2];
26327 	pointer ot3 = (pointer)p->out_tables[3];
26328 	pointer ot4 = (pointer)p->out_tables[4];
26329 	pointer im_base = (pointer)p->im_table;
26330 
26331 	for(;ip0 < ep; ip0 += 7, op0 += 5) {
26332 		unsigned int ova0;	/* Output value accumulator */
26333 		unsigned int ova1;	/* Output value accumulator */
26334 		unsigned int ova2;	/* Output value partial accumulator */
26335 		{
26336 			pointer imp;
26337 			unsigned int wo0;	/* Weighting value and vertex offset variable */
26338 			unsigned int wo1;	/* Weighting value and vertex offset variable */
26339 			unsigned int wo2;	/* Weighting value and vertex offset variable */
26340 			unsigned int wo3;	/* Weighting value and vertex offset variable */
26341 			unsigned int wo4;	/* Weighting value and vertex offset variable */
26342 			unsigned int wo5;	/* Weighting value and vertex offset variable */
26343 			unsigned int wo6;	/* Weighting value and vertex offset variable */
26344 			{
26345 				unsigned int ti_i;	/* Interpolation index variable */
26346 
26347 				ti_i  = IT_IX(it0, ip0[0]);
26348 				wo0   = IT_WO(it0, ip0[0]);
26349 				ti_i += IT_IX(it1, ip0[1]);
26350 				wo1   = IT_WO(it1, ip0[1]);
26351 				ti_i += IT_IX(it2, ip0[2]);
26352 				wo2   = IT_WO(it2, ip0[2]);
26353 				ti_i += IT_IX(it3, ip0[3]);
26354 				wo3   = IT_WO(it3, ip0[3]);
26355 				ti_i += IT_IX(it4, ip0[4]);
26356 				wo4   = IT_WO(it4, ip0[4]);
26357 				ti_i += IT_IX(it5, ip0[5]);
26358 				wo5   = IT_WO(it5, ip0[5]);
26359 				ti_i += IT_IX(it6, ip0[6]);
26360 				wo6   = IT_WO(it6, ip0[6]);
26361 
26362 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
26363 
26364 				/* Sort weighting values and vertex offset values */
26365 				CEX(wo0, wo1);
26366 				CEX(wo0, wo2);
26367 				CEX(wo0, wo3);
26368 				CEX(wo0, wo4);
26369 				CEX(wo0, wo5);
26370 				CEX(wo0, wo6);
26371 				CEX(wo1, wo2);
26372 				CEX(wo1, wo3);
26373 				CEX(wo1, wo4);
26374 				CEX(wo1, wo5);
26375 				CEX(wo1, wo6);
26376 				CEX(wo2, wo3);
26377 				CEX(wo2, wo4);
26378 				CEX(wo2, wo5);
26379 				CEX(wo2, wo6);
26380 				CEX(wo3, wo4);
26381 				CEX(wo3, wo5);
26382 				CEX(wo3, wo6);
26383 				CEX(wo4, wo5);
26384 				CEX(wo4, wo6);
26385 				CEX(wo5, wo6);
26386 			}
26387 			{
26388 				unsigned int nvof;	/* Next vertex offset value */
26389 				unsigned int vof;	/* Vertex offset value */
26390 				unsigned int vwe;	/* Vertex weighting */
26391 
26392 				vof = 0;				/* First vertex offset is 0 */
26393 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
26394 				wo0 = (wo0 >> 23);		/* Extract weighting value */
26395 				vwe = 256 - wo0;		/* Baricentric weighting */
26396 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26397 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26398 				ova2  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26399 				vof += nvof;			/* Move to next vertex */
26400 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
26401 				wo1 = (wo1 >> 23);		/* Extract weighting value */
26402 				vwe = wo0 - wo1;		/* Baricentric weighting */
26403 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26404 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26405 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26406 				vof += nvof;			/* Move to next vertex */
26407 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
26408 				wo2 = (wo2 >> 23);		/* Extract weighting value */
26409 				vwe = wo1 - wo2;		/* Baricentric weighting */
26410 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26411 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26412 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26413 				vof += nvof;			/* Move to next vertex */
26414 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
26415 				wo3 = (wo3 >> 23);		/* Extract weighting value */
26416 				vwe = wo2 - wo3;		/* Baricentric weighting */
26417 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26418 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26419 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26420 				vof += nvof;			/* Move to next vertex */
26421 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
26422 				wo4 = (wo4 >> 23);		/* Extract weighting value */
26423 				vwe = wo3 - wo4;		/* Baricentric weighting */
26424 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26425 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26426 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26427 				vof += nvof;			/* Move to next vertex */
26428 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
26429 				wo5 = (wo5 >> 23);		/* Extract weighting value */
26430 				vwe = wo4 - wo5;		/* Baricentric weighting */
26431 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26432 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26433 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26434 				vof += nvof;			/* Move to next vertex */
26435 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
26436 				wo6 = (wo6 >> 23);		/* Extract weighting value */
26437 				vwe = wo5 - wo6;		/* Baricentric weighting */
26438 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26439 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26440 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26441 				vof += nvof;			/* Move to next vertex */
26442 				vwe = wo6;				/* Baricentric weighting */
26443 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26444 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26445 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26446 			}
26447 		}
26448 		{
26449 			unsigned int oti;	/* Vertex offset value */
26450 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
26451 			op0[0] = OT_E(ot0, oti);	/* Write result */
26452 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
26453 			op0[1] = OT_E(ot1, oti);	/* Write result */
26454 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
26455 			op0[2] = OT_E(ot2, oti);	/* Write result */
26456 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
26457 			op0[3] = OT_E(ot3, oti);	/* Write result */
26458 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
26459 			op0[4] = OT_E(ot4, oti);	/* Write result */
26460 		}
26461 	}
26462 }
26463 #undef IT_WO
26464 #undef IT_IX
26465 #undef CEX
26466 #undef IM_O
26467 #undef IM_FE
26468 #undef IM_PE
26469 #undef OT_E
26470 
26471 void
imdi_k76_gen(genspec * g)26472 imdi_k76_gen(
26473 genspec *g			/* structure to be initialised */
26474 ) {
26475 	static unsigned char data[] = {
26476 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
26477 		0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26478 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26479 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26480 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26481 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26482 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26483 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
26484 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
26485 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
26486 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
26487 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26488 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26489 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26490 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26491 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26492 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26493 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26494 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26495 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26496 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26497 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26498 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26499 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26500 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
26501 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
26502 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
26503 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26504 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26505 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26506 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26507 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26508 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26509 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26510 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26511 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26512 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26513 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26514 		0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26515 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
26516 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
26517 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
26518 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
26519 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
26520 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
26521 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
26522 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
26523 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
26524 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26525 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
26526 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
26527 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x35, 0x5f,
26528 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
26529 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
26530 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
26531 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
26532 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
26533 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
26534 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
26535 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26536 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26537 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26538 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26539 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
26540 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x37, 0x36,
26541 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26542 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26543 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
26544 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
26545 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
26546 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
26547 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
26548 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
26549 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
26550 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
26551 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
26552 		0x00, 0xf0, 0x04, 0x08
26553 	};	/* Structure image */
26554 
26555 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
26556 }
26557 
26558 void
imdi_k76_tab(tabspec * t)26559 imdi_k76_tab(
26560 tabspec *t			/* structure to be initialised */
26561 ) {
26562 	static unsigned char data[] = {
26563 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26564 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26565 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26566 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
26567 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
26568 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
26569 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26570 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
26571 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
26572 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26573 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
26574 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
26575 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
26576 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
26577 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
26578 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26579 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
26580 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
26581 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
26582 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26583 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26584 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
26585 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26586 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
26587 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26588 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26589 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26590 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
26591 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26592 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26593 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26594 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
26595 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
26596 	};	/* Structure image */
26597 
26598 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
26599 }
26600 
26601 
26602 
26603 
26604 
26605 
26606 /* Integer Multi-Dimensional Interpolation */
26607 /* Interpolation Kernel Code */
26608 /* Generated by cgen */
26609 /* Copyright 2000 - 2002 Graeme W. Gill */
26610 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
26611 
26612 /* see the Licence.txt file for licencing details.*/
26613 
26614 
26615 /*
26616    Interpolation kernel specs:
26617 
26618    Input channels per pixel = 8
26619    Input channel 0 bits = 8
26620    Input channel 0 increment = 8
26621    Input channel 1 bits = 8
26622    Input channel 1 increment = 8
26623    Input channel 2 bits = 8
26624    Input channel 2 increment = 8
26625    Input channel 3 bits = 8
26626    Input channel 3 increment = 8
26627    Input channel 4 bits = 8
26628    Input channel 4 increment = 8
26629    Input channel 5 bits = 8
26630    Input channel 5 increment = 8
26631    Input channel 6 bits = 8
26632    Input channel 6 increment = 8
26633    Input channel 7 bits = 8
26634    Input channel 7 increment = 8
26635    Input is channel interleaved
26636    Input channels are separate words
26637    Input value extraction is done in input table lookup
26638 
26639    Output channels per pixel = 5
26640    Output channel 0 bits = 16
26641    Output channel 0 increment = 5
26642    Output channel 1 bits = 16
26643    Output channel 1 increment = 5
26644    Output channel 2 bits = 16
26645    Output channel 2 increment = 5
26646    Output channel 3 bits = 16
26647    Output channel 3 increment = 5
26648    Output channel 4 bits = 16
26649    Output channel 4 increment = 5
26650    Output is channel interleaved
26651 
26652    Output channels are separate words
26653    Weight+voffset bits       = 32
26654    Interpolation table index bits = 32
26655    Interpolation table max resolution = 8
26656  */
26657 
26658 /*
26659    Machine architecture specs:
26660 
26661    Little endian
26662    Reading and writing pixel values separately
26663    Pointer size = 32 bits
26664 
26665    Ordinal size  8 bits is known as 'unsigned char'
26666    Ordinal size 16 bits is known as 'unsigned short'
26667    Ordinal size 32 bits is known as 'unsigned int'
26668    Natural ordinal is 'unsigned int'
26669 
26670    Integer size  8 bits is known as 'signed char'
26671    Integer size 16 bits is known as 'short'
26672    Integer size 32 bits is known as 'int'
26673    Natural integer is 'int'
26674 
26675  */
26676 
26677 #ifndef  IMDI_INCLUDED
26678 #include <memory.h>
26679 #include "imdi_imp.h"
26680 #define  IMDI_INCLUDED
26681 #endif  /* IMDI_INCLUDED */
26682 
26683 #ifndef DEFINED_pointer
26684 #define DEFINED_pointer
26685 typedef unsigned char * pointer;
26686 #endif
26687 
26688 /* Input table interp. index */
26689 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
26690 
26691 /* Input table input weighting/offset value enty */
26692 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
26693 
26694 /* Conditional exchange for sorting */
26695 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
26696 
26697 /* Interpolation multi-dim. table access */
26698 #define IM_O(off) ((off) * 12)
26699 
26700 /* Interpolation table - get vertex values */
26701 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
26702 #define IM_PE(p, v) *((unsigned int *)((p) + 8 + (v) * 4))
26703 
26704 /* Output table indexes */
26705 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
26706 
26707 void
imdi_k77(imdi * s,void ** outp,void ** inp,unsigned int npix)26708 imdi_k77(
26709 imdi *s,			/* imdi context */
26710 void **outp,		/* pointer to output pointers */
26711 void **inp,		/* pointer to input pointers */
26712 unsigned int npix	/* Number of pixels to process */
26713 ) {
26714 	imdi_imp *p = (imdi_imp *)(s->impl);
26715 	unsigned char *ip0 = (unsigned char *)inp[0];
26716 	unsigned short *op0 = (unsigned short *)outp[0];
26717 	unsigned char *ep = ip0 + npix * 8 ;
26718 	pointer it0 = (pointer)p->in_tables[0];
26719 	pointer it1 = (pointer)p->in_tables[1];
26720 	pointer it2 = (pointer)p->in_tables[2];
26721 	pointer it3 = (pointer)p->in_tables[3];
26722 	pointer it4 = (pointer)p->in_tables[4];
26723 	pointer it5 = (pointer)p->in_tables[5];
26724 	pointer it6 = (pointer)p->in_tables[6];
26725 	pointer it7 = (pointer)p->in_tables[7];
26726 	pointer ot0 = (pointer)p->out_tables[0];
26727 	pointer ot1 = (pointer)p->out_tables[1];
26728 	pointer ot2 = (pointer)p->out_tables[2];
26729 	pointer ot3 = (pointer)p->out_tables[3];
26730 	pointer ot4 = (pointer)p->out_tables[4];
26731 	pointer im_base = (pointer)p->im_table;
26732 
26733 	for(;ip0 < ep; ip0 += 8, op0 += 5) {
26734 		unsigned int ova0;	/* Output value accumulator */
26735 		unsigned int ova1;	/* Output value accumulator */
26736 		unsigned int ova2;	/* Output value partial accumulator */
26737 		{
26738 			pointer imp;
26739 			unsigned int wo0;	/* Weighting value and vertex offset variable */
26740 			unsigned int wo1;	/* Weighting value and vertex offset variable */
26741 			unsigned int wo2;	/* Weighting value and vertex offset variable */
26742 			unsigned int wo3;	/* Weighting value and vertex offset variable */
26743 			unsigned int wo4;	/* Weighting value and vertex offset variable */
26744 			unsigned int wo5;	/* Weighting value and vertex offset variable */
26745 			unsigned int wo6;	/* Weighting value and vertex offset variable */
26746 			unsigned int wo7;	/* Weighting value and vertex offset variable */
26747 			{
26748 				unsigned int ti_i;	/* Interpolation index variable */
26749 
26750 				ti_i  = IT_IX(it0, ip0[0]);
26751 				wo0   = IT_WO(it0, ip0[0]);
26752 				ti_i += IT_IX(it1, ip0[1]);
26753 				wo1   = IT_WO(it1, ip0[1]);
26754 				ti_i += IT_IX(it2, ip0[2]);
26755 				wo2   = IT_WO(it2, ip0[2]);
26756 				ti_i += IT_IX(it3, ip0[3]);
26757 				wo3   = IT_WO(it3, ip0[3]);
26758 				ti_i += IT_IX(it4, ip0[4]);
26759 				wo4   = IT_WO(it4, ip0[4]);
26760 				ti_i += IT_IX(it5, ip0[5]);
26761 				wo5   = IT_WO(it5, ip0[5]);
26762 				ti_i += IT_IX(it6, ip0[6]);
26763 				wo6   = IT_WO(it6, ip0[6]);
26764 				ti_i += IT_IX(it7, ip0[7]);
26765 				wo7   = IT_WO(it7, ip0[7]);
26766 
26767 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
26768 
26769 				/* Sort weighting values and vertex offset values */
26770 				CEX(wo0, wo1);
26771 				CEX(wo0, wo2);
26772 				CEX(wo0, wo3);
26773 				CEX(wo0, wo4);
26774 				CEX(wo0, wo5);
26775 				CEX(wo0, wo6);
26776 				CEX(wo0, wo7);
26777 				CEX(wo1, wo2);
26778 				CEX(wo1, wo3);
26779 				CEX(wo1, wo4);
26780 				CEX(wo1, wo5);
26781 				CEX(wo1, wo6);
26782 				CEX(wo1, wo7);
26783 				CEX(wo2, wo3);
26784 				CEX(wo2, wo4);
26785 				CEX(wo2, wo5);
26786 				CEX(wo2, wo6);
26787 				CEX(wo2, wo7);
26788 				CEX(wo3, wo4);
26789 				CEX(wo3, wo5);
26790 				CEX(wo3, wo6);
26791 				CEX(wo3, wo7);
26792 				CEX(wo4, wo5);
26793 				CEX(wo4, wo6);
26794 				CEX(wo4, wo7);
26795 				CEX(wo5, wo6);
26796 				CEX(wo5, wo7);
26797 				CEX(wo6, wo7);
26798 			}
26799 			{
26800 				unsigned int nvof;	/* Next vertex offset value */
26801 				unsigned int vof;	/* Vertex offset value */
26802 				unsigned int vwe;	/* Vertex weighting */
26803 
26804 				vof = 0;				/* First vertex offset is 0 */
26805 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
26806 				wo0 = (wo0 >> 23);		/* Extract weighting value */
26807 				vwe = 256 - wo0;		/* Baricentric weighting */
26808 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26809 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26810 				ova2  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26811 				vof += nvof;			/* Move to next vertex */
26812 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
26813 				wo1 = (wo1 >> 23);		/* Extract weighting value */
26814 				vwe = wo0 - wo1;		/* Baricentric weighting */
26815 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26816 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26817 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26818 				vof += nvof;			/* Move to next vertex */
26819 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
26820 				wo2 = (wo2 >> 23);		/* Extract weighting value */
26821 				vwe = wo1 - wo2;		/* Baricentric weighting */
26822 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26823 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26824 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26825 				vof += nvof;			/* Move to next vertex */
26826 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
26827 				wo3 = (wo3 >> 23);		/* Extract weighting value */
26828 				vwe = wo2 - wo3;		/* Baricentric weighting */
26829 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26830 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26831 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26832 				vof += nvof;			/* Move to next vertex */
26833 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
26834 				wo4 = (wo4 >> 23);		/* Extract weighting value */
26835 				vwe = wo3 - wo4;		/* Baricentric weighting */
26836 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26837 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26838 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26839 				vof += nvof;			/* Move to next vertex */
26840 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
26841 				wo5 = (wo5 >> 23);		/* Extract weighting value */
26842 				vwe = wo4 - wo5;		/* Baricentric weighting */
26843 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26844 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26845 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26846 				vof += nvof;			/* Move to next vertex */
26847 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
26848 				wo6 = (wo6 >> 23);		/* Extract weighting value */
26849 				vwe = wo5 - wo6;		/* Baricentric weighting */
26850 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26851 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26852 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26853 				vof += nvof;			/* Move to next vertex */
26854 				nvof = (wo7 & 0x7fffff);	/* Extract offset value */
26855 				wo7 = (wo7 >> 23);		/* Extract weighting value */
26856 				vwe = wo6 - wo7;		/* Baricentric weighting */
26857 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26858 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26859 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26860 				vof += nvof;			/* Move to next vertex */
26861 				vwe = wo7;				/* Baricentric weighting */
26862 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
26863 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
26864 				ova2 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
26865 			}
26866 		}
26867 		{
26868 			unsigned int oti;	/* Vertex offset value */
26869 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
26870 			op0[0] = OT_E(ot0, oti);	/* Write result */
26871 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
26872 			op0[1] = OT_E(ot1, oti);	/* Write result */
26873 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
26874 			op0[2] = OT_E(ot2, oti);	/* Write result */
26875 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
26876 			op0[3] = OT_E(ot3, oti);	/* Write result */
26877 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
26878 			op0[4] = OT_E(ot4, oti);	/* Write result */
26879 		}
26880 	}
26881 }
26882 #undef IT_WO
26883 #undef IT_IX
26884 #undef CEX
26885 #undef IM_O
26886 #undef IM_FE
26887 #undef IM_PE
26888 #undef OT_E
26889 
26890 void
imdi_k77_gen(genspec * g)26891 imdi_k77_gen(
26892 genspec *g			/* structure to be initialised */
26893 ) {
26894 	static unsigned char data[] = {
26895 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26896 		0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26897 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26898 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26899 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26900 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26901 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26902 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26903 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26904 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26905 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26906 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26907 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26908 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26909 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26910 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26911 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26912 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26913 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26914 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26915 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26916 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26917 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26918 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26919 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
26920 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
26921 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
26922 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26923 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26924 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26925 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26926 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26927 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26928 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26929 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
26930 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26931 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26932 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26933 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26934 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
26935 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
26936 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
26937 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
26938 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
26939 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
26940 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
26941 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
26942 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
26943 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26944 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
26945 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
26946 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x35, 0x5f,
26947 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
26948 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
26949 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
26950 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
26951 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
26952 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
26953 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
26954 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26955 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26956 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26957 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26958 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
26959 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x37, 0x37,
26960 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26961 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26962 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
26963 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
26964 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
26965 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
26966 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
26967 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
26968 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
26969 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
26970 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
26971 		0x00, 0xf0, 0x04, 0x08
26972 	};	/* Structure image */
26973 
26974 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
26975 }
26976 
26977 void
imdi_k77_tab(tabspec * t)26978 imdi_k77_tab(
26979 tabspec *t			/* structure to be initialised */
26980 ) {
26981 	static unsigned char data[] = {
26982 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26983 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26984 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26985 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
26986 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
26987 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
26988 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
26989 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
26990 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
26991 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26992 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
26993 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
26994 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
26995 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
26996 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
26997 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
26998 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
26999 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
27000 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
27001 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27002 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27003 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
27004 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27005 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
27006 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27007 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27008 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27009 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
27010 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27011 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27012 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27013 		0x21, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
27014 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
27015 	};	/* Structure image */
27016 
27017 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
27018 }
27019 
27020 
27021 
27022 
27023 
27024 
27025 /* Integer Multi-Dimensional Interpolation */
27026 /* Interpolation Kernel Code */
27027 /* Generated by cgen */
27028 /* Copyright 2000 - 2002 Graeme W. Gill */
27029 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
27030 
27031 /* see the Licence.txt file for licencing details.*/
27032 
27033 
27034 /*
27035    Interpolation kernel specs:
27036 
27037    Input channels per pixel = 1
27038    Input channel 0 bits = 8
27039    Input channel 0 increment = 1
27040    Input is channel interleaved
27041    Input channels are separate words
27042    Input value extraction is done in input table lookup
27043 
27044    Output channels per pixel = 6
27045    Output channel 0 bits = 16
27046    Output channel 0 increment = 6
27047    Output channel 1 bits = 16
27048    Output channel 1 increment = 6
27049    Output channel 2 bits = 16
27050    Output channel 2 increment = 6
27051    Output channel 3 bits = 16
27052    Output channel 3 increment = 6
27053    Output channel 4 bits = 16
27054    Output channel 4 increment = 6
27055    Output channel 5 bits = 16
27056    Output channel 5 increment = 6
27057    Output is channel interleaved
27058 
27059    Output channels are separate words
27060    Simplex table index bits       = 0
27061    Interpolation table index bits = 8
27062    Simplex table max resolution = 1
27063    Interpolation table max resolution = 255
27064  */
27065 
27066 /*
27067    Machine architecture specs:
27068 
27069    Little endian
27070    Reading and writing pixel values separately
27071    Pointer size = 32 bits
27072 
27073    Ordinal size  8 bits is known as 'unsigned char'
27074    Ordinal size 16 bits is known as 'unsigned short'
27075    Ordinal size 32 bits is known as 'unsigned int'
27076    Natural ordinal is 'unsigned int'
27077 
27078    Integer size  8 bits is known as 'signed char'
27079    Integer size 16 bits is known as 'short'
27080    Integer size 32 bits is known as 'int'
27081    Natural integer is 'int'
27082 
27083  */
27084 
27085 #ifndef  IMDI_INCLUDED
27086 #include <memory.h>
27087 #include "imdi_imp.h"
27088 #define  IMDI_INCLUDED
27089 #endif  /* IMDI_INCLUDED */
27090 
27091 #ifndef DEFINED_pointer
27092 #define DEFINED_pointer
27093 typedef unsigned char * pointer;
27094 #endif
27095 
27096 /* Input table inter & simplex indexes */
27097 #define IT_IT(p, off) *((unsigned char *)((p) + 0 + (off) * 1))
27098 
27099 /* Simplex weighting table access */
27100 #define SW_O(off) ((off) * 4)
27101 
27102 /* Simplex table - get weighting/offset value */
27103 #define SX_WO(p, v) *((unsigned short *)((p) + (v) * 2))
27104 
27105 /* Interpolation multi-dim. table access */
27106 #define IM_O(off) ((off) * 12)
27107 
27108 /* Interpolation table - get vertex values */
27109 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
27110 
27111 /* Output table indexes */
27112 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
27113 
27114 void
imdi_k78(imdi * s,void ** outp,void ** inp,unsigned int npix)27115 imdi_k78(
27116 imdi *s,			/* imdi context */
27117 void **outp,		/* pointer to output pointers */
27118 void **inp,		/* pointer to input pointers */
27119 unsigned int npix	/* Number of pixels to process */
27120 ) {
27121 	imdi_imp *p = (imdi_imp *)(s->impl);
27122 	unsigned char *ip0 = (unsigned char *)inp[0];
27123 	unsigned short *op0 = (unsigned short *)outp[0];
27124 	unsigned char *ep = ip0 + npix * 1 ;
27125 	pointer it0 = (pointer)p->in_tables[0];
27126 	pointer ot0 = (pointer)p->out_tables[0];
27127 	pointer ot1 = (pointer)p->out_tables[1];
27128 	pointer ot2 = (pointer)p->out_tables[2];
27129 	pointer ot3 = (pointer)p->out_tables[3];
27130 	pointer ot4 = (pointer)p->out_tables[4];
27131 	pointer ot5 = (pointer)p->out_tables[5];
27132 	pointer sw_base = (pointer)p->sw_table;
27133 	pointer im_base = (pointer)p->im_table;
27134 
27135 	for(;ip0 < ep; ip0 += 1, op0 += 6) {
27136 		unsigned int ova0;	/* Output value accumulator */
27137 		unsigned int ova1;	/* Output value accumulator */
27138 		unsigned int ova2;	/* Output value accumulator */
27139 		{
27140 			pointer swp;
27141 			pointer imp;
27142 			{
27143 				unsigned int ti;	/* Simplex+Interpolation index variable */
27144 
27145 				ti  = IT_IT(it0, ip0[0]);
27146 
27147 				imp = im_base + IM_O(ti >> 0);		/* Extract interp. index and comp. entry */
27148 				swp = sw_base + SW_O(ti & 0x0);	/* Extract simplex index and comp. entry */
27149 			}
27150 			{
27151 				unsigned int vowr;	/* Vertex offset/weight value */
27152 				unsigned int vof;	/* Vertex offset value */
27153 				unsigned int vwe;	/* Vertex weighting */
27154 
27155 				vowr = SX_WO(swp, 0);	/* Read vertex offset+weighting values */
27156 				vof = (vowr & 0x7f);	/* Extract offset value */
27157 				vwe = (vowr >> 7);	/* Extract weighting value */
27158 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
27159 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
27160 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
27161 				vowr = SX_WO(swp, 1);	/* Read vertex offset+weighting values */
27162 				vof = (vowr & 0x7f);	/* Extract offset value */
27163 				vwe = (vowr >> 7);	/* Extract weighting value */
27164 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
27165 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
27166 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
27167 			}
27168 		}
27169 		{
27170 			unsigned int oti;	/* Vertex offset value */
27171 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
27172 			op0[0] = OT_E(ot0, oti);	/* Write result */
27173 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
27174 			op0[1] = OT_E(ot1, oti);	/* Write result */
27175 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
27176 			op0[2] = OT_E(ot2, oti);	/* Write result */
27177 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
27178 			op0[3] = OT_E(ot3, oti);	/* Write result */
27179 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
27180 			op0[4] = OT_E(ot4, oti);	/* Write result */
27181 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
27182 			op0[5] = OT_E(ot5, oti);	/* Write result */
27183 		}
27184 	}
27185 }
27186 #undef IT_IT
27187 #undef SW_O
27188 #undef SX_WO
27189 #undef IM_O
27190 #undef IM_FE
27191 #undef OT_E
27192 
27193 void
imdi_k78_gen(genspec * g)27194 imdi_k78_gen(
27195 genspec *g			/* structure to be initialised */
27196 ) {
27197 	static unsigned char data[] = {
27198 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27199 		0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27200 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27201 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27202 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27203 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27204 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27205 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27206 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27207 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27208 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27209 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27210 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27211 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27212 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27213 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27214 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27215 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27216 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27217 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27218 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27219 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27220 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27221 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27222 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
27223 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
27224 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
27225 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27226 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27227 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27228 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27229 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27230 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27231 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27232 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27233 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27234 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27235 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27236 		0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27237 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
27238 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
27239 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
27240 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
27241 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
27242 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
27243 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
27244 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
27245 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
27246 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27247 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
27248 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
27249 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x36, 0x5f,
27250 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
27251 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
27252 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
27253 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
27254 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
27255 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
27256 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
27257 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27258 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27259 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27260 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27261 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
27262 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x37, 0x38,
27263 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27264 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27265 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
27266 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
27267 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
27268 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
27269 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
27270 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
27271 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
27272 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
27273 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
27274 		0x00, 0xf0, 0x04, 0x08
27275 	};	/* Structure image */
27276 
27277 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
27278 }
27279 
27280 void
imdi_k78_tab(tabspec * t)27281 imdi_k78_tab(
27282 tabspec *t			/* structure to be initialised */
27283 ) {
27284 	static unsigned char data[] = {
27285 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27286 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27287 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27288 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
27289 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
27290 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
27291 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27292 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
27293 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27294 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27295 		0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27296 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27297 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
27298 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
27299 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
27300 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27301 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
27302 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
27303 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27304 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27305 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27306 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
27307 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
27308 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
27309 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27310 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27311 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27312 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
27313 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27314 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27315 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27316 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
27317 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
27318 	};	/* Structure image */
27319 
27320 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
27321 }
27322 
27323 
27324 
27325 
27326 
27327 
27328 /* Integer Multi-Dimensional Interpolation */
27329 /* Interpolation Kernel Code */
27330 /* Generated by cgen */
27331 /* Copyright 2000 - 2002 Graeme W. Gill */
27332 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
27333 
27334 /* see the Licence.txt file for licencing details.*/
27335 
27336 
27337 /*
27338    Interpolation kernel specs:
27339 
27340    Input channels per pixel = 3
27341    Input channel 0 bits = 8
27342    Input channel 0 increment = 3
27343    Input channel 1 bits = 8
27344    Input channel 1 increment = 3
27345    Input channel 2 bits = 8
27346    Input channel 2 increment = 3
27347    Input is channel interleaved
27348    Input channels are separate words
27349    Input value extraction is done in input table lookup
27350 
27351    Output channels per pixel = 6
27352    Output channel 0 bits = 16
27353    Output channel 0 increment = 6
27354    Output channel 1 bits = 16
27355    Output channel 1 increment = 6
27356    Output channel 2 bits = 16
27357    Output channel 2 increment = 6
27358    Output channel 3 bits = 16
27359    Output channel 3 increment = 6
27360    Output channel 4 bits = 16
27361    Output channel 4 increment = 6
27362    Output channel 5 bits = 16
27363    Output channel 5 increment = 6
27364    Output is channel interleaved
27365 
27366    Output channels are separate words
27367    Simplex table index bits       = 12
27368    Interpolation table index bits = 20
27369    Simplex table max resolution = 16
27370    Interpolation table max resolution = 101
27371  */
27372 
27373 /*
27374    Machine architecture specs:
27375 
27376    Little endian
27377    Reading and writing pixel values separately
27378    Pointer size = 32 bits
27379 
27380    Ordinal size  8 bits is known as 'unsigned char'
27381    Ordinal size 16 bits is known as 'unsigned short'
27382    Ordinal size 32 bits is known as 'unsigned int'
27383    Natural ordinal is 'unsigned int'
27384 
27385    Integer size  8 bits is known as 'signed char'
27386    Integer size 16 bits is known as 'short'
27387    Integer size 32 bits is known as 'int'
27388    Natural integer is 'int'
27389 
27390  */
27391 
27392 #ifndef  IMDI_INCLUDED
27393 #include <memory.h>
27394 #include "imdi_imp.h"
27395 #define  IMDI_INCLUDED
27396 #endif  /* IMDI_INCLUDED */
27397 
27398 #ifndef DEFINED_pointer
27399 #define DEFINED_pointer
27400 typedef unsigned char * pointer;
27401 #endif
27402 
27403 /* Input table inter & simplex indexes */
27404 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
27405 
27406 /* Simplex weighting table access */
27407 #define SW_O(off) ((off) * 16)
27408 
27409 /* Simplex table - get weighting value */
27410 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
27411 
27412 /* Simplex table - get offset value */
27413 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
27414 
27415 /* Interpolation multi-dim. table access */
27416 #define IM_O(off) ((off) * 12)
27417 
27418 /* Interpolation table - get vertex values */
27419 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
27420 
27421 /* Output table indexes */
27422 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
27423 
27424 void
imdi_k79(imdi * s,void ** outp,void ** inp,unsigned int npix)27425 imdi_k79(
27426 imdi *s,			/* imdi context */
27427 void **outp,		/* pointer to output pointers */
27428 void **inp,		/* pointer to input pointers */
27429 unsigned int npix	/* Number of pixels to process */
27430 ) {
27431 	imdi_imp *p = (imdi_imp *)(s->impl);
27432 	unsigned char *ip0 = (unsigned char *)inp[0];
27433 	unsigned short *op0 = (unsigned short *)outp[0];
27434 	unsigned char *ep = ip0 + npix * 3 ;
27435 	pointer it0 = (pointer)p->in_tables[0];
27436 	pointer it1 = (pointer)p->in_tables[1];
27437 	pointer it2 = (pointer)p->in_tables[2];
27438 	pointer ot0 = (pointer)p->out_tables[0];
27439 	pointer ot1 = (pointer)p->out_tables[1];
27440 	pointer ot2 = (pointer)p->out_tables[2];
27441 	pointer ot3 = (pointer)p->out_tables[3];
27442 	pointer ot4 = (pointer)p->out_tables[4];
27443 	pointer ot5 = (pointer)p->out_tables[5];
27444 	pointer sw_base = (pointer)p->sw_table;
27445 	pointer im_base = (pointer)p->im_table;
27446 
27447 	for(;ip0 < ep; ip0 += 3, op0 += 6) {
27448 		unsigned int ova0;	/* Output value accumulator */
27449 		unsigned int ova1;	/* Output value accumulator */
27450 		unsigned int ova2;	/* Output value accumulator */
27451 		{
27452 			pointer swp;
27453 			pointer imp;
27454 			{
27455 				unsigned int ti;	/* Simplex+Interpolation index variable */
27456 
27457 				ti  = IT_IT(it0, ip0[0]);
27458 				ti += IT_IT(it1, ip0[1]);
27459 				ti += IT_IT(it2, ip0[2]);
27460 
27461 				imp = im_base + IM_O(ti >> 12);		/* Extract interp. index and comp. entry */
27462 				swp = sw_base + SW_O(ti & 0xfff);	/* Extract simplex index and comp. entry */
27463 			}
27464 			{
27465 				unsigned int vof;	/* Vertex offset value */
27466 				unsigned int vwe;	/* Vertex weighting */
27467 
27468 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
27469 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
27470 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
27471 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
27472 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
27473 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
27474 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
27475 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
27476 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
27477 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
27478 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
27479 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
27480 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
27481 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
27482 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
27483 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
27484 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
27485 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
27486 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
27487 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
27488 			}
27489 		}
27490 		{
27491 			unsigned int oti;	/* Vertex offset value */
27492 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
27493 			op0[0] = OT_E(ot0, oti);	/* Write result */
27494 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
27495 			op0[1] = OT_E(ot1, oti);	/* Write result */
27496 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
27497 			op0[2] = OT_E(ot2, oti);	/* Write result */
27498 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
27499 			op0[3] = OT_E(ot3, oti);	/* Write result */
27500 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
27501 			op0[4] = OT_E(ot4, oti);	/* Write result */
27502 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
27503 			op0[5] = OT_E(ot5, oti);	/* Write result */
27504 		}
27505 	}
27506 }
27507 #undef IT_IT
27508 #undef SW_O
27509 #undef SX_WE
27510 #undef SX_VO
27511 #undef IM_O
27512 #undef IM_FE
27513 #undef OT_E
27514 
27515 void
imdi_k79_gen(genspec * g)27516 imdi_k79_gen(
27517 genspec *g			/* structure to be initialised */
27518 ) {
27519 	static unsigned char data[] = {
27520 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
27521 		0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27522 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27523 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27524 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27525 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27526 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27527 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
27528 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
27529 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27530 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27531 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27532 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27533 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27534 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27535 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27536 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27537 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27538 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27539 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27540 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27541 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27542 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27543 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27544 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
27545 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
27546 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
27547 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27548 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27549 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27550 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27551 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27552 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27553 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27554 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27555 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27556 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27557 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27558 		0x65, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27559 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
27560 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
27561 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
27562 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
27563 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
27564 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
27565 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
27566 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
27567 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
27568 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27569 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
27570 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
27571 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x36, 0x5f,
27572 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
27573 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
27574 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
27575 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
27576 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
27577 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
27578 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
27579 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27580 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27581 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27582 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27583 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
27584 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x37, 0x39,
27585 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27586 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27587 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
27588 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
27589 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
27590 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
27591 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
27592 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
27593 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
27594 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
27595 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
27596 		0x00, 0xf0, 0x04, 0x08
27597 	};	/* Structure image */
27598 
27599 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
27600 }
27601 
27602 void
imdi_k79_tab(tabspec * t)27603 imdi_k79_tab(
27604 tabspec *t			/* structure to be initialised */
27605 ) {
27606 	static unsigned char data[] = {
27607 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27608 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27609 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27610 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
27611 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
27612 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
27613 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
27614 		0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
27615 		0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
27616 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27617 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27618 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27619 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
27620 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27621 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
27622 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27623 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
27624 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
27625 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27626 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27627 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27628 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
27629 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
27630 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
27631 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27632 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27633 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27634 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
27635 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27636 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27637 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27638 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
27639 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
27640 	};	/* Structure image */
27641 
27642 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
27643 }
27644 
27645 
27646 
27647 
27648 
27649 
27650 /* Integer Multi-Dimensional Interpolation */
27651 /* Interpolation Kernel Code */
27652 /* Generated by cgen */
27653 /* Copyright 2000 - 2002 Graeme W. Gill */
27654 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
27655 
27656 /* see the Licence.txt file for licencing details.*/
27657 
27658 
27659 /*
27660    Interpolation kernel specs:
27661 
27662    Input channels per pixel = 4
27663    Input channel 0 bits = 8
27664    Input channel 0 increment = 4
27665    Input channel 1 bits = 8
27666    Input channel 1 increment = 4
27667    Input channel 2 bits = 8
27668    Input channel 2 increment = 4
27669    Input channel 3 bits = 8
27670    Input channel 3 increment = 4
27671    Input is channel interleaved
27672    Input channels are separate words
27673    Input value extraction is done in input table lookup
27674 
27675    Output channels per pixel = 6
27676    Output channel 0 bits = 16
27677    Output channel 0 increment = 6
27678    Output channel 1 bits = 16
27679    Output channel 1 increment = 6
27680    Output channel 2 bits = 16
27681    Output channel 2 increment = 6
27682    Output channel 3 bits = 16
27683    Output channel 3 increment = 6
27684    Output channel 4 bits = 16
27685    Output channel 4 increment = 6
27686    Output channel 5 bits = 16
27687    Output channel 5 increment = 6
27688    Output is channel interleaved
27689 
27690    Output channels are separate words
27691    Simplex table index bits       = 32
27692    Interpolation table index bits = 32
27693    Simplex table max resolution = 255
27694    Interpolation table max resolution = 27
27695  */
27696 
27697 /*
27698    Machine architecture specs:
27699 
27700    Little endian
27701    Reading and writing pixel values separately
27702    Pointer size = 32 bits
27703 
27704    Ordinal size  8 bits is known as 'unsigned char'
27705    Ordinal size 16 bits is known as 'unsigned short'
27706    Ordinal size 32 bits is known as 'unsigned int'
27707    Natural ordinal is 'unsigned int'
27708 
27709    Integer size  8 bits is known as 'signed char'
27710    Integer size 16 bits is known as 'short'
27711    Integer size 32 bits is known as 'int'
27712    Natural integer is 'int'
27713 
27714  */
27715 
27716 #ifndef  IMDI_INCLUDED
27717 #include <memory.h>
27718 #include "imdi_imp.h"
27719 #define  IMDI_INCLUDED
27720 #endif  /* IMDI_INCLUDED */
27721 
27722 #ifndef DEFINED_pointer
27723 #define DEFINED_pointer
27724 typedef unsigned char * pointer;
27725 #endif
27726 
27727 /* Input table interp. index */
27728 #define IT_IX(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
27729 
27730 /* Input table simplex index enty */
27731 #define IT_SX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
27732 
27733 /* Simplex weighting table access */
27734 #define SW_O(off) ((off) * 20)
27735 
27736 /* Simplex table - get weighting value */
27737 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
27738 
27739 /* Simplex table - get offset value */
27740 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
27741 
27742 /* Interpolation multi-dim. table access */
27743 #define IM_O(off) ((off) * 12)
27744 
27745 /* Interpolation table - get vertex values */
27746 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
27747 
27748 /* Output table indexes */
27749 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
27750 
27751 void
imdi_k80(imdi * s,void ** outp,void ** inp,unsigned int npix)27752 imdi_k80(
27753 imdi *s,			/* imdi context */
27754 void **outp,		/* pointer to output pointers */
27755 void **inp,		/* pointer to input pointers */
27756 unsigned int npix	/* Number of pixels to process */
27757 ) {
27758 	imdi_imp *p = (imdi_imp *)(s->impl);
27759 	unsigned char *ip0 = (unsigned char *)inp[0];
27760 	unsigned short *op0 = (unsigned short *)outp[0];
27761 	unsigned char *ep = ip0 + npix * 4 ;
27762 	pointer it0 = (pointer)p->in_tables[0];
27763 	pointer it1 = (pointer)p->in_tables[1];
27764 	pointer it2 = (pointer)p->in_tables[2];
27765 	pointer it3 = (pointer)p->in_tables[3];
27766 	pointer ot0 = (pointer)p->out_tables[0];
27767 	pointer ot1 = (pointer)p->out_tables[1];
27768 	pointer ot2 = (pointer)p->out_tables[2];
27769 	pointer ot3 = (pointer)p->out_tables[3];
27770 	pointer ot4 = (pointer)p->out_tables[4];
27771 	pointer ot5 = (pointer)p->out_tables[5];
27772 	pointer sw_base = (pointer)p->sw_table;
27773 	pointer im_base = (pointer)p->im_table;
27774 
27775 	for(;ip0 < ep; ip0 += 4, op0 += 6) {
27776 		unsigned int ova0;	/* Output value accumulator */
27777 		unsigned int ova1;	/* Output value accumulator */
27778 		unsigned int ova2;	/* Output value accumulator */
27779 		{
27780 			pointer swp;
27781 			pointer imp;
27782 			{
27783 				unsigned int ti_s;	/* Simplex index variable */
27784 				unsigned int ti_i;	/* Interpolation index variable */
27785 
27786 				ti_i  = IT_IX(it0, ip0[0]);
27787 				ti_s  = IT_SX(it0, ip0[0]);
27788 				ti_i += IT_IX(it1, ip0[1]);
27789 				ti_s += IT_SX(it1, ip0[1]);
27790 				ti_i += IT_IX(it2, ip0[2]);
27791 				ti_s += IT_SX(it2, ip0[2]);
27792 				ti_i += IT_IX(it3, ip0[3]);
27793 				ti_s += IT_SX(it3, ip0[3]);
27794 
27795 				swp = sw_base + SW_O(ti_s);		/* Compute simplex table entry pointer */
27796 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
27797 			}
27798 			{
27799 				unsigned int vof;	/* Vertex offset value */
27800 				unsigned int vwe;	/* Vertex weighting */
27801 
27802 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
27803 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
27804 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
27805 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
27806 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
27807 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
27808 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
27809 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
27810 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
27811 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
27812 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
27813 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
27814 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
27815 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
27816 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
27817 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
27818 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
27819 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
27820 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
27821 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
27822 				vof = SX_VO(swp, 4);	/* Read vertex offset value */
27823 				vwe = SX_WE(swp, 4);	/* Read vertex weighting value */
27824 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
27825 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
27826 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
27827 			}
27828 		}
27829 		{
27830 			unsigned int oti;	/* Vertex offset value */
27831 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
27832 			op0[0] = OT_E(ot0, oti);	/* Write result */
27833 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
27834 			op0[1] = OT_E(ot1, oti);	/* Write result */
27835 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
27836 			op0[2] = OT_E(ot2, oti);	/* Write result */
27837 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
27838 			op0[3] = OT_E(ot3, oti);	/* Write result */
27839 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
27840 			op0[4] = OT_E(ot4, oti);	/* Write result */
27841 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
27842 			op0[5] = OT_E(ot5, oti);	/* Write result */
27843 		}
27844 	}
27845 }
27846 #undef IT_IX
27847 #undef IT_SX
27848 #undef SW_O
27849 #undef SX_WE
27850 #undef SX_VO
27851 #undef IM_O
27852 #undef IM_FE
27853 #undef OT_E
27854 
27855 void
imdi_k80_gen(genspec * g)27856 imdi_k80_gen(
27857 genspec *g			/* structure to be initialised */
27858 ) {
27859 	static unsigned char data[] = {
27860 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
27861 		0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27862 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27863 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27864 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27865 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27866 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27867 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
27868 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
27869 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27870 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27871 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27872 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27873 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27874 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27875 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27876 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27877 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27878 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27879 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27880 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27881 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27882 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27883 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27884 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
27885 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
27886 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
27887 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27888 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27889 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27890 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27891 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27892 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27893 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27894 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27895 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27896 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27897 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27898 		0x1b, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
27899 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
27900 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
27901 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
27902 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
27903 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
27904 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
27905 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
27906 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
27907 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
27908 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27909 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
27910 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
27911 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x36, 0x5f,
27912 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
27913 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
27914 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
27915 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
27916 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
27917 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
27918 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
27919 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27920 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27921 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27922 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27923 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
27924 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x38, 0x30,
27925 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27926 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27927 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
27928 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
27929 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
27930 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
27931 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
27932 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
27933 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
27934 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
27935 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
27936 		0x00, 0xf0, 0x04, 0x08
27937 	};	/* Structure image */
27938 
27939 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
27940 }
27941 
27942 void
imdi_k80_tab(tabspec * t)27943 imdi_k80_tab(
27944 tabspec *t			/* structure to be initialised */
27945 ) {
27946 	static unsigned char data[] = {
27947 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27948 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27949 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27950 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
27951 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
27952 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
27953 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
27954 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
27955 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
27956 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27957 		0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27958 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27959 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
27960 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27961 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
27962 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27963 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
27964 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
27965 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27966 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27967 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
27968 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
27969 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
27970 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
27971 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27972 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27973 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27974 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
27975 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27976 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27977 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
27978 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
27979 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
27980 	};	/* Structure image */
27981 
27982 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
27983 }
27984 
27985 
27986 
27987 
27988 
27989 
27990 /* Integer Multi-Dimensional Interpolation */
27991 /* Interpolation Kernel Code */
27992 /* Generated by cgen */
27993 /* Copyright 2000 - 2002 Graeme W. Gill */
27994 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
27995 
27996 /* see the Licence.txt file for licencing details.*/
27997 
27998 
27999 /*
28000    Interpolation kernel specs:
28001 
28002    Input channels per pixel = 5
28003    Input channel 0 bits = 8
28004    Input channel 0 increment = 5
28005    Input channel 1 bits = 8
28006    Input channel 1 increment = 5
28007    Input channel 2 bits = 8
28008    Input channel 2 increment = 5
28009    Input channel 3 bits = 8
28010    Input channel 3 increment = 5
28011    Input channel 4 bits = 8
28012    Input channel 4 increment = 5
28013    Input is channel interleaved
28014    Input channels are separate words
28015    Input value extraction is done in input table lookup
28016 
28017    Output channels per pixel = 6
28018    Output channel 0 bits = 16
28019    Output channel 0 increment = 6
28020    Output channel 1 bits = 16
28021    Output channel 1 increment = 6
28022    Output channel 2 bits = 16
28023    Output channel 2 increment = 6
28024    Output channel 3 bits = 16
28025    Output channel 3 increment = 6
28026    Output channel 4 bits = 16
28027    Output channel 4 increment = 6
28028    Output channel 5 bits = 16
28029    Output channel 5 increment = 6
28030    Output is channel interleaved
28031 
28032    Output channels are separate words
28033    Weight+voffset bits       = 32
28034    Interpolation table index bits = 32
28035    Interpolation table max resolution = 40
28036  */
28037 
28038 /*
28039    Machine architecture specs:
28040 
28041    Little endian
28042    Reading and writing pixel values separately
28043    Pointer size = 32 bits
28044 
28045    Ordinal size  8 bits is known as 'unsigned char'
28046    Ordinal size 16 bits is known as 'unsigned short'
28047    Ordinal size 32 bits is known as 'unsigned int'
28048    Natural ordinal is 'unsigned int'
28049 
28050    Integer size  8 bits is known as 'signed char'
28051    Integer size 16 bits is known as 'short'
28052    Integer size 32 bits is known as 'int'
28053    Natural integer is 'int'
28054 
28055  */
28056 
28057 #ifndef  IMDI_INCLUDED
28058 #include <memory.h>
28059 #include "imdi_imp.h"
28060 #define  IMDI_INCLUDED
28061 #endif  /* IMDI_INCLUDED */
28062 
28063 #ifndef DEFINED_pointer
28064 #define DEFINED_pointer
28065 typedef unsigned char * pointer;
28066 #endif
28067 
28068 /* Input table interp. index */
28069 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
28070 
28071 /* Input table input weighting/offset value enty */
28072 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
28073 
28074 /* Conditional exchange for sorting */
28075 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
28076 
28077 /* Interpolation multi-dim. table access */
28078 #define IM_O(off) ((off) * 12)
28079 
28080 /* Interpolation table - get vertex values */
28081 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
28082 
28083 /* Output table indexes */
28084 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
28085 
28086 void
imdi_k81(imdi * s,void ** outp,void ** inp,unsigned int npix)28087 imdi_k81(
28088 imdi *s,			/* imdi context */
28089 void **outp,		/* pointer to output pointers */
28090 void **inp,		/* pointer to input pointers */
28091 unsigned int npix	/* Number of pixels to process */
28092 ) {
28093 	imdi_imp *p = (imdi_imp *)(s->impl);
28094 	unsigned char *ip0 = (unsigned char *)inp[0];
28095 	unsigned short *op0 = (unsigned short *)outp[0];
28096 	unsigned char *ep = ip0 + npix * 5 ;
28097 	pointer it0 = (pointer)p->in_tables[0];
28098 	pointer it1 = (pointer)p->in_tables[1];
28099 	pointer it2 = (pointer)p->in_tables[2];
28100 	pointer it3 = (pointer)p->in_tables[3];
28101 	pointer it4 = (pointer)p->in_tables[4];
28102 	pointer ot0 = (pointer)p->out_tables[0];
28103 	pointer ot1 = (pointer)p->out_tables[1];
28104 	pointer ot2 = (pointer)p->out_tables[2];
28105 	pointer ot3 = (pointer)p->out_tables[3];
28106 	pointer ot4 = (pointer)p->out_tables[4];
28107 	pointer ot5 = (pointer)p->out_tables[5];
28108 	pointer im_base = (pointer)p->im_table;
28109 
28110 	for(;ip0 < ep; ip0 += 5, op0 += 6) {
28111 		unsigned int ova0;	/* Output value accumulator */
28112 		unsigned int ova1;	/* Output value accumulator */
28113 		unsigned int ova2;	/* Output value accumulator */
28114 		{
28115 			pointer imp;
28116 			unsigned int wo0;	/* Weighting value and vertex offset variable */
28117 			unsigned int wo1;	/* Weighting value and vertex offset variable */
28118 			unsigned int wo2;	/* Weighting value and vertex offset variable */
28119 			unsigned int wo3;	/* Weighting value and vertex offset variable */
28120 			unsigned int wo4;	/* Weighting value and vertex offset variable */
28121 			{
28122 				unsigned int ti_i;	/* Interpolation index variable */
28123 
28124 				ti_i  = IT_IX(it0, ip0[0]);
28125 				wo0   = IT_WO(it0, ip0[0]);
28126 				ti_i += IT_IX(it1, ip0[1]);
28127 				wo1   = IT_WO(it1, ip0[1]);
28128 				ti_i += IT_IX(it2, ip0[2]);
28129 				wo2   = IT_WO(it2, ip0[2]);
28130 				ti_i += IT_IX(it3, ip0[3]);
28131 				wo3   = IT_WO(it3, ip0[3]);
28132 				ti_i += IT_IX(it4, ip0[4]);
28133 				wo4   = IT_WO(it4, ip0[4]);
28134 
28135 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
28136 
28137 				/* Sort weighting values and vertex offset values */
28138 				CEX(wo0, wo1);
28139 				CEX(wo0, wo2);
28140 				CEX(wo0, wo3);
28141 				CEX(wo0, wo4);
28142 				CEX(wo1, wo2);
28143 				CEX(wo1, wo3);
28144 				CEX(wo1, wo4);
28145 				CEX(wo2, wo3);
28146 				CEX(wo2, wo4);
28147 				CEX(wo3, wo4);
28148 			}
28149 			{
28150 				unsigned int nvof;	/* Next vertex offset value */
28151 				unsigned int vof;	/* Vertex offset value */
28152 				unsigned int vwe;	/* Vertex weighting */
28153 
28154 				vof = 0;				/* First vertex offset is 0 */
28155 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
28156 				wo0 = (wo0 >> 23);		/* Extract weighting value */
28157 				vwe = 256 - wo0;		/* Baricentric weighting */
28158 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28159 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28160 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28161 				vof += nvof;			/* Move to next vertex */
28162 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
28163 				wo1 = (wo1 >> 23);		/* Extract weighting value */
28164 				vwe = wo0 - wo1;		/* Baricentric weighting */
28165 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28166 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28167 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28168 				vof += nvof;			/* Move to next vertex */
28169 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
28170 				wo2 = (wo2 >> 23);		/* Extract weighting value */
28171 				vwe = wo1 - wo2;		/* Baricentric weighting */
28172 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28173 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28174 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28175 				vof += nvof;			/* Move to next vertex */
28176 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
28177 				wo3 = (wo3 >> 23);		/* Extract weighting value */
28178 				vwe = wo2 - wo3;		/* Baricentric weighting */
28179 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28180 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28181 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28182 				vof += nvof;			/* Move to next vertex */
28183 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
28184 				wo4 = (wo4 >> 23);		/* Extract weighting value */
28185 				vwe = wo3 - wo4;		/* Baricentric weighting */
28186 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28187 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28188 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28189 				vof += nvof;			/* Move to next vertex */
28190 				vwe = wo4;				/* Baricentric weighting */
28191 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28192 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28193 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28194 			}
28195 		}
28196 		{
28197 			unsigned int oti;	/* Vertex offset value */
28198 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
28199 			op0[0] = OT_E(ot0, oti);	/* Write result */
28200 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
28201 			op0[1] = OT_E(ot1, oti);	/* Write result */
28202 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
28203 			op0[2] = OT_E(ot2, oti);	/* Write result */
28204 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
28205 			op0[3] = OT_E(ot3, oti);	/* Write result */
28206 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
28207 			op0[4] = OT_E(ot4, oti);	/* Write result */
28208 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
28209 			op0[5] = OT_E(ot5, oti);	/* Write result */
28210 		}
28211 	}
28212 }
28213 #undef IT_WO
28214 #undef IT_IX
28215 #undef CEX
28216 #undef IM_O
28217 #undef IM_FE
28218 #undef OT_E
28219 
28220 void
imdi_k81_gen(genspec * g)28221 imdi_k81_gen(
28222 genspec *g			/* structure to be initialised */
28223 ) {
28224 	static unsigned char data[] = {
28225 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
28226 		0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
28227 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28228 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28229 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28230 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28231 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28232 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
28233 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
28234 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
28235 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28236 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28237 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28238 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28239 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28240 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28241 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28242 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28243 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28244 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
28245 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
28246 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
28247 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
28248 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28249 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
28250 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
28251 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
28252 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28253 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28254 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28255 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28256 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28257 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
28258 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
28259 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
28260 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28261 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
28262 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
28263 		0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28264 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
28265 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
28266 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
28267 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
28268 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
28269 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
28270 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
28271 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
28272 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
28273 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28274 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
28275 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
28276 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x36, 0x5f,
28277 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
28278 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
28279 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
28280 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
28281 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
28282 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
28283 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
28284 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28285 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28286 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28287 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28288 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
28289 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x38, 0x31,
28290 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28291 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28292 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
28293 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
28294 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
28295 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
28296 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
28297 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
28298 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
28299 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
28300 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
28301 		0x00, 0xf0, 0x04, 0x08
28302 	};	/* Structure image */
28303 
28304 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
28305 }
28306 
28307 void
imdi_k81_tab(tabspec * t)28308 imdi_k81_tab(
28309 tabspec *t			/* structure to be initialised */
28310 ) {
28311 	static unsigned char data[] = {
28312 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
28313 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
28314 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
28315 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
28316 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
28317 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
28318 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28319 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
28320 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
28321 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28322 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
28323 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
28324 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
28325 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
28326 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
28327 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
28328 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
28329 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
28330 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28331 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28332 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
28333 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
28334 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
28335 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
28336 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28337 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28338 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28339 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
28340 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
28341 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
28342 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
28343 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
28344 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
28345 	};	/* Structure image */
28346 
28347 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
28348 }
28349 
28350 
28351 
28352 
28353 
28354 
28355 /* Integer Multi-Dimensional Interpolation */
28356 /* Interpolation Kernel Code */
28357 /* Generated by cgen */
28358 /* Copyright 2000 - 2002 Graeme W. Gill */
28359 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
28360 
28361 /* see the Licence.txt file for licencing details.*/
28362 
28363 
28364 /*
28365    Interpolation kernel specs:
28366 
28367    Input channels per pixel = 6
28368    Input channel 0 bits = 8
28369    Input channel 0 increment = 6
28370    Input channel 1 bits = 8
28371    Input channel 1 increment = 6
28372    Input channel 2 bits = 8
28373    Input channel 2 increment = 6
28374    Input channel 3 bits = 8
28375    Input channel 3 increment = 6
28376    Input channel 4 bits = 8
28377    Input channel 4 increment = 6
28378    Input channel 5 bits = 8
28379    Input channel 5 increment = 6
28380    Input is channel interleaved
28381    Input channels are separate words
28382    Input value extraction is done in input table lookup
28383 
28384    Output channels per pixel = 6
28385    Output channel 0 bits = 16
28386    Output channel 0 increment = 6
28387    Output channel 1 bits = 16
28388    Output channel 1 increment = 6
28389    Output channel 2 bits = 16
28390    Output channel 2 increment = 6
28391    Output channel 3 bits = 16
28392    Output channel 3 increment = 6
28393    Output channel 4 bits = 16
28394    Output channel 4 increment = 6
28395    Output channel 5 bits = 16
28396    Output channel 5 increment = 6
28397    Output is channel interleaved
28398 
28399    Output channels are separate words
28400    Weight+voffset bits       = 32
28401    Interpolation table index bits = 32
28402    Interpolation table max resolution = 19
28403  */
28404 
28405 /*
28406    Machine architecture specs:
28407 
28408    Little endian
28409    Reading and writing pixel values separately
28410    Pointer size = 32 bits
28411 
28412    Ordinal size  8 bits is known as 'unsigned char'
28413    Ordinal size 16 bits is known as 'unsigned short'
28414    Ordinal size 32 bits is known as 'unsigned int'
28415    Natural ordinal is 'unsigned int'
28416 
28417    Integer size  8 bits is known as 'signed char'
28418    Integer size 16 bits is known as 'short'
28419    Integer size 32 bits is known as 'int'
28420    Natural integer is 'int'
28421 
28422  */
28423 
28424 #ifndef  IMDI_INCLUDED
28425 #include <memory.h>
28426 #include "imdi_imp.h"
28427 #define  IMDI_INCLUDED
28428 #endif  /* IMDI_INCLUDED */
28429 
28430 #ifndef DEFINED_pointer
28431 #define DEFINED_pointer
28432 typedef unsigned char * pointer;
28433 #endif
28434 
28435 /* Input table interp. index */
28436 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
28437 
28438 /* Input table input weighting/offset value enty */
28439 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
28440 
28441 /* Conditional exchange for sorting */
28442 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
28443 
28444 /* Interpolation multi-dim. table access */
28445 #define IM_O(off) ((off) * 12)
28446 
28447 /* Interpolation table - get vertex values */
28448 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
28449 
28450 /* Output table indexes */
28451 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
28452 
28453 void
imdi_k82(imdi * s,void ** outp,void ** inp,unsigned int npix)28454 imdi_k82(
28455 imdi *s,			/* imdi context */
28456 void **outp,		/* pointer to output pointers */
28457 void **inp,		/* pointer to input pointers */
28458 unsigned int npix	/* Number of pixels to process */
28459 ) {
28460 	imdi_imp *p = (imdi_imp *)(s->impl);
28461 	unsigned char *ip0 = (unsigned char *)inp[0];
28462 	unsigned short *op0 = (unsigned short *)outp[0];
28463 	unsigned char *ep = ip0 + npix * 6 ;
28464 	pointer it0 = (pointer)p->in_tables[0];
28465 	pointer it1 = (pointer)p->in_tables[1];
28466 	pointer it2 = (pointer)p->in_tables[2];
28467 	pointer it3 = (pointer)p->in_tables[3];
28468 	pointer it4 = (pointer)p->in_tables[4];
28469 	pointer it5 = (pointer)p->in_tables[5];
28470 	pointer ot0 = (pointer)p->out_tables[0];
28471 	pointer ot1 = (pointer)p->out_tables[1];
28472 	pointer ot2 = (pointer)p->out_tables[2];
28473 	pointer ot3 = (pointer)p->out_tables[3];
28474 	pointer ot4 = (pointer)p->out_tables[4];
28475 	pointer ot5 = (pointer)p->out_tables[5];
28476 	pointer im_base = (pointer)p->im_table;
28477 
28478 	for(;ip0 < ep; ip0 += 6, op0 += 6) {
28479 		unsigned int ova0;	/* Output value accumulator */
28480 		unsigned int ova1;	/* Output value accumulator */
28481 		unsigned int ova2;	/* Output value accumulator */
28482 		{
28483 			pointer imp;
28484 			unsigned int wo0;	/* Weighting value and vertex offset variable */
28485 			unsigned int wo1;	/* Weighting value and vertex offset variable */
28486 			unsigned int wo2;	/* Weighting value and vertex offset variable */
28487 			unsigned int wo3;	/* Weighting value and vertex offset variable */
28488 			unsigned int wo4;	/* Weighting value and vertex offset variable */
28489 			unsigned int wo5;	/* Weighting value and vertex offset variable */
28490 			{
28491 				unsigned int ti_i;	/* Interpolation index variable */
28492 
28493 				ti_i  = IT_IX(it0, ip0[0]);
28494 				wo0   = IT_WO(it0, ip0[0]);
28495 				ti_i += IT_IX(it1, ip0[1]);
28496 				wo1   = IT_WO(it1, ip0[1]);
28497 				ti_i += IT_IX(it2, ip0[2]);
28498 				wo2   = IT_WO(it2, ip0[2]);
28499 				ti_i += IT_IX(it3, ip0[3]);
28500 				wo3   = IT_WO(it3, ip0[3]);
28501 				ti_i += IT_IX(it4, ip0[4]);
28502 				wo4   = IT_WO(it4, ip0[4]);
28503 				ti_i += IT_IX(it5, ip0[5]);
28504 				wo5   = IT_WO(it5, ip0[5]);
28505 
28506 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
28507 
28508 				/* Sort weighting values and vertex offset values */
28509 				CEX(wo0, wo1);
28510 				CEX(wo0, wo2);
28511 				CEX(wo0, wo3);
28512 				CEX(wo0, wo4);
28513 				CEX(wo0, wo5);
28514 				CEX(wo1, wo2);
28515 				CEX(wo1, wo3);
28516 				CEX(wo1, wo4);
28517 				CEX(wo1, wo5);
28518 				CEX(wo2, wo3);
28519 				CEX(wo2, wo4);
28520 				CEX(wo2, wo5);
28521 				CEX(wo3, wo4);
28522 				CEX(wo3, wo5);
28523 				CEX(wo4, wo5);
28524 			}
28525 			{
28526 				unsigned int nvof;	/* Next vertex offset value */
28527 				unsigned int vof;	/* Vertex offset value */
28528 				unsigned int vwe;	/* Vertex weighting */
28529 
28530 				vof = 0;				/* First vertex offset is 0 */
28531 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
28532 				wo0 = (wo0 >> 23);		/* Extract weighting value */
28533 				vwe = 256 - wo0;		/* Baricentric weighting */
28534 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28535 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28536 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28537 				vof += nvof;			/* Move to next vertex */
28538 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
28539 				wo1 = (wo1 >> 23);		/* Extract weighting value */
28540 				vwe = wo0 - wo1;		/* Baricentric weighting */
28541 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28542 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28543 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28544 				vof += nvof;			/* Move to next vertex */
28545 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
28546 				wo2 = (wo2 >> 23);		/* Extract weighting value */
28547 				vwe = wo1 - wo2;		/* Baricentric weighting */
28548 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28549 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28550 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28551 				vof += nvof;			/* Move to next vertex */
28552 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
28553 				wo3 = (wo3 >> 23);		/* Extract weighting value */
28554 				vwe = wo2 - wo3;		/* Baricentric weighting */
28555 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28556 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28557 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28558 				vof += nvof;			/* Move to next vertex */
28559 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
28560 				wo4 = (wo4 >> 23);		/* Extract weighting value */
28561 				vwe = wo3 - wo4;		/* Baricentric weighting */
28562 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28563 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28564 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28565 				vof += nvof;			/* Move to next vertex */
28566 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
28567 				wo5 = (wo5 >> 23);		/* Extract weighting value */
28568 				vwe = wo4 - wo5;		/* Baricentric weighting */
28569 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28570 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28571 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28572 				vof += nvof;			/* Move to next vertex */
28573 				vwe = wo5;				/* Baricentric weighting */
28574 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28575 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28576 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28577 			}
28578 		}
28579 		{
28580 			unsigned int oti;	/* Vertex offset value */
28581 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
28582 			op0[0] = OT_E(ot0, oti);	/* Write result */
28583 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
28584 			op0[1] = OT_E(ot1, oti);	/* Write result */
28585 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
28586 			op0[2] = OT_E(ot2, oti);	/* Write result */
28587 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
28588 			op0[3] = OT_E(ot3, oti);	/* Write result */
28589 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
28590 			op0[4] = OT_E(ot4, oti);	/* Write result */
28591 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
28592 			op0[5] = OT_E(ot5, oti);	/* Write result */
28593 		}
28594 	}
28595 }
28596 #undef IT_WO
28597 #undef IT_IX
28598 #undef CEX
28599 #undef IM_O
28600 #undef IM_FE
28601 #undef OT_E
28602 
28603 void
imdi_k82_gen(genspec * g)28604 imdi_k82_gen(
28605 genspec *g			/* structure to be initialised */
28606 ) {
28607 	static unsigned char data[] = {
28608 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
28609 		0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
28610 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28611 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28612 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28613 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28614 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28615 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
28616 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
28617 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
28618 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28619 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28620 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28621 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28622 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28623 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28624 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28625 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28626 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28627 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
28628 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
28629 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
28630 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
28631 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28632 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
28633 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
28634 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
28635 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28636 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28637 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28638 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28639 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28640 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
28641 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
28642 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
28643 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28644 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
28645 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
28646 		0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28647 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
28648 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
28649 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
28650 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
28651 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
28652 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
28653 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
28654 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
28655 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
28656 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28657 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
28658 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
28659 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x36, 0x5f,
28660 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
28661 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
28662 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
28663 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
28664 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
28665 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
28666 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
28667 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28668 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28669 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28670 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28671 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
28672 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x38, 0x32,
28673 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28674 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28675 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
28676 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
28677 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
28678 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
28679 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
28680 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
28681 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
28682 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
28683 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
28684 		0x00, 0xf0, 0x04, 0x08
28685 	};	/* Structure image */
28686 
28687 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
28688 }
28689 
28690 void
imdi_k82_tab(tabspec * t)28691 imdi_k82_tab(
28692 tabspec *t			/* structure to be initialised */
28693 ) {
28694 	static unsigned char data[] = {
28695 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
28696 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
28697 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
28698 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
28699 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
28700 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
28701 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
28702 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
28703 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
28704 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28705 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
28706 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
28707 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
28708 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
28709 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
28710 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
28711 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
28712 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
28713 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28714 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28715 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
28716 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
28717 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
28718 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
28719 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28720 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28721 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28722 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
28723 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
28724 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
28725 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
28726 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
28727 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
28728 	};	/* Structure image */
28729 
28730 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
28731 }
28732 
28733 
28734 
28735 
28736 
28737 
28738 /* Integer Multi-Dimensional Interpolation */
28739 /* Interpolation Kernel Code */
28740 /* Generated by cgen */
28741 /* Copyright 2000 - 2002 Graeme W. Gill */
28742 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
28743 
28744 /* see the Licence.txt file for licencing details.*/
28745 
28746 
28747 /*
28748    Interpolation kernel specs:
28749 
28750    Input channels per pixel = 7
28751    Input channel 0 bits = 8
28752    Input channel 0 increment = 7
28753    Input channel 1 bits = 8
28754    Input channel 1 increment = 7
28755    Input channel 2 bits = 8
28756    Input channel 2 increment = 7
28757    Input channel 3 bits = 8
28758    Input channel 3 increment = 7
28759    Input channel 4 bits = 8
28760    Input channel 4 increment = 7
28761    Input channel 5 bits = 8
28762    Input channel 5 increment = 7
28763    Input channel 6 bits = 8
28764    Input channel 6 increment = 7
28765    Input is channel interleaved
28766    Input channels are separate words
28767    Input value extraction is done in input table lookup
28768 
28769    Output channels per pixel = 6
28770    Output channel 0 bits = 16
28771    Output channel 0 increment = 6
28772    Output channel 1 bits = 16
28773    Output channel 1 increment = 6
28774    Output channel 2 bits = 16
28775    Output channel 2 increment = 6
28776    Output channel 3 bits = 16
28777    Output channel 3 increment = 6
28778    Output channel 4 bits = 16
28779    Output channel 4 increment = 6
28780    Output channel 5 bits = 16
28781    Output channel 5 increment = 6
28782    Output is channel interleaved
28783 
28784    Output channels are separate words
28785    Weight+voffset bits       = 32
28786    Interpolation table index bits = 32
28787    Interpolation table max resolution = 11
28788  */
28789 
28790 /*
28791    Machine architecture specs:
28792 
28793    Little endian
28794    Reading and writing pixel values separately
28795    Pointer size = 32 bits
28796 
28797    Ordinal size  8 bits is known as 'unsigned char'
28798    Ordinal size 16 bits is known as 'unsigned short'
28799    Ordinal size 32 bits is known as 'unsigned int'
28800    Natural ordinal is 'unsigned int'
28801 
28802    Integer size  8 bits is known as 'signed char'
28803    Integer size 16 bits is known as 'short'
28804    Integer size 32 bits is known as 'int'
28805    Natural integer is 'int'
28806 
28807  */
28808 
28809 #ifndef  IMDI_INCLUDED
28810 #include <memory.h>
28811 #include "imdi_imp.h"
28812 #define  IMDI_INCLUDED
28813 #endif  /* IMDI_INCLUDED */
28814 
28815 #ifndef DEFINED_pointer
28816 #define DEFINED_pointer
28817 typedef unsigned char * pointer;
28818 #endif
28819 
28820 /* Input table interp. index */
28821 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
28822 
28823 /* Input table input weighting/offset value enty */
28824 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
28825 
28826 /* Conditional exchange for sorting */
28827 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
28828 
28829 /* Interpolation multi-dim. table access */
28830 #define IM_O(off) ((off) * 12)
28831 
28832 /* Interpolation table - get vertex values */
28833 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
28834 
28835 /* Output table indexes */
28836 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
28837 
28838 void
imdi_k83(imdi * s,void ** outp,void ** inp,unsigned int npix)28839 imdi_k83(
28840 imdi *s,			/* imdi context */
28841 void **outp,		/* pointer to output pointers */
28842 void **inp,		/* pointer to input pointers */
28843 unsigned int npix	/* Number of pixels to process */
28844 ) {
28845 	imdi_imp *p = (imdi_imp *)(s->impl);
28846 	unsigned char *ip0 = (unsigned char *)inp[0];
28847 	unsigned short *op0 = (unsigned short *)outp[0];
28848 	unsigned char *ep = ip0 + npix * 7 ;
28849 	pointer it0 = (pointer)p->in_tables[0];
28850 	pointer it1 = (pointer)p->in_tables[1];
28851 	pointer it2 = (pointer)p->in_tables[2];
28852 	pointer it3 = (pointer)p->in_tables[3];
28853 	pointer it4 = (pointer)p->in_tables[4];
28854 	pointer it5 = (pointer)p->in_tables[5];
28855 	pointer it6 = (pointer)p->in_tables[6];
28856 	pointer ot0 = (pointer)p->out_tables[0];
28857 	pointer ot1 = (pointer)p->out_tables[1];
28858 	pointer ot2 = (pointer)p->out_tables[2];
28859 	pointer ot3 = (pointer)p->out_tables[3];
28860 	pointer ot4 = (pointer)p->out_tables[4];
28861 	pointer ot5 = (pointer)p->out_tables[5];
28862 	pointer im_base = (pointer)p->im_table;
28863 
28864 	for(;ip0 < ep; ip0 += 7, op0 += 6) {
28865 		unsigned int ova0;	/* Output value accumulator */
28866 		unsigned int ova1;	/* Output value accumulator */
28867 		unsigned int ova2;	/* Output value accumulator */
28868 		{
28869 			pointer imp;
28870 			unsigned int wo0;	/* Weighting value and vertex offset variable */
28871 			unsigned int wo1;	/* Weighting value and vertex offset variable */
28872 			unsigned int wo2;	/* Weighting value and vertex offset variable */
28873 			unsigned int wo3;	/* Weighting value and vertex offset variable */
28874 			unsigned int wo4;	/* Weighting value and vertex offset variable */
28875 			unsigned int wo5;	/* Weighting value and vertex offset variable */
28876 			unsigned int wo6;	/* Weighting value and vertex offset variable */
28877 			{
28878 				unsigned int ti_i;	/* Interpolation index variable */
28879 
28880 				ti_i  = IT_IX(it0, ip0[0]);
28881 				wo0   = IT_WO(it0, ip0[0]);
28882 				ti_i += IT_IX(it1, ip0[1]);
28883 				wo1   = IT_WO(it1, ip0[1]);
28884 				ti_i += IT_IX(it2, ip0[2]);
28885 				wo2   = IT_WO(it2, ip0[2]);
28886 				ti_i += IT_IX(it3, ip0[3]);
28887 				wo3   = IT_WO(it3, ip0[3]);
28888 				ti_i += IT_IX(it4, ip0[4]);
28889 				wo4   = IT_WO(it4, ip0[4]);
28890 				ti_i += IT_IX(it5, ip0[5]);
28891 				wo5   = IT_WO(it5, ip0[5]);
28892 				ti_i += IT_IX(it6, ip0[6]);
28893 				wo6   = IT_WO(it6, ip0[6]);
28894 
28895 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
28896 
28897 				/* Sort weighting values and vertex offset values */
28898 				CEX(wo0, wo1);
28899 				CEX(wo0, wo2);
28900 				CEX(wo0, wo3);
28901 				CEX(wo0, wo4);
28902 				CEX(wo0, wo5);
28903 				CEX(wo0, wo6);
28904 				CEX(wo1, wo2);
28905 				CEX(wo1, wo3);
28906 				CEX(wo1, wo4);
28907 				CEX(wo1, wo5);
28908 				CEX(wo1, wo6);
28909 				CEX(wo2, wo3);
28910 				CEX(wo2, wo4);
28911 				CEX(wo2, wo5);
28912 				CEX(wo2, wo6);
28913 				CEX(wo3, wo4);
28914 				CEX(wo3, wo5);
28915 				CEX(wo3, wo6);
28916 				CEX(wo4, wo5);
28917 				CEX(wo4, wo6);
28918 				CEX(wo5, wo6);
28919 			}
28920 			{
28921 				unsigned int nvof;	/* Next vertex offset value */
28922 				unsigned int vof;	/* Vertex offset value */
28923 				unsigned int vwe;	/* Vertex weighting */
28924 
28925 				vof = 0;				/* First vertex offset is 0 */
28926 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
28927 				wo0 = (wo0 >> 23);		/* Extract weighting value */
28928 				vwe = 256 - wo0;		/* Baricentric weighting */
28929 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28930 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28931 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28932 				vof += nvof;			/* Move to next vertex */
28933 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
28934 				wo1 = (wo1 >> 23);		/* Extract weighting value */
28935 				vwe = wo0 - wo1;		/* Baricentric weighting */
28936 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28937 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28938 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28939 				vof += nvof;			/* Move to next vertex */
28940 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
28941 				wo2 = (wo2 >> 23);		/* Extract weighting value */
28942 				vwe = wo1 - wo2;		/* Baricentric weighting */
28943 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28944 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28945 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28946 				vof += nvof;			/* Move to next vertex */
28947 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
28948 				wo3 = (wo3 >> 23);		/* Extract weighting value */
28949 				vwe = wo2 - wo3;		/* Baricentric weighting */
28950 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28951 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28952 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28953 				vof += nvof;			/* Move to next vertex */
28954 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
28955 				wo4 = (wo4 >> 23);		/* Extract weighting value */
28956 				vwe = wo3 - wo4;		/* Baricentric weighting */
28957 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28958 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28959 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28960 				vof += nvof;			/* Move to next vertex */
28961 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
28962 				wo5 = (wo5 >> 23);		/* Extract weighting value */
28963 				vwe = wo4 - wo5;		/* Baricentric weighting */
28964 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28965 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28966 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28967 				vof += nvof;			/* Move to next vertex */
28968 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
28969 				wo6 = (wo6 >> 23);		/* Extract weighting value */
28970 				vwe = wo5 - wo6;		/* Baricentric weighting */
28971 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28972 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28973 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28974 				vof += nvof;			/* Move to next vertex */
28975 				vwe = wo6;				/* Baricentric weighting */
28976 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
28977 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
28978 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
28979 			}
28980 		}
28981 		{
28982 			unsigned int oti;	/* Vertex offset value */
28983 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
28984 			op0[0] = OT_E(ot0, oti);	/* Write result */
28985 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
28986 			op0[1] = OT_E(ot1, oti);	/* Write result */
28987 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
28988 			op0[2] = OT_E(ot2, oti);	/* Write result */
28989 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
28990 			op0[3] = OT_E(ot3, oti);	/* Write result */
28991 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
28992 			op0[4] = OT_E(ot4, oti);	/* Write result */
28993 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
28994 			op0[5] = OT_E(ot5, oti);	/* Write result */
28995 		}
28996 	}
28997 }
28998 #undef IT_WO
28999 #undef IT_IX
29000 #undef CEX
29001 #undef IM_O
29002 #undef IM_FE
29003 #undef OT_E
29004 
29005 void
imdi_k83_gen(genspec * g)29006 imdi_k83_gen(
29007 genspec *g			/* structure to be initialised */
29008 ) {
29009 	static unsigned char data[] = {
29010 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
29011 		0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29012 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29013 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29014 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29015 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29016 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29017 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
29018 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
29019 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
29020 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
29021 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29022 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29023 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29024 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29025 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29026 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29027 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29028 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29029 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29030 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29031 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29032 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29033 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29034 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
29035 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
29036 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
29037 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29038 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29039 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29040 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29041 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29042 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29043 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29044 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29045 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29046 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29047 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29048 		0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29049 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
29050 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
29051 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
29052 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
29053 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
29054 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
29055 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
29056 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
29057 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
29058 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29059 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
29060 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
29061 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x36, 0x5f,
29062 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
29063 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
29064 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
29065 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
29066 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
29067 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
29068 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
29069 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29070 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29071 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29072 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29073 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
29074 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x38, 0x33,
29075 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29076 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29077 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
29078 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
29079 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
29080 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
29081 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
29082 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
29083 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
29084 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
29085 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
29086 		0x00, 0xf0, 0x04, 0x08
29087 	};	/* Structure image */
29088 
29089 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
29090 }
29091 
29092 void
imdi_k83_tab(tabspec * t)29093 imdi_k83_tab(
29094 tabspec *t			/* structure to be initialised */
29095 ) {
29096 	static unsigned char data[] = {
29097 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29098 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29099 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29100 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
29101 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
29102 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
29103 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29104 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
29105 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
29106 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29107 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
29108 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
29109 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
29110 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
29111 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
29112 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29113 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
29114 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
29115 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29116 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29117 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29118 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
29119 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
29120 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
29121 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29122 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29123 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29124 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
29125 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29126 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29127 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29128 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
29129 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
29130 	};	/* Structure image */
29131 
29132 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
29133 }
29134 
29135 
29136 
29137 
29138 
29139 
29140 /* Integer Multi-Dimensional Interpolation */
29141 /* Interpolation Kernel Code */
29142 /* Generated by cgen */
29143 /* Copyright 2000 - 2002 Graeme W. Gill */
29144 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
29145 
29146 /* see the Licence.txt file for licencing details.*/
29147 
29148 
29149 /*
29150    Interpolation kernel specs:
29151 
29152    Input channels per pixel = 8
29153    Input channel 0 bits = 8
29154    Input channel 0 increment = 8
29155    Input channel 1 bits = 8
29156    Input channel 1 increment = 8
29157    Input channel 2 bits = 8
29158    Input channel 2 increment = 8
29159    Input channel 3 bits = 8
29160    Input channel 3 increment = 8
29161    Input channel 4 bits = 8
29162    Input channel 4 increment = 8
29163    Input channel 5 bits = 8
29164    Input channel 5 increment = 8
29165    Input channel 6 bits = 8
29166    Input channel 6 increment = 8
29167    Input channel 7 bits = 8
29168    Input channel 7 increment = 8
29169    Input is channel interleaved
29170    Input channels are separate words
29171    Input value extraction is done in input table lookup
29172 
29173    Output channels per pixel = 6
29174    Output channel 0 bits = 16
29175    Output channel 0 increment = 6
29176    Output channel 1 bits = 16
29177    Output channel 1 increment = 6
29178    Output channel 2 bits = 16
29179    Output channel 2 increment = 6
29180    Output channel 3 bits = 16
29181    Output channel 3 increment = 6
29182    Output channel 4 bits = 16
29183    Output channel 4 increment = 6
29184    Output channel 5 bits = 16
29185    Output channel 5 increment = 6
29186    Output is channel interleaved
29187 
29188    Output channels are separate words
29189    Weight+voffset bits       = 32
29190    Interpolation table index bits = 32
29191    Interpolation table max resolution = 8
29192  */
29193 
29194 /*
29195    Machine architecture specs:
29196 
29197    Little endian
29198    Reading and writing pixel values separately
29199    Pointer size = 32 bits
29200 
29201    Ordinal size  8 bits is known as 'unsigned char'
29202    Ordinal size 16 bits is known as 'unsigned short'
29203    Ordinal size 32 bits is known as 'unsigned int'
29204    Natural ordinal is 'unsigned int'
29205 
29206    Integer size  8 bits is known as 'signed char'
29207    Integer size 16 bits is known as 'short'
29208    Integer size 32 bits is known as 'int'
29209    Natural integer is 'int'
29210 
29211  */
29212 
29213 #ifndef  IMDI_INCLUDED
29214 #include <memory.h>
29215 #include "imdi_imp.h"
29216 #define  IMDI_INCLUDED
29217 #endif  /* IMDI_INCLUDED */
29218 
29219 #ifndef DEFINED_pointer
29220 #define DEFINED_pointer
29221 typedef unsigned char * pointer;
29222 #endif
29223 
29224 /* Input table interp. index */
29225 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
29226 
29227 /* Input table input weighting/offset value enty */
29228 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
29229 
29230 /* Conditional exchange for sorting */
29231 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
29232 
29233 /* Interpolation multi-dim. table access */
29234 #define IM_O(off) ((off) * 12)
29235 
29236 /* Interpolation table - get vertex values */
29237 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 4 + (c) * 4))
29238 
29239 /* Output table indexes */
29240 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
29241 
29242 void
imdi_k84(imdi * s,void ** outp,void ** inp,unsigned int npix)29243 imdi_k84(
29244 imdi *s,			/* imdi context */
29245 void **outp,		/* pointer to output pointers */
29246 void **inp,		/* pointer to input pointers */
29247 unsigned int npix	/* Number of pixels to process */
29248 ) {
29249 	imdi_imp *p = (imdi_imp *)(s->impl);
29250 	unsigned char *ip0 = (unsigned char *)inp[0];
29251 	unsigned short *op0 = (unsigned short *)outp[0];
29252 	unsigned char *ep = ip0 + npix * 8 ;
29253 	pointer it0 = (pointer)p->in_tables[0];
29254 	pointer it1 = (pointer)p->in_tables[1];
29255 	pointer it2 = (pointer)p->in_tables[2];
29256 	pointer it3 = (pointer)p->in_tables[3];
29257 	pointer it4 = (pointer)p->in_tables[4];
29258 	pointer it5 = (pointer)p->in_tables[5];
29259 	pointer it6 = (pointer)p->in_tables[6];
29260 	pointer it7 = (pointer)p->in_tables[7];
29261 	pointer ot0 = (pointer)p->out_tables[0];
29262 	pointer ot1 = (pointer)p->out_tables[1];
29263 	pointer ot2 = (pointer)p->out_tables[2];
29264 	pointer ot3 = (pointer)p->out_tables[3];
29265 	pointer ot4 = (pointer)p->out_tables[4];
29266 	pointer ot5 = (pointer)p->out_tables[5];
29267 	pointer im_base = (pointer)p->im_table;
29268 
29269 	for(;ip0 < ep; ip0 += 8, op0 += 6) {
29270 		unsigned int ova0;	/* Output value accumulator */
29271 		unsigned int ova1;	/* Output value accumulator */
29272 		unsigned int ova2;	/* Output value accumulator */
29273 		{
29274 			pointer imp;
29275 			unsigned int wo0;	/* Weighting value and vertex offset variable */
29276 			unsigned int wo1;	/* Weighting value and vertex offset variable */
29277 			unsigned int wo2;	/* Weighting value and vertex offset variable */
29278 			unsigned int wo3;	/* Weighting value and vertex offset variable */
29279 			unsigned int wo4;	/* Weighting value and vertex offset variable */
29280 			unsigned int wo5;	/* Weighting value and vertex offset variable */
29281 			unsigned int wo6;	/* Weighting value and vertex offset variable */
29282 			unsigned int wo7;	/* Weighting value and vertex offset variable */
29283 			{
29284 				unsigned int ti_i;	/* Interpolation index variable */
29285 
29286 				ti_i  = IT_IX(it0, ip0[0]);
29287 				wo0   = IT_WO(it0, ip0[0]);
29288 				ti_i += IT_IX(it1, ip0[1]);
29289 				wo1   = IT_WO(it1, ip0[1]);
29290 				ti_i += IT_IX(it2, ip0[2]);
29291 				wo2   = IT_WO(it2, ip0[2]);
29292 				ti_i += IT_IX(it3, ip0[3]);
29293 				wo3   = IT_WO(it3, ip0[3]);
29294 				ti_i += IT_IX(it4, ip0[4]);
29295 				wo4   = IT_WO(it4, ip0[4]);
29296 				ti_i += IT_IX(it5, ip0[5]);
29297 				wo5   = IT_WO(it5, ip0[5]);
29298 				ti_i += IT_IX(it6, ip0[6]);
29299 				wo6   = IT_WO(it6, ip0[6]);
29300 				ti_i += IT_IX(it7, ip0[7]);
29301 				wo7   = IT_WO(it7, ip0[7]);
29302 
29303 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
29304 
29305 				/* Sort weighting values and vertex offset values */
29306 				CEX(wo0, wo1);
29307 				CEX(wo0, wo2);
29308 				CEX(wo0, wo3);
29309 				CEX(wo0, wo4);
29310 				CEX(wo0, wo5);
29311 				CEX(wo0, wo6);
29312 				CEX(wo0, wo7);
29313 				CEX(wo1, wo2);
29314 				CEX(wo1, wo3);
29315 				CEX(wo1, wo4);
29316 				CEX(wo1, wo5);
29317 				CEX(wo1, wo6);
29318 				CEX(wo1, wo7);
29319 				CEX(wo2, wo3);
29320 				CEX(wo2, wo4);
29321 				CEX(wo2, wo5);
29322 				CEX(wo2, wo6);
29323 				CEX(wo2, wo7);
29324 				CEX(wo3, wo4);
29325 				CEX(wo3, wo5);
29326 				CEX(wo3, wo6);
29327 				CEX(wo3, wo7);
29328 				CEX(wo4, wo5);
29329 				CEX(wo4, wo6);
29330 				CEX(wo4, wo7);
29331 				CEX(wo5, wo6);
29332 				CEX(wo5, wo7);
29333 				CEX(wo6, wo7);
29334 			}
29335 			{
29336 				unsigned int nvof;	/* Next vertex offset value */
29337 				unsigned int vof;	/* Vertex offset value */
29338 				unsigned int vwe;	/* Vertex weighting */
29339 
29340 				vof = 0;				/* First vertex offset is 0 */
29341 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
29342 				wo0 = (wo0 >> 23);		/* Extract weighting value */
29343 				vwe = 256 - wo0;		/* Baricentric weighting */
29344 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
29345 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
29346 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
29347 				vof += nvof;			/* Move to next vertex */
29348 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
29349 				wo1 = (wo1 >> 23);		/* Extract weighting value */
29350 				vwe = wo0 - wo1;		/* Baricentric weighting */
29351 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
29352 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
29353 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
29354 				vof += nvof;			/* Move to next vertex */
29355 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
29356 				wo2 = (wo2 >> 23);		/* Extract weighting value */
29357 				vwe = wo1 - wo2;		/* Baricentric weighting */
29358 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
29359 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
29360 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
29361 				vof += nvof;			/* Move to next vertex */
29362 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
29363 				wo3 = (wo3 >> 23);		/* Extract weighting value */
29364 				vwe = wo2 - wo3;		/* Baricentric weighting */
29365 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
29366 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
29367 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
29368 				vof += nvof;			/* Move to next vertex */
29369 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
29370 				wo4 = (wo4 >> 23);		/* Extract weighting value */
29371 				vwe = wo3 - wo4;		/* Baricentric weighting */
29372 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
29373 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
29374 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
29375 				vof += nvof;			/* Move to next vertex */
29376 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
29377 				wo5 = (wo5 >> 23);		/* Extract weighting value */
29378 				vwe = wo4 - wo5;		/* Baricentric weighting */
29379 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
29380 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
29381 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
29382 				vof += nvof;			/* Move to next vertex */
29383 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
29384 				wo6 = (wo6 >> 23);		/* Extract weighting value */
29385 				vwe = wo5 - wo6;		/* Baricentric weighting */
29386 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
29387 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
29388 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
29389 				vof += nvof;			/* Move to next vertex */
29390 				nvof = (wo7 & 0x7fffff);	/* Extract offset value */
29391 				wo7 = (wo7 >> 23);		/* Extract weighting value */
29392 				vwe = wo6 - wo7;		/* Baricentric weighting */
29393 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
29394 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
29395 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
29396 				vof += nvof;			/* Move to next vertex */
29397 				vwe = wo7;				/* Baricentric weighting */
29398 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
29399 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
29400 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
29401 			}
29402 		}
29403 		{
29404 			unsigned int oti;	/* Vertex offset value */
29405 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
29406 			op0[0] = OT_E(ot0, oti);	/* Write result */
29407 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
29408 			op0[1] = OT_E(ot1, oti);	/* Write result */
29409 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
29410 			op0[2] = OT_E(ot2, oti);	/* Write result */
29411 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
29412 			op0[3] = OT_E(ot3, oti);	/* Write result */
29413 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
29414 			op0[4] = OT_E(ot4, oti);	/* Write result */
29415 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
29416 			op0[5] = OT_E(ot5, oti);	/* Write result */
29417 		}
29418 	}
29419 }
29420 #undef IT_WO
29421 #undef IT_IX
29422 #undef CEX
29423 #undef IM_O
29424 #undef IM_FE
29425 #undef OT_E
29426 
29427 void
imdi_k84_gen(genspec * g)29428 imdi_k84_gen(
29429 genspec *g			/* structure to be initialised */
29430 ) {
29431 	static unsigned char data[] = {
29432 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29433 		0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29434 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29435 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29436 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29437 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29438 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29439 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29440 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29441 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29442 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29443 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29444 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29445 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29446 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29447 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29448 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29449 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29450 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29451 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29452 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29453 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29454 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29455 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29456 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
29457 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
29458 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
29459 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29460 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29461 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29462 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29463 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29464 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29465 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29466 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29467 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29468 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29469 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29470 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29471 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
29472 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
29473 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
29474 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
29475 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
29476 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
29477 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
29478 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
29479 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
29480 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29481 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
29482 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
29483 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x36, 0x5f,
29484 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
29485 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
29486 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
29487 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
29488 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
29489 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
29490 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
29491 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29492 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29493 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29494 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29495 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
29496 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x38, 0x34,
29497 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29498 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29499 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
29500 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
29501 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
29502 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
29503 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
29504 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
29505 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
29506 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
29507 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
29508 		0x00, 0xf0, 0x04, 0x08
29509 	};	/* Structure image */
29510 
29511 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
29512 }
29513 
29514 void
imdi_k84_tab(tabspec * t)29515 imdi_k84_tab(
29516 tabspec *t			/* structure to be initialised */
29517 ) {
29518 	static unsigned char data[] = {
29519 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29520 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29521 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29522 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
29523 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
29524 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
29525 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29526 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
29527 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
29528 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29529 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
29530 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
29531 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
29532 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
29533 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
29534 		0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29535 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
29536 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
29537 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29538 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29539 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29540 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
29541 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
29542 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
29543 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29544 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29545 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29546 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
29547 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29548 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29549 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29550 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
29551 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
29552 	};	/* Structure image */
29553 
29554 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
29555 }
29556 
29557 
29558 
29559 
29560 
29561 
29562 /* Integer Multi-Dimensional Interpolation */
29563 /* Interpolation Kernel Code */
29564 /* Generated by cgen */
29565 /* Copyright 2000 - 2002 Graeme W. Gill */
29566 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
29567 
29568 /* see the Licence.txt file for licencing details.*/
29569 
29570 
29571 /*
29572    Interpolation kernel specs:
29573 
29574    Input channels per pixel = 1
29575    Input channel 0 bits = 8
29576    Input channel 0 increment = 1
29577    Input is channel interleaved
29578    Input channels are separate words
29579    Input value extraction is done in input table lookup
29580 
29581    Output channels per pixel = 7
29582    Output channel 0 bits = 16
29583    Output channel 0 increment = 7
29584    Output channel 1 bits = 16
29585    Output channel 1 increment = 7
29586    Output channel 2 bits = 16
29587    Output channel 2 increment = 7
29588    Output channel 3 bits = 16
29589    Output channel 3 increment = 7
29590    Output channel 4 bits = 16
29591    Output channel 4 increment = 7
29592    Output channel 5 bits = 16
29593    Output channel 5 increment = 7
29594    Output channel 6 bits = 16
29595    Output channel 6 increment = 7
29596    Output is channel interleaved
29597 
29598    Output channels are separate words
29599    Simplex table index bits       = 0
29600    Interpolation table index bits = 8
29601    Simplex table max resolution = 1
29602    Interpolation table max resolution = 255
29603  */
29604 
29605 /*
29606    Machine architecture specs:
29607 
29608    Little endian
29609    Reading and writing pixel values separately
29610    Pointer size = 32 bits
29611 
29612    Ordinal size  8 bits is known as 'unsigned char'
29613    Ordinal size 16 bits is known as 'unsigned short'
29614    Ordinal size 32 bits is known as 'unsigned int'
29615    Natural ordinal is 'unsigned int'
29616 
29617    Integer size  8 bits is known as 'signed char'
29618    Integer size 16 bits is known as 'short'
29619    Integer size 32 bits is known as 'int'
29620    Natural integer is 'int'
29621 
29622  */
29623 
29624 #ifndef  IMDI_INCLUDED
29625 #include <memory.h>
29626 #include "imdi_imp.h"
29627 #define  IMDI_INCLUDED
29628 #endif  /* IMDI_INCLUDED */
29629 
29630 #ifndef DEFINED_pointer
29631 #define DEFINED_pointer
29632 typedef unsigned char * pointer;
29633 #endif
29634 
29635 /* Input table inter & simplex indexes */
29636 #define IT_IT(p, off) *((unsigned char *)((p) + 0 + (off) * 1))
29637 
29638 /* Simplex weighting table access */
29639 #define SW_O(off) ((off) * 4)
29640 
29641 /* Simplex table - get weighting/offset value */
29642 #define SX_WO(p, v) *((unsigned short *)((p) + (v) * 2))
29643 
29644 /* Interpolation multi-dim. table access */
29645 #define IM_O(off) ((off) * 16)
29646 
29647 /* Interpolation table - get vertex values */
29648 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
29649 #define IM_PE(p, v) *((unsigned int *)((p) + 12 + (v) * 8))
29650 
29651 /* Output table indexes */
29652 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
29653 
29654 void
imdi_k85(imdi * s,void ** outp,void ** inp,unsigned int npix)29655 imdi_k85(
29656 imdi *s,			/* imdi context */
29657 void **outp,		/* pointer to output pointers */
29658 void **inp,		/* pointer to input pointers */
29659 unsigned int npix	/* Number of pixels to process */
29660 ) {
29661 	imdi_imp *p = (imdi_imp *)(s->impl);
29662 	unsigned char *ip0 = (unsigned char *)inp[0];
29663 	unsigned short *op0 = (unsigned short *)outp[0];
29664 	unsigned char *ep = ip0 + npix * 1 ;
29665 	pointer it0 = (pointer)p->in_tables[0];
29666 	pointer ot0 = (pointer)p->out_tables[0];
29667 	pointer ot1 = (pointer)p->out_tables[1];
29668 	pointer ot2 = (pointer)p->out_tables[2];
29669 	pointer ot3 = (pointer)p->out_tables[3];
29670 	pointer ot4 = (pointer)p->out_tables[4];
29671 	pointer ot5 = (pointer)p->out_tables[5];
29672 	pointer ot6 = (pointer)p->out_tables[6];
29673 	pointer sw_base = (pointer)p->sw_table;
29674 	pointer im_base = (pointer)p->im_table;
29675 
29676 	for(;ip0 < ep; ip0 += 1, op0 += 7) {
29677 		unsigned int ova0;	/* Output value accumulator */
29678 		unsigned int ova1;	/* Output value accumulator */
29679 		unsigned int ova2;	/* Output value accumulator */
29680 		unsigned int ova3;	/* Output value partial accumulator */
29681 		{
29682 			pointer swp;
29683 			pointer imp;
29684 			{
29685 				unsigned int ti;	/* Simplex+Interpolation index variable */
29686 
29687 				ti  = IT_IT(it0, ip0[0]);
29688 
29689 				imp = im_base + IM_O(ti >> 0);		/* Extract interp. index and comp. entry */
29690 				swp = sw_base + SW_O(ti & 0x0);	/* Extract simplex index and comp. entry */
29691 			}
29692 			{
29693 				unsigned int vowr;	/* Vertex offset/weight value */
29694 				unsigned int vof;	/* Vertex offset value */
29695 				unsigned int vwe;	/* Vertex weighting */
29696 
29697 				vowr = SX_WO(swp, 0);	/* Read vertex offset+weighting values */
29698 				vof = (vowr & 0x7f);	/* Extract offset value */
29699 				vwe = (vowr >> 7);	/* Extract weighting value */
29700 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
29701 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
29702 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
29703 				ova3  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
29704 				vowr = SX_WO(swp, 1);	/* Read vertex offset+weighting values */
29705 				vof = (vowr & 0x7f);	/* Extract offset value */
29706 				vwe = (vowr >> 7);	/* Extract weighting value */
29707 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
29708 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
29709 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
29710 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
29711 			}
29712 		}
29713 		{
29714 			unsigned int oti;	/* Vertex offset value */
29715 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
29716 			op0[0] = OT_E(ot0, oti);	/* Write result */
29717 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
29718 			op0[1] = OT_E(ot1, oti);	/* Write result */
29719 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
29720 			op0[2] = OT_E(ot2, oti);	/* Write result */
29721 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
29722 			op0[3] = OT_E(ot3, oti);	/* Write result */
29723 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
29724 			op0[4] = OT_E(ot4, oti);	/* Write result */
29725 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
29726 			op0[5] = OT_E(ot5, oti);	/* Write result */
29727 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
29728 			op0[6] = OT_E(ot6, oti);	/* Write result */
29729 		}
29730 	}
29731 }
29732 #undef IT_IT
29733 #undef SW_O
29734 #undef SX_WO
29735 #undef IM_O
29736 #undef IM_FE
29737 #undef IM_PE
29738 #undef OT_E
29739 
29740 void
imdi_k85_gen(genspec * g)29741 imdi_k85_gen(
29742 genspec *g			/* structure to be initialised */
29743 ) {
29744 	static unsigned char data[] = {
29745 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29746 		0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29747 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29748 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29749 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29750 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29751 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29752 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29753 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29754 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29755 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29756 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29757 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29758 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29759 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29760 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29761 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29762 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29763 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29764 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29765 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29766 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29767 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29768 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29769 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
29770 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
29771 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
29772 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
29773 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29774 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29775 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29776 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29777 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29778 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29779 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29780 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29781 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29782 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29783 		0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29784 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
29785 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
29786 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
29787 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
29788 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
29789 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
29790 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
29791 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
29792 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
29793 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29794 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
29795 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
29796 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x37, 0x5f,
29797 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
29798 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
29799 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
29800 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
29801 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
29802 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
29803 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
29804 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29805 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29806 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29807 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29808 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
29809 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x38, 0x35,
29810 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29811 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29812 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
29813 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
29814 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
29815 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
29816 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
29817 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
29818 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
29819 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
29820 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
29821 		0x00, 0xf0, 0x04, 0x08
29822 	};	/* Structure image */
29823 
29824 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
29825 }
29826 
29827 void
imdi_k85_tab(tabspec * t)29828 imdi_k85_tab(
29829 tabspec *t			/* structure to be initialised */
29830 ) {
29831 	static unsigned char data[] = {
29832 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29833 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29834 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29835 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
29836 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
29837 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
29838 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29839 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
29840 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29841 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29842 		0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29843 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29844 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
29845 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
29846 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
29847 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29848 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29849 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
29850 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
29851 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29852 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
29853 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
29854 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
29855 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
29856 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29857 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29858 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29859 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29860 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29861 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29862 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29863 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
29864 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
29865 	};	/* Structure image */
29866 
29867 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
29868 }
29869 
29870 
29871 
29872 
29873 
29874 
29875 /* Integer Multi-Dimensional Interpolation */
29876 /* Interpolation Kernel Code */
29877 /* Generated by cgen */
29878 /* Copyright 2000 - 2002 Graeme W. Gill */
29879 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
29880 
29881 /* see the Licence.txt file for licencing details.*/
29882 
29883 
29884 /*
29885    Interpolation kernel specs:
29886 
29887    Input channels per pixel = 3
29888    Input channel 0 bits = 8
29889    Input channel 0 increment = 3
29890    Input channel 1 bits = 8
29891    Input channel 1 increment = 3
29892    Input channel 2 bits = 8
29893    Input channel 2 increment = 3
29894    Input is channel interleaved
29895    Input channels are separate words
29896    Input value extraction is done in input table lookup
29897 
29898    Output channels per pixel = 7
29899    Output channel 0 bits = 16
29900    Output channel 0 increment = 7
29901    Output channel 1 bits = 16
29902    Output channel 1 increment = 7
29903    Output channel 2 bits = 16
29904    Output channel 2 increment = 7
29905    Output channel 3 bits = 16
29906    Output channel 3 increment = 7
29907    Output channel 4 bits = 16
29908    Output channel 4 increment = 7
29909    Output channel 5 bits = 16
29910    Output channel 5 increment = 7
29911    Output channel 6 bits = 16
29912    Output channel 6 increment = 7
29913    Output is channel interleaved
29914 
29915    Output channels are separate words
29916    Simplex table index bits       = 12
29917    Interpolation table index bits = 20
29918    Simplex table max resolution = 16
29919    Interpolation table max resolution = 101
29920  */
29921 
29922 /*
29923    Machine architecture specs:
29924 
29925    Little endian
29926    Reading and writing pixel values separately
29927    Pointer size = 32 bits
29928 
29929    Ordinal size  8 bits is known as 'unsigned char'
29930    Ordinal size 16 bits is known as 'unsigned short'
29931    Ordinal size 32 bits is known as 'unsigned int'
29932    Natural ordinal is 'unsigned int'
29933 
29934    Integer size  8 bits is known as 'signed char'
29935    Integer size 16 bits is known as 'short'
29936    Integer size 32 bits is known as 'int'
29937    Natural integer is 'int'
29938 
29939  */
29940 
29941 #ifndef  IMDI_INCLUDED
29942 #include <memory.h>
29943 #include "imdi_imp.h"
29944 #define  IMDI_INCLUDED
29945 #endif  /* IMDI_INCLUDED */
29946 
29947 #ifndef DEFINED_pointer
29948 #define DEFINED_pointer
29949 typedef unsigned char * pointer;
29950 #endif
29951 
29952 /* Input table inter & simplex indexes */
29953 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
29954 
29955 /* Simplex weighting table access */
29956 #define SW_O(off) ((off) * 16)
29957 
29958 /* Simplex table - get weighting value */
29959 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
29960 
29961 /* Simplex table - get offset value */
29962 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
29963 
29964 /* Interpolation multi-dim. table access */
29965 #define IM_O(off) ((off) * 16)
29966 
29967 /* Interpolation table - get vertex values */
29968 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
29969 #define IM_PE(p, v) *((unsigned int *)((p) + 12 + (v) * 8))
29970 
29971 /* Output table indexes */
29972 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
29973 
29974 void
imdi_k86(imdi * s,void ** outp,void ** inp,unsigned int npix)29975 imdi_k86(
29976 imdi *s,			/* imdi context */
29977 void **outp,		/* pointer to output pointers */
29978 void **inp,		/* pointer to input pointers */
29979 unsigned int npix	/* Number of pixels to process */
29980 ) {
29981 	imdi_imp *p = (imdi_imp *)(s->impl);
29982 	unsigned char *ip0 = (unsigned char *)inp[0];
29983 	unsigned short *op0 = (unsigned short *)outp[0];
29984 	unsigned char *ep = ip0 + npix * 3 ;
29985 	pointer it0 = (pointer)p->in_tables[0];
29986 	pointer it1 = (pointer)p->in_tables[1];
29987 	pointer it2 = (pointer)p->in_tables[2];
29988 	pointer ot0 = (pointer)p->out_tables[0];
29989 	pointer ot1 = (pointer)p->out_tables[1];
29990 	pointer ot2 = (pointer)p->out_tables[2];
29991 	pointer ot3 = (pointer)p->out_tables[3];
29992 	pointer ot4 = (pointer)p->out_tables[4];
29993 	pointer ot5 = (pointer)p->out_tables[5];
29994 	pointer ot6 = (pointer)p->out_tables[6];
29995 	pointer sw_base = (pointer)p->sw_table;
29996 	pointer im_base = (pointer)p->im_table;
29997 
29998 	for(;ip0 < ep; ip0 += 3, op0 += 7) {
29999 		unsigned int ova0;	/* Output value accumulator */
30000 		unsigned int ova1;	/* Output value accumulator */
30001 		unsigned int ova2;	/* Output value accumulator */
30002 		unsigned int ova3;	/* Output value partial accumulator */
30003 		{
30004 			pointer swp;
30005 			pointer imp;
30006 			{
30007 				unsigned int ti;	/* Simplex+Interpolation index variable */
30008 
30009 				ti  = IT_IT(it0, ip0[0]);
30010 				ti += IT_IT(it1, ip0[1]);
30011 				ti += IT_IT(it2, ip0[2]);
30012 
30013 				imp = im_base + IM_O(ti >> 12);		/* Extract interp. index and comp. entry */
30014 				swp = sw_base + SW_O(ti & 0xfff);	/* Extract simplex index and comp. entry */
30015 			}
30016 			{
30017 				unsigned int vof;	/* Vertex offset value */
30018 				unsigned int vwe;	/* Vertex weighting */
30019 
30020 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
30021 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
30022 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
30023 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
30024 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
30025 				ova3  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
30026 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
30027 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
30028 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
30029 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
30030 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
30031 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
30032 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
30033 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
30034 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
30035 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
30036 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
30037 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
30038 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
30039 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
30040 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
30041 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
30042 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
30043 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
30044 			}
30045 		}
30046 		{
30047 			unsigned int oti;	/* Vertex offset value */
30048 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
30049 			op0[0] = OT_E(ot0, oti);	/* Write result */
30050 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
30051 			op0[1] = OT_E(ot1, oti);	/* Write result */
30052 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
30053 			op0[2] = OT_E(ot2, oti);	/* Write result */
30054 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
30055 			op0[3] = OT_E(ot3, oti);	/* Write result */
30056 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
30057 			op0[4] = OT_E(ot4, oti);	/* Write result */
30058 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
30059 			op0[5] = OT_E(ot5, oti);	/* Write result */
30060 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
30061 			op0[6] = OT_E(ot6, oti);	/* Write result */
30062 		}
30063 	}
30064 }
30065 #undef IT_IT
30066 #undef SW_O
30067 #undef SX_WE
30068 #undef SX_VO
30069 #undef IM_O
30070 #undef IM_FE
30071 #undef IM_PE
30072 #undef OT_E
30073 
30074 void
imdi_k86_gen(genspec * g)30075 imdi_k86_gen(
30076 genspec *g			/* structure to be initialised */
30077 ) {
30078 	static unsigned char data[] = {
30079 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
30080 		0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30081 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30082 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30083 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30084 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30085 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30086 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
30087 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
30088 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30089 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30090 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30091 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30092 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30093 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30094 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30095 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30096 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30097 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30098 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30099 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30100 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30101 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30102 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30103 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
30104 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
30105 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
30106 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
30107 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30108 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30109 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30110 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30111 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30112 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30113 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30114 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30115 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30116 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30117 		0x65, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30118 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
30119 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
30120 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
30121 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
30122 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
30123 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
30124 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
30125 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
30126 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
30127 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30128 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
30129 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
30130 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x37, 0x5f,
30131 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
30132 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
30133 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
30134 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
30135 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
30136 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
30137 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
30138 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30139 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30140 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30141 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30142 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
30143 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x38, 0x36,
30144 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30145 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30146 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
30147 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
30148 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
30149 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
30150 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
30151 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
30152 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
30153 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
30154 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
30155 		0x00, 0xf0, 0x04, 0x08
30156 	};	/* Structure image */
30157 
30158 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
30159 }
30160 
30161 void
imdi_k86_tab(tabspec * t)30162 imdi_k86_tab(
30163 tabspec *t			/* structure to be initialised */
30164 ) {
30165 	static unsigned char data[] = {
30166 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30167 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30168 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30169 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
30170 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
30171 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
30172 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
30173 		0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
30174 		0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
30175 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30176 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30177 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30178 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
30179 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30180 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
30181 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30182 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30183 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
30184 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
30185 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30186 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30187 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
30188 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
30189 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
30190 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30191 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30192 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30193 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30194 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30195 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30196 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30197 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30198 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
30199 	};	/* Structure image */
30200 
30201 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
30202 }
30203 
30204 
30205 
30206 
30207 
30208 
30209 /* Integer Multi-Dimensional Interpolation */
30210 /* Interpolation Kernel Code */
30211 /* Generated by cgen */
30212 /* Copyright 2000 - 2002 Graeme W. Gill */
30213 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
30214 
30215 /* see the Licence.txt file for licencing details.*/
30216 
30217 
30218 /*
30219    Interpolation kernel specs:
30220 
30221    Input channels per pixel = 4
30222    Input channel 0 bits = 8
30223    Input channel 0 increment = 4
30224    Input channel 1 bits = 8
30225    Input channel 1 increment = 4
30226    Input channel 2 bits = 8
30227    Input channel 2 increment = 4
30228    Input channel 3 bits = 8
30229    Input channel 3 increment = 4
30230    Input is channel interleaved
30231    Input channels are separate words
30232    Input value extraction is done in input table lookup
30233 
30234    Output channels per pixel = 7
30235    Output channel 0 bits = 16
30236    Output channel 0 increment = 7
30237    Output channel 1 bits = 16
30238    Output channel 1 increment = 7
30239    Output channel 2 bits = 16
30240    Output channel 2 increment = 7
30241    Output channel 3 bits = 16
30242    Output channel 3 increment = 7
30243    Output channel 4 bits = 16
30244    Output channel 4 increment = 7
30245    Output channel 5 bits = 16
30246    Output channel 5 increment = 7
30247    Output channel 6 bits = 16
30248    Output channel 6 increment = 7
30249    Output is channel interleaved
30250 
30251    Output channels are separate words
30252    Simplex table index bits       = 32
30253    Interpolation table index bits = 32
30254    Simplex table max resolution = 255
30255    Interpolation table max resolution = 31
30256  */
30257 
30258 /*
30259    Machine architecture specs:
30260 
30261    Little endian
30262    Reading and writing pixel values separately
30263    Pointer size = 32 bits
30264 
30265    Ordinal size  8 bits is known as 'unsigned char'
30266    Ordinal size 16 bits is known as 'unsigned short'
30267    Ordinal size 32 bits is known as 'unsigned int'
30268    Natural ordinal is 'unsigned int'
30269 
30270    Integer size  8 bits is known as 'signed char'
30271    Integer size 16 bits is known as 'short'
30272    Integer size 32 bits is known as 'int'
30273    Natural integer is 'int'
30274 
30275  */
30276 
30277 #ifndef  IMDI_INCLUDED
30278 #include <memory.h>
30279 #include "imdi_imp.h"
30280 #define  IMDI_INCLUDED
30281 #endif  /* IMDI_INCLUDED */
30282 
30283 #ifndef DEFINED_pointer
30284 #define DEFINED_pointer
30285 typedef unsigned char * pointer;
30286 #endif
30287 
30288 /* Input table interp. index */
30289 #define IT_IX(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
30290 
30291 /* Input table simplex index enty */
30292 #define IT_SX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
30293 
30294 /* Simplex weighting table access */
30295 #define SW_O(off) ((off) * 20)
30296 
30297 /* Simplex table - get weighting value */
30298 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
30299 
30300 /* Simplex table - get offset value */
30301 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
30302 
30303 /* Interpolation multi-dim. table access */
30304 #define IM_O(off) ((off) * 16)
30305 
30306 /* Interpolation table - get vertex values */
30307 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
30308 #define IM_PE(p, v) *((unsigned int *)((p) + 12 + (v) * 8))
30309 
30310 /* Output table indexes */
30311 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
30312 
30313 void
imdi_k87(imdi * s,void ** outp,void ** inp,unsigned int npix)30314 imdi_k87(
30315 imdi *s,			/* imdi context */
30316 void **outp,		/* pointer to output pointers */
30317 void **inp,		/* pointer to input pointers */
30318 unsigned int npix	/* Number of pixels to process */
30319 ) {
30320 	imdi_imp *p = (imdi_imp *)(s->impl);
30321 	unsigned char *ip0 = (unsigned char *)inp[0];
30322 	unsigned short *op0 = (unsigned short *)outp[0];
30323 	unsigned char *ep = ip0 + npix * 4 ;
30324 	pointer it0 = (pointer)p->in_tables[0];
30325 	pointer it1 = (pointer)p->in_tables[1];
30326 	pointer it2 = (pointer)p->in_tables[2];
30327 	pointer it3 = (pointer)p->in_tables[3];
30328 	pointer ot0 = (pointer)p->out_tables[0];
30329 	pointer ot1 = (pointer)p->out_tables[1];
30330 	pointer ot2 = (pointer)p->out_tables[2];
30331 	pointer ot3 = (pointer)p->out_tables[3];
30332 	pointer ot4 = (pointer)p->out_tables[4];
30333 	pointer ot5 = (pointer)p->out_tables[5];
30334 	pointer ot6 = (pointer)p->out_tables[6];
30335 	pointer sw_base = (pointer)p->sw_table;
30336 	pointer im_base = (pointer)p->im_table;
30337 
30338 	for(;ip0 < ep; ip0 += 4, op0 += 7) {
30339 		unsigned int ova0;	/* Output value accumulator */
30340 		unsigned int ova1;	/* Output value accumulator */
30341 		unsigned int ova2;	/* Output value accumulator */
30342 		unsigned int ova3;	/* Output value partial accumulator */
30343 		{
30344 			pointer swp;
30345 			pointer imp;
30346 			{
30347 				unsigned int ti_s;	/* Simplex index variable */
30348 				unsigned int ti_i;	/* Interpolation index variable */
30349 
30350 				ti_i  = IT_IX(it0, ip0[0]);
30351 				ti_s  = IT_SX(it0, ip0[0]);
30352 				ti_i += IT_IX(it1, ip0[1]);
30353 				ti_s += IT_SX(it1, ip0[1]);
30354 				ti_i += IT_IX(it2, ip0[2]);
30355 				ti_s += IT_SX(it2, ip0[2]);
30356 				ti_i += IT_IX(it3, ip0[3]);
30357 				ti_s += IT_SX(it3, ip0[3]);
30358 
30359 				swp = sw_base + SW_O(ti_s);		/* Compute simplex table entry pointer */
30360 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
30361 			}
30362 			{
30363 				unsigned int vof;	/* Vertex offset value */
30364 				unsigned int vwe;	/* Vertex weighting */
30365 
30366 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
30367 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
30368 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
30369 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
30370 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
30371 				ova3  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
30372 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
30373 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
30374 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
30375 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
30376 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
30377 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
30378 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
30379 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
30380 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
30381 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
30382 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
30383 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
30384 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
30385 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
30386 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
30387 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
30388 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
30389 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
30390 				vof = SX_VO(swp, 4);	/* Read vertex offset value */
30391 				vwe = SX_WE(swp, 4);	/* Read vertex weighting value */
30392 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
30393 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
30394 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
30395 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
30396 			}
30397 		}
30398 		{
30399 			unsigned int oti;	/* Vertex offset value */
30400 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
30401 			op0[0] = OT_E(ot0, oti);	/* Write result */
30402 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
30403 			op0[1] = OT_E(ot1, oti);	/* Write result */
30404 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
30405 			op0[2] = OT_E(ot2, oti);	/* Write result */
30406 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
30407 			op0[3] = OT_E(ot3, oti);	/* Write result */
30408 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
30409 			op0[4] = OT_E(ot4, oti);	/* Write result */
30410 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
30411 			op0[5] = OT_E(ot5, oti);	/* Write result */
30412 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
30413 			op0[6] = OT_E(ot6, oti);	/* Write result */
30414 		}
30415 	}
30416 }
30417 #undef IT_IX
30418 #undef IT_SX
30419 #undef SW_O
30420 #undef SX_WE
30421 #undef SX_VO
30422 #undef IM_O
30423 #undef IM_FE
30424 #undef IM_PE
30425 #undef OT_E
30426 
30427 void
imdi_k87_gen(genspec * g)30428 imdi_k87_gen(
30429 genspec *g			/* structure to be initialised */
30430 ) {
30431 	static unsigned char data[] = {
30432 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
30433 		0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30434 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30435 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30436 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30437 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30438 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30439 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
30440 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
30441 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30442 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30443 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30444 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30445 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30446 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30447 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30448 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30449 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30450 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30451 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30452 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30453 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30454 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30455 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30456 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
30457 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
30458 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
30459 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
30460 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30461 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30462 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30463 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30464 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30465 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30466 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30467 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30468 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30469 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30470 		0x1f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
30471 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
30472 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
30473 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
30474 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
30475 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
30476 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
30477 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
30478 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
30479 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
30480 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30481 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
30482 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
30483 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x37, 0x5f,
30484 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
30485 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
30486 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
30487 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
30488 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
30489 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
30490 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
30491 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30492 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30493 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30494 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30495 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
30496 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x38, 0x37,
30497 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30498 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30499 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
30500 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
30501 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
30502 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
30503 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
30504 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
30505 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
30506 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
30507 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
30508 		0x00, 0xf0, 0x04, 0x08
30509 	};	/* Structure image */
30510 
30511 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
30512 }
30513 
30514 void
imdi_k87_tab(tabspec * t)30515 imdi_k87_tab(
30516 tabspec *t			/* structure to be initialised */
30517 ) {
30518 	static unsigned char data[] = {
30519 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30520 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30521 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30522 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
30523 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
30524 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
30525 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30526 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
30527 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
30528 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30529 		0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30530 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30531 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
30532 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30533 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
30534 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30535 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30536 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
30537 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
30538 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30539 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30540 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
30541 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
30542 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
30543 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30544 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30545 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30546 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30547 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30548 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30549 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30550 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30551 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
30552 	};	/* Structure image */
30553 
30554 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
30555 }
30556 
30557 
30558 
30559 
30560 
30561 
30562 /* Integer Multi-Dimensional Interpolation */
30563 /* Interpolation Kernel Code */
30564 /* Generated by cgen */
30565 /* Copyright 2000 - 2002 Graeme W. Gill */
30566 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
30567 
30568 /* see the Licence.txt file for licencing details.*/
30569 
30570 
30571 /*
30572    Interpolation kernel specs:
30573 
30574    Input channels per pixel = 5
30575    Input channel 0 bits = 8
30576    Input channel 0 increment = 5
30577    Input channel 1 bits = 8
30578    Input channel 1 increment = 5
30579    Input channel 2 bits = 8
30580    Input channel 2 increment = 5
30581    Input channel 3 bits = 8
30582    Input channel 3 increment = 5
30583    Input channel 4 bits = 8
30584    Input channel 4 increment = 5
30585    Input is channel interleaved
30586    Input channels are separate words
30587    Input value extraction is done in input table lookup
30588 
30589    Output channels per pixel = 7
30590    Output channel 0 bits = 16
30591    Output channel 0 increment = 7
30592    Output channel 1 bits = 16
30593    Output channel 1 increment = 7
30594    Output channel 2 bits = 16
30595    Output channel 2 increment = 7
30596    Output channel 3 bits = 16
30597    Output channel 3 increment = 7
30598    Output channel 4 bits = 16
30599    Output channel 4 increment = 7
30600    Output channel 5 bits = 16
30601    Output channel 5 increment = 7
30602    Output channel 6 bits = 16
30603    Output channel 6 increment = 7
30604    Output is channel interleaved
30605 
30606    Output channels are separate words
30607    Weight+voffset bits       = 32
30608    Interpolation table index bits = 32
30609    Interpolation table max resolution = 45
30610  */
30611 
30612 /*
30613    Machine architecture specs:
30614 
30615    Little endian
30616    Reading and writing pixel values separately
30617    Pointer size = 32 bits
30618 
30619    Ordinal size  8 bits is known as 'unsigned char'
30620    Ordinal size 16 bits is known as 'unsigned short'
30621    Ordinal size 32 bits is known as 'unsigned int'
30622    Natural ordinal is 'unsigned int'
30623 
30624    Integer size  8 bits is known as 'signed char'
30625    Integer size 16 bits is known as 'short'
30626    Integer size 32 bits is known as 'int'
30627    Natural integer is 'int'
30628 
30629  */
30630 
30631 #ifndef  IMDI_INCLUDED
30632 #include <memory.h>
30633 #include "imdi_imp.h"
30634 #define  IMDI_INCLUDED
30635 #endif  /* IMDI_INCLUDED */
30636 
30637 #ifndef DEFINED_pointer
30638 #define DEFINED_pointer
30639 typedef unsigned char * pointer;
30640 #endif
30641 
30642 /* Input table interp. index */
30643 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
30644 
30645 /* Input table input weighting/offset value enty */
30646 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
30647 
30648 /* Conditional exchange for sorting */
30649 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
30650 
30651 /* Interpolation multi-dim. table access */
30652 #define IM_O(off) ((off) * 16)
30653 
30654 /* Interpolation table - get vertex values */
30655 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
30656 #define IM_PE(p, v) *((unsigned int *)((p) + 12 + (v) * 8))
30657 
30658 /* Output table indexes */
30659 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
30660 
30661 void
imdi_k88(imdi * s,void ** outp,void ** inp,unsigned int npix)30662 imdi_k88(
30663 imdi *s,			/* imdi context */
30664 void **outp,		/* pointer to output pointers */
30665 void **inp,		/* pointer to input pointers */
30666 unsigned int npix	/* Number of pixels to process */
30667 ) {
30668 	imdi_imp *p = (imdi_imp *)(s->impl);
30669 	unsigned char *ip0 = (unsigned char *)inp[0];
30670 	unsigned short *op0 = (unsigned short *)outp[0];
30671 	unsigned char *ep = ip0 + npix * 5 ;
30672 	pointer it0 = (pointer)p->in_tables[0];
30673 	pointer it1 = (pointer)p->in_tables[1];
30674 	pointer it2 = (pointer)p->in_tables[2];
30675 	pointer it3 = (pointer)p->in_tables[3];
30676 	pointer it4 = (pointer)p->in_tables[4];
30677 	pointer ot0 = (pointer)p->out_tables[0];
30678 	pointer ot1 = (pointer)p->out_tables[1];
30679 	pointer ot2 = (pointer)p->out_tables[2];
30680 	pointer ot3 = (pointer)p->out_tables[3];
30681 	pointer ot4 = (pointer)p->out_tables[4];
30682 	pointer ot5 = (pointer)p->out_tables[5];
30683 	pointer ot6 = (pointer)p->out_tables[6];
30684 	pointer im_base = (pointer)p->im_table;
30685 
30686 	for(;ip0 < ep; ip0 += 5, op0 += 7) {
30687 		unsigned int ova0;	/* Output value accumulator */
30688 		unsigned int ova1;	/* Output value accumulator */
30689 		unsigned int ova2;	/* Output value accumulator */
30690 		unsigned int ova3;	/* Output value partial accumulator */
30691 		{
30692 			pointer imp;
30693 			unsigned int wo0;	/* Weighting value and vertex offset variable */
30694 			unsigned int wo1;	/* Weighting value and vertex offset variable */
30695 			unsigned int wo2;	/* Weighting value and vertex offset variable */
30696 			unsigned int wo3;	/* Weighting value and vertex offset variable */
30697 			unsigned int wo4;	/* Weighting value and vertex offset variable */
30698 			{
30699 				unsigned int ti_i;	/* Interpolation index variable */
30700 
30701 				ti_i  = IT_IX(it0, ip0[0]);
30702 				wo0   = IT_WO(it0, ip0[0]);
30703 				ti_i += IT_IX(it1, ip0[1]);
30704 				wo1   = IT_WO(it1, ip0[1]);
30705 				ti_i += IT_IX(it2, ip0[2]);
30706 				wo2   = IT_WO(it2, ip0[2]);
30707 				ti_i += IT_IX(it3, ip0[3]);
30708 				wo3   = IT_WO(it3, ip0[3]);
30709 				ti_i += IT_IX(it4, ip0[4]);
30710 				wo4   = IT_WO(it4, ip0[4]);
30711 
30712 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
30713 
30714 				/* Sort weighting values and vertex offset values */
30715 				CEX(wo0, wo1);
30716 				CEX(wo0, wo2);
30717 				CEX(wo0, wo3);
30718 				CEX(wo0, wo4);
30719 				CEX(wo1, wo2);
30720 				CEX(wo1, wo3);
30721 				CEX(wo1, wo4);
30722 				CEX(wo2, wo3);
30723 				CEX(wo2, wo4);
30724 				CEX(wo3, wo4);
30725 			}
30726 			{
30727 				unsigned int nvof;	/* Next vertex offset value */
30728 				unsigned int vof;	/* Vertex offset value */
30729 				unsigned int vwe;	/* Vertex weighting */
30730 
30731 				vof = 0;				/* First vertex offset is 0 */
30732 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
30733 				wo0 = (wo0 >> 23);		/* Extract weighting value */
30734 				vwe = 256 - wo0;		/* Baricentric weighting */
30735 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
30736 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
30737 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
30738 				ova3  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
30739 				vof += nvof;			/* Move to next vertex */
30740 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
30741 				wo1 = (wo1 >> 23);		/* Extract weighting value */
30742 				vwe = wo0 - wo1;		/* Baricentric weighting */
30743 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
30744 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
30745 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
30746 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
30747 				vof += nvof;			/* Move to next vertex */
30748 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
30749 				wo2 = (wo2 >> 23);		/* Extract weighting value */
30750 				vwe = wo1 - wo2;		/* Baricentric weighting */
30751 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
30752 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
30753 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
30754 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
30755 				vof += nvof;			/* Move to next vertex */
30756 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
30757 				wo3 = (wo3 >> 23);		/* Extract weighting value */
30758 				vwe = wo2 - wo3;		/* Baricentric weighting */
30759 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
30760 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
30761 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
30762 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
30763 				vof += nvof;			/* Move to next vertex */
30764 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
30765 				wo4 = (wo4 >> 23);		/* Extract weighting value */
30766 				vwe = wo3 - wo4;		/* Baricentric weighting */
30767 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
30768 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
30769 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
30770 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
30771 				vof += nvof;			/* Move to next vertex */
30772 				vwe = wo4;				/* Baricentric weighting */
30773 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
30774 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
30775 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
30776 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
30777 			}
30778 		}
30779 		{
30780 			unsigned int oti;	/* Vertex offset value */
30781 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
30782 			op0[0] = OT_E(ot0, oti);	/* Write result */
30783 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
30784 			op0[1] = OT_E(ot1, oti);	/* Write result */
30785 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
30786 			op0[2] = OT_E(ot2, oti);	/* Write result */
30787 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
30788 			op0[3] = OT_E(ot3, oti);	/* Write result */
30789 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
30790 			op0[4] = OT_E(ot4, oti);	/* Write result */
30791 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
30792 			op0[5] = OT_E(ot5, oti);	/* Write result */
30793 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
30794 			op0[6] = OT_E(ot6, oti);	/* Write result */
30795 		}
30796 	}
30797 }
30798 #undef IT_WO
30799 #undef IT_IX
30800 #undef CEX
30801 #undef IM_O
30802 #undef IM_FE
30803 #undef IM_PE
30804 #undef OT_E
30805 
30806 void
imdi_k88_gen(genspec * g)30807 imdi_k88_gen(
30808 genspec *g			/* structure to be initialised */
30809 ) {
30810 	static unsigned char data[] = {
30811 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
30812 		0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30813 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30814 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30815 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30816 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30817 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30818 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
30819 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
30820 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
30821 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30822 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30823 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30824 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30825 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30826 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30827 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30828 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30829 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30830 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30831 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30832 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30833 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30834 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30835 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
30836 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
30837 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
30838 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
30839 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30840 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30841 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30842 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30843 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30844 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30845 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30846 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30847 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30848 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30849 		0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30850 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
30851 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
30852 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
30853 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
30854 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
30855 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
30856 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
30857 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
30858 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
30859 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30860 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
30861 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
30862 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x37, 0x5f,
30863 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
30864 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
30865 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
30866 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
30867 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
30868 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
30869 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
30870 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30871 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30872 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30873 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30874 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
30875 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x38, 0x38,
30876 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30877 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30878 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
30879 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
30880 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
30881 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
30882 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
30883 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
30884 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
30885 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
30886 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
30887 		0x00, 0xf0, 0x04, 0x08
30888 	};	/* Structure image */
30889 
30890 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
30891 }
30892 
30893 void
imdi_k88_tab(tabspec * t)30894 imdi_k88_tab(
30895 tabspec *t			/* structure to be initialised */
30896 ) {
30897 	static unsigned char data[] = {
30898 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30899 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30900 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30901 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
30902 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
30903 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
30904 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30905 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
30906 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
30907 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30908 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
30909 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
30910 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
30911 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
30912 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
30913 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30914 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
30915 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
30916 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
30917 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30918 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30919 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
30920 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
30921 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
30922 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30923 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30924 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30925 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30926 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30927 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30928 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30929 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
30930 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
30931 	};	/* Structure image */
30932 
30933 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
30934 }
30935 
30936 
30937 
30938 
30939 
30940 
30941 /* Integer Multi-Dimensional Interpolation */
30942 /* Interpolation Kernel Code */
30943 /* Generated by cgen */
30944 /* Copyright 2000 - 2002 Graeme W. Gill */
30945 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
30946 
30947 /* see the Licence.txt file for licencing details.*/
30948 
30949 
30950 /*
30951    Interpolation kernel specs:
30952 
30953    Input channels per pixel = 6
30954    Input channel 0 bits = 8
30955    Input channel 0 increment = 6
30956    Input channel 1 bits = 8
30957    Input channel 1 increment = 6
30958    Input channel 2 bits = 8
30959    Input channel 2 increment = 6
30960    Input channel 3 bits = 8
30961    Input channel 3 increment = 6
30962    Input channel 4 bits = 8
30963    Input channel 4 increment = 6
30964    Input channel 5 bits = 8
30965    Input channel 5 increment = 6
30966    Input is channel interleaved
30967    Input channels are separate words
30968    Input value extraction is done in input table lookup
30969 
30970    Output channels per pixel = 7
30971    Output channel 0 bits = 16
30972    Output channel 0 increment = 7
30973    Output channel 1 bits = 16
30974    Output channel 1 increment = 7
30975    Output channel 2 bits = 16
30976    Output channel 2 increment = 7
30977    Output channel 3 bits = 16
30978    Output channel 3 increment = 7
30979    Output channel 4 bits = 16
30980    Output channel 4 increment = 7
30981    Output channel 5 bits = 16
30982    Output channel 5 increment = 7
30983    Output channel 6 bits = 16
30984    Output channel 6 increment = 7
30985    Output is channel interleaved
30986 
30987    Output channels are separate words
30988    Weight+voffset bits       = 32
30989    Interpolation table index bits = 32
30990    Interpolation table max resolution = 20
30991  */
30992 
30993 /*
30994    Machine architecture specs:
30995 
30996    Little endian
30997    Reading and writing pixel values separately
30998    Pointer size = 32 bits
30999 
31000    Ordinal size  8 bits is known as 'unsigned char'
31001    Ordinal size 16 bits is known as 'unsigned short'
31002    Ordinal size 32 bits is known as 'unsigned int'
31003    Natural ordinal is 'unsigned int'
31004 
31005    Integer size  8 bits is known as 'signed char'
31006    Integer size 16 bits is known as 'short'
31007    Integer size 32 bits is known as 'int'
31008    Natural integer is 'int'
31009 
31010  */
31011 
31012 #ifndef  IMDI_INCLUDED
31013 #include <memory.h>
31014 #include "imdi_imp.h"
31015 #define  IMDI_INCLUDED
31016 #endif  /* IMDI_INCLUDED */
31017 
31018 #ifndef DEFINED_pointer
31019 #define DEFINED_pointer
31020 typedef unsigned char * pointer;
31021 #endif
31022 
31023 /* Input table interp. index */
31024 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
31025 
31026 /* Input table input weighting/offset value enty */
31027 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
31028 
31029 /* Conditional exchange for sorting */
31030 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
31031 
31032 /* Interpolation multi-dim. table access */
31033 #define IM_O(off) ((off) * 16)
31034 
31035 /* Interpolation table - get vertex values */
31036 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
31037 #define IM_PE(p, v) *((unsigned int *)((p) + 12 + (v) * 8))
31038 
31039 /* Output table indexes */
31040 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
31041 
31042 void
imdi_k89(imdi * s,void ** outp,void ** inp,unsigned int npix)31043 imdi_k89(
31044 imdi *s,			/* imdi context */
31045 void **outp,		/* pointer to output pointers */
31046 void **inp,		/* pointer to input pointers */
31047 unsigned int npix	/* Number of pixels to process */
31048 ) {
31049 	imdi_imp *p = (imdi_imp *)(s->impl);
31050 	unsigned char *ip0 = (unsigned char *)inp[0];
31051 	unsigned short *op0 = (unsigned short *)outp[0];
31052 	unsigned char *ep = ip0 + npix * 6 ;
31053 	pointer it0 = (pointer)p->in_tables[0];
31054 	pointer it1 = (pointer)p->in_tables[1];
31055 	pointer it2 = (pointer)p->in_tables[2];
31056 	pointer it3 = (pointer)p->in_tables[3];
31057 	pointer it4 = (pointer)p->in_tables[4];
31058 	pointer it5 = (pointer)p->in_tables[5];
31059 	pointer ot0 = (pointer)p->out_tables[0];
31060 	pointer ot1 = (pointer)p->out_tables[1];
31061 	pointer ot2 = (pointer)p->out_tables[2];
31062 	pointer ot3 = (pointer)p->out_tables[3];
31063 	pointer ot4 = (pointer)p->out_tables[4];
31064 	pointer ot5 = (pointer)p->out_tables[5];
31065 	pointer ot6 = (pointer)p->out_tables[6];
31066 	pointer im_base = (pointer)p->im_table;
31067 
31068 	for(;ip0 < ep; ip0 += 6, op0 += 7) {
31069 		unsigned int ova0;	/* Output value accumulator */
31070 		unsigned int ova1;	/* Output value accumulator */
31071 		unsigned int ova2;	/* Output value accumulator */
31072 		unsigned int ova3;	/* Output value partial accumulator */
31073 		{
31074 			pointer imp;
31075 			unsigned int wo0;	/* Weighting value and vertex offset variable */
31076 			unsigned int wo1;	/* Weighting value and vertex offset variable */
31077 			unsigned int wo2;	/* Weighting value and vertex offset variable */
31078 			unsigned int wo3;	/* Weighting value and vertex offset variable */
31079 			unsigned int wo4;	/* Weighting value and vertex offset variable */
31080 			unsigned int wo5;	/* Weighting value and vertex offset variable */
31081 			{
31082 				unsigned int ti_i;	/* Interpolation index variable */
31083 
31084 				ti_i  = IT_IX(it0, ip0[0]);
31085 				wo0   = IT_WO(it0, ip0[0]);
31086 				ti_i += IT_IX(it1, ip0[1]);
31087 				wo1   = IT_WO(it1, ip0[1]);
31088 				ti_i += IT_IX(it2, ip0[2]);
31089 				wo2   = IT_WO(it2, ip0[2]);
31090 				ti_i += IT_IX(it3, ip0[3]);
31091 				wo3   = IT_WO(it3, ip0[3]);
31092 				ti_i += IT_IX(it4, ip0[4]);
31093 				wo4   = IT_WO(it4, ip0[4]);
31094 				ti_i += IT_IX(it5, ip0[5]);
31095 				wo5   = IT_WO(it5, ip0[5]);
31096 
31097 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
31098 
31099 				/* Sort weighting values and vertex offset values */
31100 				CEX(wo0, wo1);
31101 				CEX(wo0, wo2);
31102 				CEX(wo0, wo3);
31103 				CEX(wo0, wo4);
31104 				CEX(wo0, wo5);
31105 				CEX(wo1, wo2);
31106 				CEX(wo1, wo3);
31107 				CEX(wo1, wo4);
31108 				CEX(wo1, wo5);
31109 				CEX(wo2, wo3);
31110 				CEX(wo2, wo4);
31111 				CEX(wo2, wo5);
31112 				CEX(wo3, wo4);
31113 				CEX(wo3, wo5);
31114 				CEX(wo4, wo5);
31115 			}
31116 			{
31117 				unsigned int nvof;	/* Next vertex offset value */
31118 				unsigned int vof;	/* Vertex offset value */
31119 				unsigned int vwe;	/* Vertex weighting */
31120 
31121 				vof = 0;				/* First vertex offset is 0 */
31122 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
31123 				wo0 = (wo0 >> 23);		/* Extract weighting value */
31124 				vwe = 256 - wo0;		/* Baricentric weighting */
31125 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31126 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
31127 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
31128 				ova3  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
31129 				vof += nvof;			/* Move to next vertex */
31130 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
31131 				wo1 = (wo1 >> 23);		/* Extract weighting value */
31132 				vwe = wo0 - wo1;		/* Baricentric weighting */
31133 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31134 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
31135 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
31136 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
31137 				vof += nvof;			/* Move to next vertex */
31138 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
31139 				wo2 = (wo2 >> 23);		/* Extract weighting value */
31140 				vwe = wo1 - wo2;		/* Baricentric weighting */
31141 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31142 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
31143 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
31144 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
31145 				vof += nvof;			/* Move to next vertex */
31146 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
31147 				wo3 = (wo3 >> 23);		/* Extract weighting value */
31148 				vwe = wo2 - wo3;		/* Baricentric weighting */
31149 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31150 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
31151 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
31152 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
31153 				vof += nvof;			/* Move to next vertex */
31154 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
31155 				wo4 = (wo4 >> 23);		/* Extract weighting value */
31156 				vwe = wo3 - wo4;		/* Baricentric weighting */
31157 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31158 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
31159 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
31160 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
31161 				vof += nvof;			/* Move to next vertex */
31162 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
31163 				wo5 = (wo5 >> 23);		/* Extract weighting value */
31164 				vwe = wo4 - wo5;		/* Baricentric weighting */
31165 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31166 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
31167 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
31168 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
31169 				vof += nvof;			/* Move to next vertex */
31170 				vwe = wo5;				/* Baricentric weighting */
31171 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31172 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
31173 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
31174 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
31175 			}
31176 		}
31177 		{
31178 			unsigned int oti;	/* Vertex offset value */
31179 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
31180 			op0[0] = OT_E(ot0, oti);	/* Write result */
31181 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
31182 			op0[1] = OT_E(ot1, oti);	/* Write result */
31183 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
31184 			op0[2] = OT_E(ot2, oti);	/* Write result */
31185 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
31186 			op0[3] = OT_E(ot3, oti);	/* Write result */
31187 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
31188 			op0[4] = OT_E(ot4, oti);	/* Write result */
31189 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
31190 			op0[5] = OT_E(ot5, oti);	/* Write result */
31191 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
31192 			op0[6] = OT_E(ot6, oti);	/* Write result */
31193 		}
31194 	}
31195 }
31196 #undef IT_WO
31197 #undef IT_IX
31198 #undef CEX
31199 #undef IM_O
31200 #undef IM_FE
31201 #undef IM_PE
31202 #undef OT_E
31203 
31204 void
imdi_k89_gen(genspec * g)31205 imdi_k89_gen(
31206 genspec *g			/* structure to be initialised */
31207 ) {
31208 	static unsigned char data[] = {
31209 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
31210 		0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31211 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31212 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31213 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31214 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31215 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31216 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
31217 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
31218 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
31219 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31220 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31221 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31222 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31223 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31224 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31225 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31226 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31227 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31228 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31229 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31230 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31231 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31232 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31233 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
31234 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
31235 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
31236 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
31237 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31238 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31239 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31240 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31241 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31242 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31243 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31244 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31245 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31246 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31247 		0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31248 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
31249 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
31250 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
31251 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
31252 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
31253 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
31254 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
31255 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
31256 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
31257 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31258 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
31259 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
31260 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x37, 0x5f,
31261 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
31262 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
31263 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
31264 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
31265 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
31266 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
31267 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
31268 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31269 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31270 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31271 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31272 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
31273 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x38, 0x39,
31274 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31275 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31276 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
31277 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
31278 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
31279 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
31280 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
31281 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
31282 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
31283 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
31284 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
31285 		0x00, 0xf0, 0x04, 0x08
31286 	};	/* Structure image */
31287 
31288 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
31289 }
31290 
31291 void
imdi_k89_tab(tabspec * t)31292 imdi_k89_tab(
31293 tabspec *t			/* structure to be initialised */
31294 ) {
31295 	static unsigned char data[] = {
31296 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31297 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31298 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31299 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
31300 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
31301 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
31302 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31303 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
31304 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
31305 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31306 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
31307 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
31308 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
31309 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
31310 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
31311 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31312 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31313 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
31314 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
31315 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31316 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31317 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
31318 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
31319 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
31320 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31321 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31322 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31323 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31324 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31325 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31326 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31327 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31328 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
31329 	};	/* Structure image */
31330 
31331 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
31332 }
31333 
31334 
31335 
31336 
31337 
31338 
31339 /* Integer Multi-Dimensional Interpolation */
31340 /* Interpolation Kernel Code */
31341 /* Generated by cgen */
31342 /* Copyright 2000 - 2002 Graeme W. Gill */
31343 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
31344 
31345 /* see the Licence.txt file for licencing details.*/
31346 
31347 
31348 /*
31349    Interpolation kernel specs:
31350 
31351    Input channels per pixel = 7
31352    Input channel 0 bits = 8
31353    Input channel 0 increment = 7
31354    Input channel 1 bits = 8
31355    Input channel 1 increment = 7
31356    Input channel 2 bits = 8
31357    Input channel 2 increment = 7
31358    Input channel 3 bits = 8
31359    Input channel 3 increment = 7
31360    Input channel 4 bits = 8
31361    Input channel 4 increment = 7
31362    Input channel 5 bits = 8
31363    Input channel 5 increment = 7
31364    Input channel 6 bits = 8
31365    Input channel 6 increment = 7
31366    Input is channel interleaved
31367    Input channels are separate words
31368    Input value extraction is done in input table lookup
31369 
31370    Output channels per pixel = 7
31371    Output channel 0 bits = 16
31372    Output channel 0 increment = 7
31373    Output channel 1 bits = 16
31374    Output channel 1 increment = 7
31375    Output channel 2 bits = 16
31376    Output channel 2 increment = 7
31377    Output channel 3 bits = 16
31378    Output channel 3 increment = 7
31379    Output channel 4 bits = 16
31380    Output channel 4 increment = 7
31381    Output channel 5 bits = 16
31382    Output channel 5 increment = 7
31383    Output channel 6 bits = 16
31384    Output channel 6 increment = 7
31385    Output is channel interleaved
31386 
31387    Output channels are separate words
31388    Weight+voffset bits       = 32
31389    Interpolation table index bits = 32
31390    Interpolation table max resolution = 12
31391  */
31392 
31393 /*
31394    Machine architecture specs:
31395 
31396    Little endian
31397    Reading and writing pixel values separately
31398    Pointer size = 32 bits
31399 
31400    Ordinal size  8 bits is known as 'unsigned char'
31401    Ordinal size 16 bits is known as 'unsigned short'
31402    Ordinal size 32 bits is known as 'unsigned int'
31403    Natural ordinal is 'unsigned int'
31404 
31405    Integer size  8 bits is known as 'signed char'
31406    Integer size 16 bits is known as 'short'
31407    Integer size 32 bits is known as 'int'
31408    Natural integer is 'int'
31409 
31410  */
31411 
31412 #ifndef  IMDI_INCLUDED
31413 #include <memory.h>
31414 #include "imdi_imp.h"
31415 #define  IMDI_INCLUDED
31416 #endif  /* IMDI_INCLUDED */
31417 
31418 #ifndef DEFINED_pointer
31419 #define DEFINED_pointer
31420 typedef unsigned char * pointer;
31421 #endif
31422 
31423 /* Input table interp. index */
31424 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
31425 
31426 /* Input table input weighting/offset value enty */
31427 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
31428 
31429 /* Conditional exchange for sorting */
31430 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
31431 
31432 /* Interpolation multi-dim. table access */
31433 #define IM_O(off) ((off) * 16)
31434 
31435 /* Interpolation table - get vertex values */
31436 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
31437 #define IM_PE(p, v) *((unsigned int *)((p) + 12 + (v) * 8))
31438 
31439 /* Output table indexes */
31440 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
31441 
31442 void
imdi_k90(imdi * s,void ** outp,void ** inp,unsigned int npix)31443 imdi_k90(
31444 imdi *s,			/* imdi context */
31445 void **outp,		/* pointer to output pointers */
31446 void **inp,		/* pointer to input pointers */
31447 unsigned int npix	/* Number of pixels to process */
31448 ) {
31449 	imdi_imp *p = (imdi_imp *)(s->impl);
31450 	unsigned char *ip0 = (unsigned char *)inp[0];
31451 	unsigned short *op0 = (unsigned short *)outp[0];
31452 	unsigned char *ep = ip0 + npix * 7 ;
31453 	pointer it0 = (pointer)p->in_tables[0];
31454 	pointer it1 = (pointer)p->in_tables[1];
31455 	pointer it2 = (pointer)p->in_tables[2];
31456 	pointer it3 = (pointer)p->in_tables[3];
31457 	pointer it4 = (pointer)p->in_tables[4];
31458 	pointer it5 = (pointer)p->in_tables[5];
31459 	pointer it6 = (pointer)p->in_tables[6];
31460 	pointer ot0 = (pointer)p->out_tables[0];
31461 	pointer ot1 = (pointer)p->out_tables[1];
31462 	pointer ot2 = (pointer)p->out_tables[2];
31463 	pointer ot3 = (pointer)p->out_tables[3];
31464 	pointer ot4 = (pointer)p->out_tables[4];
31465 	pointer ot5 = (pointer)p->out_tables[5];
31466 	pointer ot6 = (pointer)p->out_tables[6];
31467 	pointer im_base = (pointer)p->im_table;
31468 
31469 	for(;ip0 < ep; ip0 += 7, op0 += 7) {
31470 		unsigned int ova0;	/* Output value accumulator */
31471 		unsigned int ova1;	/* Output value accumulator */
31472 		unsigned int ova2;	/* Output value accumulator */
31473 		unsigned int ova3;	/* Output value partial accumulator */
31474 		{
31475 			pointer imp;
31476 			unsigned int wo0;	/* Weighting value and vertex offset variable */
31477 			unsigned int wo1;	/* Weighting value and vertex offset variable */
31478 			unsigned int wo2;	/* Weighting value and vertex offset variable */
31479 			unsigned int wo3;	/* Weighting value and vertex offset variable */
31480 			unsigned int wo4;	/* Weighting value and vertex offset variable */
31481 			unsigned int wo5;	/* Weighting value and vertex offset variable */
31482 			unsigned int wo6;	/* Weighting value and vertex offset variable */
31483 			{
31484 				unsigned int ti_i;	/* Interpolation index variable */
31485 
31486 				ti_i  = IT_IX(it0, ip0[0]);
31487 				wo0   = IT_WO(it0, ip0[0]);
31488 				ti_i += IT_IX(it1, ip0[1]);
31489 				wo1   = IT_WO(it1, ip0[1]);
31490 				ti_i += IT_IX(it2, ip0[2]);
31491 				wo2   = IT_WO(it2, ip0[2]);
31492 				ti_i += IT_IX(it3, ip0[3]);
31493 				wo3   = IT_WO(it3, ip0[3]);
31494 				ti_i += IT_IX(it4, ip0[4]);
31495 				wo4   = IT_WO(it4, ip0[4]);
31496 				ti_i += IT_IX(it5, ip0[5]);
31497 				wo5   = IT_WO(it5, ip0[5]);
31498 				ti_i += IT_IX(it6, ip0[6]);
31499 				wo6   = IT_WO(it6, ip0[6]);
31500 
31501 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
31502 
31503 				/* Sort weighting values and vertex offset values */
31504 				CEX(wo0, wo1);
31505 				CEX(wo0, wo2);
31506 				CEX(wo0, wo3);
31507 				CEX(wo0, wo4);
31508 				CEX(wo0, wo5);
31509 				CEX(wo0, wo6);
31510 				CEX(wo1, wo2);
31511 				CEX(wo1, wo3);
31512 				CEX(wo1, wo4);
31513 				CEX(wo1, wo5);
31514 				CEX(wo1, wo6);
31515 				CEX(wo2, wo3);
31516 				CEX(wo2, wo4);
31517 				CEX(wo2, wo5);
31518 				CEX(wo2, wo6);
31519 				CEX(wo3, wo4);
31520 				CEX(wo3, wo5);
31521 				CEX(wo3, wo6);
31522 				CEX(wo4, wo5);
31523 				CEX(wo4, wo6);
31524 				CEX(wo5, wo6);
31525 			}
31526 			{
31527 				unsigned int nvof;	/* Next vertex offset value */
31528 				unsigned int vof;	/* Vertex offset value */
31529 				unsigned int vwe;	/* Vertex weighting */
31530 
31531 				vof = 0;				/* First vertex offset is 0 */
31532 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
31533 				wo0 = (wo0 >> 23);		/* Extract weighting value */
31534 				vwe = 256 - wo0;		/* Baricentric weighting */
31535 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31536 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
31537 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
31538 				ova3  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
31539 				vof += nvof;			/* Move to next vertex */
31540 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
31541 				wo1 = (wo1 >> 23);		/* Extract weighting value */
31542 				vwe = wo0 - wo1;		/* Baricentric weighting */
31543 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31544 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
31545 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
31546 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
31547 				vof += nvof;			/* Move to next vertex */
31548 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
31549 				wo2 = (wo2 >> 23);		/* Extract weighting value */
31550 				vwe = wo1 - wo2;		/* Baricentric weighting */
31551 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31552 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
31553 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
31554 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
31555 				vof += nvof;			/* Move to next vertex */
31556 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
31557 				wo3 = (wo3 >> 23);		/* Extract weighting value */
31558 				vwe = wo2 - wo3;		/* Baricentric weighting */
31559 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31560 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
31561 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
31562 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
31563 				vof += nvof;			/* Move to next vertex */
31564 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
31565 				wo4 = (wo4 >> 23);		/* Extract weighting value */
31566 				vwe = wo3 - wo4;		/* Baricentric weighting */
31567 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31568 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
31569 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
31570 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
31571 				vof += nvof;			/* Move to next vertex */
31572 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
31573 				wo5 = (wo5 >> 23);		/* Extract weighting value */
31574 				vwe = wo4 - wo5;		/* Baricentric weighting */
31575 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31576 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
31577 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
31578 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
31579 				vof += nvof;			/* Move to next vertex */
31580 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
31581 				wo6 = (wo6 >> 23);		/* Extract weighting value */
31582 				vwe = wo5 - wo6;		/* Baricentric weighting */
31583 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31584 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
31585 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
31586 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
31587 				vof += nvof;			/* Move to next vertex */
31588 				vwe = wo6;				/* Baricentric weighting */
31589 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31590 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
31591 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
31592 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
31593 			}
31594 		}
31595 		{
31596 			unsigned int oti;	/* Vertex offset value */
31597 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
31598 			op0[0] = OT_E(ot0, oti);	/* Write result */
31599 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
31600 			op0[1] = OT_E(ot1, oti);	/* Write result */
31601 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
31602 			op0[2] = OT_E(ot2, oti);	/* Write result */
31603 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
31604 			op0[3] = OT_E(ot3, oti);	/* Write result */
31605 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
31606 			op0[4] = OT_E(ot4, oti);	/* Write result */
31607 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
31608 			op0[5] = OT_E(ot5, oti);	/* Write result */
31609 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
31610 			op0[6] = OT_E(ot6, oti);	/* Write result */
31611 		}
31612 	}
31613 }
31614 #undef IT_WO
31615 #undef IT_IX
31616 #undef CEX
31617 #undef IM_O
31618 #undef IM_FE
31619 #undef IM_PE
31620 #undef OT_E
31621 
31622 void
imdi_k90_gen(genspec * g)31623 imdi_k90_gen(
31624 genspec *g			/* structure to be initialised */
31625 ) {
31626 	static unsigned char data[] = {
31627 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
31628 		0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31629 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31630 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31631 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31632 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31633 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31634 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
31635 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
31636 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
31637 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
31638 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31639 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31640 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31641 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31642 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31643 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31644 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31645 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31646 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31647 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31648 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31649 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31650 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31651 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
31652 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
31653 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
31654 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
31655 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31656 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31657 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31658 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31659 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31660 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31661 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31662 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31663 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31664 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31665 		0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31666 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
31667 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
31668 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
31669 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
31670 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
31671 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
31672 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
31673 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
31674 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
31675 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31676 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
31677 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
31678 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x37, 0x5f,
31679 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
31680 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
31681 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
31682 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
31683 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
31684 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
31685 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
31686 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31687 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31688 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31689 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31690 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
31691 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x39, 0x30,
31692 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31693 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31694 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
31695 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
31696 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
31697 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
31698 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
31699 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
31700 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
31701 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
31702 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
31703 		0x00, 0xf0, 0x04, 0x08
31704 	};	/* Structure image */
31705 
31706 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
31707 }
31708 
31709 void
imdi_k90_tab(tabspec * t)31710 imdi_k90_tab(
31711 tabspec *t			/* structure to be initialised */
31712 ) {
31713 	static unsigned char data[] = {
31714 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31715 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31716 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31717 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
31718 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
31719 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
31720 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31721 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
31722 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
31723 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31724 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
31725 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
31726 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
31727 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
31728 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
31729 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31730 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
31731 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
31732 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
31733 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31734 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
31735 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
31736 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
31737 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
31738 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31739 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31740 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31741 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31742 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31743 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31744 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31745 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
31746 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
31747 	};	/* Structure image */
31748 
31749 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
31750 }
31751 
31752 
31753 
31754 
31755 
31756 
31757 /* Integer Multi-Dimensional Interpolation */
31758 /* Interpolation Kernel Code */
31759 /* Generated by cgen */
31760 /* Copyright 2000 - 2002 Graeme W. Gill */
31761 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
31762 
31763 /* see the Licence.txt file for licencing details.*/
31764 
31765 
31766 /*
31767    Interpolation kernel specs:
31768 
31769    Input channels per pixel = 8
31770    Input channel 0 bits = 8
31771    Input channel 0 increment = 8
31772    Input channel 1 bits = 8
31773    Input channel 1 increment = 8
31774    Input channel 2 bits = 8
31775    Input channel 2 increment = 8
31776    Input channel 3 bits = 8
31777    Input channel 3 increment = 8
31778    Input channel 4 bits = 8
31779    Input channel 4 increment = 8
31780    Input channel 5 bits = 8
31781    Input channel 5 increment = 8
31782    Input channel 6 bits = 8
31783    Input channel 6 increment = 8
31784    Input channel 7 bits = 8
31785    Input channel 7 increment = 8
31786    Input is channel interleaved
31787    Input channels are separate words
31788    Input value extraction is done in input table lookup
31789 
31790    Output channels per pixel = 7
31791    Output channel 0 bits = 16
31792    Output channel 0 increment = 7
31793    Output channel 1 bits = 16
31794    Output channel 1 increment = 7
31795    Output channel 2 bits = 16
31796    Output channel 2 increment = 7
31797    Output channel 3 bits = 16
31798    Output channel 3 increment = 7
31799    Output channel 4 bits = 16
31800    Output channel 4 increment = 7
31801    Output channel 5 bits = 16
31802    Output channel 5 increment = 7
31803    Output channel 6 bits = 16
31804    Output channel 6 increment = 7
31805    Output is channel interleaved
31806 
31807    Output channels are separate words
31808    Weight+voffset bits       = 32
31809    Interpolation table index bits = 32
31810    Interpolation table max resolution = 8
31811  */
31812 
31813 /*
31814    Machine architecture specs:
31815 
31816    Little endian
31817    Reading and writing pixel values separately
31818    Pointer size = 32 bits
31819 
31820    Ordinal size  8 bits is known as 'unsigned char'
31821    Ordinal size 16 bits is known as 'unsigned short'
31822    Ordinal size 32 bits is known as 'unsigned int'
31823    Natural ordinal is 'unsigned int'
31824 
31825    Integer size  8 bits is known as 'signed char'
31826    Integer size 16 bits is known as 'short'
31827    Integer size 32 bits is known as 'int'
31828    Natural integer is 'int'
31829 
31830  */
31831 
31832 #ifndef  IMDI_INCLUDED
31833 #include <memory.h>
31834 #include "imdi_imp.h"
31835 #define  IMDI_INCLUDED
31836 #endif  /* IMDI_INCLUDED */
31837 
31838 #ifndef DEFINED_pointer
31839 #define DEFINED_pointer
31840 typedef unsigned char * pointer;
31841 #endif
31842 
31843 /* Input table interp. index */
31844 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
31845 
31846 /* Input table input weighting/offset value enty */
31847 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
31848 
31849 /* Conditional exchange for sorting */
31850 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
31851 
31852 /* Interpolation multi-dim. table access */
31853 #define IM_O(off) ((off) * 16)
31854 
31855 /* Interpolation table - get vertex values */
31856 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
31857 #define IM_PE(p, v) *((unsigned int *)((p) + 12 + (v) * 8))
31858 
31859 /* Output table indexes */
31860 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
31861 
31862 void
imdi_k91(imdi * s,void ** outp,void ** inp,unsigned int npix)31863 imdi_k91(
31864 imdi *s,			/* imdi context */
31865 void **outp,		/* pointer to output pointers */
31866 void **inp,		/* pointer to input pointers */
31867 unsigned int npix	/* Number of pixels to process */
31868 ) {
31869 	imdi_imp *p = (imdi_imp *)(s->impl);
31870 	unsigned char *ip0 = (unsigned char *)inp[0];
31871 	unsigned short *op0 = (unsigned short *)outp[0];
31872 	unsigned char *ep = ip0 + npix * 8 ;
31873 	pointer it0 = (pointer)p->in_tables[0];
31874 	pointer it1 = (pointer)p->in_tables[1];
31875 	pointer it2 = (pointer)p->in_tables[2];
31876 	pointer it3 = (pointer)p->in_tables[3];
31877 	pointer it4 = (pointer)p->in_tables[4];
31878 	pointer it5 = (pointer)p->in_tables[5];
31879 	pointer it6 = (pointer)p->in_tables[6];
31880 	pointer it7 = (pointer)p->in_tables[7];
31881 	pointer ot0 = (pointer)p->out_tables[0];
31882 	pointer ot1 = (pointer)p->out_tables[1];
31883 	pointer ot2 = (pointer)p->out_tables[2];
31884 	pointer ot3 = (pointer)p->out_tables[3];
31885 	pointer ot4 = (pointer)p->out_tables[4];
31886 	pointer ot5 = (pointer)p->out_tables[5];
31887 	pointer ot6 = (pointer)p->out_tables[6];
31888 	pointer im_base = (pointer)p->im_table;
31889 
31890 	for(;ip0 < ep; ip0 += 8, op0 += 7) {
31891 		unsigned int ova0;	/* Output value accumulator */
31892 		unsigned int ova1;	/* Output value accumulator */
31893 		unsigned int ova2;	/* Output value accumulator */
31894 		unsigned int ova3;	/* Output value partial accumulator */
31895 		{
31896 			pointer imp;
31897 			unsigned int wo0;	/* Weighting value and vertex offset variable */
31898 			unsigned int wo1;	/* Weighting value and vertex offset variable */
31899 			unsigned int wo2;	/* Weighting value and vertex offset variable */
31900 			unsigned int wo3;	/* Weighting value and vertex offset variable */
31901 			unsigned int wo4;	/* Weighting value and vertex offset variable */
31902 			unsigned int wo5;	/* Weighting value and vertex offset variable */
31903 			unsigned int wo6;	/* Weighting value and vertex offset variable */
31904 			unsigned int wo7;	/* Weighting value and vertex offset variable */
31905 			{
31906 				unsigned int ti_i;	/* Interpolation index variable */
31907 
31908 				ti_i  = IT_IX(it0, ip0[0]);
31909 				wo0   = IT_WO(it0, ip0[0]);
31910 				ti_i += IT_IX(it1, ip0[1]);
31911 				wo1   = IT_WO(it1, ip0[1]);
31912 				ti_i += IT_IX(it2, ip0[2]);
31913 				wo2   = IT_WO(it2, ip0[2]);
31914 				ti_i += IT_IX(it3, ip0[3]);
31915 				wo3   = IT_WO(it3, ip0[3]);
31916 				ti_i += IT_IX(it4, ip0[4]);
31917 				wo4   = IT_WO(it4, ip0[4]);
31918 				ti_i += IT_IX(it5, ip0[5]);
31919 				wo5   = IT_WO(it5, ip0[5]);
31920 				ti_i += IT_IX(it6, ip0[6]);
31921 				wo6   = IT_WO(it6, ip0[6]);
31922 				ti_i += IT_IX(it7, ip0[7]);
31923 				wo7   = IT_WO(it7, ip0[7]);
31924 
31925 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
31926 
31927 				/* Sort weighting values and vertex offset values */
31928 				CEX(wo0, wo1);
31929 				CEX(wo0, wo2);
31930 				CEX(wo0, wo3);
31931 				CEX(wo0, wo4);
31932 				CEX(wo0, wo5);
31933 				CEX(wo0, wo6);
31934 				CEX(wo0, wo7);
31935 				CEX(wo1, wo2);
31936 				CEX(wo1, wo3);
31937 				CEX(wo1, wo4);
31938 				CEX(wo1, wo5);
31939 				CEX(wo1, wo6);
31940 				CEX(wo1, wo7);
31941 				CEX(wo2, wo3);
31942 				CEX(wo2, wo4);
31943 				CEX(wo2, wo5);
31944 				CEX(wo2, wo6);
31945 				CEX(wo2, wo7);
31946 				CEX(wo3, wo4);
31947 				CEX(wo3, wo5);
31948 				CEX(wo3, wo6);
31949 				CEX(wo3, wo7);
31950 				CEX(wo4, wo5);
31951 				CEX(wo4, wo6);
31952 				CEX(wo4, wo7);
31953 				CEX(wo5, wo6);
31954 				CEX(wo5, wo7);
31955 				CEX(wo6, wo7);
31956 			}
31957 			{
31958 				unsigned int nvof;	/* Next vertex offset value */
31959 				unsigned int vof;	/* Vertex offset value */
31960 				unsigned int vwe;	/* Vertex weighting */
31961 
31962 				vof = 0;				/* First vertex offset is 0 */
31963 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
31964 				wo0 = (wo0 >> 23);		/* Extract weighting value */
31965 				vwe = 256 - wo0;		/* Baricentric weighting */
31966 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31967 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
31968 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
31969 				ova3  = IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
31970 				vof += nvof;			/* Move to next vertex */
31971 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
31972 				wo1 = (wo1 >> 23);		/* Extract weighting value */
31973 				vwe = wo0 - wo1;		/* Baricentric weighting */
31974 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31975 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
31976 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
31977 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
31978 				vof += nvof;			/* Move to next vertex */
31979 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
31980 				wo2 = (wo2 >> 23);		/* Extract weighting value */
31981 				vwe = wo1 - wo2;		/* Baricentric weighting */
31982 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31983 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
31984 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
31985 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
31986 				vof += nvof;			/* Move to next vertex */
31987 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
31988 				wo3 = (wo3 >> 23);		/* Extract weighting value */
31989 				vwe = wo2 - wo3;		/* Baricentric weighting */
31990 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31991 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
31992 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
31993 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
31994 				vof += nvof;			/* Move to next vertex */
31995 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
31996 				wo4 = (wo4 >> 23);		/* Extract weighting value */
31997 				vwe = wo3 - wo4;		/* Baricentric weighting */
31998 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
31999 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
32000 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
32001 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
32002 				vof += nvof;			/* Move to next vertex */
32003 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
32004 				wo5 = (wo5 >> 23);		/* Extract weighting value */
32005 				vwe = wo4 - wo5;		/* Baricentric weighting */
32006 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
32007 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
32008 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
32009 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
32010 				vof += nvof;			/* Move to next vertex */
32011 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
32012 				wo6 = (wo6 >> 23);		/* Extract weighting value */
32013 				vwe = wo5 - wo6;		/* Baricentric weighting */
32014 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
32015 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
32016 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
32017 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
32018 				vof += nvof;			/* Move to next vertex */
32019 				nvof = (wo7 & 0x7fffff);	/* Extract offset value */
32020 				wo7 = (wo7 >> 23);		/* Extract weighting value */
32021 				vwe = wo6 - wo7;		/* Baricentric weighting */
32022 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
32023 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
32024 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
32025 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
32026 				vof += nvof;			/* Move to next vertex */
32027 				vwe = wo7;				/* Baricentric weighting */
32028 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
32029 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
32030 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
32031 				ova3 += IM_PE(imp, vof) * vwe;	/* Accumulate last weighted output values */
32032 			}
32033 		}
32034 		{
32035 			unsigned int oti;	/* Vertex offset value */
32036 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
32037 			op0[0] = OT_E(ot0, oti);	/* Write result */
32038 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
32039 			op0[1] = OT_E(ot1, oti);	/* Write result */
32040 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
32041 			op0[2] = OT_E(ot2, oti);	/* Write result */
32042 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
32043 			op0[3] = OT_E(ot3, oti);	/* Write result */
32044 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
32045 			op0[4] = OT_E(ot4, oti);	/* Write result */
32046 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
32047 			op0[5] = OT_E(ot5, oti);	/* Write result */
32048 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
32049 			op0[6] = OT_E(ot6, oti);	/* Write result */
32050 		}
32051 	}
32052 }
32053 #undef IT_WO
32054 #undef IT_IX
32055 #undef CEX
32056 #undef IM_O
32057 #undef IM_FE
32058 #undef IM_PE
32059 #undef OT_E
32060 
32061 void
imdi_k91_gen(genspec * g)32062 imdi_k91_gen(
32063 genspec *g			/* structure to be initialised */
32064 ) {
32065 	static unsigned char data[] = {
32066 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32067 		0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32068 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32069 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32070 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32071 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32072 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32073 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32074 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32075 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32076 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32077 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32078 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32079 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32080 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32081 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32082 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32083 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32084 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32085 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32086 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32087 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32088 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32089 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32090 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
32091 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
32092 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
32093 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
32094 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32095 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32096 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32097 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32098 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32099 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32100 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32101 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32102 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32103 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32104 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32105 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
32106 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
32107 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
32108 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
32109 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
32110 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
32111 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
32112 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
32113 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
32114 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32115 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
32116 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
32117 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x37, 0x5f,
32118 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
32119 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
32120 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
32121 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
32122 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
32123 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
32124 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
32125 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32126 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32127 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32128 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32129 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
32130 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x39, 0x31,
32131 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32132 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32133 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
32134 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
32135 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
32136 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
32137 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
32138 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
32139 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
32140 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
32141 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
32142 		0x00, 0xf0, 0x04, 0x08
32143 	};	/* Structure image */
32144 
32145 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
32146 }
32147 
32148 void
imdi_k91_tab(tabspec * t)32149 imdi_k91_tab(
32150 tabspec *t			/* structure to be initialised */
32151 ) {
32152 	static unsigned char data[] = {
32153 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32154 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32155 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32156 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
32157 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
32158 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
32159 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32160 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
32161 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
32162 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32163 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
32164 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
32165 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
32166 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
32167 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
32168 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32169 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32170 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
32171 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
32172 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32173 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32174 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
32175 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
32176 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
32177 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32178 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32179 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32180 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32181 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32182 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32183 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32184 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32185 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
32186 	};	/* Structure image */
32187 
32188 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
32189 }
32190 
32191 
32192 
32193 
32194 
32195 
32196 /* Integer Multi-Dimensional Interpolation */
32197 /* Interpolation Kernel Code */
32198 /* Generated by cgen */
32199 /* Copyright 2000 - 2002 Graeme W. Gill */
32200 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
32201 
32202 /* see the Licence.txt file for licencing details.*/
32203 
32204 
32205 /*
32206    Interpolation kernel specs:
32207 
32208    Input channels per pixel = 1
32209    Input channel 0 bits = 8
32210    Input channel 0 increment = 1
32211    Input is channel interleaved
32212    Input channels are separate words
32213    Input value extraction is done in input table lookup
32214 
32215    Output channels per pixel = 8
32216    Output channel 0 bits = 16
32217    Output channel 0 increment = 8
32218    Output channel 1 bits = 16
32219    Output channel 1 increment = 8
32220    Output channel 2 bits = 16
32221    Output channel 2 increment = 8
32222    Output channel 3 bits = 16
32223    Output channel 3 increment = 8
32224    Output channel 4 bits = 16
32225    Output channel 4 increment = 8
32226    Output channel 5 bits = 16
32227    Output channel 5 increment = 8
32228    Output channel 6 bits = 16
32229    Output channel 6 increment = 8
32230    Output channel 7 bits = 16
32231    Output channel 7 increment = 8
32232    Output is channel interleaved
32233 
32234    Output channels are separate words
32235    Simplex table index bits       = 0
32236    Interpolation table index bits = 8
32237    Simplex table max resolution = 1
32238    Interpolation table max resolution = 255
32239  */
32240 
32241 /*
32242    Machine architecture specs:
32243 
32244    Little endian
32245    Reading and writing pixel values separately
32246    Pointer size = 32 bits
32247 
32248    Ordinal size  8 bits is known as 'unsigned char'
32249    Ordinal size 16 bits is known as 'unsigned short'
32250    Ordinal size 32 bits is known as 'unsigned int'
32251    Natural ordinal is 'unsigned int'
32252 
32253    Integer size  8 bits is known as 'signed char'
32254    Integer size 16 bits is known as 'short'
32255    Integer size 32 bits is known as 'int'
32256    Natural integer is 'int'
32257 
32258  */
32259 
32260 #ifndef  IMDI_INCLUDED
32261 #include <memory.h>
32262 #include "imdi_imp.h"
32263 #define  IMDI_INCLUDED
32264 #endif  /* IMDI_INCLUDED */
32265 
32266 #ifndef DEFINED_pointer
32267 #define DEFINED_pointer
32268 typedef unsigned char * pointer;
32269 #endif
32270 
32271 /* Input table inter & simplex indexes */
32272 #define IT_IT(p, off) *((unsigned char *)((p) + 0 + (off) * 1))
32273 
32274 /* Simplex weighting table access */
32275 #define SW_O(off) ((off) * 4)
32276 
32277 /* Simplex table - get weighting/offset value */
32278 #define SX_WO(p, v) *((unsigned short *)((p) + (v) * 2))
32279 
32280 /* Interpolation multi-dim. table access */
32281 #define IM_O(off) ((off) * 16)
32282 
32283 /* Interpolation table - get vertex values */
32284 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
32285 
32286 /* Output table indexes */
32287 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
32288 
32289 void
imdi_k92(imdi * s,void ** outp,void ** inp,unsigned int npix)32290 imdi_k92(
32291 imdi *s,			/* imdi context */
32292 void **outp,		/* pointer to output pointers */
32293 void **inp,		/* pointer to input pointers */
32294 unsigned int npix	/* Number of pixels to process */
32295 ) {
32296 	imdi_imp *p = (imdi_imp *)(s->impl);
32297 	unsigned char *ip0 = (unsigned char *)inp[0];
32298 	unsigned short *op0 = (unsigned short *)outp[0];
32299 	unsigned char *ep = ip0 + npix * 1 ;
32300 	pointer it0 = (pointer)p->in_tables[0];
32301 	pointer ot0 = (pointer)p->out_tables[0];
32302 	pointer ot1 = (pointer)p->out_tables[1];
32303 	pointer ot2 = (pointer)p->out_tables[2];
32304 	pointer ot3 = (pointer)p->out_tables[3];
32305 	pointer ot4 = (pointer)p->out_tables[4];
32306 	pointer ot5 = (pointer)p->out_tables[5];
32307 	pointer ot6 = (pointer)p->out_tables[6];
32308 	pointer ot7 = (pointer)p->out_tables[7];
32309 	pointer sw_base = (pointer)p->sw_table;
32310 	pointer im_base = (pointer)p->im_table;
32311 
32312 	for(;ip0 < ep; ip0 += 1, op0 += 8) {
32313 		unsigned int ova0;	/* Output value accumulator */
32314 		unsigned int ova1;	/* Output value accumulator */
32315 		unsigned int ova2;	/* Output value accumulator */
32316 		unsigned int ova3;	/* Output value accumulator */
32317 		{
32318 			pointer swp;
32319 			pointer imp;
32320 			{
32321 				unsigned int ti;	/* Simplex+Interpolation index variable */
32322 
32323 				ti  = IT_IT(it0, ip0[0]);
32324 
32325 				imp = im_base + IM_O(ti >> 0);		/* Extract interp. index and comp. entry */
32326 				swp = sw_base + SW_O(ti & 0x0);	/* Extract simplex index and comp. entry */
32327 			}
32328 			{
32329 				unsigned int vowr;	/* Vertex offset/weight value */
32330 				unsigned int vof;	/* Vertex offset value */
32331 				unsigned int vwe;	/* Vertex weighting */
32332 
32333 				vowr = SX_WO(swp, 0);	/* Read vertex offset+weighting values */
32334 				vof = (vowr & 0x7f);	/* Extract offset value */
32335 				vwe = (vowr >> 7);	/* Extract weighting value */
32336 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
32337 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
32338 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
32339 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
32340 				vowr = SX_WO(swp, 1);	/* Read vertex offset+weighting values */
32341 				vof = (vowr & 0x7f);	/* Extract offset value */
32342 				vwe = (vowr >> 7);	/* Extract weighting value */
32343 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
32344 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
32345 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
32346 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
32347 			}
32348 		}
32349 		{
32350 			unsigned int oti;	/* Vertex offset value */
32351 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
32352 			op0[0] = OT_E(ot0, oti);	/* Write result */
32353 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
32354 			op0[1] = OT_E(ot1, oti);	/* Write result */
32355 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
32356 			op0[2] = OT_E(ot2, oti);	/* Write result */
32357 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
32358 			op0[3] = OT_E(ot3, oti);	/* Write result */
32359 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
32360 			op0[4] = OT_E(ot4, oti);	/* Write result */
32361 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
32362 			op0[5] = OT_E(ot5, oti);	/* Write result */
32363 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
32364 			op0[6] = OT_E(ot6, oti);	/* Write result */
32365 			oti = ((ova3 >> 24) & 0xff);	/* Extract integer part of result */
32366 			op0[7] = OT_E(ot7, oti);	/* Write result */
32367 		}
32368 	}
32369 }
32370 #undef IT_IT
32371 #undef SW_O
32372 #undef SX_WO
32373 #undef IM_O
32374 #undef IM_FE
32375 #undef OT_E
32376 
32377 void
imdi_k92_gen(genspec * g)32378 imdi_k92_gen(
32379 genspec *g			/* structure to be initialised */
32380 ) {
32381 	static unsigned char data[] = {
32382 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32383 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32384 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32385 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32386 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32387 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32388 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32389 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32390 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32391 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32392 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32393 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32394 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32395 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32396 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32397 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32398 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32399 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32400 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32401 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32402 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32403 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32404 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32405 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32406 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32407 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32408 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32409 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32410 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32411 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32412 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32413 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32414 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32415 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32416 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32417 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32418 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32419 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32420 		0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32421 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
32422 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
32423 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
32424 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
32425 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
32426 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
32427 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
32428 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
32429 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
32430 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32431 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
32432 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
32433 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x38, 0x5f,
32434 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
32435 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
32436 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
32437 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
32438 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
32439 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
32440 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
32441 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32442 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32443 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32444 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32445 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
32446 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x39, 0x32,
32447 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32448 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32449 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
32450 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
32451 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
32452 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
32453 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
32454 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
32455 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
32456 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
32457 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
32458 		0x00, 0xf0, 0x04, 0x08
32459 	};	/* Structure image */
32460 
32461 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
32462 }
32463 
32464 void
imdi_k92_tab(tabspec * t)32465 imdi_k92_tab(
32466 tabspec *t			/* structure to be initialised */
32467 ) {
32468 	static unsigned char data[] = {
32469 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32470 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32471 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32472 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
32473 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
32474 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
32475 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32476 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
32477 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32478 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32479 		0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32480 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32481 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
32482 		0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
32483 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
32484 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32485 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32486 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
32487 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32488 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32489 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32490 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
32491 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
32492 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
32493 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32494 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32495 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32496 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32497 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32498 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32499 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32500 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32501 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
32502 	};	/* Structure image */
32503 
32504 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
32505 }
32506 
32507 
32508 
32509 
32510 
32511 
32512 /* Integer Multi-Dimensional Interpolation */
32513 /* Interpolation Kernel Code */
32514 /* Generated by cgen */
32515 /* Copyright 2000 - 2002 Graeme W. Gill */
32516 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
32517 
32518 /* see the Licence.txt file for licencing details.*/
32519 
32520 
32521 /*
32522    Interpolation kernel specs:
32523 
32524    Input channels per pixel = 3
32525    Input channel 0 bits = 8
32526    Input channel 0 increment = 3
32527    Input channel 1 bits = 8
32528    Input channel 1 increment = 3
32529    Input channel 2 bits = 8
32530    Input channel 2 increment = 3
32531    Input is channel interleaved
32532    Input channels are separate words
32533    Input value extraction is done in input table lookup
32534 
32535    Output channels per pixel = 8
32536    Output channel 0 bits = 16
32537    Output channel 0 increment = 8
32538    Output channel 1 bits = 16
32539    Output channel 1 increment = 8
32540    Output channel 2 bits = 16
32541    Output channel 2 increment = 8
32542    Output channel 3 bits = 16
32543    Output channel 3 increment = 8
32544    Output channel 4 bits = 16
32545    Output channel 4 increment = 8
32546    Output channel 5 bits = 16
32547    Output channel 5 increment = 8
32548    Output channel 6 bits = 16
32549    Output channel 6 increment = 8
32550    Output channel 7 bits = 16
32551    Output channel 7 increment = 8
32552    Output is channel interleaved
32553 
32554    Output channels are separate words
32555    Simplex table index bits       = 12
32556    Interpolation table index bits = 20
32557    Simplex table max resolution = 16
32558    Interpolation table max resolution = 101
32559  */
32560 
32561 /*
32562    Machine architecture specs:
32563 
32564    Little endian
32565    Reading and writing pixel values separately
32566    Pointer size = 32 bits
32567 
32568    Ordinal size  8 bits is known as 'unsigned char'
32569    Ordinal size 16 bits is known as 'unsigned short'
32570    Ordinal size 32 bits is known as 'unsigned int'
32571    Natural ordinal is 'unsigned int'
32572 
32573    Integer size  8 bits is known as 'signed char'
32574    Integer size 16 bits is known as 'short'
32575    Integer size 32 bits is known as 'int'
32576    Natural integer is 'int'
32577 
32578  */
32579 
32580 #ifndef  IMDI_INCLUDED
32581 #include <memory.h>
32582 #include "imdi_imp.h"
32583 #define  IMDI_INCLUDED
32584 #endif  /* IMDI_INCLUDED */
32585 
32586 #ifndef DEFINED_pointer
32587 #define DEFINED_pointer
32588 typedef unsigned char * pointer;
32589 #endif
32590 
32591 /* Input table inter & simplex indexes */
32592 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
32593 
32594 /* Simplex weighting table access */
32595 #define SW_O(off) ((off) * 16)
32596 
32597 /* Simplex table - get weighting value */
32598 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
32599 
32600 /* Simplex table - get offset value */
32601 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
32602 
32603 /* Interpolation multi-dim. table access */
32604 #define IM_O(off) ((off) * 16)
32605 
32606 /* Interpolation table - get vertex values */
32607 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
32608 
32609 /* Output table indexes */
32610 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
32611 
32612 void
imdi_k93(imdi * s,void ** outp,void ** inp,unsigned int npix)32613 imdi_k93(
32614 imdi *s,			/* imdi context */
32615 void **outp,		/* pointer to output pointers */
32616 void **inp,		/* pointer to input pointers */
32617 unsigned int npix	/* Number of pixels to process */
32618 ) {
32619 	imdi_imp *p = (imdi_imp *)(s->impl);
32620 	unsigned char *ip0 = (unsigned char *)inp[0];
32621 	unsigned short *op0 = (unsigned short *)outp[0];
32622 	unsigned char *ep = ip0 + npix * 3 ;
32623 	pointer it0 = (pointer)p->in_tables[0];
32624 	pointer it1 = (pointer)p->in_tables[1];
32625 	pointer it2 = (pointer)p->in_tables[2];
32626 	pointer ot0 = (pointer)p->out_tables[0];
32627 	pointer ot1 = (pointer)p->out_tables[1];
32628 	pointer ot2 = (pointer)p->out_tables[2];
32629 	pointer ot3 = (pointer)p->out_tables[3];
32630 	pointer ot4 = (pointer)p->out_tables[4];
32631 	pointer ot5 = (pointer)p->out_tables[5];
32632 	pointer ot6 = (pointer)p->out_tables[6];
32633 	pointer ot7 = (pointer)p->out_tables[7];
32634 	pointer sw_base = (pointer)p->sw_table;
32635 	pointer im_base = (pointer)p->im_table;
32636 
32637 	for(;ip0 < ep; ip0 += 3, op0 += 8) {
32638 		unsigned int ova0;	/* Output value accumulator */
32639 		unsigned int ova1;	/* Output value accumulator */
32640 		unsigned int ova2;	/* Output value accumulator */
32641 		unsigned int ova3;	/* Output value accumulator */
32642 		{
32643 			pointer swp;
32644 			pointer imp;
32645 			{
32646 				unsigned int ti;	/* Simplex+Interpolation index variable */
32647 
32648 				ti  = IT_IT(it0, ip0[0]);
32649 				ti += IT_IT(it1, ip0[1]);
32650 				ti += IT_IT(it2, ip0[2]);
32651 
32652 				imp = im_base + IM_O(ti >> 12);		/* Extract interp. index and comp. entry */
32653 				swp = sw_base + SW_O(ti & 0xfff);	/* Extract simplex index and comp. entry */
32654 			}
32655 			{
32656 				unsigned int vof;	/* Vertex offset value */
32657 				unsigned int vwe;	/* Vertex weighting */
32658 
32659 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
32660 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
32661 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
32662 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
32663 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
32664 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
32665 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
32666 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
32667 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
32668 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
32669 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
32670 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
32671 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
32672 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
32673 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
32674 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
32675 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
32676 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
32677 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
32678 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
32679 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
32680 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
32681 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
32682 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
32683 			}
32684 		}
32685 		{
32686 			unsigned int oti;	/* Vertex offset value */
32687 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
32688 			op0[0] = OT_E(ot0, oti);	/* Write result */
32689 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
32690 			op0[1] = OT_E(ot1, oti);	/* Write result */
32691 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
32692 			op0[2] = OT_E(ot2, oti);	/* Write result */
32693 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
32694 			op0[3] = OT_E(ot3, oti);	/* Write result */
32695 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
32696 			op0[4] = OT_E(ot4, oti);	/* Write result */
32697 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
32698 			op0[5] = OT_E(ot5, oti);	/* Write result */
32699 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
32700 			op0[6] = OT_E(ot6, oti);	/* Write result */
32701 			oti = ((ova3 >> 24) & 0xff);	/* Extract integer part of result */
32702 			op0[7] = OT_E(ot7, oti);	/* Write result */
32703 		}
32704 	}
32705 }
32706 #undef IT_IT
32707 #undef SW_O
32708 #undef SX_WE
32709 #undef SX_VO
32710 #undef IM_O
32711 #undef IM_FE
32712 #undef OT_E
32713 
32714 void
imdi_k93_gen(genspec * g)32715 imdi_k93_gen(
32716 genspec *g			/* structure to be initialised */
32717 ) {
32718 	static unsigned char data[] = {
32719 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
32720 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32721 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32722 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32723 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32724 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32725 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32726 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
32727 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
32728 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32729 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32730 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32731 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32732 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32733 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32734 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32735 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32736 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32737 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32738 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32739 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32740 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32741 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32742 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32743 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32744 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32745 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32746 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32747 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32748 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32749 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32750 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32751 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32752 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32753 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32754 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32755 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32756 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32757 		0x65, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32758 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
32759 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
32760 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
32761 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
32762 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
32763 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
32764 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
32765 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
32766 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
32767 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32768 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
32769 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
32770 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x38, 0x5f,
32771 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
32772 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
32773 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
32774 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
32775 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
32776 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
32777 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
32778 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32779 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32780 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32781 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32782 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
32783 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x39, 0x33,
32784 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32785 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32786 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
32787 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
32788 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
32789 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
32790 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
32791 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
32792 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
32793 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
32794 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
32795 		0x00, 0xf0, 0x04, 0x08
32796 	};	/* Structure image */
32797 
32798 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
32799 }
32800 
32801 void
imdi_k93_tab(tabspec * t)32802 imdi_k93_tab(
32803 tabspec *t			/* structure to be initialised */
32804 ) {
32805 	static unsigned char data[] = {
32806 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32807 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32808 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32809 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
32810 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
32811 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
32812 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
32813 		0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
32814 		0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
32815 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32816 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32817 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32818 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
32819 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32820 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
32821 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32822 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32823 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
32824 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32825 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32826 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32827 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
32828 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
32829 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
32830 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32831 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32832 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32833 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32834 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32835 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32836 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32837 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
32838 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
32839 	};	/* Structure image */
32840 
32841 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
32842 }
32843 
32844 
32845 
32846 
32847 
32848 
32849 /* Integer Multi-Dimensional Interpolation */
32850 /* Interpolation Kernel Code */
32851 /* Generated by cgen */
32852 /* Copyright 2000 - 2002 Graeme W. Gill */
32853 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
32854 
32855 /* see the Licence.txt file for licencing details.*/
32856 
32857 
32858 /*
32859    Interpolation kernel specs:
32860 
32861    Input channels per pixel = 4
32862    Input channel 0 bits = 8
32863    Input channel 0 increment = 4
32864    Input channel 1 bits = 8
32865    Input channel 1 increment = 4
32866    Input channel 2 bits = 8
32867    Input channel 2 increment = 4
32868    Input channel 3 bits = 8
32869    Input channel 3 increment = 4
32870    Input is channel interleaved
32871    Input channels are separate words
32872    Input value extraction is done in input table lookup
32873 
32874    Output channels per pixel = 8
32875    Output channel 0 bits = 16
32876    Output channel 0 increment = 8
32877    Output channel 1 bits = 16
32878    Output channel 1 increment = 8
32879    Output channel 2 bits = 16
32880    Output channel 2 increment = 8
32881    Output channel 3 bits = 16
32882    Output channel 3 increment = 8
32883    Output channel 4 bits = 16
32884    Output channel 4 increment = 8
32885    Output channel 5 bits = 16
32886    Output channel 5 increment = 8
32887    Output channel 6 bits = 16
32888    Output channel 6 increment = 8
32889    Output channel 7 bits = 16
32890    Output channel 7 increment = 8
32891    Output is channel interleaved
32892 
32893    Output channels are separate words
32894    Simplex table index bits       = 32
32895    Interpolation table index bits = 32
32896    Simplex table max resolution = 255
32897    Interpolation table max resolution = 31
32898  */
32899 
32900 /*
32901    Machine architecture specs:
32902 
32903    Little endian
32904    Reading and writing pixel values separately
32905    Pointer size = 32 bits
32906 
32907    Ordinal size  8 bits is known as 'unsigned char'
32908    Ordinal size 16 bits is known as 'unsigned short'
32909    Ordinal size 32 bits is known as 'unsigned int'
32910    Natural ordinal is 'unsigned int'
32911 
32912    Integer size  8 bits is known as 'signed char'
32913    Integer size 16 bits is known as 'short'
32914    Integer size 32 bits is known as 'int'
32915    Natural integer is 'int'
32916 
32917  */
32918 
32919 #ifndef  IMDI_INCLUDED
32920 #include <memory.h>
32921 #include "imdi_imp.h"
32922 #define  IMDI_INCLUDED
32923 #endif  /* IMDI_INCLUDED */
32924 
32925 #ifndef DEFINED_pointer
32926 #define DEFINED_pointer
32927 typedef unsigned char * pointer;
32928 #endif
32929 
32930 /* Input table interp. index */
32931 #define IT_IX(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
32932 
32933 /* Input table simplex index enty */
32934 #define IT_SX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
32935 
32936 /* Simplex weighting table access */
32937 #define SW_O(off) ((off) * 20)
32938 
32939 /* Simplex table - get weighting value */
32940 #define SX_WE(p, v) *((unsigned short *)((p) + (v) * 4 + 0))
32941 
32942 /* Simplex table - get offset value */
32943 #define SX_VO(p, v) *((unsigned short *)((p) + (v) * 4 + 2))
32944 
32945 /* Interpolation multi-dim. table access */
32946 #define IM_O(off) ((off) * 16)
32947 
32948 /* Interpolation table - get vertex values */
32949 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
32950 
32951 /* Output table indexes */
32952 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
32953 
32954 void
imdi_k94(imdi * s,void ** outp,void ** inp,unsigned int npix)32955 imdi_k94(
32956 imdi *s,			/* imdi context */
32957 void **outp,		/* pointer to output pointers */
32958 void **inp,		/* pointer to input pointers */
32959 unsigned int npix	/* Number of pixels to process */
32960 ) {
32961 	imdi_imp *p = (imdi_imp *)(s->impl);
32962 	unsigned char *ip0 = (unsigned char *)inp[0];
32963 	unsigned short *op0 = (unsigned short *)outp[0];
32964 	unsigned char *ep = ip0 + npix * 4 ;
32965 	pointer it0 = (pointer)p->in_tables[0];
32966 	pointer it1 = (pointer)p->in_tables[1];
32967 	pointer it2 = (pointer)p->in_tables[2];
32968 	pointer it3 = (pointer)p->in_tables[3];
32969 	pointer ot0 = (pointer)p->out_tables[0];
32970 	pointer ot1 = (pointer)p->out_tables[1];
32971 	pointer ot2 = (pointer)p->out_tables[2];
32972 	pointer ot3 = (pointer)p->out_tables[3];
32973 	pointer ot4 = (pointer)p->out_tables[4];
32974 	pointer ot5 = (pointer)p->out_tables[5];
32975 	pointer ot6 = (pointer)p->out_tables[6];
32976 	pointer ot7 = (pointer)p->out_tables[7];
32977 	pointer sw_base = (pointer)p->sw_table;
32978 	pointer im_base = (pointer)p->im_table;
32979 
32980 	for(;ip0 < ep; ip0 += 4, op0 += 8) {
32981 		unsigned int ova0;	/* Output value accumulator */
32982 		unsigned int ova1;	/* Output value accumulator */
32983 		unsigned int ova2;	/* Output value accumulator */
32984 		unsigned int ova3;	/* Output value accumulator */
32985 		{
32986 			pointer swp;
32987 			pointer imp;
32988 			{
32989 				unsigned int ti_s;	/* Simplex index variable */
32990 				unsigned int ti_i;	/* Interpolation index variable */
32991 
32992 				ti_i  = IT_IX(it0, ip0[0]);
32993 				ti_s  = IT_SX(it0, ip0[0]);
32994 				ti_i += IT_IX(it1, ip0[1]);
32995 				ti_s += IT_SX(it1, ip0[1]);
32996 				ti_i += IT_IX(it2, ip0[2]);
32997 				ti_s += IT_SX(it2, ip0[2]);
32998 				ti_i += IT_IX(it3, ip0[3]);
32999 				ti_s += IT_SX(it3, ip0[3]);
33000 
33001 				swp = sw_base + SW_O(ti_s);		/* Compute simplex table entry pointer */
33002 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
33003 			}
33004 			{
33005 				unsigned int vof;	/* Vertex offset value */
33006 				unsigned int vwe;	/* Vertex weighting */
33007 
33008 				vof = SX_VO(swp, 0);	/* Read vertex offset value */
33009 				vwe = SX_WE(swp, 0);	/* Read vertex weighting value */
33010 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
33011 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
33012 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
33013 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
33014 				vof = SX_VO(swp, 1);	/* Read vertex offset value */
33015 				vwe = SX_WE(swp, 1);	/* Read vertex weighting value */
33016 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
33017 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
33018 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
33019 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
33020 				vof = SX_VO(swp, 2);	/* Read vertex offset value */
33021 				vwe = SX_WE(swp, 2);	/* Read vertex weighting value */
33022 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
33023 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
33024 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
33025 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
33026 				vof = SX_VO(swp, 3);	/* Read vertex offset value */
33027 				vwe = SX_WE(swp, 3);	/* Read vertex weighting value */
33028 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
33029 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
33030 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
33031 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
33032 				vof = SX_VO(swp, 4);	/* Read vertex offset value */
33033 				vwe = SX_WE(swp, 4);	/* Read vertex weighting value */
33034 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
33035 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
33036 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
33037 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
33038 			}
33039 		}
33040 		{
33041 			unsigned int oti;	/* Vertex offset value */
33042 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
33043 			op0[0] = OT_E(ot0, oti);	/* Write result */
33044 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
33045 			op0[1] = OT_E(ot1, oti);	/* Write result */
33046 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
33047 			op0[2] = OT_E(ot2, oti);	/* Write result */
33048 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
33049 			op0[3] = OT_E(ot3, oti);	/* Write result */
33050 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
33051 			op0[4] = OT_E(ot4, oti);	/* Write result */
33052 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
33053 			op0[5] = OT_E(ot5, oti);	/* Write result */
33054 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
33055 			op0[6] = OT_E(ot6, oti);	/* Write result */
33056 			oti = ((ova3 >> 24) & 0xff);	/* Extract integer part of result */
33057 			op0[7] = OT_E(ot7, oti);	/* Write result */
33058 		}
33059 	}
33060 }
33061 #undef IT_IX
33062 #undef IT_SX
33063 #undef SW_O
33064 #undef SX_WE
33065 #undef SX_VO
33066 #undef IM_O
33067 #undef IM_FE
33068 #undef OT_E
33069 
33070 void
imdi_k94_gen(genspec * g)33071 imdi_k94_gen(
33072 genspec *g			/* structure to be initialised */
33073 ) {
33074 	static unsigned char data[] = {
33075 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
33076 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33077 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33078 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33079 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33080 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33081 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33082 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
33083 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
33084 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33085 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33086 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33087 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33088 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33089 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33090 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33091 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33092 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33093 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33094 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33095 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33096 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33097 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33098 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33099 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33100 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33101 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33102 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33103 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33104 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33105 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33106 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33107 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33108 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33109 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33110 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33111 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33112 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33113 		0x1f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
33114 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
33115 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
33116 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
33117 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
33118 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
33119 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
33120 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
33121 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
33122 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
33123 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33124 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
33125 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
33126 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x38, 0x5f,
33127 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
33128 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
33129 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
33130 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
33131 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
33132 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
33133 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
33134 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33135 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33136 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33137 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33138 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
33139 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x39, 0x34,
33140 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33141 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33142 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
33143 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
33144 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
33145 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
33146 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
33147 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
33148 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
33149 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
33150 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
33151 		0x00, 0xf0, 0x04, 0x08
33152 	};	/* Structure image */
33153 
33154 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
33155 }
33156 
33157 void
imdi_k94_tab(tabspec * t)33158 imdi_k94_tab(
33159 tabspec *t			/* structure to be initialised */
33160 ) {
33161 	static unsigned char data[] = {
33162 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33163 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33164 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33165 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
33166 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
33167 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
33168 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33169 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
33170 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
33171 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33172 		0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33173 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33174 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
33175 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33176 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
33177 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33178 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33179 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
33180 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33181 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33182 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33183 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
33184 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
33185 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
33186 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33187 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33188 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33189 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33190 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33191 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33192 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33193 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33194 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
33195 	};	/* Structure image */
33196 
33197 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
33198 }
33199 
33200 
33201 
33202 
33203 
33204 
33205 /* Integer Multi-Dimensional Interpolation */
33206 /* Interpolation Kernel Code */
33207 /* Generated by cgen */
33208 /* Copyright 2000 - 2002 Graeme W. Gill */
33209 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
33210 
33211 /* see the Licence.txt file for licencing details.*/
33212 
33213 
33214 /*
33215    Interpolation kernel specs:
33216 
33217    Input channels per pixel = 5
33218    Input channel 0 bits = 8
33219    Input channel 0 increment = 5
33220    Input channel 1 bits = 8
33221    Input channel 1 increment = 5
33222    Input channel 2 bits = 8
33223    Input channel 2 increment = 5
33224    Input channel 3 bits = 8
33225    Input channel 3 increment = 5
33226    Input channel 4 bits = 8
33227    Input channel 4 increment = 5
33228    Input is channel interleaved
33229    Input channels are separate words
33230    Input value extraction is done in input table lookup
33231 
33232    Output channels per pixel = 8
33233    Output channel 0 bits = 16
33234    Output channel 0 increment = 8
33235    Output channel 1 bits = 16
33236    Output channel 1 increment = 8
33237    Output channel 2 bits = 16
33238    Output channel 2 increment = 8
33239    Output channel 3 bits = 16
33240    Output channel 3 increment = 8
33241    Output channel 4 bits = 16
33242    Output channel 4 increment = 8
33243    Output channel 5 bits = 16
33244    Output channel 5 increment = 8
33245    Output channel 6 bits = 16
33246    Output channel 6 increment = 8
33247    Output channel 7 bits = 16
33248    Output channel 7 increment = 8
33249    Output is channel interleaved
33250 
33251    Output channels are separate words
33252    Weight+voffset bits       = 32
33253    Interpolation table index bits = 32
33254    Interpolation table max resolution = 45
33255  */
33256 
33257 /*
33258    Machine architecture specs:
33259 
33260    Little endian
33261    Reading and writing pixel values separately
33262    Pointer size = 32 bits
33263 
33264    Ordinal size  8 bits is known as 'unsigned char'
33265    Ordinal size 16 bits is known as 'unsigned short'
33266    Ordinal size 32 bits is known as 'unsigned int'
33267    Natural ordinal is 'unsigned int'
33268 
33269    Integer size  8 bits is known as 'signed char'
33270    Integer size 16 bits is known as 'short'
33271    Integer size 32 bits is known as 'int'
33272    Natural integer is 'int'
33273 
33274  */
33275 
33276 #ifndef  IMDI_INCLUDED
33277 #include <memory.h>
33278 #include "imdi_imp.h"
33279 #define  IMDI_INCLUDED
33280 #endif  /* IMDI_INCLUDED */
33281 
33282 #ifndef DEFINED_pointer
33283 #define DEFINED_pointer
33284 typedef unsigned char * pointer;
33285 #endif
33286 
33287 /* Input table interp. index */
33288 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
33289 
33290 /* Input table input weighting/offset value enty */
33291 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
33292 
33293 /* Conditional exchange for sorting */
33294 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
33295 
33296 /* Interpolation multi-dim. table access */
33297 #define IM_O(off) ((off) * 16)
33298 
33299 /* Interpolation table - get vertex values */
33300 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
33301 
33302 /* Output table indexes */
33303 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
33304 
33305 void
imdi_k95(imdi * s,void ** outp,void ** inp,unsigned int npix)33306 imdi_k95(
33307 imdi *s,			/* imdi context */
33308 void **outp,		/* pointer to output pointers */
33309 void **inp,		/* pointer to input pointers */
33310 unsigned int npix	/* Number of pixels to process */
33311 ) {
33312 	imdi_imp *p = (imdi_imp *)(s->impl);
33313 	unsigned char *ip0 = (unsigned char *)inp[0];
33314 	unsigned short *op0 = (unsigned short *)outp[0];
33315 	unsigned char *ep = ip0 + npix * 5 ;
33316 	pointer it0 = (pointer)p->in_tables[0];
33317 	pointer it1 = (pointer)p->in_tables[1];
33318 	pointer it2 = (pointer)p->in_tables[2];
33319 	pointer it3 = (pointer)p->in_tables[3];
33320 	pointer it4 = (pointer)p->in_tables[4];
33321 	pointer ot0 = (pointer)p->out_tables[0];
33322 	pointer ot1 = (pointer)p->out_tables[1];
33323 	pointer ot2 = (pointer)p->out_tables[2];
33324 	pointer ot3 = (pointer)p->out_tables[3];
33325 	pointer ot4 = (pointer)p->out_tables[4];
33326 	pointer ot5 = (pointer)p->out_tables[5];
33327 	pointer ot6 = (pointer)p->out_tables[6];
33328 	pointer ot7 = (pointer)p->out_tables[7];
33329 	pointer im_base = (pointer)p->im_table;
33330 
33331 	for(;ip0 < ep; ip0 += 5, op0 += 8) {
33332 		unsigned int ova0;	/* Output value accumulator */
33333 		unsigned int ova1;	/* Output value accumulator */
33334 		unsigned int ova2;	/* Output value accumulator */
33335 		unsigned int ova3;	/* Output value accumulator */
33336 		{
33337 			pointer imp;
33338 			unsigned int wo0;	/* Weighting value and vertex offset variable */
33339 			unsigned int wo1;	/* Weighting value and vertex offset variable */
33340 			unsigned int wo2;	/* Weighting value and vertex offset variable */
33341 			unsigned int wo3;	/* Weighting value and vertex offset variable */
33342 			unsigned int wo4;	/* Weighting value and vertex offset variable */
33343 			{
33344 				unsigned int ti_i;	/* Interpolation index variable */
33345 
33346 				ti_i  = IT_IX(it0, ip0[0]);
33347 				wo0   = IT_WO(it0, ip0[0]);
33348 				ti_i += IT_IX(it1, ip0[1]);
33349 				wo1   = IT_WO(it1, ip0[1]);
33350 				ti_i += IT_IX(it2, ip0[2]);
33351 				wo2   = IT_WO(it2, ip0[2]);
33352 				ti_i += IT_IX(it3, ip0[3]);
33353 				wo3   = IT_WO(it3, ip0[3]);
33354 				ti_i += IT_IX(it4, ip0[4]);
33355 				wo4   = IT_WO(it4, ip0[4]);
33356 
33357 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
33358 
33359 				/* Sort weighting values and vertex offset values */
33360 				CEX(wo0, wo1);
33361 				CEX(wo0, wo2);
33362 				CEX(wo0, wo3);
33363 				CEX(wo0, wo4);
33364 				CEX(wo1, wo2);
33365 				CEX(wo1, wo3);
33366 				CEX(wo1, wo4);
33367 				CEX(wo2, wo3);
33368 				CEX(wo2, wo4);
33369 				CEX(wo3, wo4);
33370 			}
33371 			{
33372 				unsigned int nvof;	/* Next vertex offset value */
33373 				unsigned int vof;	/* Vertex offset value */
33374 				unsigned int vwe;	/* Vertex weighting */
33375 
33376 				vof = 0;				/* First vertex offset is 0 */
33377 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
33378 				wo0 = (wo0 >> 23);		/* Extract weighting value */
33379 				vwe = 256 - wo0;		/* Baricentric weighting */
33380 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
33381 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
33382 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
33383 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
33384 				vof += nvof;			/* Move to next vertex */
33385 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
33386 				wo1 = (wo1 >> 23);		/* Extract weighting value */
33387 				vwe = wo0 - wo1;		/* Baricentric weighting */
33388 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
33389 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
33390 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
33391 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
33392 				vof += nvof;			/* Move to next vertex */
33393 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
33394 				wo2 = (wo2 >> 23);		/* Extract weighting value */
33395 				vwe = wo1 - wo2;		/* Baricentric weighting */
33396 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
33397 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
33398 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
33399 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
33400 				vof += nvof;			/* Move to next vertex */
33401 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
33402 				wo3 = (wo3 >> 23);		/* Extract weighting value */
33403 				vwe = wo2 - wo3;		/* Baricentric weighting */
33404 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
33405 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
33406 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
33407 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
33408 				vof += nvof;			/* Move to next vertex */
33409 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
33410 				wo4 = (wo4 >> 23);		/* Extract weighting value */
33411 				vwe = wo3 - wo4;		/* Baricentric weighting */
33412 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
33413 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
33414 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
33415 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
33416 				vof += nvof;			/* Move to next vertex */
33417 				vwe = wo4;				/* Baricentric weighting */
33418 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
33419 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
33420 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
33421 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
33422 			}
33423 		}
33424 		{
33425 			unsigned int oti;	/* Vertex offset value */
33426 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
33427 			op0[0] = OT_E(ot0, oti);	/* Write result */
33428 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
33429 			op0[1] = OT_E(ot1, oti);	/* Write result */
33430 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
33431 			op0[2] = OT_E(ot2, oti);	/* Write result */
33432 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
33433 			op0[3] = OT_E(ot3, oti);	/* Write result */
33434 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
33435 			op0[4] = OT_E(ot4, oti);	/* Write result */
33436 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
33437 			op0[5] = OT_E(ot5, oti);	/* Write result */
33438 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
33439 			op0[6] = OT_E(ot6, oti);	/* Write result */
33440 			oti = ((ova3 >> 24) & 0xff);	/* Extract integer part of result */
33441 			op0[7] = OT_E(ot7, oti);	/* Write result */
33442 		}
33443 	}
33444 }
33445 #undef IT_WO
33446 #undef IT_IX
33447 #undef CEX
33448 #undef IM_O
33449 #undef IM_FE
33450 #undef OT_E
33451 
33452 void
imdi_k95_gen(genspec * g)33453 imdi_k95_gen(
33454 genspec *g			/* structure to be initialised */
33455 ) {
33456 	static unsigned char data[] = {
33457 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
33458 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33459 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33460 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33461 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33462 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33463 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33464 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
33465 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
33466 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
33467 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33468 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33469 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33470 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33471 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33472 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33473 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33474 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33475 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33476 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33477 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33478 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33479 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33480 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33481 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33482 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33483 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33484 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33485 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33486 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33487 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33488 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33489 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33490 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33491 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33492 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33493 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33494 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33495 		0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33496 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
33497 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
33498 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
33499 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
33500 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
33501 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
33502 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
33503 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
33504 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
33505 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33506 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
33507 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
33508 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x38, 0x5f,
33509 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
33510 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
33511 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
33512 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
33513 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
33514 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
33515 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
33516 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33517 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33518 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33519 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33520 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
33521 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x39, 0x35,
33522 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33523 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33524 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
33525 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
33526 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
33527 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
33528 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
33529 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
33530 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
33531 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
33532 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
33533 		0x00, 0xf0, 0x04, 0x08
33534 	};	/* Structure image */
33535 
33536 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
33537 }
33538 
33539 void
imdi_k95_tab(tabspec * t)33540 imdi_k95_tab(
33541 tabspec *t			/* structure to be initialised */
33542 ) {
33543 	static unsigned char data[] = {
33544 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33545 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33546 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33547 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
33548 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
33549 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
33550 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33551 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
33552 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
33553 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33554 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
33555 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
33556 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
33557 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
33558 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
33559 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33560 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33561 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
33562 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33563 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33564 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33565 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
33566 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
33567 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
33568 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33569 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33570 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33571 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33572 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33573 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33574 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33575 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33576 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
33577 	};	/* Structure image */
33578 
33579 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
33580 }
33581 
33582 
33583 
33584 
33585 
33586 
33587 /* Integer Multi-Dimensional Interpolation */
33588 /* Interpolation Kernel Code */
33589 /* Generated by cgen */
33590 /* Copyright 2000 - 2002 Graeme W. Gill */
33591 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
33592 
33593 /* see the Licence.txt file for licencing details.*/
33594 
33595 
33596 /*
33597    Interpolation kernel specs:
33598 
33599    Input channels per pixel = 6
33600    Input channel 0 bits = 8
33601    Input channel 0 increment = 6
33602    Input channel 1 bits = 8
33603    Input channel 1 increment = 6
33604    Input channel 2 bits = 8
33605    Input channel 2 increment = 6
33606    Input channel 3 bits = 8
33607    Input channel 3 increment = 6
33608    Input channel 4 bits = 8
33609    Input channel 4 increment = 6
33610    Input channel 5 bits = 8
33611    Input channel 5 increment = 6
33612    Input is channel interleaved
33613    Input channels are separate words
33614    Input value extraction is done in input table lookup
33615 
33616    Output channels per pixel = 8
33617    Output channel 0 bits = 16
33618    Output channel 0 increment = 8
33619    Output channel 1 bits = 16
33620    Output channel 1 increment = 8
33621    Output channel 2 bits = 16
33622    Output channel 2 increment = 8
33623    Output channel 3 bits = 16
33624    Output channel 3 increment = 8
33625    Output channel 4 bits = 16
33626    Output channel 4 increment = 8
33627    Output channel 5 bits = 16
33628    Output channel 5 increment = 8
33629    Output channel 6 bits = 16
33630    Output channel 6 increment = 8
33631    Output channel 7 bits = 16
33632    Output channel 7 increment = 8
33633    Output is channel interleaved
33634 
33635    Output channels are separate words
33636    Weight+voffset bits       = 32
33637    Interpolation table index bits = 32
33638    Interpolation table max resolution = 20
33639  */
33640 
33641 /*
33642    Machine architecture specs:
33643 
33644    Little endian
33645    Reading and writing pixel values separately
33646    Pointer size = 32 bits
33647 
33648    Ordinal size  8 bits is known as 'unsigned char'
33649    Ordinal size 16 bits is known as 'unsigned short'
33650    Ordinal size 32 bits is known as 'unsigned int'
33651    Natural ordinal is 'unsigned int'
33652 
33653    Integer size  8 bits is known as 'signed char'
33654    Integer size 16 bits is known as 'short'
33655    Integer size 32 bits is known as 'int'
33656    Natural integer is 'int'
33657 
33658  */
33659 
33660 #ifndef  IMDI_INCLUDED
33661 #include <memory.h>
33662 #include "imdi_imp.h"
33663 #define  IMDI_INCLUDED
33664 #endif  /* IMDI_INCLUDED */
33665 
33666 #ifndef DEFINED_pointer
33667 #define DEFINED_pointer
33668 typedef unsigned char * pointer;
33669 #endif
33670 
33671 /* Input table interp. index */
33672 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
33673 
33674 /* Input table input weighting/offset value enty */
33675 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
33676 
33677 /* Conditional exchange for sorting */
33678 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
33679 
33680 /* Interpolation multi-dim. table access */
33681 #define IM_O(off) ((off) * 16)
33682 
33683 /* Interpolation table - get vertex values */
33684 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
33685 
33686 /* Output table indexes */
33687 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
33688 
33689 void
imdi_k96(imdi * s,void ** outp,void ** inp,unsigned int npix)33690 imdi_k96(
33691 imdi *s,			/* imdi context */
33692 void **outp,		/* pointer to output pointers */
33693 void **inp,		/* pointer to input pointers */
33694 unsigned int npix	/* Number of pixels to process */
33695 ) {
33696 	imdi_imp *p = (imdi_imp *)(s->impl);
33697 	unsigned char *ip0 = (unsigned char *)inp[0];
33698 	unsigned short *op0 = (unsigned short *)outp[0];
33699 	unsigned char *ep = ip0 + npix * 6 ;
33700 	pointer it0 = (pointer)p->in_tables[0];
33701 	pointer it1 = (pointer)p->in_tables[1];
33702 	pointer it2 = (pointer)p->in_tables[2];
33703 	pointer it3 = (pointer)p->in_tables[3];
33704 	pointer it4 = (pointer)p->in_tables[4];
33705 	pointer it5 = (pointer)p->in_tables[5];
33706 	pointer ot0 = (pointer)p->out_tables[0];
33707 	pointer ot1 = (pointer)p->out_tables[1];
33708 	pointer ot2 = (pointer)p->out_tables[2];
33709 	pointer ot3 = (pointer)p->out_tables[3];
33710 	pointer ot4 = (pointer)p->out_tables[4];
33711 	pointer ot5 = (pointer)p->out_tables[5];
33712 	pointer ot6 = (pointer)p->out_tables[6];
33713 	pointer ot7 = (pointer)p->out_tables[7];
33714 	pointer im_base = (pointer)p->im_table;
33715 
33716 	for(;ip0 < ep; ip0 += 6, op0 += 8) {
33717 		unsigned int ova0;	/* Output value accumulator */
33718 		unsigned int ova1;	/* Output value accumulator */
33719 		unsigned int ova2;	/* Output value accumulator */
33720 		unsigned int ova3;	/* Output value accumulator */
33721 		{
33722 			pointer imp;
33723 			unsigned int wo0;	/* Weighting value and vertex offset variable */
33724 			unsigned int wo1;	/* Weighting value and vertex offset variable */
33725 			unsigned int wo2;	/* Weighting value and vertex offset variable */
33726 			unsigned int wo3;	/* Weighting value and vertex offset variable */
33727 			unsigned int wo4;	/* Weighting value and vertex offset variable */
33728 			unsigned int wo5;	/* Weighting value and vertex offset variable */
33729 			{
33730 				unsigned int ti_i;	/* Interpolation index variable */
33731 
33732 				ti_i  = IT_IX(it0, ip0[0]);
33733 				wo0   = IT_WO(it0, ip0[0]);
33734 				ti_i += IT_IX(it1, ip0[1]);
33735 				wo1   = IT_WO(it1, ip0[1]);
33736 				ti_i += IT_IX(it2, ip0[2]);
33737 				wo2   = IT_WO(it2, ip0[2]);
33738 				ti_i += IT_IX(it3, ip0[3]);
33739 				wo3   = IT_WO(it3, ip0[3]);
33740 				ti_i += IT_IX(it4, ip0[4]);
33741 				wo4   = IT_WO(it4, ip0[4]);
33742 				ti_i += IT_IX(it5, ip0[5]);
33743 				wo5   = IT_WO(it5, ip0[5]);
33744 
33745 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
33746 
33747 				/* Sort weighting values and vertex offset values */
33748 				CEX(wo0, wo1);
33749 				CEX(wo0, wo2);
33750 				CEX(wo0, wo3);
33751 				CEX(wo0, wo4);
33752 				CEX(wo0, wo5);
33753 				CEX(wo1, wo2);
33754 				CEX(wo1, wo3);
33755 				CEX(wo1, wo4);
33756 				CEX(wo1, wo5);
33757 				CEX(wo2, wo3);
33758 				CEX(wo2, wo4);
33759 				CEX(wo2, wo5);
33760 				CEX(wo3, wo4);
33761 				CEX(wo3, wo5);
33762 				CEX(wo4, wo5);
33763 			}
33764 			{
33765 				unsigned int nvof;	/* Next vertex offset value */
33766 				unsigned int vof;	/* Vertex offset value */
33767 				unsigned int vwe;	/* Vertex weighting */
33768 
33769 				vof = 0;				/* First vertex offset is 0 */
33770 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
33771 				wo0 = (wo0 >> 23);		/* Extract weighting value */
33772 				vwe = 256 - wo0;		/* Baricentric weighting */
33773 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
33774 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
33775 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
33776 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
33777 				vof += nvof;			/* Move to next vertex */
33778 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
33779 				wo1 = (wo1 >> 23);		/* Extract weighting value */
33780 				vwe = wo0 - wo1;		/* Baricentric weighting */
33781 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
33782 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
33783 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
33784 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
33785 				vof += nvof;			/* Move to next vertex */
33786 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
33787 				wo2 = (wo2 >> 23);		/* Extract weighting value */
33788 				vwe = wo1 - wo2;		/* Baricentric weighting */
33789 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
33790 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
33791 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
33792 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
33793 				vof += nvof;			/* Move to next vertex */
33794 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
33795 				wo3 = (wo3 >> 23);		/* Extract weighting value */
33796 				vwe = wo2 - wo3;		/* Baricentric weighting */
33797 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
33798 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
33799 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
33800 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
33801 				vof += nvof;			/* Move to next vertex */
33802 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
33803 				wo4 = (wo4 >> 23);		/* Extract weighting value */
33804 				vwe = wo3 - wo4;		/* Baricentric weighting */
33805 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
33806 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
33807 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
33808 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
33809 				vof += nvof;			/* Move to next vertex */
33810 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
33811 				wo5 = (wo5 >> 23);		/* Extract weighting value */
33812 				vwe = wo4 - wo5;		/* Baricentric weighting */
33813 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
33814 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
33815 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
33816 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
33817 				vof += nvof;			/* Move to next vertex */
33818 				vwe = wo5;				/* Baricentric weighting */
33819 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
33820 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
33821 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
33822 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
33823 			}
33824 		}
33825 		{
33826 			unsigned int oti;	/* Vertex offset value */
33827 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
33828 			op0[0] = OT_E(ot0, oti);	/* Write result */
33829 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
33830 			op0[1] = OT_E(ot1, oti);	/* Write result */
33831 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
33832 			op0[2] = OT_E(ot2, oti);	/* Write result */
33833 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
33834 			op0[3] = OT_E(ot3, oti);	/* Write result */
33835 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
33836 			op0[4] = OT_E(ot4, oti);	/* Write result */
33837 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
33838 			op0[5] = OT_E(ot5, oti);	/* Write result */
33839 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
33840 			op0[6] = OT_E(ot6, oti);	/* Write result */
33841 			oti = ((ova3 >> 24) & 0xff);	/* Extract integer part of result */
33842 			op0[7] = OT_E(ot7, oti);	/* Write result */
33843 		}
33844 	}
33845 }
33846 #undef IT_WO
33847 #undef IT_IX
33848 #undef CEX
33849 #undef IM_O
33850 #undef IM_FE
33851 #undef OT_E
33852 
33853 void
imdi_k96_gen(genspec * g)33854 imdi_k96_gen(
33855 genspec *g			/* structure to be initialised */
33856 ) {
33857 	static unsigned char data[] = {
33858 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
33859 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33860 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33861 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33862 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33863 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33864 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33865 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
33866 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
33867 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
33868 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33869 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33870 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33871 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33872 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33873 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33874 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33875 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33876 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33877 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33878 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33879 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33880 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33881 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33882 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33883 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33884 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33885 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33886 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33887 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33888 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33889 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33890 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33891 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33892 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33893 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33894 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33895 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33896 		0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33897 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
33898 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
33899 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
33900 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
33901 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
33902 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
33903 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
33904 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
33905 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
33906 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33907 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
33908 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
33909 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x38, 0x5f,
33910 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
33911 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
33912 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
33913 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
33914 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
33915 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
33916 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
33917 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33918 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33919 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33920 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33921 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
33922 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x39, 0x36,
33923 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33924 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33925 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
33926 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
33927 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
33928 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
33929 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
33930 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
33931 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
33932 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
33933 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
33934 		0x00, 0xf0, 0x04, 0x08
33935 	};	/* Structure image */
33936 
33937 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
33938 }
33939 
33940 void
imdi_k96_tab(tabspec * t)33941 imdi_k96_tab(
33942 tabspec *t			/* structure to be initialised */
33943 ) {
33944 	static unsigned char data[] = {
33945 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33946 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33947 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33948 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
33949 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
33950 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
33951 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33952 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
33953 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
33954 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33955 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
33956 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
33957 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
33958 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
33959 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
33960 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33961 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
33962 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
33963 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33964 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33965 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
33966 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
33967 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
33968 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
33969 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33970 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33971 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33972 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33973 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33974 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33975 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33976 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
33977 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
33978 	};	/* Structure image */
33979 
33980 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
33981 }
33982 
33983 
33984 
33985 
33986 
33987 
33988 /* Integer Multi-Dimensional Interpolation */
33989 /* Interpolation Kernel Code */
33990 /* Generated by cgen */
33991 /* Copyright 2000 - 2002 Graeme W. Gill */
33992 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
33993 
33994 /* see the Licence.txt file for licencing details.*/
33995 
33996 
33997 /*
33998    Interpolation kernel specs:
33999 
34000    Input channels per pixel = 7
34001    Input channel 0 bits = 8
34002    Input channel 0 increment = 7
34003    Input channel 1 bits = 8
34004    Input channel 1 increment = 7
34005    Input channel 2 bits = 8
34006    Input channel 2 increment = 7
34007    Input channel 3 bits = 8
34008    Input channel 3 increment = 7
34009    Input channel 4 bits = 8
34010    Input channel 4 increment = 7
34011    Input channel 5 bits = 8
34012    Input channel 5 increment = 7
34013    Input channel 6 bits = 8
34014    Input channel 6 increment = 7
34015    Input is channel interleaved
34016    Input channels are separate words
34017    Input value extraction is done in input table lookup
34018 
34019    Output channels per pixel = 8
34020    Output channel 0 bits = 16
34021    Output channel 0 increment = 8
34022    Output channel 1 bits = 16
34023    Output channel 1 increment = 8
34024    Output channel 2 bits = 16
34025    Output channel 2 increment = 8
34026    Output channel 3 bits = 16
34027    Output channel 3 increment = 8
34028    Output channel 4 bits = 16
34029    Output channel 4 increment = 8
34030    Output channel 5 bits = 16
34031    Output channel 5 increment = 8
34032    Output channel 6 bits = 16
34033    Output channel 6 increment = 8
34034    Output channel 7 bits = 16
34035    Output channel 7 increment = 8
34036    Output is channel interleaved
34037 
34038    Output channels are separate words
34039    Weight+voffset bits       = 32
34040    Interpolation table index bits = 32
34041    Interpolation table max resolution = 12
34042  */
34043 
34044 /*
34045    Machine architecture specs:
34046 
34047    Little endian
34048    Reading and writing pixel values separately
34049    Pointer size = 32 bits
34050 
34051    Ordinal size  8 bits is known as 'unsigned char'
34052    Ordinal size 16 bits is known as 'unsigned short'
34053    Ordinal size 32 bits is known as 'unsigned int'
34054    Natural ordinal is 'unsigned int'
34055 
34056    Integer size  8 bits is known as 'signed char'
34057    Integer size 16 bits is known as 'short'
34058    Integer size 32 bits is known as 'int'
34059    Natural integer is 'int'
34060 
34061  */
34062 
34063 #ifndef  IMDI_INCLUDED
34064 #include <memory.h>
34065 #include "imdi_imp.h"
34066 #define  IMDI_INCLUDED
34067 #endif  /* IMDI_INCLUDED */
34068 
34069 #ifndef DEFINED_pointer
34070 #define DEFINED_pointer
34071 typedef unsigned char * pointer;
34072 #endif
34073 
34074 /* Input table interp. index */
34075 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
34076 
34077 /* Input table input weighting/offset value enty */
34078 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
34079 
34080 /* Conditional exchange for sorting */
34081 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
34082 
34083 /* Interpolation multi-dim. table access */
34084 #define IM_O(off) ((off) * 16)
34085 
34086 /* Interpolation table - get vertex values */
34087 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
34088 
34089 /* Output table indexes */
34090 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
34091 
34092 void
imdi_k97(imdi * s,void ** outp,void ** inp,unsigned int npix)34093 imdi_k97(
34094 imdi *s,			/* imdi context */
34095 void **outp,		/* pointer to output pointers */
34096 void **inp,		/* pointer to input pointers */
34097 unsigned int npix	/* Number of pixels to process */
34098 ) {
34099 	imdi_imp *p = (imdi_imp *)(s->impl);
34100 	unsigned char *ip0 = (unsigned char *)inp[0];
34101 	unsigned short *op0 = (unsigned short *)outp[0];
34102 	unsigned char *ep = ip0 + npix * 7 ;
34103 	pointer it0 = (pointer)p->in_tables[0];
34104 	pointer it1 = (pointer)p->in_tables[1];
34105 	pointer it2 = (pointer)p->in_tables[2];
34106 	pointer it3 = (pointer)p->in_tables[3];
34107 	pointer it4 = (pointer)p->in_tables[4];
34108 	pointer it5 = (pointer)p->in_tables[5];
34109 	pointer it6 = (pointer)p->in_tables[6];
34110 	pointer ot0 = (pointer)p->out_tables[0];
34111 	pointer ot1 = (pointer)p->out_tables[1];
34112 	pointer ot2 = (pointer)p->out_tables[2];
34113 	pointer ot3 = (pointer)p->out_tables[3];
34114 	pointer ot4 = (pointer)p->out_tables[4];
34115 	pointer ot5 = (pointer)p->out_tables[5];
34116 	pointer ot6 = (pointer)p->out_tables[6];
34117 	pointer ot7 = (pointer)p->out_tables[7];
34118 	pointer im_base = (pointer)p->im_table;
34119 
34120 	for(;ip0 < ep; ip0 += 7, op0 += 8) {
34121 		unsigned int ova0;	/* Output value accumulator */
34122 		unsigned int ova1;	/* Output value accumulator */
34123 		unsigned int ova2;	/* Output value accumulator */
34124 		unsigned int ova3;	/* Output value accumulator */
34125 		{
34126 			pointer imp;
34127 			unsigned int wo0;	/* Weighting value and vertex offset variable */
34128 			unsigned int wo1;	/* Weighting value and vertex offset variable */
34129 			unsigned int wo2;	/* Weighting value and vertex offset variable */
34130 			unsigned int wo3;	/* Weighting value and vertex offset variable */
34131 			unsigned int wo4;	/* Weighting value and vertex offset variable */
34132 			unsigned int wo5;	/* Weighting value and vertex offset variable */
34133 			unsigned int wo6;	/* Weighting value and vertex offset variable */
34134 			{
34135 				unsigned int ti_i;	/* Interpolation index variable */
34136 
34137 				ti_i  = IT_IX(it0, ip0[0]);
34138 				wo0   = IT_WO(it0, ip0[0]);
34139 				ti_i += IT_IX(it1, ip0[1]);
34140 				wo1   = IT_WO(it1, ip0[1]);
34141 				ti_i += IT_IX(it2, ip0[2]);
34142 				wo2   = IT_WO(it2, ip0[2]);
34143 				ti_i += IT_IX(it3, ip0[3]);
34144 				wo3   = IT_WO(it3, ip0[3]);
34145 				ti_i += IT_IX(it4, ip0[4]);
34146 				wo4   = IT_WO(it4, ip0[4]);
34147 				ti_i += IT_IX(it5, ip0[5]);
34148 				wo5   = IT_WO(it5, ip0[5]);
34149 				ti_i += IT_IX(it6, ip0[6]);
34150 				wo6   = IT_WO(it6, ip0[6]);
34151 
34152 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
34153 
34154 				/* Sort weighting values and vertex offset values */
34155 				CEX(wo0, wo1);
34156 				CEX(wo0, wo2);
34157 				CEX(wo0, wo3);
34158 				CEX(wo0, wo4);
34159 				CEX(wo0, wo5);
34160 				CEX(wo0, wo6);
34161 				CEX(wo1, wo2);
34162 				CEX(wo1, wo3);
34163 				CEX(wo1, wo4);
34164 				CEX(wo1, wo5);
34165 				CEX(wo1, wo6);
34166 				CEX(wo2, wo3);
34167 				CEX(wo2, wo4);
34168 				CEX(wo2, wo5);
34169 				CEX(wo2, wo6);
34170 				CEX(wo3, wo4);
34171 				CEX(wo3, wo5);
34172 				CEX(wo3, wo6);
34173 				CEX(wo4, wo5);
34174 				CEX(wo4, wo6);
34175 				CEX(wo5, wo6);
34176 			}
34177 			{
34178 				unsigned int nvof;	/* Next vertex offset value */
34179 				unsigned int vof;	/* Vertex offset value */
34180 				unsigned int vwe;	/* Vertex weighting */
34181 
34182 				vof = 0;				/* First vertex offset is 0 */
34183 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
34184 				wo0 = (wo0 >> 23);		/* Extract weighting value */
34185 				vwe = 256 - wo0;		/* Baricentric weighting */
34186 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
34187 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
34188 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
34189 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
34190 				vof += nvof;			/* Move to next vertex */
34191 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
34192 				wo1 = (wo1 >> 23);		/* Extract weighting value */
34193 				vwe = wo0 - wo1;		/* Baricentric weighting */
34194 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
34195 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
34196 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
34197 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
34198 				vof += nvof;			/* Move to next vertex */
34199 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
34200 				wo2 = (wo2 >> 23);		/* Extract weighting value */
34201 				vwe = wo1 - wo2;		/* Baricentric weighting */
34202 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
34203 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
34204 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
34205 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
34206 				vof += nvof;			/* Move to next vertex */
34207 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
34208 				wo3 = (wo3 >> 23);		/* Extract weighting value */
34209 				vwe = wo2 - wo3;		/* Baricentric weighting */
34210 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
34211 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
34212 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
34213 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
34214 				vof += nvof;			/* Move to next vertex */
34215 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
34216 				wo4 = (wo4 >> 23);		/* Extract weighting value */
34217 				vwe = wo3 - wo4;		/* Baricentric weighting */
34218 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
34219 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
34220 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
34221 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
34222 				vof += nvof;			/* Move to next vertex */
34223 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
34224 				wo5 = (wo5 >> 23);		/* Extract weighting value */
34225 				vwe = wo4 - wo5;		/* Baricentric weighting */
34226 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
34227 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
34228 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
34229 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
34230 				vof += nvof;			/* Move to next vertex */
34231 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
34232 				wo6 = (wo6 >> 23);		/* Extract weighting value */
34233 				vwe = wo5 - wo6;		/* Baricentric weighting */
34234 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
34235 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
34236 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
34237 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
34238 				vof += nvof;			/* Move to next vertex */
34239 				vwe = wo6;				/* Baricentric weighting */
34240 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
34241 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
34242 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
34243 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
34244 			}
34245 		}
34246 		{
34247 			unsigned int oti;	/* Vertex offset value */
34248 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
34249 			op0[0] = OT_E(ot0, oti);	/* Write result */
34250 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
34251 			op0[1] = OT_E(ot1, oti);	/* Write result */
34252 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
34253 			op0[2] = OT_E(ot2, oti);	/* Write result */
34254 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
34255 			op0[3] = OT_E(ot3, oti);	/* Write result */
34256 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
34257 			op0[4] = OT_E(ot4, oti);	/* Write result */
34258 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
34259 			op0[5] = OT_E(ot5, oti);	/* Write result */
34260 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
34261 			op0[6] = OT_E(ot6, oti);	/* Write result */
34262 			oti = ((ova3 >> 24) & 0xff);	/* Extract integer part of result */
34263 			op0[7] = OT_E(ot7, oti);	/* Write result */
34264 		}
34265 	}
34266 }
34267 #undef IT_WO
34268 #undef IT_IX
34269 #undef CEX
34270 #undef IM_O
34271 #undef IM_FE
34272 #undef OT_E
34273 
34274 void
imdi_k97_gen(genspec * g)34275 imdi_k97_gen(
34276 genspec *g			/* structure to be initialised */
34277 ) {
34278 	static unsigned char data[] = {
34279 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
34280 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34281 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34282 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34283 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34284 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34285 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34286 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
34287 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
34288 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
34289 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
34290 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34291 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34292 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34293 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34294 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34295 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34296 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34297 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34298 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34299 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34300 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34301 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34302 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34303 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34304 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34305 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34306 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34307 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34308 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34309 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34310 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34311 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34312 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34313 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34314 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34315 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34316 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34317 		0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34318 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
34319 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
34320 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
34321 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
34322 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
34323 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
34324 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
34325 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
34326 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
34327 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34328 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
34329 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
34330 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x38, 0x5f,
34331 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
34332 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
34333 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
34334 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
34335 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
34336 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
34337 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
34338 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34339 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34340 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34341 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34342 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
34343 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x39, 0x37,
34344 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34345 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34346 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
34347 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
34348 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
34349 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
34350 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
34351 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
34352 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
34353 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
34354 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
34355 		0x00, 0xf0, 0x04, 0x08
34356 	};	/* Structure image */
34357 
34358 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
34359 }
34360 
34361 void
imdi_k97_tab(tabspec * t)34362 imdi_k97_tab(
34363 tabspec *t			/* structure to be initialised */
34364 ) {
34365 	static unsigned char data[] = {
34366 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34367 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34368 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34369 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
34370 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
34371 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
34372 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34373 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
34374 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
34375 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34376 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
34377 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
34378 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
34379 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
34380 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
34381 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34382 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34383 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
34384 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34385 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34386 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34387 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
34388 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
34389 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
34390 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34391 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34392 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34393 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34394 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34395 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34396 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34397 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34398 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
34399 	};	/* Structure image */
34400 
34401 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
34402 }
34403 
34404 
34405 
34406 
34407 
34408 
34409 /* Integer Multi-Dimensional Interpolation */
34410 /* Interpolation Kernel Code */
34411 /* Generated by cgen */
34412 /* Copyright 2000 - 2002 Graeme W. Gill */
34413 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
34414 
34415 /* see the Licence.txt file for licencing details.*/
34416 
34417 
34418 /*
34419    Interpolation kernel specs:
34420 
34421    Input channels per pixel = 8
34422    Input channel 0 bits = 8
34423    Input channel 0 increment = 8
34424    Input channel 1 bits = 8
34425    Input channel 1 increment = 8
34426    Input channel 2 bits = 8
34427    Input channel 2 increment = 8
34428    Input channel 3 bits = 8
34429    Input channel 3 increment = 8
34430    Input channel 4 bits = 8
34431    Input channel 4 increment = 8
34432    Input channel 5 bits = 8
34433    Input channel 5 increment = 8
34434    Input channel 6 bits = 8
34435    Input channel 6 increment = 8
34436    Input channel 7 bits = 8
34437    Input channel 7 increment = 8
34438    Input is channel interleaved
34439    Input channels are separate words
34440    Input value extraction is done in input table lookup
34441 
34442    Output channels per pixel = 8
34443    Output channel 0 bits = 16
34444    Output channel 0 increment = 8
34445    Output channel 1 bits = 16
34446    Output channel 1 increment = 8
34447    Output channel 2 bits = 16
34448    Output channel 2 increment = 8
34449    Output channel 3 bits = 16
34450    Output channel 3 increment = 8
34451    Output channel 4 bits = 16
34452    Output channel 4 increment = 8
34453    Output channel 5 bits = 16
34454    Output channel 5 increment = 8
34455    Output channel 6 bits = 16
34456    Output channel 6 increment = 8
34457    Output channel 7 bits = 16
34458    Output channel 7 increment = 8
34459    Output is channel interleaved
34460 
34461    Output channels are separate words
34462    Weight+voffset bits       = 32
34463    Interpolation table index bits = 32
34464    Interpolation table max resolution = 8
34465  */
34466 
34467 /*
34468    Machine architecture specs:
34469 
34470    Little endian
34471    Reading and writing pixel values separately
34472    Pointer size = 32 bits
34473 
34474    Ordinal size  8 bits is known as 'unsigned char'
34475    Ordinal size 16 bits is known as 'unsigned short'
34476    Ordinal size 32 bits is known as 'unsigned int'
34477    Natural ordinal is 'unsigned int'
34478 
34479    Integer size  8 bits is known as 'signed char'
34480    Integer size 16 bits is known as 'short'
34481    Integer size 32 bits is known as 'int'
34482    Natural integer is 'int'
34483 
34484  */
34485 
34486 #ifndef  IMDI_INCLUDED
34487 #include <memory.h>
34488 #include "imdi_imp.h"
34489 #define  IMDI_INCLUDED
34490 #endif  /* IMDI_INCLUDED */
34491 
34492 #ifndef DEFINED_pointer
34493 #define DEFINED_pointer
34494 typedef unsigned char * pointer;
34495 #endif
34496 
34497 /* Input table interp. index */
34498 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
34499 
34500 /* Input table input weighting/offset value enty */
34501 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
34502 
34503 /* Conditional exchange for sorting */
34504 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
34505 
34506 /* Interpolation multi-dim. table access */
34507 #define IM_O(off) ((off) * 16)
34508 
34509 /* Interpolation table - get vertex values */
34510 #define IM_FE(p, v, c) *((unsigned int *)((p) + (v) * 8 + (c) * 4))
34511 
34512 /* Output table indexes */
34513 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
34514 
34515 void
imdi_k98(imdi * s,void ** outp,void ** inp,unsigned int npix)34516 imdi_k98(
34517 imdi *s,			/* imdi context */
34518 void **outp,		/* pointer to output pointers */
34519 void **inp,		/* pointer to input pointers */
34520 unsigned int npix	/* Number of pixels to process */
34521 ) {
34522 	imdi_imp *p = (imdi_imp *)(s->impl);
34523 	unsigned char *ip0 = (unsigned char *)inp[0];
34524 	unsigned short *op0 = (unsigned short *)outp[0];
34525 	unsigned char *ep = ip0 + npix * 8 ;
34526 	pointer it0 = (pointer)p->in_tables[0];
34527 	pointer it1 = (pointer)p->in_tables[1];
34528 	pointer it2 = (pointer)p->in_tables[2];
34529 	pointer it3 = (pointer)p->in_tables[3];
34530 	pointer it4 = (pointer)p->in_tables[4];
34531 	pointer it5 = (pointer)p->in_tables[5];
34532 	pointer it6 = (pointer)p->in_tables[6];
34533 	pointer it7 = (pointer)p->in_tables[7];
34534 	pointer ot0 = (pointer)p->out_tables[0];
34535 	pointer ot1 = (pointer)p->out_tables[1];
34536 	pointer ot2 = (pointer)p->out_tables[2];
34537 	pointer ot3 = (pointer)p->out_tables[3];
34538 	pointer ot4 = (pointer)p->out_tables[4];
34539 	pointer ot5 = (pointer)p->out_tables[5];
34540 	pointer ot6 = (pointer)p->out_tables[6];
34541 	pointer ot7 = (pointer)p->out_tables[7];
34542 	pointer im_base = (pointer)p->im_table;
34543 
34544 	for(;ip0 < ep; ip0 += 8, op0 += 8) {
34545 		unsigned int ova0;	/* Output value accumulator */
34546 		unsigned int ova1;	/* Output value accumulator */
34547 		unsigned int ova2;	/* Output value accumulator */
34548 		unsigned int ova3;	/* Output value accumulator */
34549 		{
34550 			pointer imp;
34551 			unsigned int wo0;	/* Weighting value and vertex offset variable */
34552 			unsigned int wo1;	/* Weighting value and vertex offset variable */
34553 			unsigned int wo2;	/* Weighting value and vertex offset variable */
34554 			unsigned int wo3;	/* Weighting value and vertex offset variable */
34555 			unsigned int wo4;	/* Weighting value and vertex offset variable */
34556 			unsigned int wo5;	/* Weighting value and vertex offset variable */
34557 			unsigned int wo6;	/* Weighting value and vertex offset variable */
34558 			unsigned int wo7;	/* Weighting value and vertex offset variable */
34559 			{
34560 				unsigned int ti_i;	/* Interpolation index variable */
34561 
34562 				ti_i  = IT_IX(it0, ip0[0]);
34563 				wo0   = IT_WO(it0, ip0[0]);
34564 				ti_i += IT_IX(it1, ip0[1]);
34565 				wo1   = IT_WO(it1, ip0[1]);
34566 				ti_i += IT_IX(it2, ip0[2]);
34567 				wo2   = IT_WO(it2, ip0[2]);
34568 				ti_i += IT_IX(it3, ip0[3]);
34569 				wo3   = IT_WO(it3, ip0[3]);
34570 				ti_i += IT_IX(it4, ip0[4]);
34571 				wo4   = IT_WO(it4, ip0[4]);
34572 				ti_i += IT_IX(it5, ip0[5]);
34573 				wo5   = IT_WO(it5, ip0[5]);
34574 				ti_i += IT_IX(it6, ip0[6]);
34575 				wo6   = IT_WO(it6, ip0[6]);
34576 				ti_i += IT_IX(it7, ip0[7]);
34577 				wo7   = IT_WO(it7, ip0[7]);
34578 
34579 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
34580 
34581 				/* Sort weighting values and vertex offset values */
34582 				CEX(wo0, wo1);
34583 				CEX(wo0, wo2);
34584 				CEX(wo0, wo3);
34585 				CEX(wo0, wo4);
34586 				CEX(wo0, wo5);
34587 				CEX(wo0, wo6);
34588 				CEX(wo0, wo7);
34589 				CEX(wo1, wo2);
34590 				CEX(wo1, wo3);
34591 				CEX(wo1, wo4);
34592 				CEX(wo1, wo5);
34593 				CEX(wo1, wo6);
34594 				CEX(wo1, wo7);
34595 				CEX(wo2, wo3);
34596 				CEX(wo2, wo4);
34597 				CEX(wo2, wo5);
34598 				CEX(wo2, wo6);
34599 				CEX(wo2, wo7);
34600 				CEX(wo3, wo4);
34601 				CEX(wo3, wo5);
34602 				CEX(wo3, wo6);
34603 				CEX(wo3, wo7);
34604 				CEX(wo4, wo5);
34605 				CEX(wo4, wo6);
34606 				CEX(wo4, wo7);
34607 				CEX(wo5, wo6);
34608 				CEX(wo5, wo7);
34609 				CEX(wo6, wo7);
34610 			}
34611 			{
34612 				unsigned int nvof;	/* Next vertex offset value */
34613 				unsigned int vof;	/* Vertex offset value */
34614 				unsigned int vwe;	/* Vertex weighting */
34615 
34616 				vof = 0;				/* First vertex offset is 0 */
34617 				nvof = (wo0 & 0x7fffff);	/* Extract offset value */
34618 				wo0 = (wo0 >> 23);		/* Extract weighting value */
34619 				vwe = 256 - wo0;		/* Baricentric weighting */
34620 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
34621 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
34622 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
34623 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
34624 				vof += nvof;			/* Move to next vertex */
34625 				nvof = (wo1 & 0x7fffff);	/* Extract offset value */
34626 				wo1 = (wo1 >> 23);		/* Extract weighting value */
34627 				vwe = wo0 - wo1;		/* Baricentric weighting */
34628 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
34629 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
34630 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
34631 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
34632 				vof += nvof;			/* Move to next vertex */
34633 				nvof = (wo2 & 0x7fffff);	/* Extract offset value */
34634 				wo2 = (wo2 >> 23);		/* Extract weighting value */
34635 				vwe = wo1 - wo2;		/* Baricentric weighting */
34636 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
34637 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
34638 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
34639 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
34640 				vof += nvof;			/* Move to next vertex */
34641 				nvof = (wo3 & 0x7fffff);	/* Extract offset value */
34642 				wo3 = (wo3 >> 23);		/* Extract weighting value */
34643 				vwe = wo2 - wo3;		/* Baricentric weighting */
34644 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
34645 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
34646 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
34647 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
34648 				vof += nvof;			/* Move to next vertex */
34649 				nvof = (wo4 & 0x7fffff);	/* Extract offset value */
34650 				wo4 = (wo4 >> 23);		/* Extract weighting value */
34651 				vwe = wo3 - wo4;		/* Baricentric weighting */
34652 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
34653 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
34654 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
34655 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
34656 				vof += nvof;			/* Move to next vertex */
34657 				nvof = (wo5 & 0x7fffff);	/* Extract offset value */
34658 				wo5 = (wo5 >> 23);		/* Extract weighting value */
34659 				vwe = wo4 - wo5;		/* Baricentric weighting */
34660 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
34661 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
34662 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
34663 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
34664 				vof += nvof;			/* Move to next vertex */
34665 				nvof = (wo6 & 0x7fffff);	/* Extract offset value */
34666 				wo6 = (wo6 >> 23);		/* Extract weighting value */
34667 				vwe = wo5 - wo6;		/* Baricentric weighting */
34668 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
34669 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
34670 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
34671 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
34672 				vof += nvof;			/* Move to next vertex */
34673 				nvof = (wo7 & 0x7fffff);	/* Extract offset value */
34674 				wo7 = (wo7 >> 23);		/* Extract weighting value */
34675 				vwe = wo6 - wo7;		/* Baricentric weighting */
34676 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
34677 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
34678 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
34679 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
34680 				vof += nvof;			/* Move to next vertex */
34681 				vwe = wo7;				/* Baricentric weighting */
34682 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
34683 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
34684 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
34685 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
34686 			}
34687 		}
34688 		{
34689 			unsigned int oti;	/* Vertex offset value */
34690 			oti = ((ova0 >> 8) & 0xff);	/* Extract integer part of result */
34691 			op0[0] = OT_E(ot0, oti);	/* Write result */
34692 			oti = ((ova0 >> 24) & 0xff);	/* Extract integer part of result */
34693 			op0[1] = OT_E(ot1, oti);	/* Write result */
34694 			oti = ((ova1 >> 8) & 0xff);	/* Extract integer part of result */
34695 			op0[2] = OT_E(ot2, oti);	/* Write result */
34696 			oti = ((ova1 >> 24) & 0xff);	/* Extract integer part of result */
34697 			op0[3] = OT_E(ot3, oti);	/* Write result */
34698 			oti = ((ova2 >> 8) & 0xff);	/* Extract integer part of result */
34699 			op0[4] = OT_E(ot4, oti);	/* Write result */
34700 			oti = ((ova2 >> 24) & 0xff);	/* Extract integer part of result */
34701 			op0[5] = OT_E(ot5, oti);	/* Write result */
34702 			oti = ((ova3 >> 8) & 0xff);	/* Extract integer part of result */
34703 			op0[6] = OT_E(ot6, oti);	/* Write result */
34704 			oti = ((ova3 >> 24) & 0xff);	/* Extract integer part of result */
34705 			op0[7] = OT_E(ot7, oti);	/* Write result */
34706 		}
34707 	}
34708 }
34709 #undef IT_WO
34710 #undef IT_IX
34711 #undef CEX
34712 #undef IM_O
34713 #undef IM_FE
34714 #undef OT_E
34715 
34716 void
imdi_k98_gen(genspec * g)34717 imdi_k98_gen(
34718 genspec *g			/* structure to be initialised */
34719 ) {
34720 	static unsigned char data[] = {
34721 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34722 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34723 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34724 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34725 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34726 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34727 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34728 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34729 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34730 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34731 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34732 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34733 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34734 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34735 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34736 		0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34737 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34738 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34739 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34740 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34741 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34742 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34743 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34744 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34745 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34746 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34747 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34748 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34749 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34750 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34751 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34752 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34753 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34754 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34755 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34756 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34757 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34758 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34759 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34760 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
34761 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
34762 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
34763 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
34764 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
34765 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
34766 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
34767 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
34768 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
34769 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34770 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
34771 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
34772 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x38, 0x5f,
34773 		0x69, 0x38, 0x5f, 0x69, 0x31, 0x36, 0x5f, 0x66,
34774 		0x00, 0xff, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
34775 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
34776 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
34777 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
34778 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
34779 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
34780 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34781 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34782 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34783 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34784 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
34785 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x39, 0x38,
34786 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34787 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34788 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
34789 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
34790 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
34791 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
34792 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
34793 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
34794 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
34795 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
34796 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
34797 		0x00, 0xf0, 0x04, 0x08
34798 	};	/* Structure image */
34799 
34800 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
34801 }
34802 
34803 void
imdi_k98_tab(tabspec * t)34804 imdi_k98_tab(
34805 tabspec *t			/* structure to be initialised */
34806 ) {
34807 	static unsigned char data[] = {
34808 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34809 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34810 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34811 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
34812 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
34813 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
34814 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34815 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
34816 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
34817 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34818 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
34819 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
34820 		0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
34821 		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
34822 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
34823 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34824 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34825 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
34826 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34827 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34828 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34829 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
34830 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
34831 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
34832 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34833 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34834 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34835 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34836 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34837 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34838 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34839 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34840 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
34841 	};	/* Structure image */
34842 
34843 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
34844 }
34845 
34846 
34847 
34848 
34849 
34850 
34851 /* Integer Multi-Dimensional Interpolation */
34852 /* Interpolation Kernel Code */
34853 /* Generated by cgen */
34854 /* Copyright 2000 - 2002 Graeme W. Gill */
34855 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
34856 
34857 /* see the Licence.txt file for licencing details.*/
34858 
34859 
34860 /*
34861    Interpolation kernel specs:
34862 
34863    Input channels per pixel = 1
34864    Input channel 0 bits = 16
34865    Input channel 0 increment = 1
34866    Input is channel interleaved
34867    Input channels are separate words
34868    Input value extraction is done in input table lookup
34869 
34870    Output channels per pixel = 1
34871    Output channel 0 bits = 16
34872    Output channel 0 increment = 1
34873    Output is channel interleaved
34874 
34875    Output channels are separate words
34876    Weight+voffset bits       = 32
34877    Interpolation table index bits = 12
34878    Interpolation table max resolution = 4095
34879  */
34880 
34881 /*
34882    Machine architecture specs:
34883 
34884    Little endian
34885    Reading and writing pixel values separately
34886    Pointer size = 32 bits
34887 
34888    Ordinal size  8 bits is known as 'unsigned char'
34889    Ordinal size 16 bits is known as 'unsigned short'
34890    Ordinal size 32 bits is known as 'unsigned int'
34891    Natural ordinal is 'unsigned int'
34892 
34893    Integer size  8 bits is known as 'signed char'
34894    Integer size 16 bits is known as 'short'
34895    Integer size 32 bits is known as 'int'
34896    Natural integer is 'int'
34897 
34898  */
34899 
34900 #ifndef  IMDI_INCLUDED
34901 #include <memory.h>
34902 #include "imdi_imp.h"
34903 #define  IMDI_INCLUDED
34904 #endif  /* IMDI_INCLUDED */
34905 
34906 #ifndef DEFINED_pointer
34907 #define DEFINED_pointer
34908 typedef unsigned char * pointer;
34909 #endif
34910 
34911 /* Input table interp index, weighting and vertex offset */
34912 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
34913 
34914 /* Conditional exchange for sorting */
34915 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
34916 
34917 /* Interpolation multi-dim. table access */
34918 #define IM_O(off) ((off) * 2)
34919 
34920 /* Interpolation table - get vertex values */
34921 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
34922 
34923 /* Output table indexes */
34924 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
34925 
34926 void
imdi_k99(imdi * s,void ** outp,void ** inp,unsigned int npix)34927 imdi_k99(
34928 imdi *s,			/* imdi context */
34929 void **outp,		/* pointer to output pointers */
34930 void **inp,		/* pointer to input pointers */
34931 unsigned int npix	/* Number of pixels to process */
34932 ) {
34933 	imdi_imp *p = (imdi_imp *)(s->impl);
34934 	unsigned short *ip0 = (unsigned short *)inp[0];
34935 	unsigned short *op0 = (unsigned short *)outp[0];
34936 	unsigned short *ep = ip0 + npix * 1 ;
34937 	pointer it0 = (pointer)p->in_tables[0];
34938 	pointer ot0 = (pointer)p->out_tables[0];
34939 	pointer im_base = (pointer)p->im_table;
34940 
34941 	for(;ip0 < ep; ip0 += 1, op0 += 1) {
34942 		unsigned int ova0;	/* Output value accumulator */
34943 		{
34944 			pointer imp;
34945 			unsigned int wo0;	/* Weighting value and vertex offset variable */
34946 			{
34947 				unsigned int ti;		/* Input table entry variable */
34948 				unsigned int ti_i;	/* Interpolation index variable */
34949 
34950 				ti = IT_IT(it0, ip0[0]);
34951 				wo0   = (ti & 0xfffff);	/* Extract weighting/vertex offset value */
34952 				ti_i  = (ti >> 20);	/* Extract interpolation table value */
34953 
34954 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
34955 
34956 				/* Sort weighting values and vertex offset values */
34957 			}
34958 			{
34959 				unsigned int nvof;	/* Next vertex offset value */
34960 				unsigned int vof;	/* Vertex offset value */
34961 				unsigned int vwe;	/* Vertex weighting */
34962 
34963 				vof = 0;				/* First vertex offset is 0 */
34964 				nvof = (wo0 & 0x7);	/* Extract offset value */
34965 				wo0 = (wo0 >> 3);		/* Extract weighting value */
34966 				vwe = 65536 - wo0;		/* Baricentric weighting */
34967 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
34968 				vof += nvof;			/* Move to next vertex */
34969 				vwe = wo0;				/* Baricentric weighting */
34970 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
34971 			}
34972 		}
34973 		{
34974 			unsigned int oti;	/* Vertex offset value */
34975 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
34976 			op0[0] = OT_E(ot0, oti);	/* Write result */
34977 		}
34978 	}
34979 }
34980 #undef IT_IT
34981 #undef CEX
34982 #undef IM_O
34983 #undef IM_FE
34984 #undef OT_E
34985 
34986 void
imdi_k99_gen(genspec * g)34987 imdi_k99_gen(
34988 genspec *g			/* structure to be initialised */
34989 ) {
34990 	static unsigned char data[] = {
34991 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34992 		0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
34993 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34994 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
34995 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34996 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34997 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34998 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
34999 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35000 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35001 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35002 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35003 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35004 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35005 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35006 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35007 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35008 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35009 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35010 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35011 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35012 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35013 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35014 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35015 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35016 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35017 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35018 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35019 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35020 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35021 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35022 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35023 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35024 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35025 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35026 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35027 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35028 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35029 		0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35030 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
35031 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
35032 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
35033 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
35034 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
35035 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
35036 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
35037 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
35038 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
35039 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35040 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
35041 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
35042 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x31, 0x5f,
35043 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
35044 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
35045 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
35046 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
35047 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
35048 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
35049 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
35050 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35051 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35052 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35053 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35054 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
35055 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x39, 0x39,
35056 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35057 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35058 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
35059 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
35060 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
35061 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
35062 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
35063 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
35064 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
35065 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
35066 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
35067 		0x00, 0xf0, 0x04, 0x08
35068 	};	/* Structure image */
35069 
35070 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
35071 }
35072 
35073 void
imdi_k99_tab(tabspec * t)35074 imdi_k99_tab(
35075 tabspec *t			/* structure to be initialised */
35076 ) {
35077 	static unsigned char data[] = {
35078 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35079 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35080 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35081 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
35082 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
35083 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
35084 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
35085 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
35086 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
35087 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35088 		0x14, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
35089 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
35090 		0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
35091 		0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
35092 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
35093 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35094 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
35095 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35096 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35097 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35098 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
35099 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
35100 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
35101 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
35102 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35103 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
35104 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
35105 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
35106 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35107 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
35108 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
35109 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
35110 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
35111 	};	/* Structure image */
35112 
35113 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
35114 }
35115 
35116 
35117 
35118 
35119 
35120 
35121 /* Integer Multi-Dimensional Interpolation */
35122 /* Interpolation Kernel Code */
35123 /* Generated by cgen */
35124 /* Copyright 2000 - 2002 Graeme W. Gill */
35125 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
35126 
35127 /* see the Licence.txt file for licencing details.*/
35128 
35129 
35130 /*
35131    Interpolation kernel specs:
35132 
35133    Input channels per pixel = 3
35134    Input channel 0 bits = 16
35135    Input channel 0 increment = 3
35136    Input channel 1 bits = 16
35137    Input channel 1 increment = 3
35138    Input channel 2 bits = 16
35139    Input channel 2 increment = 3
35140    Input is channel interleaved
35141    Input channels are separate words
35142    Input value extraction is done in input table lookup
35143 
35144    Output channels per pixel = 1
35145    Output channel 0 bits = 16
35146    Output channel 0 increment = 1
35147    Output is channel interleaved
35148 
35149    Output channels are separate words
35150    Weight+voffset bits       = 32
35151    Interpolation table index bits = 16
35152    Interpolation table max resolution = 40
35153  */
35154 
35155 /*
35156    Machine architecture specs:
35157 
35158    Little endian
35159    Reading and writing pixel values separately
35160    Pointer size = 32 bits
35161 
35162    Ordinal size  8 bits is known as 'unsigned char'
35163    Ordinal size 16 bits is known as 'unsigned short'
35164    Ordinal size 32 bits is known as 'unsigned int'
35165    Natural ordinal is 'unsigned int'
35166 
35167    Integer size  8 bits is known as 'signed char'
35168    Integer size 16 bits is known as 'short'
35169    Integer size 32 bits is known as 'int'
35170    Natural integer is 'int'
35171 
35172  */
35173 
35174 #ifndef  IMDI_INCLUDED
35175 #include <memory.h>
35176 #include "imdi_imp.h"
35177 #define  IMDI_INCLUDED
35178 #endif  /* IMDI_INCLUDED */
35179 
35180 #ifndef DEFINED_pointer
35181 #define DEFINED_pointer
35182 typedef unsigned char * pointer;
35183 #endif
35184 
35185 /* Input table interp. index */
35186 #define IT_IX(p, off) *((unsigned short *)((p) + 0 + (off) * 6))
35187 
35188 /* Input table input weighting/offset value enty */
35189 #define IT_WO(p, off) *((unsigned int *)((p) + 2 + (off) * 6))
35190 
35191 /* Conditional exchange for sorting */
35192 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
35193 
35194 /* Interpolation multi-dim. table access */
35195 #define IM_O(off) ((off) * 2)
35196 
35197 /* Interpolation table - get vertex values */
35198 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
35199 
35200 /* Output table indexes */
35201 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
35202 
35203 void
imdi_k100(imdi * s,void ** outp,void ** inp,unsigned int npix)35204 imdi_k100(
35205 imdi *s,			/* imdi context */
35206 void **outp,		/* pointer to output pointers */
35207 void **inp,		/* pointer to input pointers */
35208 unsigned int npix	/* Number of pixels to process */
35209 ) {
35210 	imdi_imp *p = (imdi_imp *)(s->impl);
35211 	unsigned short *ip0 = (unsigned short *)inp[0];
35212 	unsigned short *op0 = (unsigned short *)outp[0];
35213 	unsigned short *ep = ip0 + npix * 3 ;
35214 	pointer it0 = (pointer)p->in_tables[0];
35215 	pointer it1 = (pointer)p->in_tables[1];
35216 	pointer it2 = (pointer)p->in_tables[2];
35217 	pointer ot0 = (pointer)p->out_tables[0];
35218 	pointer im_base = (pointer)p->im_table;
35219 
35220 	for(;ip0 < ep; ip0 += 3, op0 += 1) {
35221 		unsigned int ova0;	/* Output value accumulator */
35222 		{
35223 			pointer imp;
35224 			unsigned int wo0;	/* Weighting value and vertex offset variable */
35225 			unsigned int wo1;	/* Weighting value and vertex offset variable */
35226 			unsigned int wo2;	/* Weighting value and vertex offset variable */
35227 			{
35228 				unsigned int ti_i;	/* Interpolation index variable */
35229 
35230 				ti_i  = IT_IX(it0, ip0[0]);
35231 				wo0   = IT_WO(it0, ip0[0]);
35232 				ti_i += IT_IX(it1, ip0[1]);
35233 				wo1   = IT_WO(it1, ip0[1]);
35234 				ti_i += IT_IX(it2, ip0[2]);
35235 				wo2   = IT_WO(it2, ip0[2]);
35236 
35237 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
35238 
35239 				/* Sort weighting values and vertex offset values */
35240 				CEX(wo0, wo1);
35241 				CEX(wo0, wo2);
35242 				CEX(wo1, wo2);
35243 			}
35244 			{
35245 				unsigned int nvof;	/* Next vertex offset value */
35246 				unsigned int vof;	/* Vertex offset value */
35247 				unsigned int vwe;	/* Vertex weighting */
35248 
35249 				vof = 0;				/* First vertex offset is 0 */
35250 				nvof = (wo0 & 0x7fff);	/* Extract offset value */
35251 				wo0 = (wo0 >> 15);		/* Extract weighting value */
35252 				vwe = 65536 - wo0;		/* Baricentric weighting */
35253 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
35254 				vof += nvof;			/* Move to next vertex */
35255 				nvof = (wo1 & 0x7fff);	/* Extract offset value */
35256 				wo1 = (wo1 >> 15);		/* Extract weighting value */
35257 				vwe = wo0 - wo1;		/* Baricentric weighting */
35258 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
35259 				vof += nvof;			/* Move to next vertex */
35260 				nvof = (wo2 & 0x7fff);	/* Extract offset value */
35261 				wo2 = (wo2 >> 15);		/* Extract weighting value */
35262 				vwe = wo1 - wo2;		/* Baricentric weighting */
35263 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
35264 				vof += nvof;			/* Move to next vertex */
35265 				vwe = wo2;				/* Baricentric weighting */
35266 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
35267 			}
35268 		}
35269 		{
35270 			unsigned int oti;	/* Vertex offset value */
35271 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
35272 			op0[0] = OT_E(ot0, oti);	/* Write result */
35273 		}
35274 	}
35275 }
35276 #undef IT_WO
35277 #undef IT_IX
35278 #undef CEX
35279 #undef IM_O
35280 #undef IM_FE
35281 #undef OT_E
35282 
35283 void
imdi_k100_gen(genspec * g)35284 imdi_k100_gen(
35285 genspec *g			/* structure to be initialised */
35286 ) {
35287 	static unsigned char data[] = {
35288 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
35289 		0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
35290 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35291 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35292 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35293 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35294 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35295 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
35296 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
35297 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35298 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35299 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35300 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35301 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35302 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35303 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35304 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35305 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35306 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35307 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35308 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35309 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35310 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35311 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35312 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35313 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35314 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35315 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35316 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35317 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35318 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35319 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35320 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35321 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35322 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35323 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35324 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35325 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35326 		0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35327 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
35328 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
35329 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
35330 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
35331 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
35332 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
35333 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
35334 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
35335 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
35336 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35337 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
35338 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
35339 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x31, 0x5f,
35340 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
35341 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
35342 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
35343 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
35344 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
35345 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
35346 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
35347 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35348 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35349 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35350 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35351 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
35352 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x30,
35353 		0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35354 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35355 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
35356 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
35357 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
35358 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
35359 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
35360 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
35361 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
35362 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
35363 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
35364 		0x00, 0xf0, 0x04, 0x08
35365 	};	/* Structure image */
35366 
35367 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
35368 }
35369 
35370 void
imdi_k100_tab(tabspec * t)35371 imdi_k100_tab(
35372 tabspec *t			/* structure to be initialised */
35373 ) {
35374 	static unsigned char data[] = {
35375 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35376 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35377 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35378 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
35379 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
35380 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
35381 		0x20, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
35382 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
35383 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
35384 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35385 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
35386 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
35387 		0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
35388 		0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
35389 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
35390 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35391 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
35392 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35393 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35394 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35395 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
35396 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
35397 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
35398 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
35399 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35400 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
35401 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
35402 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
35403 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35404 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
35405 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
35406 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
35407 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
35408 	};	/* Structure image */
35409 
35410 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
35411 }
35412 
35413 
35414 
35415 
35416 
35417 
35418 /* Integer Multi-Dimensional Interpolation */
35419 /* Interpolation Kernel Code */
35420 /* Generated by cgen */
35421 /* Copyright 2000 - 2002 Graeme W. Gill */
35422 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
35423 
35424 /* see the Licence.txt file for licencing details.*/
35425 
35426 
35427 /*
35428    Interpolation kernel specs:
35429 
35430    Input channels per pixel = 4
35431    Input channel 0 bits = 16
35432    Input channel 0 increment = 4
35433    Input channel 1 bits = 16
35434    Input channel 1 increment = 4
35435    Input channel 2 bits = 16
35436    Input channel 2 increment = 4
35437    Input channel 3 bits = 16
35438    Input channel 3 increment = 4
35439    Input is channel interleaved
35440    Input channels are separate words
35441    Input value extraction is done in input table lookup
35442 
35443    Output channels per pixel = 1
35444    Output channel 0 bits = 16
35445    Output channel 0 increment = 1
35446    Output is channel interleaved
35447 
35448    Output channels are separate words
35449    Weight+voffset bits       = 32
35450    Interpolation table index bits = 32
35451    Interpolation table max resolution = 31
35452  */
35453 
35454 /*
35455    Machine architecture specs:
35456 
35457    Little endian
35458    Reading and writing pixel values separately
35459    Pointer size = 32 bits
35460 
35461    Ordinal size  8 bits is known as 'unsigned char'
35462    Ordinal size 16 bits is known as 'unsigned short'
35463    Ordinal size 32 bits is known as 'unsigned int'
35464    Natural ordinal is 'unsigned int'
35465 
35466    Integer size  8 bits is known as 'signed char'
35467    Integer size 16 bits is known as 'short'
35468    Integer size 32 bits is known as 'int'
35469    Natural integer is 'int'
35470 
35471  */
35472 
35473 #ifndef  IMDI_INCLUDED
35474 #include <memory.h>
35475 #include "imdi_imp.h"
35476 #define  IMDI_INCLUDED
35477 #endif  /* IMDI_INCLUDED */
35478 
35479 #ifndef DEFINED_pointer
35480 #define DEFINED_pointer
35481 typedef unsigned char * pointer;
35482 #endif
35483 
35484 /* Input table interp. index */
35485 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
35486 
35487 /* Input table input weighting/offset value enty */
35488 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
35489 
35490 /* Conditional exchange for sorting */
35491 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
35492 
35493 /* Interpolation multi-dim. table access */
35494 #define IM_O(off) ((off) * 2)
35495 
35496 /* Interpolation table - get vertex values */
35497 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
35498 
35499 /* Output table indexes */
35500 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
35501 
35502 void
imdi_k101(imdi * s,void ** outp,void ** inp,unsigned int npix)35503 imdi_k101(
35504 imdi *s,			/* imdi context */
35505 void **outp,		/* pointer to output pointers */
35506 void **inp,		/* pointer to input pointers */
35507 unsigned int npix	/* Number of pixels to process */
35508 ) {
35509 	imdi_imp *p = (imdi_imp *)(s->impl);
35510 	unsigned short *ip0 = (unsigned short *)inp[0];
35511 	unsigned short *op0 = (unsigned short *)outp[0];
35512 	unsigned short *ep = ip0 + npix * 4 ;
35513 	pointer it0 = (pointer)p->in_tables[0];
35514 	pointer it1 = (pointer)p->in_tables[1];
35515 	pointer it2 = (pointer)p->in_tables[2];
35516 	pointer it3 = (pointer)p->in_tables[3];
35517 	pointer ot0 = (pointer)p->out_tables[0];
35518 	pointer im_base = (pointer)p->im_table;
35519 
35520 	for(;ip0 < ep; ip0 += 4, op0 += 1) {
35521 		unsigned int ova0;	/* Output value accumulator */
35522 		{
35523 			pointer imp;
35524 			unsigned int wo0;	/* Weighting value and vertex offset variable */
35525 			unsigned int wo1;	/* Weighting value and vertex offset variable */
35526 			unsigned int wo2;	/* Weighting value and vertex offset variable */
35527 			unsigned int wo3;	/* Weighting value and vertex offset variable */
35528 			{
35529 				unsigned int ti_i;	/* Interpolation index variable */
35530 
35531 				ti_i  = IT_IX(it0, ip0[0]);
35532 				wo0   = IT_WO(it0, ip0[0]);
35533 				ti_i += IT_IX(it1, ip0[1]);
35534 				wo1   = IT_WO(it1, ip0[1]);
35535 				ti_i += IT_IX(it2, ip0[2]);
35536 				wo2   = IT_WO(it2, ip0[2]);
35537 				ti_i += IT_IX(it3, ip0[3]);
35538 				wo3   = IT_WO(it3, ip0[3]);
35539 
35540 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
35541 
35542 				/* Sort weighting values and vertex offset values */
35543 				CEX(wo0, wo1);
35544 				CEX(wo0, wo2);
35545 				CEX(wo0, wo3);
35546 				CEX(wo1, wo2);
35547 				CEX(wo1, wo3);
35548 				CEX(wo2, wo3);
35549 			}
35550 			{
35551 				unsigned int nvof;	/* Next vertex offset value */
35552 				unsigned int vof;	/* Vertex offset value */
35553 				unsigned int vwe;	/* Vertex weighting */
35554 
35555 				vof = 0;				/* First vertex offset is 0 */
35556 				nvof = (wo0 & 0x7fff);	/* Extract offset value */
35557 				wo0 = (wo0 >> 15);		/* Extract weighting value */
35558 				vwe = 65536 - wo0;		/* Baricentric weighting */
35559 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
35560 				vof += nvof;			/* Move to next vertex */
35561 				nvof = (wo1 & 0x7fff);	/* Extract offset value */
35562 				wo1 = (wo1 >> 15);		/* Extract weighting value */
35563 				vwe = wo0 - wo1;		/* Baricentric weighting */
35564 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
35565 				vof += nvof;			/* Move to next vertex */
35566 				nvof = (wo2 & 0x7fff);	/* Extract offset value */
35567 				wo2 = (wo2 >> 15);		/* Extract weighting value */
35568 				vwe = wo1 - wo2;		/* Baricentric weighting */
35569 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
35570 				vof += nvof;			/* Move to next vertex */
35571 				nvof = (wo3 & 0x7fff);	/* Extract offset value */
35572 				wo3 = (wo3 >> 15);		/* Extract weighting value */
35573 				vwe = wo2 - wo3;		/* Baricentric weighting */
35574 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
35575 				vof += nvof;			/* Move to next vertex */
35576 				vwe = wo3;				/* Baricentric weighting */
35577 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
35578 			}
35579 		}
35580 		{
35581 			unsigned int oti;	/* Vertex offset value */
35582 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
35583 			op0[0] = OT_E(ot0, oti);	/* Write result */
35584 		}
35585 	}
35586 }
35587 #undef IT_WO
35588 #undef IT_IX
35589 #undef CEX
35590 #undef IM_O
35591 #undef IM_FE
35592 #undef OT_E
35593 
35594 void
imdi_k101_gen(genspec * g)35595 imdi_k101_gen(
35596 genspec *g			/* structure to be initialised */
35597 ) {
35598 	static unsigned char data[] = {
35599 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
35600 		0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
35601 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35602 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35603 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35604 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35605 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35606 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
35607 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
35608 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35609 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35610 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35611 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35612 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35613 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35614 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35615 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35616 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35617 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35618 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35619 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35620 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35621 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35622 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35623 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35624 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35625 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35626 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35627 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35628 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35629 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35630 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35631 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35632 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35633 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35634 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35635 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35636 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35637 		0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35638 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
35639 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
35640 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
35641 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
35642 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
35643 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
35644 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
35645 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
35646 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
35647 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35648 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
35649 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
35650 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x31, 0x5f,
35651 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
35652 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
35653 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
35654 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
35655 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
35656 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
35657 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
35658 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35659 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35660 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35661 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35662 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
35663 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x30,
35664 		0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35665 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35666 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
35667 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
35668 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
35669 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
35670 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
35671 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
35672 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
35673 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
35674 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
35675 		0x00, 0xf0, 0x04, 0x08
35676 	};	/* Structure image */
35677 
35678 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
35679 }
35680 
35681 void
imdi_k101_tab(tabspec * t)35682 imdi_k101_tab(
35683 tabspec *t			/* structure to be initialised */
35684 ) {
35685 	static unsigned char data[] = {
35686 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35687 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35688 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35689 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
35690 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
35691 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
35692 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35693 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
35694 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
35695 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35696 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
35697 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
35698 		0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
35699 		0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
35700 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
35701 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35702 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
35703 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35704 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35705 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35706 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
35707 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
35708 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
35709 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
35710 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35711 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
35712 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
35713 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
35714 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35715 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
35716 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
35717 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
35718 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
35719 	};	/* Structure image */
35720 
35721 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
35722 }
35723 
35724 
35725 
35726 
35727 
35728 
35729 /* Integer Multi-Dimensional Interpolation */
35730 /* Interpolation Kernel Code */
35731 /* Generated by cgen */
35732 /* Copyright 2000 - 2002 Graeme W. Gill */
35733 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
35734 
35735 /* see the Licence.txt file for licencing details.*/
35736 
35737 
35738 /*
35739    Interpolation kernel specs:
35740 
35741    Input channels per pixel = 5
35742    Input channel 0 bits = 16
35743    Input channel 0 increment = 5
35744    Input channel 1 bits = 16
35745    Input channel 1 increment = 5
35746    Input channel 2 bits = 16
35747    Input channel 2 increment = 5
35748    Input channel 3 bits = 16
35749    Input channel 3 increment = 5
35750    Input channel 4 bits = 16
35751    Input channel 4 increment = 5
35752    Input is channel interleaved
35753    Input channels are separate words
35754    Input value extraction is done in input table lookup
35755 
35756    Output channels per pixel = 1
35757    Output channel 0 bits = 16
35758    Output channel 0 increment = 1
35759    Output is channel interleaved
35760 
35761    Output channels are separate words
35762    Weight+voffset bits       = 32
35763    Interpolation table index bits = 32
35764    Interpolation table max resolution = 84
35765  */
35766 
35767 /*
35768    Machine architecture specs:
35769 
35770    Little endian
35771    Reading and writing pixel values separately
35772    Pointer size = 32 bits
35773 
35774    Ordinal size  8 bits is known as 'unsigned char'
35775    Ordinal size 16 bits is known as 'unsigned short'
35776    Ordinal size 32 bits is known as 'unsigned int'
35777    Natural ordinal is 'unsigned int'
35778 
35779    Integer size  8 bits is known as 'signed char'
35780    Integer size 16 bits is known as 'short'
35781    Integer size 32 bits is known as 'int'
35782    Natural integer is 'int'
35783 
35784  */
35785 
35786 #ifndef  IMDI_INCLUDED
35787 #include <memory.h>
35788 #include "imdi_imp.h"
35789 #define  IMDI_INCLUDED
35790 #endif  /* IMDI_INCLUDED */
35791 
35792 #ifndef DEFINED_pointer
35793 #define DEFINED_pointer
35794 typedef unsigned char * pointer;
35795 #endif
35796 
35797 /* Input table interp. index */
35798 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
35799 
35800 /* Input table input weighting enty */
35801 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
35802 
35803 /* Input table input offset value enty */
35804 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
35805 
35806 /* Conditional exchange for sorting */
35807 #define CEX(A, AA, B, BB) if (A < B) { \
35808             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
35809 
35810 /* Interpolation multi-dim. table access */
35811 #define IM_O(off) ((off) * 2)
35812 
35813 /* Interpolation table - get vertex values */
35814 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
35815 
35816 /* Output table indexes */
35817 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
35818 
35819 void
imdi_k102(imdi * s,void ** outp,void ** inp,unsigned int npix)35820 imdi_k102(
35821 imdi *s,			/* imdi context */
35822 void **outp,		/* pointer to output pointers */
35823 void **inp,		/* pointer to input pointers */
35824 unsigned int npix	/* Number of pixels to process */
35825 ) {
35826 	imdi_imp *p = (imdi_imp *)(s->impl);
35827 	unsigned short *ip0 = (unsigned short *)inp[0];
35828 	unsigned short *op0 = (unsigned short *)outp[0];
35829 	unsigned short *ep = ip0 + npix * 5 ;
35830 	pointer it0 = (pointer)p->in_tables[0];
35831 	pointer it1 = (pointer)p->in_tables[1];
35832 	pointer it2 = (pointer)p->in_tables[2];
35833 	pointer it3 = (pointer)p->in_tables[3];
35834 	pointer it4 = (pointer)p->in_tables[4];
35835 	pointer ot0 = (pointer)p->out_tables[0];
35836 	pointer im_base = (pointer)p->im_table;
35837 
35838 	for(;ip0 < ep; ip0 += 5, op0 += 1) {
35839 		unsigned int ova0;	/* Output value accumulator */
35840 		{
35841 			pointer imp;
35842 			unsigned int we0;	/* Weighting value variable */
35843 			unsigned int vo0;	/* Vertex offset variable */
35844 			unsigned int we1;	/* Weighting value variable */
35845 			unsigned int vo1;	/* Vertex offset variable */
35846 			unsigned int we2;	/* Weighting value variable */
35847 			unsigned int vo2;	/* Vertex offset variable */
35848 			unsigned int we3;	/* Weighting value variable */
35849 			unsigned int vo3;	/* Vertex offset variable */
35850 			unsigned int we4;	/* Weighting value variable */
35851 			unsigned int vo4;	/* Vertex offset variable */
35852 			{
35853 				unsigned int ti_i;	/* Interpolation index variable */
35854 
35855 				ti_i  = IT_IX(it0, ip0[0]);
35856 				we0   = IT_WE(it0, ip0[0]);
35857 				vo0   = IT_VO(it0, ip0[0]);
35858 				ti_i += IT_IX(it1, ip0[1]);
35859 				we1   = IT_WE(it1, ip0[1]);
35860 				vo1   = IT_VO(it1, ip0[1]);
35861 				ti_i += IT_IX(it2, ip0[2]);
35862 				we2   = IT_WE(it2, ip0[2]);
35863 				vo2   = IT_VO(it2, ip0[2]);
35864 				ti_i += IT_IX(it3, ip0[3]);
35865 				we3   = IT_WE(it3, ip0[3]);
35866 				vo3   = IT_VO(it3, ip0[3]);
35867 				ti_i += IT_IX(it4, ip0[4]);
35868 				we4   = IT_WE(it4, ip0[4]);
35869 				vo4   = IT_VO(it4, ip0[4]);
35870 
35871 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
35872 
35873 				/* Sort weighting values and vertex offset values */
35874 				CEX(we0, vo0, we1, vo1);
35875 				CEX(we0, vo0, we2, vo2);
35876 				CEX(we0, vo0, we3, vo3);
35877 				CEX(we0, vo0, we4, vo4);
35878 				CEX(we1, vo1, we2, vo2);
35879 				CEX(we1, vo1, we3, vo3);
35880 				CEX(we1, vo1, we4, vo4);
35881 				CEX(we2, vo2, we3, vo3);
35882 				CEX(we2, vo2, we4, vo4);
35883 				CEX(we3, vo3, we4, vo4);
35884 			}
35885 			{
35886 				unsigned int vof;	/* Vertex offset value */
35887 				unsigned int vwe;	/* Vertex weighting */
35888 
35889 				vof = 0;				/* First vertex offset is 0 */
35890 				vwe = 65536 - we0;		/* Baricentric weighting */
35891 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
35892 				vof += vo0;			/* Move to next vertex */
35893 				vwe = we0 - we1;		/* Baricentric weighting */
35894 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
35895 				vof += vo1;			/* Move to next vertex */
35896 				vwe = we1 - we2;		/* Baricentric weighting */
35897 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
35898 				vof += vo2;			/* Move to next vertex */
35899 				vwe = we2 - we3;		/* Baricentric weighting */
35900 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
35901 				vof += vo3;			/* Move to next vertex */
35902 				vwe = we3 - we4;		/* Baricentric weighting */
35903 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
35904 				vof += vo4;			/* Move to next vertex */
35905 				vwe = we4;				/* Baricentric weighting */
35906 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
35907 			}
35908 		}
35909 		{
35910 			unsigned int oti;	/* Vertex offset value */
35911 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
35912 			op0[0] = OT_E(ot0, oti);	/* Write result */
35913 		}
35914 	}
35915 }
35916 #undef IT_WE
35917 #undef IT_VO
35918 #undef IT_IX
35919 #undef CEX
35920 #undef IM_O
35921 #undef IM_FE
35922 #undef OT_E
35923 
35924 void
imdi_k102_gen(genspec * g)35925 imdi_k102_gen(
35926 genspec *g			/* structure to be initialised */
35927 ) {
35928 	static unsigned char data[] = {
35929 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
35930 		0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
35931 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35932 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35933 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35934 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35935 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35936 		0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
35937 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
35938 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
35939 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35940 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35941 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35942 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35943 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35944 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35945 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35946 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35947 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35948 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35949 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35950 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35951 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35952 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35953 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35954 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35955 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35956 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
35957 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35958 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35959 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35960 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35961 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35962 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35963 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35964 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
35965 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35966 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
35967 		0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35968 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
35969 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
35970 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
35971 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
35972 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
35973 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
35974 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
35975 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
35976 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
35977 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35978 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
35979 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
35980 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x31, 0x5f,
35981 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
35982 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
35983 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
35984 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
35985 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
35986 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
35987 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
35988 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35989 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35990 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35991 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35992 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
35993 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x30,
35994 		0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35995 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35996 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
35997 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
35998 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
35999 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
36000 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
36001 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
36002 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
36003 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
36004 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
36005 		0x00, 0xf0, 0x04, 0x08
36006 	};	/* Structure image */
36007 
36008 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
36009 }
36010 
36011 void
imdi_k102_tab(tabspec * t)36012 imdi_k102_tab(
36013 tabspec *t			/* structure to be initialised */
36014 ) {
36015 	static unsigned char data[] = {
36016 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36017 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36018 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36019 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
36020 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
36021 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
36022 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
36023 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
36024 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
36025 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36026 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
36027 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
36028 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
36029 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
36030 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
36031 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36032 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
36033 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36034 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36035 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36036 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
36037 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
36038 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
36039 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
36040 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36041 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
36042 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
36043 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
36044 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36045 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
36046 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
36047 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
36048 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
36049 	};	/* Structure image */
36050 
36051 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
36052 }
36053 
36054 
36055 
36056 
36057 
36058 
36059 /* Integer Multi-Dimensional Interpolation */
36060 /* Interpolation Kernel Code */
36061 /* Generated by cgen */
36062 /* Copyright 2000 - 2002 Graeme W. Gill */
36063 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
36064 
36065 /* see the Licence.txt file for licencing details.*/
36066 
36067 
36068 /*
36069    Interpolation kernel specs:
36070 
36071    Input channels per pixel = 6
36072    Input channel 0 bits = 16
36073    Input channel 0 increment = 6
36074    Input channel 1 bits = 16
36075    Input channel 1 increment = 6
36076    Input channel 2 bits = 16
36077    Input channel 2 increment = 6
36078    Input channel 3 bits = 16
36079    Input channel 3 increment = 6
36080    Input channel 4 bits = 16
36081    Input channel 4 increment = 6
36082    Input channel 5 bits = 16
36083    Input channel 5 increment = 6
36084    Input is channel interleaved
36085    Input channels are separate words
36086    Input value extraction is done in input table lookup
36087 
36088    Output channels per pixel = 1
36089    Output channel 0 bits = 16
36090    Output channel 0 increment = 1
36091    Output is channel interleaved
36092 
36093    Output channels are separate words
36094    Weight+voffset bits       = 32
36095    Interpolation table index bits = 32
36096    Interpolation table max resolution = 40
36097  */
36098 
36099 /*
36100    Machine architecture specs:
36101 
36102    Little endian
36103    Reading and writing pixel values separately
36104    Pointer size = 32 bits
36105 
36106    Ordinal size  8 bits is known as 'unsigned char'
36107    Ordinal size 16 bits is known as 'unsigned short'
36108    Ordinal size 32 bits is known as 'unsigned int'
36109    Natural ordinal is 'unsigned int'
36110 
36111    Integer size  8 bits is known as 'signed char'
36112    Integer size 16 bits is known as 'short'
36113    Integer size 32 bits is known as 'int'
36114    Natural integer is 'int'
36115 
36116  */
36117 
36118 #ifndef  IMDI_INCLUDED
36119 #include <memory.h>
36120 #include "imdi_imp.h"
36121 #define  IMDI_INCLUDED
36122 #endif  /* IMDI_INCLUDED */
36123 
36124 #ifndef DEFINED_pointer
36125 #define DEFINED_pointer
36126 typedef unsigned char * pointer;
36127 #endif
36128 
36129 /* Input table interp. index */
36130 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
36131 
36132 /* Input table input weighting enty */
36133 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
36134 
36135 /* Input table input offset value enty */
36136 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
36137 
36138 /* Conditional exchange for sorting */
36139 #define CEX(A, AA, B, BB) if (A < B) { \
36140             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
36141 
36142 /* Interpolation multi-dim. table access */
36143 #define IM_O(off) ((off) * 2)
36144 
36145 /* Interpolation table - get vertex values */
36146 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
36147 
36148 /* Output table indexes */
36149 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
36150 
36151 void
imdi_k103(imdi * s,void ** outp,void ** inp,unsigned int npix)36152 imdi_k103(
36153 imdi *s,			/* imdi context */
36154 void **outp,		/* pointer to output pointers */
36155 void **inp,		/* pointer to input pointers */
36156 unsigned int npix	/* Number of pixels to process */
36157 ) {
36158 	imdi_imp *p = (imdi_imp *)(s->impl);
36159 	unsigned short *ip0 = (unsigned short *)inp[0];
36160 	unsigned short *op0 = (unsigned short *)outp[0];
36161 	unsigned short *ep = ip0 + npix * 6 ;
36162 	pointer it0 = (pointer)p->in_tables[0];
36163 	pointer it1 = (pointer)p->in_tables[1];
36164 	pointer it2 = (pointer)p->in_tables[2];
36165 	pointer it3 = (pointer)p->in_tables[3];
36166 	pointer it4 = (pointer)p->in_tables[4];
36167 	pointer it5 = (pointer)p->in_tables[5];
36168 	pointer ot0 = (pointer)p->out_tables[0];
36169 	pointer im_base = (pointer)p->im_table;
36170 
36171 	for(;ip0 < ep; ip0 += 6, op0 += 1) {
36172 		unsigned int ova0;	/* Output value accumulator */
36173 		{
36174 			pointer imp;
36175 			unsigned int we0;	/* Weighting value variable */
36176 			unsigned int vo0;	/* Vertex offset variable */
36177 			unsigned int we1;	/* Weighting value variable */
36178 			unsigned int vo1;	/* Vertex offset variable */
36179 			unsigned int we2;	/* Weighting value variable */
36180 			unsigned int vo2;	/* Vertex offset variable */
36181 			unsigned int we3;	/* Weighting value variable */
36182 			unsigned int vo3;	/* Vertex offset variable */
36183 			unsigned int we4;	/* Weighting value variable */
36184 			unsigned int vo4;	/* Vertex offset variable */
36185 			unsigned int we5;	/* Weighting value variable */
36186 			unsigned int vo5;	/* Vertex offset variable */
36187 			{
36188 				unsigned int ti_i;	/* Interpolation index variable */
36189 
36190 				ti_i  = IT_IX(it0, ip0[0]);
36191 				we0   = IT_WE(it0, ip0[0]);
36192 				vo0   = IT_VO(it0, ip0[0]);
36193 				ti_i += IT_IX(it1, ip0[1]);
36194 				we1   = IT_WE(it1, ip0[1]);
36195 				vo1   = IT_VO(it1, ip0[1]);
36196 				ti_i += IT_IX(it2, ip0[2]);
36197 				we2   = IT_WE(it2, ip0[2]);
36198 				vo2   = IT_VO(it2, ip0[2]);
36199 				ti_i += IT_IX(it3, ip0[3]);
36200 				we3   = IT_WE(it3, ip0[3]);
36201 				vo3   = IT_VO(it3, ip0[3]);
36202 				ti_i += IT_IX(it4, ip0[4]);
36203 				we4   = IT_WE(it4, ip0[4]);
36204 				vo4   = IT_VO(it4, ip0[4]);
36205 				ti_i += IT_IX(it5, ip0[5]);
36206 				we5   = IT_WE(it5, ip0[5]);
36207 				vo5   = IT_VO(it5, ip0[5]);
36208 
36209 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
36210 
36211 				/* Sort weighting values and vertex offset values */
36212 				CEX(we0, vo0, we1, vo1);
36213 				CEX(we0, vo0, we2, vo2);
36214 				CEX(we0, vo0, we3, vo3);
36215 				CEX(we0, vo0, we4, vo4);
36216 				CEX(we0, vo0, we5, vo5);
36217 				CEX(we1, vo1, we2, vo2);
36218 				CEX(we1, vo1, we3, vo3);
36219 				CEX(we1, vo1, we4, vo4);
36220 				CEX(we1, vo1, we5, vo5);
36221 				CEX(we2, vo2, we3, vo3);
36222 				CEX(we2, vo2, we4, vo4);
36223 				CEX(we2, vo2, we5, vo5);
36224 				CEX(we3, vo3, we4, vo4);
36225 				CEX(we3, vo3, we5, vo5);
36226 				CEX(we4, vo4, we5, vo5);
36227 			}
36228 			{
36229 				unsigned int vof;	/* Vertex offset value */
36230 				unsigned int vwe;	/* Vertex weighting */
36231 
36232 				vof = 0;				/* First vertex offset is 0 */
36233 				vwe = 65536 - we0;		/* Baricentric weighting */
36234 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36235 				vof += vo0;			/* Move to next vertex */
36236 				vwe = we0 - we1;		/* Baricentric weighting */
36237 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36238 				vof += vo1;			/* Move to next vertex */
36239 				vwe = we1 - we2;		/* Baricentric weighting */
36240 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36241 				vof += vo2;			/* Move to next vertex */
36242 				vwe = we2 - we3;		/* Baricentric weighting */
36243 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36244 				vof += vo3;			/* Move to next vertex */
36245 				vwe = we3 - we4;		/* Baricentric weighting */
36246 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36247 				vof += vo4;			/* Move to next vertex */
36248 				vwe = we4 - we5;		/* Baricentric weighting */
36249 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36250 				vof += vo5;			/* Move to next vertex */
36251 				vwe = we5;				/* Baricentric weighting */
36252 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36253 			}
36254 		}
36255 		{
36256 			unsigned int oti;	/* Vertex offset value */
36257 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
36258 			op0[0] = OT_E(ot0, oti);	/* Write result */
36259 		}
36260 	}
36261 }
36262 #undef IT_WE
36263 #undef IT_VO
36264 #undef IT_IX
36265 #undef CEX
36266 #undef IM_O
36267 #undef IM_FE
36268 #undef OT_E
36269 
36270 void
imdi_k103_gen(genspec * g)36271 imdi_k103_gen(
36272 genspec *g			/* structure to be initialised */
36273 ) {
36274 	static unsigned char data[] = {
36275 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
36276 		0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
36277 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36278 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36279 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36280 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36281 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
36282 		0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
36283 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
36284 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
36285 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
36286 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36287 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36288 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36289 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36290 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36291 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36292 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36293 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
36294 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36295 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36296 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36297 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36298 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36299 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36300 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
36301 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
36302 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
36303 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36304 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36305 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36306 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36307 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36308 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36309 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36310 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36311 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36312 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36313 		0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36314 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
36315 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
36316 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
36317 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
36318 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
36319 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
36320 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
36321 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
36322 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
36323 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36324 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
36325 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
36326 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x31, 0x5f,
36327 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
36328 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
36329 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
36330 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
36331 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
36332 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
36333 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
36334 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36335 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36336 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36337 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36338 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
36339 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x30,
36340 		0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36341 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36342 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
36343 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
36344 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
36345 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
36346 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
36347 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
36348 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
36349 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
36350 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
36351 		0x00, 0xf0, 0x04, 0x08
36352 	};	/* Structure image */
36353 
36354 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
36355 }
36356 
36357 void
imdi_k103_tab(tabspec * t)36358 imdi_k103_tab(
36359 tabspec *t			/* structure to be initialised */
36360 ) {
36361 	static unsigned char data[] = {
36362 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36363 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36364 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36365 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
36366 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
36367 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
36368 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
36369 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
36370 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
36371 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36372 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
36373 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
36374 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
36375 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
36376 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
36377 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36378 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
36379 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36380 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36381 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36382 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
36383 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
36384 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
36385 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
36386 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36387 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
36388 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
36389 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
36390 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36391 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
36392 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
36393 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
36394 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
36395 	};	/* Structure image */
36396 
36397 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
36398 }
36399 
36400 
36401 
36402 
36403 
36404 
36405 /* Integer Multi-Dimensional Interpolation */
36406 /* Interpolation Kernel Code */
36407 /* Generated by cgen */
36408 /* Copyright 2000 - 2002 Graeme W. Gill */
36409 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
36410 
36411 /* see the Licence.txt file for licencing details.*/
36412 
36413 
36414 /*
36415    Interpolation kernel specs:
36416 
36417    Input channels per pixel = 7
36418    Input channel 0 bits = 16
36419    Input channel 0 increment = 7
36420    Input channel 1 bits = 16
36421    Input channel 1 increment = 7
36422    Input channel 2 bits = 16
36423    Input channel 2 increment = 7
36424    Input channel 3 bits = 16
36425    Input channel 3 increment = 7
36426    Input channel 4 bits = 16
36427    Input channel 4 increment = 7
36428    Input channel 5 bits = 16
36429    Input channel 5 increment = 7
36430    Input channel 6 bits = 16
36431    Input channel 6 increment = 7
36432    Input is channel interleaved
36433    Input channels are separate words
36434    Input value extraction is done in input table lookup
36435 
36436    Output channels per pixel = 1
36437    Output channel 0 bits = 16
36438    Output channel 0 increment = 1
36439    Output is channel interleaved
36440 
36441    Output channels are separate words
36442    Weight+voffset bits       = 32
36443    Interpolation table index bits = 32
36444    Interpolation table max resolution = 23
36445  */
36446 
36447 /*
36448    Machine architecture specs:
36449 
36450    Little endian
36451    Reading and writing pixel values separately
36452    Pointer size = 32 bits
36453 
36454    Ordinal size  8 bits is known as 'unsigned char'
36455    Ordinal size 16 bits is known as 'unsigned short'
36456    Ordinal size 32 bits is known as 'unsigned int'
36457    Natural ordinal is 'unsigned int'
36458 
36459    Integer size  8 bits is known as 'signed char'
36460    Integer size 16 bits is known as 'short'
36461    Integer size 32 bits is known as 'int'
36462    Natural integer is 'int'
36463 
36464  */
36465 
36466 #ifndef  IMDI_INCLUDED
36467 #include <memory.h>
36468 #include "imdi_imp.h"
36469 #define  IMDI_INCLUDED
36470 #endif  /* IMDI_INCLUDED */
36471 
36472 #ifndef DEFINED_pointer
36473 #define DEFINED_pointer
36474 typedef unsigned char * pointer;
36475 #endif
36476 
36477 /* Input table interp. index */
36478 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
36479 
36480 /* Input table input weighting enty */
36481 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
36482 
36483 /* Input table input offset value enty */
36484 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
36485 
36486 /* Conditional exchange for sorting */
36487 #define CEX(A, AA, B, BB) if (A < B) { \
36488             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
36489 
36490 /* Interpolation multi-dim. table access */
36491 #define IM_O(off) ((off) * 2)
36492 
36493 /* Interpolation table - get vertex values */
36494 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
36495 
36496 /* Output table indexes */
36497 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
36498 
36499 void
imdi_k104(imdi * s,void ** outp,void ** inp,unsigned int npix)36500 imdi_k104(
36501 imdi *s,			/* imdi context */
36502 void **outp,		/* pointer to output pointers */
36503 void **inp,		/* pointer to input pointers */
36504 unsigned int npix	/* Number of pixels to process */
36505 ) {
36506 	imdi_imp *p = (imdi_imp *)(s->impl);
36507 	unsigned short *ip0 = (unsigned short *)inp[0];
36508 	unsigned short *op0 = (unsigned short *)outp[0];
36509 	unsigned short *ep = ip0 + npix * 7 ;
36510 	pointer it0 = (pointer)p->in_tables[0];
36511 	pointer it1 = (pointer)p->in_tables[1];
36512 	pointer it2 = (pointer)p->in_tables[2];
36513 	pointer it3 = (pointer)p->in_tables[3];
36514 	pointer it4 = (pointer)p->in_tables[4];
36515 	pointer it5 = (pointer)p->in_tables[5];
36516 	pointer it6 = (pointer)p->in_tables[6];
36517 	pointer ot0 = (pointer)p->out_tables[0];
36518 	pointer im_base = (pointer)p->im_table;
36519 
36520 	for(;ip0 < ep; ip0 += 7, op0 += 1) {
36521 		unsigned int ova0;	/* Output value accumulator */
36522 		{
36523 			pointer imp;
36524 			unsigned int we0;	/* Weighting value variable */
36525 			unsigned int vo0;	/* Vertex offset variable */
36526 			unsigned int we1;	/* Weighting value variable */
36527 			unsigned int vo1;	/* Vertex offset variable */
36528 			unsigned int we2;	/* Weighting value variable */
36529 			unsigned int vo2;	/* Vertex offset variable */
36530 			unsigned int we3;	/* Weighting value variable */
36531 			unsigned int vo3;	/* Vertex offset variable */
36532 			unsigned int we4;	/* Weighting value variable */
36533 			unsigned int vo4;	/* Vertex offset variable */
36534 			unsigned int we5;	/* Weighting value variable */
36535 			unsigned int vo5;	/* Vertex offset variable */
36536 			unsigned int we6;	/* Weighting value variable */
36537 			unsigned int vo6;	/* Vertex offset variable */
36538 			{
36539 				unsigned int ti_i;	/* Interpolation index variable */
36540 
36541 				ti_i  = IT_IX(it0, ip0[0]);
36542 				we0   = IT_WE(it0, ip0[0]);
36543 				vo0   = IT_VO(it0, ip0[0]);
36544 				ti_i += IT_IX(it1, ip0[1]);
36545 				we1   = IT_WE(it1, ip0[1]);
36546 				vo1   = IT_VO(it1, ip0[1]);
36547 				ti_i += IT_IX(it2, ip0[2]);
36548 				we2   = IT_WE(it2, ip0[2]);
36549 				vo2   = IT_VO(it2, ip0[2]);
36550 				ti_i += IT_IX(it3, ip0[3]);
36551 				we3   = IT_WE(it3, ip0[3]);
36552 				vo3   = IT_VO(it3, ip0[3]);
36553 				ti_i += IT_IX(it4, ip0[4]);
36554 				we4   = IT_WE(it4, ip0[4]);
36555 				vo4   = IT_VO(it4, ip0[4]);
36556 				ti_i += IT_IX(it5, ip0[5]);
36557 				we5   = IT_WE(it5, ip0[5]);
36558 				vo5   = IT_VO(it5, ip0[5]);
36559 				ti_i += IT_IX(it6, ip0[6]);
36560 				we6   = IT_WE(it6, ip0[6]);
36561 				vo6   = IT_VO(it6, ip0[6]);
36562 
36563 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
36564 
36565 				/* Sort weighting values and vertex offset values */
36566 				CEX(we0, vo0, we1, vo1);
36567 				CEX(we0, vo0, we2, vo2);
36568 				CEX(we0, vo0, we3, vo3);
36569 				CEX(we0, vo0, we4, vo4);
36570 				CEX(we0, vo0, we5, vo5);
36571 				CEX(we0, vo0, we6, vo6);
36572 				CEX(we1, vo1, we2, vo2);
36573 				CEX(we1, vo1, we3, vo3);
36574 				CEX(we1, vo1, we4, vo4);
36575 				CEX(we1, vo1, we5, vo5);
36576 				CEX(we1, vo1, we6, vo6);
36577 				CEX(we2, vo2, we3, vo3);
36578 				CEX(we2, vo2, we4, vo4);
36579 				CEX(we2, vo2, we5, vo5);
36580 				CEX(we2, vo2, we6, vo6);
36581 				CEX(we3, vo3, we4, vo4);
36582 				CEX(we3, vo3, we5, vo5);
36583 				CEX(we3, vo3, we6, vo6);
36584 				CEX(we4, vo4, we5, vo5);
36585 				CEX(we4, vo4, we6, vo6);
36586 				CEX(we5, vo5, we6, vo6);
36587 			}
36588 			{
36589 				unsigned int vof;	/* Vertex offset value */
36590 				unsigned int vwe;	/* Vertex weighting */
36591 
36592 				vof = 0;				/* First vertex offset is 0 */
36593 				vwe = 65536 - we0;		/* Baricentric weighting */
36594 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36595 				vof += vo0;			/* Move to next vertex */
36596 				vwe = we0 - we1;		/* Baricentric weighting */
36597 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36598 				vof += vo1;			/* Move to next vertex */
36599 				vwe = we1 - we2;		/* Baricentric weighting */
36600 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36601 				vof += vo2;			/* Move to next vertex */
36602 				vwe = we2 - we3;		/* Baricentric weighting */
36603 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36604 				vof += vo3;			/* Move to next vertex */
36605 				vwe = we3 - we4;		/* Baricentric weighting */
36606 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36607 				vof += vo4;			/* Move to next vertex */
36608 				vwe = we4 - we5;		/* Baricentric weighting */
36609 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36610 				vof += vo5;			/* Move to next vertex */
36611 				vwe = we5 - we6;		/* Baricentric weighting */
36612 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36613 				vof += vo6;			/* Move to next vertex */
36614 				vwe = we6;				/* Baricentric weighting */
36615 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36616 			}
36617 		}
36618 		{
36619 			unsigned int oti;	/* Vertex offset value */
36620 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
36621 			op0[0] = OT_E(ot0, oti);	/* Write result */
36622 		}
36623 	}
36624 }
36625 #undef IT_WE
36626 #undef IT_VO
36627 #undef IT_IX
36628 #undef CEX
36629 #undef IM_O
36630 #undef IM_FE
36631 #undef OT_E
36632 
36633 void
imdi_k104_gen(genspec * g)36634 imdi_k104_gen(
36635 genspec *g			/* structure to be initialised */
36636 ) {
36637 	static unsigned char data[] = {
36638 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
36639 		0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
36640 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36641 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36642 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36643 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36644 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36645 		0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
36646 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
36647 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
36648 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
36649 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36650 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36651 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36652 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36653 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36654 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36655 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36656 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36657 		0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36658 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36659 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36660 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36661 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36662 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36663 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
36664 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
36665 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
36666 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36667 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36668 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36669 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36670 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36671 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36672 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36673 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36674 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36675 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36676 		0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36677 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
36678 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
36679 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
36680 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
36681 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
36682 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
36683 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
36684 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
36685 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
36686 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36687 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
36688 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
36689 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x31, 0x5f,
36690 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
36691 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
36692 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
36693 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
36694 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
36695 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
36696 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
36697 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36698 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36699 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36700 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36701 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
36702 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x30,
36703 		0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36704 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36705 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
36706 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
36707 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
36708 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
36709 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
36710 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
36711 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
36712 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
36713 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
36714 		0x00, 0xf0, 0x04, 0x08
36715 	};	/* Structure image */
36716 
36717 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
36718 }
36719 
36720 void
imdi_k104_tab(tabspec * t)36721 imdi_k104_tab(
36722 tabspec *t			/* structure to be initialised */
36723 ) {
36724 	static unsigned char data[] = {
36725 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36726 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36727 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36728 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
36729 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
36730 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
36731 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
36732 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
36733 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
36734 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36735 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
36736 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
36737 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
36738 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
36739 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
36740 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36741 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
36742 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
36743 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36744 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36745 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
36746 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
36747 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
36748 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
36749 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36750 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
36751 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
36752 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
36753 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
36754 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
36755 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
36756 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
36757 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
36758 	};	/* Structure image */
36759 
36760 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
36761 }
36762 
36763 
36764 
36765 
36766 
36767 
36768 /* Integer Multi-Dimensional Interpolation */
36769 /* Interpolation Kernel Code */
36770 /* Generated by cgen */
36771 /* Copyright 2000 - 2002 Graeme W. Gill */
36772 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
36773 
36774 /* see the Licence.txt file for licencing details.*/
36775 
36776 
36777 /*
36778    Interpolation kernel specs:
36779 
36780    Input channels per pixel = 8
36781    Input channel 0 bits = 16
36782    Input channel 0 increment = 8
36783    Input channel 1 bits = 16
36784    Input channel 1 increment = 8
36785    Input channel 2 bits = 16
36786    Input channel 2 increment = 8
36787    Input channel 3 bits = 16
36788    Input channel 3 increment = 8
36789    Input channel 4 bits = 16
36790    Input channel 4 increment = 8
36791    Input channel 5 bits = 16
36792    Input channel 5 increment = 8
36793    Input channel 6 bits = 16
36794    Input channel 6 increment = 8
36795    Input channel 7 bits = 16
36796    Input channel 7 increment = 8
36797    Input is channel interleaved
36798    Input channels are separate words
36799    Input value extraction is done in input table lookup
36800 
36801    Output channels per pixel = 1
36802    Output channel 0 bits = 16
36803    Output channel 0 increment = 1
36804    Output is channel interleaved
36805 
36806    Output channels are separate words
36807    Weight+voffset bits       = 32
36808    Interpolation table index bits = 32
36809    Interpolation table max resolution = 16
36810  */
36811 
36812 /*
36813    Machine architecture specs:
36814 
36815    Little endian
36816    Reading and writing pixel values separately
36817    Pointer size = 32 bits
36818 
36819    Ordinal size  8 bits is known as 'unsigned char'
36820    Ordinal size 16 bits is known as 'unsigned short'
36821    Ordinal size 32 bits is known as 'unsigned int'
36822    Natural ordinal is 'unsigned int'
36823 
36824    Integer size  8 bits is known as 'signed char'
36825    Integer size 16 bits is known as 'short'
36826    Integer size 32 bits is known as 'int'
36827    Natural integer is 'int'
36828 
36829  */
36830 
36831 #ifndef  IMDI_INCLUDED
36832 #include <memory.h>
36833 #include "imdi_imp.h"
36834 #define  IMDI_INCLUDED
36835 #endif  /* IMDI_INCLUDED */
36836 
36837 #ifndef DEFINED_pointer
36838 #define DEFINED_pointer
36839 typedef unsigned char * pointer;
36840 #endif
36841 
36842 /* Input table interp. index */
36843 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
36844 
36845 /* Input table input weighting enty */
36846 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
36847 
36848 /* Input table input offset value enty */
36849 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
36850 
36851 /* Conditional exchange for sorting */
36852 #define CEX(A, AA, B, BB) if (A < B) { \
36853             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
36854 
36855 /* Interpolation multi-dim. table access */
36856 #define IM_O(off) ((off) * 2)
36857 
36858 /* Interpolation table - get vertex values */
36859 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
36860 
36861 /* Output table indexes */
36862 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
36863 
36864 void
imdi_k105(imdi * s,void ** outp,void ** inp,unsigned int npix)36865 imdi_k105(
36866 imdi *s,			/* imdi context */
36867 void **outp,		/* pointer to output pointers */
36868 void **inp,		/* pointer to input pointers */
36869 unsigned int npix	/* Number of pixels to process */
36870 ) {
36871 	imdi_imp *p = (imdi_imp *)(s->impl);
36872 	unsigned short *ip0 = (unsigned short *)inp[0];
36873 	unsigned short *op0 = (unsigned short *)outp[0];
36874 	unsigned short *ep = ip0 + npix * 8 ;
36875 	pointer it0 = (pointer)p->in_tables[0];
36876 	pointer it1 = (pointer)p->in_tables[1];
36877 	pointer it2 = (pointer)p->in_tables[2];
36878 	pointer it3 = (pointer)p->in_tables[3];
36879 	pointer it4 = (pointer)p->in_tables[4];
36880 	pointer it5 = (pointer)p->in_tables[5];
36881 	pointer it6 = (pointer)p->in_tables[6];
36882 	pointer it7 = (pointer)p->in_tables[7];
36883 	pointer ot0 = (pointer)p->out_tables[0];
36884 	pointer im_base = (pointer)p->im_table;
36885 
36886 	for(;ip0 < ep; ip0 += 8, op0 += 1) {
36887 		unsigned int ova0;	/* Output value accumulator */
36888 		{
36889 			pointer imp;
36890 			unsigned int we0;	/* Weighting value variable */
36891 			unsigned int vo0;	/* Vertex offset variable */
36892 			unsigned int we1;	/* Weighting value variable */
36893 			unsigned int vo1;	/* Vertex offset variable */
36894 			unsigned int we2;	/* Weighting value variable */
36895 			unsigned int vo2;	/* Vertex offset variable */
36896 			unsigned int we3;	/* Weighting value variable */
36897 			unsigned int vo3;	/* Vertex offset variable */
36898 			unsigned int we4;	/* Weighting value variable */
36899 			unsigned int vo4;	/* Vertex offset variable */
36900 			unsigned int we5;	/* Weighting value variable */
36901 			unsigned int vo5;	/* Vertex offset variable */
36902 			unsigned int we6;	/* Weighting value variable */
36903 			unsigned int vo6;	/* Vertex offset variable */
36904 			unsigned int we7;	/* Weighting value variable */
36905 			unsigned int vo7;	/* Vertex offset variable */
36906 			{
36907 				unsigned int ti_i;	/* Interpolation index variable */
36908 
36909 				ti_i  = IT_IX(it0, ip0[0]);
36910 				we0   = IT_WE(it0, ip0[0]);
36911 				vo0   = IT_VO(it0, ip0[0]);
36912 				ti_i += IT_IX(it1, ip0[1]);
36913 				we1   = IT_WE(it1, ip0[1]);
36914 				vo1   = IT_VO(it1, ip0[1]);
36915 				ti_i += IT_IX(it2, ip0[2]);
36916 				we2   = IT_WE(it2, ip0[2]);
36917 				vo2   = IT_VO(it2, ip0[2]);
36918 				ti_i += IT_IX(it3, ip0[3]);
36919 				we3   = IT_WE(it3, ip0[3]);
36920 				vo3   = IT_VO(it3, ip0[3]);
36921 				ti_i += IT_IX(it4, ip0[4]);
36922 				we4   = IT_WE(it4, ip0[4]);
36923 				vo4   = IT_VO(it4, ip0[4]);
36924 				ti_i += IT_IX(it5, ip0[5]);
36925 				we5   = IT_WE(it5, ip0[5]);
36926 				vo5   = IT_VO(it5, ip0[5]);
36927 				ti_i += IT_IX(it6, ip0[6]);
36928 				we6   = IT_WE(it6, ip0[6]);
36929 				vo6   = IT_VO(it6, ip0[6]);
36930 				ti_i += IT_IX(it7, ip0[7]);
36931 				we7   = IT_WE(it7, ip0[7]);
36932 				vo7   = IT_VO(it7, ip0[7]);
36933 
36934 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
36935 
36936 				/* Sort weighting values and vertex offset values */
36937 				CEX(we0, vo0, we1, vo1);
36938 				CEX(we0, vo0, we2, vo2);
36939 				CEX(we0, vo0, we3, vo3);
36940 				CEX(we0, vo0, we4, vo4);
36941 				CEX(we0, vo0, we5, vo5);
36942 				CEX(we0, vo0, we6, vo6);
36943 				CEX(we0, vo0, we7, vo7);
36944 				CEX(we1, vo1, we2, vo2);
36945 				CEX(we1, vo1, we3, vo3);
36946 				CEX(we1, vo1, we4, vo4);
36947 				CEX(we1, vo1, we5, vo5);
36948 				CEX(we1, vo1, we6, vo6);
36949 				CEX(we1, vo1, we7, vo7);
36950 				CEX(we2, vo2, we3, vo3);
36951 				CEX(we2, vo2, we4, vo4);
36952 				CEX(we2, vo2, we5, vo5);
36953 				CEX(we2, vo2, we6, vo6);
36954 				CEX(we2, vo2, we7, vo7);
36955 				CEX(we3, vo3, we4, vo4);
36956 				CEX(we3, vo3, we5, vo5);
36957 				CEX(we3, vo3, we6, vo6);
36958 				CEX(we3, vo3, we7, vo7);
36959 				CEX(we4, vo4, we5, vo5);
36960 				CEX(we4, vo4, we6, vo6);
36961 				CEX(we4, vo4, we7, vo7);
36962 				CEX(we5, vo5, we6, vo6);
36963 				CEX(we5, vo5, we7, vo7);
36964 				CEX(we6, vo6, we7, vo7);
36965 			}
36966 			{
36967 				unsigned int vof;	/* Vertex offset value */
36968 				unsigned int vwe;	/* Vertex weighting */
36969 
36970 				vof = 0;				/* First vertex offset is 0 */
36971 				vwe = 65536 - we0;		/* Baricentric weighting */
36972 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36973 				vof += vo0;			/* Move to next vertex */
36974 				vwe = we0 - we1;		/* Baricentric weighting */
36975 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36976 				vof += vo1;			/* Move to next vertex */
36977 				vwe = we1 - we2;		/* Baricentric weighting */
36978 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36979 				vof += vo2;			/* Move to next vertex */
36980 				vwe = we2 - we3;		/* Baricentric weighting */
36981 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36982 				vof += vo3;			/* Move to next vertex */
36983 				vwe = we3 - we4;		/* Baricentric weighting */
36984 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36985 				vof += vo4;			/* Move to next vertex */
36986 				vwe = we4 - we5;		/* Baricentric weighting */
36987 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36988 				vof += vo5;			/* Move to next vertex */
36989 				vwe = we5 - we6;		/* Baricentric weighting */
36990 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36991 				vof += vo6;			/* Move to next vertex */
36992 				vwe = we6 - we7;		/* Baricentric weighting */
36993 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36994 				vof += vo7;			/* Move to next vertex */
36995 				vwe = we7;				/* Baricentric weighting */
36996 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
36997 			}
36998 		}
36999 		{
37000 			unsigned int oti;	/* Vertex offset value */
37001 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
37002 			op0[0] = OT_E(ot0, oti);	/* Write result */
37003 		}
37004 	}
37005 }
37006 #undef IT_WE
37007 #undef IT_VO
37008 #undef IT_IX
37009 #undef CEX
37010 #undef IM_O
37011 #undef IM_FE
37012 #undef OT_E
37013 
37014 void
imdi_k105_gen(genspec * g)37015 imdi_k105_gen(
37016 genspec *g			/* structure to be initialised */
37017 ) {
37018 	static unsigned char data[] = {
37019 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37020 		0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
37021 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37022 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37023 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37024 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37025 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37026 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37027 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37028 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37029 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37030 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37031 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37032 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37033 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37034 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37035 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37036 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37037 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37038 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37039 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37040 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37041 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37042 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37043 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37044 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37045 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37046 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37047 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37048 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37049 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37050 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37051 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37052 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37053 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37054 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37055 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37056 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37057 		0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37058 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
37059 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
37060 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
37061 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
37062 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
37063 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
37064 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
37065 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
37066 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
37067 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37068 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
37069 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
37070 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x31, 0x5f,
37071 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
37072 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
37073 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
37074 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
37075 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
37076 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
37077 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
37078 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37079 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37080 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37081 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37082 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
37083 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x30,
37084 		0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37085 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37086 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
37087 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
37088 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
37089 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
37090 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
37091 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
37092 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
37093 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
37094 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
37095 		0x00, 0xf0, 0x04, 0x08
37096 	};	/* Structure image */
37097 
37098 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
37099 }
37100 
37101 void
imdi_k105_tab(tabspec * t)37102 imdi_k105_tab(
37103 tabspec *t			/* structure to be initialised */
37104 ) {
37105 	static unsigned char data[] = {
37106 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37107 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37108 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37109 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
37110 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
37111 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
37112 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
37113 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
37114 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
37115 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37116 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
37117 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
37118 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
37119 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
37120 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37121 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37122 		0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
37123 		0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37124 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37125 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37126 		0x00, 0x00, 0x00, 0x00, 0xa1, 0xd4, 0xe2, 0xb7,
37127 		0xf4, 0xd5, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
37128 		0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
37129 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
37130 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37131 		0xa0, 0xd6, 0x83, 0xbf, 0x8b, 0x22, 0xe2, 0xb7,
37132 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
37133 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
37134 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37135 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
37136 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
37137 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
37138 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
37139 	};	/* Structure image */
37140 
37141 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
37142 }
37143 
37144 
37145 
37146 
37147 
37148 
37149 /* Integer Multi-Dimensional Interpolation */
37150 /* Interpolation Kernel Code */
37151 /* Generated by cgen */
37152 /* Copyright 2000 - 2002 Graeme W. Gill */
37153 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
37154 
37155 /* see the Licence.txt file for licencing details.*/
37156 
37157 
37158 /*
37159    Interpolation kernel specs:
37160 
37161    Input channels per pixel = 1
37162    Input channel 0 bits = 16
37163    Input channel 0 increment = 1
37164    Input is channel interleaved
37165    Input channels are separate words
37166    Input value extraction is done in input table lookup
37167 
37168    Output channels per pixel = 3
37169    Output channel 0 bits = 16
37170    Output channel 0 increment = 3
37171    Output channel 1 bits = 16
37172    Output channel 1 increment = 3
37173    Output channel 2 bits = 16
37174    Output channel 2 increment = 3
37175    Output is channel interleaved
37176 
37177    Output channels are separate words
37178    Weight+voffset bits       = 32
37179    Interpolation table index bits = 11
37180    Interpolation table max resolution = 2048
37181  */
37182 
37183 /*
37184    Machine architecture specs:
37185 
37186    Little endian
37187    Reading and writing pixel values separately
37188    Pointer size = 32 bits
37189 
37190    Ordinal size  8 bits is known as 'unsigned char'
37191    Ordinal size 16 bits is known as 'unsigned short'
37192    Ordinal size 32 bits is known as 'unsigned int'
37193    Natural ordinal is 'unsigned int'
37194 
37195    Integer size  8 bits is known as 'signed char'
37196    Integer size 16 bits is known as 'short'
37197    Integer size 32 bits is known as 'int'
37198    Natural integer is 'int'
37199 
37200  */
37201 
37202 #ifndef  IMDI_INCLUDED
37203 #include <memory.h>
37204 #include "imdi_imp.h"
37205 #define  IMDI_INCLUDED
37206 #endif  /* IMDI_INCLUDED */
37207 
37208 #ifndef DEFINED_pointer
37209 #define DEFINED_pointer
37210 typedef unsigned char * pointer;
37211 #endif
37212 
37213 /* Input table interp index, weighting and vertex offset */
37214 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
37215 
37216 /* Conditional exchange for sorting */
37217 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
37218 
37219 /* Interpolation multi-dim. table access */
37220 #define IM_O(off) ((off) * 6)
37221 
37222 /* Interpolation table - get vertex values */
37223 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
37224 
37225 /* Output table indexes */
37226 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
37227 
37228 void
imdi_k106(imdi * s,void ** outp,void ** inp,unsigned int npix)37229 imdi_k106(
37230 imdi *s,			/* imdi context */
37231 void **outp,		/* pointer to output pointers */
37232 void **inp,		/* pointer to input pointers */
37233 unsigned int npix	/* Number of pixels to process */
37234 ) {
37235 	imdi_imp *p = (imdi_imp *)(s->impl);
37236 	unsigned short *ip0 = (unsigned short *)inp[0];
37237 	unsigned short *op0 = (unsigned short *)outp[0];
37238 	unsigned short *ep = ip0 + npix * 1 ;
37239 	pointer it0 = (pointer)p->in_tables[0];
37240 	pointer ot0 = (pointer)p->out_tables[0];
37241 	pointer ot1 = (pointer)p->out_tables[1];
37242 	pointer ot2 = (pointer)p->out_tables[2];
37243 	pointer im_base = (pointer)p->im_table;
37244 
37245 	for(;ip0 < ep; ip0 += 1, op0 += 3) {
37246 		unsigned int ova0;	/* Output value accumulator */
37247 		unsigned int ova1;	/* Output value accumulator */
37248 		unsigned int ova2;	/* Output value accumulator */
37249 		{
37250 			pointer imp;
37251 			unsigned int wo0;	/* Weighting value and vertex offset variable */
37252 			{
37253 				unsigned int ti;		/* Input table entry variable */
37254 				unsigned int ti_i;	/* Interpolation index variable */
37255 
37256 				ti = IT_IT(it0, ip0[0]);
37257 				wo0   = (ti & 0x1fffff);	/* Extract weighting/vertex offset value */
37258 				ti_i  = (ti >> 21);	/* Extract interpolation table value */
37259 
37260 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
37261 
37262 				/* Sort weighting values and vertex offset values */
37263 			}
37264 			{
37265 				unsigned int nvof;	/* Next vertex offset value */
37266 				unsigned int vof;	/* Vertex offset value */
37267 				unsigned int vwe;	/* Vertex weighting */
37268 
37269 				vof = 0;				/* First vertex offset is 0 */
37270 				nvof = (wo0 & 0xf);	/* Extract offset value */
37271 				wo0 = (wo0 >> 4);		/* Extract weighting value */
37272 				vwe = 65536 - wo0;		/* Baricentric weighting */
37273 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
37274 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
37275 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
37276 				vof += nvof;			/* Move to next vertex */
37277 				vwe = wo0;				/* Baricentric weighting */
37278 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
37279 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
37280 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
37281 			}
37282 		}
37283 		{
37284 			unsigned int oti;	/* Vertex offset value */
37285 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
37286 			op0[0] = OT_E(ot0, oti);	/* Write result */
37287 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
37288 			op0[1] = OT_E(ot1, oti);	/* Write result */
37289 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
37290 			op0[2] = OT_E(ot2, oti);	/* Write result */
37291 		}
37292 	}
37293 }
37294 #undef IT_IT
37295 #undef CEX
37296 #undef IM_O
37297 #undef IM_FE
37298 #undef OT_E
37299 
37300 void
imdi_k106_gen(genspec * g)37301 imdi_k106_gen(
37302 genspec *g			/* structure to be initialised */
37303 ) {
37304 	static unsigned char data[] = {
37305 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37306 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
37307 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37308 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37309 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37310 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37311 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37312 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37313 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37314 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37315 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37316 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37317 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37318 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37319 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37320 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37321 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37322 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37323 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37324 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37325 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37326 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37327 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37328 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37329 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
37330 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
37331 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37332 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37333 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37334 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37335 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37336 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37337 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37338 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37339 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37340 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37341 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37342 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37343 		0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37344 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
37345 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
37346 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
37347 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
37348 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
37349 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
37350 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
37351 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
37352 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
37353 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37354 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
37355 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
37356 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x33, 0x5f,
37357 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
37358 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
37359 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
37360 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
37361 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
37362 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
37363 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
37364 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37365 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37366 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37367 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37368 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
37369 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x30,
37370 		0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37371 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37372 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
37373 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
37374 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
37375 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
37376 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
37377 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
37378 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
37379 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
37380 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
37381 		0x00, 0xf0, 0x04, 0x08
37382 	};	/* Structure image */
37383 
37384 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
37385 }
37386 
37387 void
imdi_k106_tab(tabspec * t)37388 imdi_k106_tab(
37389 tabspec *t			/* structure to be initialised */
37390 ) {
37391 	static unsigned char data[] = {
37392 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37393 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37394 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37395 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
37396 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
37397 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
37398 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
37399 		0x0b, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
37400 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
37401 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37402 		0x14, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
37403 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
37404 		0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
37405 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
37406 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37407 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37408 		0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
37409 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
37410 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37411 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37412 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37413 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
37414 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
37415 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
37416 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37417 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37418 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
37419 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
37420 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37421 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37422 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
37423 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
37424 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
37425 	};	/* Structure image */
37426 
37427 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
37428 }
37429 
37430 
37431 
37432 
37433 
37434 
37435 /* Integer Multi-Dimensional Interpolation */
37436 /* Interpolation Kernel Code */
37437 /* Generated by cgen */
37438 /* Copyright 2000 - 2002 Graeme W. Gill */
37439 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
37440 
37441 /* see the Licence.txt file for licencing details.*/
37442 
37443 
37444 /*
37445    Interpolation kernel specs:
37446 
37447    Input channels per pixel = 3
37448    Input channel 0 bits = 16
37449    Input channel 0 increment = 3
37450    Input channel 1 bits = 16
37451    Input channel 1 increment = 3
37452    Input channel 2 bits = 16
37453    Input channel 2 increment = 3
37454    Input is channel interleaved
37455    Input channels are separate words
37456    Input value extraction is done in input table lookup
37457 
37458    Output channels per pixel = 3
37459    Output channel 0 bits = 16
37460    Output channel 0 increment = 3
37461    Output channel 1 bits = 16
37462    Output channel 1 increment = 3
37463    Output channel 2 bits = 16
37464    Output channel 2 increment = 3
37465    Output is channel interleaved
37466 
37467    Output channels are separate words
37468    Weight+voffset bits       = 32
37469    Interpolation table index bits = 16
37470    Interpolation table max resolution = 40
37471  */
37472 
37473 /*
37474    Machine architecture specs:
37475 
37476    Little endian
37477    Reading and writing pixel values separately
37478    Pointer size = 32 bits
37479 
37480    Ordinal size  8 bits is known as 'unsigned char'
37481    Ordinal size 16 bits is known as 'unsigned short'
37482    Ordinal size 32 bits is known as 'unsigned int'
37483    Natural ordinal is 'unsigned int'
37484 
37485    Integer size  8 bits is known as 'signed char'
37486    Integer size 16 bits is known as 'short'
37487    Integer size 32 bits is known as 'int'
37488    Natural integer is 'int'
37489 
37490  */
37491 
37492 #ifndef  IMDI_INCLUDED
37493 #include <memory.h>
37494 #include "imdi_imp.h"
37495 #define  IMDI_INCLUDED
37496 #endif  /* IMDI_INCLUDED */
37497 
37498 #ifndef DEFINED_pointer
37499 #define DEFINED_pointer
37500 typedef unsigned char * pointer;
37501 #endif
37502 
37503 /* Input table interp. index */
37504 #define IT_IX(p, off) *((unsigned short *)((p) + 0 + (off) * 6))
37505 
37506 /* Input table input weighting/offset value enty */
37507 #define IT_WO(p, off) *((unsigned int *)((p) + 2 + (off) * 6))
37508 
37509 /* Conditional exchange for sorting */
37510 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
37511 
37512 /* Interpolation multi-dim. table access */
37513 #define IM_O(off) ((off) * 6)
37514 
37515 /* Interpolation table - get vertex values */
37516 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
37517 
37518 /* Output table indexes */
37519 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
37520 
37521 void
imdi_k107(imdi * s,void ** outp,void ** inp,unsigned int npix)37522 imdi_k107(
37523 imdi *s,			/* imdi context */
37524 void **outp,		/* pointer to output pointers */
37525 void **inp,		/* pointer to input pointers */
37526 unsigned int npix	/* Number of pixels to process */
37527 ) {
37528 	imdi_imp *p = (imdi_imp *)(s->impl);
37529 	unsigned short *ip0 = (unsigned short *)inp[0];
37530 	unsigned short *op0 = (unsigned short *)outp[0];
37531 	unsigned short *ep = ip0 + npix * 3 ;
37532 	pointer it0 = (pointer)p->in_tables[0];
37533 	pointer it1 = (pointer)p->in_tables[1];
37534 	pointer it2 = (pointer)p->in_tables[2];
37535 	pointer ot0 = (pointer)p->out_tables[0];
37536 	pointer ot1 = (pointer)p->out_tables[1];
37537 	pointer ot2 = (pointer)p->out_tables[2];
37538 	pointer im_base = (pointer)p->im_table;
37539 
37540 	for(;ip0 < ep; ip0 += 3, op0 += 3) {
37541 		unsigned int ova0;	/* Output value accumulator */
37542 		unsigned int ova1;	/* Output value accumulator */
37543 		unsigned int ova2;	/* Output value accumulator */
37544 		{
37545 			pointer imp;
37546 			unsigned int wo0;	/* Weighting value and vertex offset variable */
37547 			unsigned int wo1;	/* Weighting value and vertex offset variable */
37548 			unsigned int wo2;	/* Weighting value and vertex offset variable */
37549 			{
37550 				unsigned int ti_i;	/* Interpolation index variable */
37551 
37552 				ti_i  = IT_IX(it0, ip0[0]);
37553 				wo0   = IT_WO(it0, ip0[0]);
37554 				ti_i += IT_IX(it1, ip0[1]);
37555 				wo1   = IT_WO(it1, ip0[1]);
37556 				ti_i += IT_IX(it2, ip0[2]);
37557 				wo2   = IT_WO(it2, ip0[2]);
37558 
37559 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
37560 
37561 				/* Sort weighting values and vertex offset values */
37562 				CEX(wo0, wo1);
37563 				CEX(wo0, wo2);
37564 				CEX(wo1, wo2);
37565 			}
37566 			{
37567 				unsigned int nvof;	/* Next vertex offset value */
37568 				unsigned int vof;	/* Vertex offset value */
37569 				unsigned int vwe;	/* Vertex weighting */
37570 
37571 				vof = 0;				/* First vertex offset is 0 */
37572 				nvof = (wo0 & 0x7fff);	/* Extract offset value */
37573 				wo0 = (wo0 >> 15);		/* Extract weighting value */
37574 				vwe = 65536 - wo0;		/* Baricentric weighting */
37575 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
37576 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
37577 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
37578 				vof += nvof;			/* Move to next vertex */
37579 				nvof = (wo1 & 0x7fff);	/* Extract offset value */
37580 				wo1 = (wo1 >> 15);		/* Extract weighting value */
37581 				vwe = wo0 - wo1;		/* Baricentric weighting */
37582 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
37583 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
37584 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
37585 				vof += nvof;			/* Move to next vertex */
37586 				nvof = (wo2 & 0x7fff);	/* Extract offset value */
37587 				wo2 = (wo2 >> 15);		/* Extract weighting value */
37588 				vwe = wo1 - wo2;		/* Baricentric weighting */
37589 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
37590 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
37591 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
37592 				vof += nvof;			/* Move to next vertex */
37593 				vwe = wo2;				/* Baricentric weighting */
37594 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
37595 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
37596 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
37597 			}
37598 		}
37599 		{
37600 			unsigned int oti;	/* Vertex offset value */
37601 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
37602 			op0[0] = OT_E(ot0, oti);	/* Write result */
37603 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
37604 			op0[1] = OT_E(ot1, oti);	/* Write result */
37605 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
37606 			op0[2] = OT_E(ot2, oti);	/* Write result */
37607 		}
37608 	}
37609 }
37610 #undef IT_WO
37611 #undef IT_IX
37612 #undef CEX
37613 #undef IM_O
37614 #undef IM_FE
37615 #undef OT_E
37616 
37617 void
imdi_k107_gen(genspec * g)37618 imdi_k107_gen(
37619 genspec *g			/* structure to be initialised */
37620 ) {
37621 	static unsigned char data[] = {
37622 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
37623 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
37624 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37625 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37626 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37627 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37628 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37629 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
37630 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
37631 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37632 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37633 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37634 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37635 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37636 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37637 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37638 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37639 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37640 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37641 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37642 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37643 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37644 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37645 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37646 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
37647 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
37648 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37649 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37650 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37651 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37652 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37653 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37654 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37655 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37656 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37657 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37658 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37659 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37660 		0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37661 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
37662 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
37663 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
37664 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
37665 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
37666 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
37667 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
37668 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
37669 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
37670 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37671 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
37672 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
37673 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x33, 0x5f,
37674 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
37675 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
37676 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
37677 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
37678 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
37679 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
37680 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
37681 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37682 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37683 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37684 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37685 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
37686 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x30,
37687 		0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37688 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37689 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
37690 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
37691 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
37692 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
37693 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
37694 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
37695 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
37696 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
37697 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
37698 		0x00, 0xf0, 0x04, 0x08
37699 	};	/* Structure image */
37700 
37701 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
37702 }
37703 
37704 void
imdi_k107_tab(tabspec * t)37705 imdi_k107_tab(
37706 tabspec *t			/* structure to be initialised */
37707 ) {
37708 	static unsigned char data[] = {
37709 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37710 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37711 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37712 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
37713 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
37714 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
37715 		0x20, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
37716 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
37717 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
37718 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37719 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
37720 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
37721 		0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
37722 		0x04, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
37723 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37724 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37725 		0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
37726 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
37727 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37728 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37729 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37730 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
37731 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
37732 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
37733 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37734 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37735 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
37736 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
37737 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37738 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37739 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
37740 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
37741 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
37742 	};	/* Structure image */
37743 
37744 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
37745 }
37746 
37747 
37748 
37749 
37750 
37751 
37752 /* Integer Multi-Dimensional Interpolation */
37753 /* Interpolation Kernel Code */
37754 /* Generated by cgen */
37755 /* Copyright 2000 - 2002 Graeme W. Gill */
37756 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
37757 
37758 /* see the Licence.txt file for licencing details.*/
37759 
37760 
37761 /*
37762    Interpolation kernel specs:
37763 
37764    Input channels per pixel = 4
37765    Input channel 0 bits = 16
37766    Input channel 0 increment = 4
37767    Input channel 1 bits = 16
37768    Input channel 1 increment = 4
37769    Input channel 2 bits = 16
37770    Input channel 2 increment = 4
37771    Input channel 3 bits = 16
37772    Input channel 3 increment = 4
37773    Input is channel interleaved
37774    Input channels are separate words
37775    Input value extraction is done in input table lookup
37776 
37777    Output channels per pixel = 3
37778    Output channel 0 bits = 16
37779    Output channel 0 increment = 3
37780    Output channel 1 bits = 16
37781    Output channel 1 increment = 3
37782    Output channel 2 bits = 16
37783    Output channel 2 increment = 3
37784    Output is channel interleaved
37785 
37786    Output channels are separate words
37787    Weight+voffset bits       = 32
37788    Interpolation table index bits = 32
37789    Interpolation table max resolution = 21
37790  */
37791 
37792 /*
37793    Machine architecture specs:
37794 
37795    Little endian
37796    Reading and writing pixel values separately
37797    Pointer size = 32 bits
37798 
37799    Ordinal size  8 bits is known as 'unsigned char'
37800    Ordinal size 16 bits is known as 'unsigned short'
37801    Ordinal size 32 bits is known as 'unsigned int'
37802    Natural ordinal is 'unsigned int'
37803 
37804    Integer size  8 bits is known as 'signed char'
37805    Integer size 16 bits is known as 'short'
37806    Integer size 32 bits is known as 'int'
37807    Natural integer is 'int'
37808 
37809  */
37810 
37811 #ifndef  IMDI_INCLUDED
37812 #include <memory.h>
37813 #include "imdi_imp.h"
37814 #define  IMDI_INCLUDED
37815 #endif  /* IMDI_INCLUDED */
37816 
37817 #ifndef DEFINED_pointer
37818 #define DEFINED_pointer
37819 typedef unsigned char * pointer;
37820 #endif
37821 
37822 /* Input table interp. index */
37823 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
37824 
37825 /* Input table input weighting/offset value enty */
37826 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
37827 
37828 /* Conditional exchange for sorting */
37829 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
37830 
37831 /* Interpolation multi-dim. table access */
37832 #define IM_O(off) ((off) * 6)
37833 
37834 /* Interpolation table - get vertex values */
37835 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
37836 
37837 /* Output table indexes */
37838 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
37839 
37840 void
imdi_k108(imdi * s,void ** outp,void ** inp,unsigned int npix)37841 imdi_k108(
37842 imdi *s,			/* imdi context */
37843 void **outp,		/* pointer to output pointers */
37844 void **inp,		/* pointer to input pointers */
37845 unsigned int npix	/* Number of pixels to process */
37846 ) {
37847 	imdi_imp *p = (imdi_imp *)(s->impl);
37848 	unsigned short *ip0 = (unsigned short *)inp[0];
37849 	unsigned short *op0 = (unsigned short *)outp[0];
37850 	unsigned short *ep = ip0 + npix * 4 ;
37851 	pointer it0 = (pointer)p->in_tables[0];
37852 	pointer it1 = (pointer)p->in_tables[1];
37853 	pointer it2 = (pointer)p->in_tables[2];
37854 	pointer it3 = (pointer)p->in_tables[3];
37855 	pointer ot0 = (pointer)p->out_tables[0];
37856 	pointer ot1 = (pointer)p->out_tables[1];
37857 	pointer ot2 = (pointer)p->out_tables[2];
37858 	pointer im_base = (pointer)p->im_table;
37859 
37860 	for(;ip0 < ep; ip0 += 4, op0 += 3) {
37861 		unsigned int ova0;	/* Output value accumulator */
37862 		unsigned int ova1;	/* Output value accumulator */
37863 		unsigned int ova2;	/* Output value accumulator */
37864 		{
37865 			pointer imp;
37866 			unsigned int wo0;	/* Weighting value and vertex offset variable */
37867 			unsigned int wo1;	/* Weighting value and vertex offset variable */
37868 			unsigned int wo2;	/* Weighting value and vertex offset variable */
37869 			unsigned int wo3;	/* Weighting value and vertex offset variable */
37870 			{
37871 				unsigned int ti_i;	/* Interpolation index variable */
37872 
37873 				ti_i  = IT_IX(it0, ip0[0]);
37874 				wo0   = IT_WO(it0, ip0[0]);
37875 				ti_i += IT_IX(it1, ip0[1]);
37876 				wo1   = IT_WO(it1, ip0[1]);
37877 				ti_i += IT_IX(it2, ip0[2]);
37878 				wo2   = IT_WO(it2, ip0[2]);
37879 				ti_i += IT_IX(it3, ip0[3]);
37880 				wo3   = IT_WO(it3, ip0[3]);
37881 
37882 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
37883 
37884 				/* Sort weighting values and vertex offset values */
37885 				CEX(wo0, wo1);
37886 				CEX(wo0, wo2);
37887 				CEX(wo0, wo3);
37888 				CEX(wo1, wo2);
37889 				CEX(wo1, wo3);
37890 				CEX(wo2, wo3);
37891 			}
37892 			{
37893 				unsigned int nvof;	/* Next vertex offset value */
37894 				unsigned int vof;	/* Vertex offset value */
37895 				unsigned int vwe;	/* Vertex weighting */
37896 
37897 				vof = 0;				/* First vertex offset is 0 */
37898 				nvof = (wo0 & 0x7fff);	/* Extract offset value */
37899 				wo0 = (wo0 >> 15);		/* Extract weighting value */
37900 				vwe = 65536 - wo0;		/* Baricentric weighting */
37901 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
37902 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
37903 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
37904 				vof += nvof;			/* Move to next vertex */
37905 				nvof = (wo1 & 0x7fff);	/* Extract offset value */
37906 				wo1 = (wo1 >> 15);		/* Extract weighting value */
37907 				vwe = wo0 - wo1;		/* Baricentric weighting */
37908 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
37909 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
37910 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
37911 				vof += nvof;			/* Move to next vertex */
37912 				nvof = (wo2 & 0x7fff);	/* Extract offset value */
37913 				wo2 = (wo2 >> 15);		/* Extract weighting value */
37914 				vwe = wo1 - wo2;		/* Baricentric weighting */
37915 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
37916 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
37917 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
37918 				vof += nvof;			/* Move to next vertex */
37919 				nvof = (wo3 & 0x7fff);	/* Extract offset value */
37920 				wo3 = (wo3 >> 15);		/* Extract weighting value */
37921 				vwe = wo2 - wo3;		/* Baricentric weighting */
37922 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
37923 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
37924 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
37925 				vof += nvof;			/* Move to next vertex */
37926 				vwe = wo3;				/* Baricentric weighting */
37927 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
37928 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
37929 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
37930 			}
37931 		}
37932 		{
37933 			unsigned int oti;	/* Vertex offset value */
37934 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
37935 			op0[0] = OT_E(ot0, oti);	/* Write result */
37936 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
37937 			op0[1] = OT_E(ot1, oti);	/* Write result */
37938 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
37939 			op0[2] = OT_E(ot2, oti);	/* Write result */
37940 		}
37941 	}
37942 }
37943 #undef IT_WO
37944 #undef IT_IX
37945 #undef CEX
37946 #undef IM_O
37947 #undef IM_FE
37948 #undef OT_E
37949 
37950 void
imdi_k108_gen(genspec * g)37951 imdi_k108_gen(
37952 genspec *g			/* structure to be initialised */
37953 ) {
37954 	static unsigned char data[] = {
37955 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
37956 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
37957 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37958 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37959 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37960 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37961 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37962 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
37963 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
37964 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37965 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37966 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37967 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37968 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37969 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37970 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37971 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37972 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37973 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37974 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37975 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37976 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37977 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37978 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37979 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
37980 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
37981 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37982 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
37983 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37984 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37985 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37986 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37987 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37988 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37989 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37990 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
37991 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37992 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
37993 		0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37994 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
37995 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
37996 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
37997 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
37998 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
37999 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
38000 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
38001 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
38002 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
38003 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38004 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
38005 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
38006 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x33, 0x5f,
38007 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
38008 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
38009 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
38010 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
38011 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
38012 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
38013 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
38014 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38015 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38016 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38017 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38018 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
38019 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x30,
38020 		0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38021 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38022 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
38023 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
38024 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
38025 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
38026 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
38027 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
38028 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
38029 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
38030 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
38031 		0x00, 0xf0, 0x04, 0x08
38032 	};	/* Structure image */
38033 
38034 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
38035 }
38036 
38037 void
imdi_k108_tab(tabspec * t)38038 imdi_k108_tab(
38039 tabspec *t			/* structure to be initialised */
38040 ) {
38041 	static unsigned char data[] = {
38042 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
38043 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
38044 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
38045 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
38046 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
38047 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
38048 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
38049 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
38050 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
38051 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38052 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
38053 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
38054 		0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
38055 		0x04, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
38056 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
38057 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38058 		0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
38059 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
38060 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38061 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38062 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
38063 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
38064 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
38065 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
38066 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38067 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38068 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
38069 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
38070 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38071 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38072 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
38073 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
38074 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
38075 	};	/* Structure image */
38076 
38077 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
38078 }
38079 
38080 
38081 
38082 
38083 
38084 
38085 /* Integer Multi-Dimensional Interpolation */
38086 /* Interpolation Kernel Code */
38087 /* Generated by cgen */
38088 /* Copyright 2000 - 2002 Graeme W. Gill */
38089 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
38090 
38091 /* see the Licence.txt file for licencing details.*/
38092 
38093 
38094 /*
38095    Interpolation kernel specs:
38096 
38097    Input channels per pixel = 5
38098    Input channel 0 bits = 16
38099    Input channel 0 increment = 5
38100    Input channel 1 bits = 16
38101    Input channel 1 increment = 5
38102    Input channel 2 bits = 16
38103    Input channel 2 increment = 5
38104    Input channel 3 bits = 16
38105    Input channel 3 increment = 5
38106    Input channel 4 bits = 16
38107    Input channel 4 increment = 5
38108    Input is channel interleaved
38109    Input channels are separate words
38110    Input value extraction is done in input table lookup
38111 
38112    Output channels per pixel = 3
38113    Output channel 0 bits = 16
38114    Output channel 0 increment = 3
38115    Output channel 1 bits = 16
38116    Output channel 1 increment = 3
38117    Output channel 2 bits = 16
38118    Output channel 2 increment = 3
38119    Output is channel interleaved
38120 
38121    Output channels are separate words
38122    Weight+voffset bits       = 32
38123    Interpolation table index bits = 32
38124    Interpolation table max resolution = 84
38125  */
38126 
38127 /*
38128    Machine architecture specs:
38129 
38130    Little endian
38131    Reading and writing pixel values separately
38132    Pointer size = 32 bits
38133 
38134    Ordinal size  8 bits is known as 'unsigned char'
38135    Ordinal size 16 bits is known as 'unsigned short'
38136    Ordinal size 32 bits is known as 'unsigned int'
38137    Natural ordinal is 'unsigned int'
38138 
38139    Integer size  8 bits is known as 'signed char'
38140    Integer size 16 bits is known as 'short'
38141    Integer size 32 bits is known as 'int'
38142    Natural integer is 'int'
38143 
38144  */
38145 
38146 #ifndef  IMDI_INCLUDED
38147 #include <memory.h>
38148 #include "imdi_imp.h"
38149 #define  IMDI_INCLUDED
38150 #endif  /* IMDI_INCLUDED */
38151 
38152 #ifndef DEFINED_pointer
38153 #define DEFINED_pointer
38154 typedef unsigned char * pointer;
38155 #endif
38156 
38157 /* Input table interp. index */
38158 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
38159 
38160 /* Input table input weighting enty */
38161 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
38162 
38163 /* Input table input offset value enty */
38164 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
38165 
38166 /* Conditional exchange for sorting */
38167 #define CEX(A, AA, B, BB) if (A < B) { \
38168             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
38169 
38170 /* Interpolation multi-dim. table access */
38171 #define IM_O(off) ((off) * 6)
38172 
38173 /* Interpolation table - get vertex values */
38174 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
38175 
38176 /* Output table indexes */
38177 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
38178 
38179 void
imdi_k109(imdi * s,void ** outp,void ** inp,unsigned int npix)38180 imdi_k109(
38181 imdi *s,			/* imdi context */
38182 void **outp,		/* pointer to output pointers */
38183 void **inp,		/* pointer to input pointers */
38184 unsigned int npix	/* Number of pixels to process */
38185 ) {
38186 	imdi_imp *p = (imdi_imp *)(s->impl);
38187 	unsigned short *ip0 = (unsigned short *)inp[0];
38188 	unsigned short *op0 = (unsigned short *)outp[0];
38189 	unsigned short *ep = ip0 + npix * 5 ;
38190 	pointer it0 = (pointer)p->in_tables[0];
38191 	pointer it1 = (pointer)p->in_tables[1];
38192 	pointer it2 = (pointer)p->in_tables[2];
38193 	pointer it3 = (pointer)p->in_tables[3];
38194 	pointer it4 = (pointer)p->in_tables[4];
38195 	pointer ot0 = (pointer)p->out_tables[0];
38196 	pointer ot1 = (pointer)p->out_tables[1];
38197 	pointer ot2 = (pointer)p->out_tables[2];
38198 	pointer im_base = (pointer)p->im_table;
38199 
38200 	for(;ip0 < ep; ip0 += 5, op0 += 3) {
38201 		unsigned int ova0;	/* Output value accumulator */
38202 		unsigned int ova1;	/* Output value accumulator */
38203 		unsigned int ova2;	/* Output value accumulator */
38204 		{
38205 			pointer imp;
38206 			unsigned int we0;	/* Weighting value variable */
38207 			unsigned int vo0;	/* Vertex offset variable */
38208 			unsigned int we1;	/* Weighting value variable */
38209 			unsigned int vo1;	/* Vertex offset variable */
38210 			unsigned int we2;	/* Weighting value variable */
38211 			unsigned int vo2;	/* Vertex offset variable */
38212 			unsigned int we3;	/* Weighting value variable */
38213 			unsigned int vo3;	/* Vertex offset variable */
38214 			unsigned int we4;	/* Weighting value variable */
38215 			unsigned int vo4;	/* Vertex offset variable */
38216 			{
38217 				unsigned int ti_i;	/* Interpolation index variable */
38218 
38219 				ti_i  = IT_IX(it0, ip0[0]);
38220 				we0   = IT_WE(it0, ip0[0]);
38221 				vo0   = IT_VO(it0, ip0[0]);
38222 				ti_i += IT_IX(it1, ip0[1]);
38223 				we1   = IT_WE(it1, ip0[1]);
38224 				vo1   = IT_VO(it1, ip0[1]);
38225 				ti_i += IT_IX(it2, ip0[2]);
38226 				we2   = IT_WE(it2, ip0[2]);
38227 				vo2   = IT_VO(it2, ip0[2]);
38228 				ti_i += IT_IX(it3, ip0[3]);
38229 				we3   = IT_WE(it3, ip0[3]);
38230 				vo3   = IT_VO(it3, ip0[3]);
38231 				ti_i += IT_IX(it4, ip0[4]);
38232 				we4   = IT_WE(it4, ip0[4]);
38233 				vo4   = IT_VO(it4, ip0[4]);
38234 
38235 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
38236 
38237 				/* Sort weighting values and vertex offset values */
38238 				CEX(we0, vo0, we1, vo1);
38239 				CEX(we0, vo0, we2, vo2);
38240 				CEX(we0, vo0, we3, vo3);
38241 				CEX(we0, vo0, we4, vo4);
38242 				CEX(we1, vo1, we2, vo2);
38243 				CEX(we1, vo1, we3, vo3);
38244 				CEX(we1, vo1, we4, vo4);
38245 				CEX(we2, vo2, we3, vo3);
38246 				CEX(we2, vo2, we4, vo4);
38247 				CEX(we3, vo3, we4, vo4);
38248 			}
38249 			{
38250 				unsigned int vof;	/* Vertex offset value */
38251 				unsigned int vwe;	/* Vertex weighting */
38252 
38253 				vof = 0;				/* First vertex offset is 0 */
38254 				vwe = 65536 - we0;		/* Baricentric weighting */
38255 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
38256 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
38257 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
38258 				vof += vo0;			/* Move to next vertex */
38259 				vwe = we0 - we1;		/* Baricentric weighting */
38260 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
38261 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
38262 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
38263 				vof += vo1;			/* Move to next vertex */
38264 				vwe = we1 - we2;		/* Baricentric weighting */
38265 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
38266 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
38267 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
38268 				vof += vo2;			/* Move to next vertex */
38269 				vwe = we2 - we3;		/* Baricentric weighting */
38270 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
38271 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
38272 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
38273 				vof += vo3;			/* Move to next vertex */
38274 				vwe = we3 - we4;		/* Baricentric weighting */
38275 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
38276 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
38277 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
38278 				vof += vo4;			/* Move to next vertex */
38279 				vwe = we4;				/* Baricentric weighting */
38280 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
38281 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
38282 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
38283 			}
38284 		}
38285 		{
38286 			unsigned int oti;	/* Vertex offset value */
38287 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
38288 			op0[0] = OT_E(ot0, oti);	/* Write result */
38289 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
38290 			op0[1] = OT_E(ot1, oti);	/* Write result */
38291 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
38292 			op0[2] = OT_E(ot2, oti);	/* Write result */
38293 		}
38294 	}
38295 }
38296 #undef IT_WE
38297 #undef IT_VO
38298 #undef IT_IX
38299 #undef CEX
38300 #undef IM_O
38301 #undef IM_FE
38302 #undef OT_E
38303 
38304 void
imdi_k109_gen(genspec * g)38305 imdi_k109_gen(
38306 genspec *g			/* structure to be initialised */
38307 ) {
38308 	static unsigned char data[] = {
38309 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
38310 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
38311 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38312 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38313 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38314 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38315 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38316 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
38317 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
38318 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
38319 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
38320 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38321 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38322 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38323 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38324 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38325 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38326 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38327 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38328 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
38329 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38330 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38331 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38332 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38333 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
38334 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
38335 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
38336 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
38337 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38338 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38339 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38340 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38341 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38342 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38343 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38344 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38345 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
38346 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
38347 		0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38348 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
38349 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
38350 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
38351 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
38352 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
38353 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
38354 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
38355 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
38356 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
38357 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38358 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
38359 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
38360 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x33, 0x5f,
38361 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
38362 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
38363 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
38364 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
38365 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
38366 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
38367 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
38368 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38369 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38370 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38371 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38372 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
38373 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x30,
38374 		0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38375 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38376 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
38377 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
38378 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
38379 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
38380 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
38381 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
38382 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
38383 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
38384 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
38385 		0x00, 0xf0, 0x04, 0x08
38386 	};	/* Structure image */
38387 
38388 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
38389 }
38390 
38391 void
imdi_k109_tab(tabspec * t)38392 imdi_k109_tab(
38393 tabspec *t			/* structure to be initialised */
38394 ) {
38395 	static unsigned char data[] = {
38396 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
38397 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
38398 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
38399 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
38400 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
38401 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
38402 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
38403 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
38404 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
38405 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38406 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
38407 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
38408 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
38409 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
38410 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
38411 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38412 		0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
38413 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
38414 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38415 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38416 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
38417 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
38418 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
38419 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
38420 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38421 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38422 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
38423 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
38424 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38425 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38426 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
38427 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
38428 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
38429 	};	/* Structure image */
38430 
38431 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
38432 }
38433 
38434 
38435 
38436 
38437 
38438 
38439 /* Integer Multi-Dimensional Interpolation */
38440 /* Interpolation Kernel Code */
38441 /* Generated by cgen */
38442 /* Copyright 2000 - 2002 Graeme W. Gill */
38443 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
38444 
38445 /* see the Licence.txt file for licencing details.*/
38446 
38447 
38448 /*
38449    Interpolation kernel specs:
38450 
38451    Input channels per pixel = 6
38452    Input channel 0 bits = 16
38453    Input channel 0 increment = 6
38454    Input channel 1 bits = 16
38455    Input channel 1 increment = 6
38456    Input channel 2 bits = 16
38457    Input channel 2 increment = 6
38458    Input channel 3 bits = 16
38459    Input channel 3 increment = 6
38460    Input channel 4 bits = 16
38461    Input channel 4 increment = 6
38462    Input channel 5 bits = 16
38463    Input channel 5 increment = 6
38464    Input is channel interleaved
38465    Input channels are separate words
38466    Input value extraction is done in input table lookup
38467 
38468    Output channels per pixel = 3
38469    Output channel 0 bits = 16
38470    Output channel 0 increment = 3
38471    Output channel 1 bits = 16
38472    Output channel 1 increment = 3
38473    Output channel 2 bits = 16
38474    Output channel 2 increment = 3
38475    Output is channel interleaved
38476 
38477    Output channels are separate words
38478    Weight+voffset bits       = 32
38479    Interpolation table index bits = 32
38480    Interpolation table max resolution = 40
38481  */
38482 
38483 /*
38484    Machine architecture specs:
38485 
38486    Little endian
38487    Reading and writing pixel values separately
38488    Pointer size = 32 bits
38489 
38490    Ordinal size  8 bits is known as 'unsigned char'
38491    Ordinal size 16 bits is known as 'unsigned short'
38492    Ordinal size 32 bits is known as 'unsigned int'
38493    Natural ordinal is 'unsigned int'
38494 
38495    Integer size  8 bits is known as 'signed char'
38496    Integer size 16 bits is known as 'short'
38497    Integer size 32 bits is known as 'int'
38498    Natural integer is 'int'
38499 
38500  */
38501 
38502 #ifndef  IMDI_INCLUDED
38503 #include <memory.h>
38504 #include "imdi_imp.h"
38505 #define  IMDI_INCLUDED
38506 #endif  /* IMDI_INCLUDED */
38507 
38508 #ifndef DEFINED_pointer
38509 #define DEFINED_pointer
38510 typedef unsigned char * pointer;
38511 #endif
38512 
38513 /* Input table interp. index */
38514 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
38515 
38516 /* Input table input weighting enty */
38517 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
38518 
38519 /* Input table input offset value enty */
38520 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
38521 
38522 /* Conditional exchange for sorting */
38523 #define CEX(A, AA, B, BB) if (A < B) { \
38524             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
38525 
38526 /* Interpolation multi-dim. table access */
38527 #define IM_O(off) ((off) * 6)
38528 
38529 /* Interpolation table - get vertex values */
38530 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
38531 
38532 /* Output table indexes */
38533 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
38534 
38535 void
imdi_k110(imdi * s,void ** outp,void ** inp,unsigned int npix)38536 imdi_k110(
38537 imdi *s,			/* imdi context */
38538 void **outp,		/* pointer to output pointers */
38539 void **inp,		/* pointer to input pointers */
38540 unsigned int npix	/* Number of pixels to process */
38541 ) {
38542 	imdi_imp *p = (imdi_imp *)(s->impl);
38543 	unsigned short *ip0 = (unsigned short *)inp[0];
38544 	unsigned short *op0 = (unsigned short *)outp[0];
38545 	unsigned short *ep = ip0 + npix * 6 ;
38546 	pointer it0 = (pointer)p->in_tables[0];
38547 	pointer it1 = (pointer)p->in_tables[1];
38548 	pointer it2 = (pointer)p->in_tables[2];
38549 	pointer it3 = (pointer)p->in_tables[3];
38550 	pointer it4 = (pointer)p->in_tables[4];
38551 	pointer it5 = (pointer)p->in_tables[5];
38552 	pointer ot0 = (pointer)p->out_tables[0];
38553 	pointer ot1 = (pointer)p->out_tables[1];
38554 	pointer ot2 = (pointer)p->out_tables[2];
38555 	pointer im_base = (pointer)p->im_table;
38556 
38557 	for(;ip0 < ep; ip0 += 6, op0 += 3) {
38558 		unsigned int ova0;	/* Output value accumulator */
38559 		unsigned int ova1;	/* Output value accumulator */
38560 		unsigned int ova2;	/* Output value accumulator */
38561 		{
38562 			pointer imp;
38563 			unsigned int we0;	/* Weighting value variable */
38564 			unsigned int vo0;	/* Vertex offset variable */
38565 			unsigned int we1;	/* Weighting value variable */
38566 			unsigned int vo1;	/* Vertex offset variable */
38567 			unsigned int we2;	/* Weighting value variable */
38568 			unsigned int vo2;	/* Vertex offset variable */
38569 			unsigned int we3;	/* Weighting value variable */
38570 			unsigned int vo3;	/* Vertex offset variable */
38571 			unsigned int we4;	/* Weighting value variable */
38572 			unsigned int vo4;	/* Vertex offset variable */
38573 			unsigned int we5;	/* Weighting value variable */
38574 			unsigned int vo5;	/* Vertex offset variable */
38575 			{
38576 				unsigned int ti_i;	/* Interpolation index variable */
38577 
38578 				ti_i  = IT_IX(it0, ip0[0]);
38579 				we0   = IT_WE(it0, ip0[0]);
38580 				vo0   = IT_VO(it0, ip0[0]);
38581 				ti_i += IT_IX(it1, ip0[1]);
38582 				we1   = IT_WE(it1, ip0[1]);
38583 				vo1   = IT_VO(it1, ip0[1]);
38584 				ti_i += IT_IX(it2, ip0[2]);
38585 				we2   = IT_WE(it2, ip0[2]);
38586 				vo2   = IT_VO(it2, ip0[2]);
38587 				ti_i += IT_IX(it3, ip0[3]);
38588 				we3   = IT_WE(it3, ip0[3]);
38589 				vo3   = IT_VO(it3, ip0[3]);
38590 				ti_i += IT_IX(it4, ip0[4]);
38591 				we4   = IT_WE(it4, ip0[4]);
38592 				vo4   = IT_VO(it4, ip0[4]);
38593 				ti_i += IT_IX(it5, ip0[5]);
38594 				we5   = IT_WE(it5, ip0[5]);
38595 				vo5   = IT_VO(it5, ip0[5]);
38596 
38597 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
38598 
38599 				/* Sort weighting values and vertex offset values */
38600 				CEX(we0, vo0, we1, vo1);
38601 				CEX(we0, vo0, we2, vo2);
38602 				CEX(we0, vo0, we3, vo3);
38603 				CEX(we0, vo0, we4, vo4);
38604 				CEX(we0, vo0, we5, vo5);
38605 				CEX(we1, vo1, we2, vo2);
38606 				CEX(we1, vo1, we3, vo3);
38607 				CEX(we1, vo1, we4, vo4);
38608 				CEX(we1, vo1, we5, vo5);
38609 				CEX(we2, vo2, we3, vo3);
38610 				CEX(we2, vo2, we4, vo4);
38611 				CEX(we2, vo2, we5, vo5);
38612 				CEX(we3, vo3, we4, vo4);
38613 				CEX(we3, vo3, we5, vo5);
38614 				CEX(we4, vo4, we5, vo5);
38615 			}
38616 			{
38617 				unsigned int vof;	/* Vertex offset value */
38618 				unsigned int vwe;	/* Vertex weighting */
38619 
38620 				vof = 0;				/* First vertex offset is 0 */
38621 				vwe = 65536 - we0;		/* Baricentric weighting */
38622 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
38623 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
38624 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
38625 				vof += vo0;			/* Move to next vertex */
38626 				vwe = we0 - we1;		/* Baricentric weighting */
38627 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
38628 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
38629 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
38630 				vof += vo1;			/* Move to next vertex */
38631 				vwe = we1 - we2;		/* Baricentric weighting */
38632 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
38633 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
38634 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
38635 				vof += vo2;			/* Move to next vertex */
38636 				vwe = we2 - we3;		/* Baricentric weighting */
38637 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
38638 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
38639 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
38640 				vof += vo3;			/* Move to next vertex */
38641 				vwe = we3 - we4;		/* Baricentric weighting */
38642 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
38643 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
38644 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
38645 				vof += vo4;			/* Move to next vertex */
38646 				vwe = we4 - we5;		/* Baricentric weighting */
38647 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
38648 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
38649 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
38650 				vof += vo5;			/* Move to next vertex */
38651 				vwe = we5;				/* Baricentric weighting */
38652 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
38653 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
38654 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
38655 			}
38656 		}
38657 		{
38658 			unsigned int oti;	/* Vertex offset value */
38659 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
38660 			op0[0] = OT_E(ot0, oti);	/* Write result */
38661 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
38662 			op0[1] = OT_E(ot1, oti);	/* Write result */
38663 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
38664 			op0[2] = OT_E(ot2, oti);	/* Write result */
38665 		}
38666 	}
38667 }
38668 #undef IT_WE
38669 #undef IT_VO
38670 #undef IT_IX
38671 #undef CEX
38672 #undef IM_O
38673 #undef IM_FE
38674 #undef OT_E
38675 
38676 void
imdi_k110_gen(genspec * g)38677 imdi_k110_gen(
38678 genspec *g			/* structure to be initialised */
38679 ) {
38680 	static unsigned char data[] = {
38681 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
38682 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
38683 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38684 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38685 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38686 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38687 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38688 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
38689 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
38690 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
38691 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
38692 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38693 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38694 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38695 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38696 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38697 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38698 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38699 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38700 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
38701 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38702 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38703 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38704 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38705 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
38706 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
38707 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
38708 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
38709 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38710 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38711 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38712 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38713 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38714 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38715 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38716 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38717 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
38718 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
38719 		0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38720 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
38721 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
38722 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
38723 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
38724 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
38725 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
38726 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
38727 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
38728 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
38729 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38730 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
38731 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
38732 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x33, 0x5f,
38733 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
38734 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
38735 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
38736 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
38737 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
38738 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
38739 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
38740 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38741 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38742 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38743 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38744 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
38745 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x31,
38746 		0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38747 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38748 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
38749 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
38750 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
38751 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
38752 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
38753 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
38754 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
38755 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
38756 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
38757 		0x00, 0xf0, 0x04, 0x08
38758 	};	/* Structure image */
38759 
38760 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
38761 }
38762 
38763 void
imdi_k110_tab(tabspec * t)38764 imdi_k110_tab(
38765 tabspec *t			/* structure to be initialised */
38766 ) {
38767 	static unsigned char data[] = {
38768 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
38769 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
38770 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
38771 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
38772 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
38773 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
38774 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
38775 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
38776 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
38777 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38778 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
38779 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
38780 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
38781 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
38782 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
38783 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38784 		0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
38785 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
38786 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38787 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38788 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
38789 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
38790 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
38791 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
38792 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38793 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38794 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
38795 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
38796 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38797 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
38798 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
38799 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
38800 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
38801 	};	/* Structure image */
38802 
38803 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
38804 }
38805 
38806 
38807 
38808 
38809 
38810 
38811 /* Integer Multi-Dimensional Interpolation */
38812 /* Interpolation Kernel Code */
38813 /* Generated by cgen */
38814 /* Copyright 2000 - 2002 Graeme W. Gill */
38815 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
38816 
38817 /* see the Licence.txt file for licencing details.*/
38818 
38819 
38820 /*
38821    Interpolation kernel specs:
38822 
38823    Input channels per pixel = 7
38824    Input channel 0 bits = 16
38825    Input channel 0 increment = 7
38826    Input channel 1 bits = 16
38827    Input channel 1 increment = 7
38828    Input channel 2 bits = 16
38829    Input channel 2 increment = 7
38830    Input channel 3 bits = 16
38831    Input channel 3 increment = 7
38832    Input channel 4 bits = 16
38833    Input channel 4 increment = 7
38834    Input channel 5 bits = 16
38835    Input channel 5 increment = 7
38836    Input channel 6 bits = 16
38837    Input channel 6 increment = 7
38838    Input is channel interleaved
38839    Input channels are separate words
38840    Input value extraction is done in input table lookup
38841 
38842    Output channels per pixel = 3
38843    Output channel 0 bits = 16
38844    Output channel 0 increment = 3
38845    Output channel 1 bits = 16
38846    Output channel 1 increment = 3
38847    Output channel 2 bits = 16
38848    Output channel 2 increment = 3
38849    Output is channel interleaved
38850 
38851    Output channels are separate words
38852    Weight+voffset bits       = 32
38853    Interpolation table index bits = 32
38854    Interpolation table max resolution = 23
38855  */
38856 
38857 /*
38858    Machine architecture specs:
38859 
38860    Little endian
38861    Reading and writing pixel values separately
38862    Pointer size = 32 bits
38863 
38864    Ordinal size  8 bits is known as 'unsigned char'
38865    Ordinal size 16 bits is known as 'unsigned short'
38866    Ordinal size 32 bits is known as 'unsigned int'
38867    Natural ordinal is 'unsigned int'
38868 
38869    Integer size  8 bits is known as 'signed char'
38870    Integer size 16 bits is known as 'short'
38871    Integer size 32 bits is known as 'int'
38872    Natural integer is 'int'
38873 
38874  */
38875 
38876 #ifndef  IMDI_INCLUDED
38877 #include <memory.h>
38878 #include "imdi_imp.h"
38879 #define  IMDI_INCLUDED
38880 #endif  /* IMDI_INCLUDED */
38881 
38882 #ifndef DEFINED_pointer
38883 #define DEFINED_pointer
38884 typedef unsigned char * pointer;
38885 #endif
38886 
38887 /* Input table interp. index */
38888 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
38889 
38890 /* Input table input weighting enty */
38891 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
38892 
38893 /* Input table input offset value enty */
38894 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
38895 
38896 /* Conditional exchange for sorting */
38897 #define CEX(A, AA, B, BB) if (A < B) { \
38898             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
38899 
38900 /* Interpolation multi-dim. table access */
38901 #define IM_O(off) ((off) * 6)
38902 
38903 /* Interpolation table - get vertex values */
38904 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
38905 
38906 /* Output table indexes */
38907 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
38908 
38909 void
imdi_k111(imdi * s,void ** outp,void ** inp,unsigned int npix)38910 imdi_k111(
38911 imdi *s,			/* imdi context */
38912 void **outp,		/* pointer to output pointers */
38913 void **inp,		/* pointer to input pointers */
38914 unsigned int npix	/* Number of pixels to process */
38915 ) {
38916 	imdi_imp *p = (imdi_imp *)(s->impl);
38917 	unsigned short *ip0 = (unsigned short *)inp[0];
38918 	unsigned short *op0 = (unsigned short *)outp[0];
38919 	unsigned short *ep = ip0 + npix * 7 ;
38920 	pointer it0 = (pointer)p->in_tables[0];
38921 	pointer it1 = (pointer)p->in_tables[1];
38922 	pointer it2 = (pointer)p->in_tables[2];
38923 	pointer it3 = (pointer)p->in_tables[3];
38924 	pointer it4 = (pointer)p->in_tables[4];
38925 	pointer it5 = (pointer)p->in_tables[5];
38926 	pointer it6 = (pointer)p->in_tables[6];
38927 	pointer ot0 = (pointer)p->out_tables[0];
38928 	pointer ot1 = (pointer)p->out_tables[1];
38929 	pointer ot2 = (pointer)p->out_tables[2];
38930 	pointer im_base = (pointer)p->im_table;
38931 
38932 	for(;ip0 < ep; ip0 += 7, op0 += 3) {
38933 		unsigned int ova0;	/* Output value accumulator */
38934 		unsigned int ova1;	/* Output value accumulator */
38935 		unsigned int ova2;	/* Output value accumulator */
38936 		{
38937 			pointer imp;
38938 			unsigned int we0;	/* Weighting value variable */
38939 			unsigned int vo0;	/* Vertex offset variable */
38940 			unsigned int we1;	/* Weighting value variable */
38941 			unsigned int vo1;	/* Vertex offset variable */
38942 			unsigned int we2;	/* Weighting value variable */
38943 			unsigned int vo2;	/* Vertex offset variable */
38944 			unsigned int we3;	/* Weighting value variable */
38945 			unsigned int vo3;	/* Vertex offset variable */
38946 			unsigned int we4;	/* Weighting value variable */
38947 			unsigned int vo4;	/* Vertex offset variable */
38948 			unsigned int we5;	/* Weighting value variable */
38949 			unsigned int vo5;	/* Vertex offset variable */
38950 			unsigned int we6;	/* Weighting value variable */
38951 			unsigned int vo6;	/* Vertex offset variable */
38952 			{
38953 				unsigned int ti_i;	/* Interpolation index variable */
38954 
38955 				ti_i  = IT_IX(it0, ip0[0]);
38956 				we0   = IT_WE(it0, ip0[0]);
38957 				vo0   = IT_VO(it0, ip0[0]);
38958 				ti_i += IT_IX(it1, ip0[1]);
38959 				we1   = IT_WE(it1, ip0[1]);
38960 				vo1   = IT_VO(it1, ip0[1]);
38961 				ti_i += IT_IX(it2, ip0[2]);
38962 				we2   = IT_WE(it2, ip0[2]);
38963 				vo2   = IT_VO(it2, ip0[2]);
38964 				ti_i += IT_IX(it3, ip0[3]);
38965 				we3   = IT_WE(it3, ip0[3]);
38966 				vo3   = IT_VO(it3, ip0[3]);
38967 				ti_i += IT_IX(it4, ip0[4]);
38968 				we4   = IT_WE(it4, ip0[4]);
38969 				vo4   = IT_VO(it4, ip0[4]);
38970 				ti_i += IT_IX(it5, ip0[5]);
38971 				we5   = IT_WE(it5, ip0[5]);
38972 				vo5   = IT_VO(it5, ip0[5]);
38973 				ti_i += IT_IX(it6, ip0[6]);
38974 				we6   = IT_WE(it6, ip0[6]);
38975 				vo6   = IT_VO(it6, ip0[6]);
38976 
38977 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
38978 
38979 				/* Sort weighting values and vertex offset values */
38980 				CEX(we0, vo0, we1, vo1);
38981 				CEX(we0, vo0, we2, vo2);
38982 				CEX(we0, vo0, we3, vo3);
38983 				CEX(we0, vo0, we4, vo4);
38984 				CEX(we0, vo0, we5, vo5);
38985 				CEX(we0, vo0, we6, vo6);
38986 				CEX(we1, vo1, we2, vo2);
38987 				CEX(we1, vo1, we3, vo3);
38988 				CEX(we1, vo1, we4, vo4);
38989 				CEX(we1, vo1, we5, vo5);
38990 				CEX(we1, vo1, we6, vo6);
38991 				CEX(we2, vo2, we3, vo3);
38992 				CEX(we2, vo2, we4, vo4);
38993 				CEX(we2, vo2, we5, vo5);
38994 				CEX(we2, vo2, we6, vo6);
38995 				CEX(we3, vo3, we4, vo4);
38996 				CEX(we3, vo3, we5, vo5);
38997 				CEX(we3, vo3, we6, vo6);
38998 				CEX(we4, vo4, we5, vo5);
38999 				CEX(we4, vo4, we6, vo6);
39000 				CEX(we5, vo5, we6, vo6);
39001 			}
39002 			{
39003 				unsigned int vof;	/* Vertex offset value */
39004 				unsigned int vwe;	/* Vertex weighting */
39005 
39006 				vof = 0;				/* First vertex offset is 0 */
39007 				vwe = 65536 - we0;		/* Baricentric weighting */
39008 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
39009 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
39010 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
39011 				vof += vo0;			/* Move to next vertex */
39012 				vwe = we0 - we1;		/* Baricentric weighting */
39013 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
39014 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
39015 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
39016 				vof += vo1;			/* Move to next vertex */
39017 				vwe = we1 - we2;		/* Baricentric weighting */
39018 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
39019 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
39020 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
39021 				vof += vo2;			/* Move to next vertex */
39022 				vwe = we2 - we3;		/* Baricentric weighting */
39023 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
39024 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
39025 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
39026 				vof += vo3;			/* Move to next vertex */
39027 				vwe = we3 - we4;		/* Baricentric weighting */
39028 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
39029 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
39030 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
39031 				vof += vo4;			/* Move to next vertex */
39032 				vwe = we4 - we5;		/* Baricentric weighting */
39033 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
39034 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
39035 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
39036 				vof += vo5;			/* Move to next vertex */
39037 				vwe = we5 - we6;		/* Baricentric weighting */
39038 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
39039 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
39040 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
39041 				vof += vo6;			/* Move to next vertex */
39042 				vwe = we6;				/* Baricentric weighting */
39043 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
39044 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
39045 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
39046 			}
39047 		}
39048 		{
39049 			unsigned int oti;	/* Vertex offset value */
39050 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
39051 			op0[0] = OT_E(ot0, oti);	/* Write result */
39052 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
39053 			op0[1] = OT_E(ot1, oti);	/* Write result */
39054 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
39055 			op0[2] = OT_E(ot2, oti);	/* Write result */
39056 		}
39057 	}
39058 }
39059 #undef IT_WE
39060 #undef IT_VO
39061 #undef IT_IX
39062 #undef CEX
39063 #undef IM_O
39064 #undef IM_FE
39065 #undef OT_E
39066 
39067 void
imdi_k111_gen(genspec * g)39068 imdi_k111_gen(
39069 genspec *g			/* structure to be initialised */
39070 ) {
39071 	static unsigned char data[] = {
39072 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
39073 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
39074 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39075 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39076 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39077 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39078 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39079 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
39080 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
39081 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
39082 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
39083 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39084 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39085 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39086 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39087 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39088 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39089 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39090 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39091 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39092 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39093 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39094 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39095 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39096 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
39097 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
39098 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
39099 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
39100 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39101 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39102 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39103 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39104 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39105 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39106 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39107 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39108 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39109 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39110 		0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39111 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
39112 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
39113 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
39114 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
39115 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
39116 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
39117 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
39118 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
39119 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
39120 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39121 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
39122 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
39123 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x33, 0x5f,
39124 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
39125 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
39126 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
39127 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
39128 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
39129 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
39130 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
39131 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39132 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39133 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39134 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39135 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
39136 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x31,
39137 		0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39138 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39139 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
39140 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
39141 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
39142 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
39143 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
39144 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
39145 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
39146 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
39147 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
39148 		0x00, 0xf0, 0x04, 0x08
39149 	};	/* Structure image */
39150 
39151 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
39152 }
39153 
39154 void
imdi_k111_tab(tabspec * t)39155 imdi_k111_tab(
39156 tabspec *t			/* structure to be initialised */
39157 ) {
39158 	static unsigned char data[] = {
39159 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39160 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39161 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39162 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
39163 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
39164 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
39165 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
39166 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
39167 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
39168 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39169 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
39170 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
39171 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
39172 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
39173 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
39174 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39175 		0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
39176 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
39177 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39178 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39179 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39180 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
39181 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
39182 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
39183 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39184 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39185 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
39186 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
39187 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39188 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39189 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
39190 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
39191 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
39192 	};	/* Structure image */
39193 
39194 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
39195 }
39196 
39197 
39198 
39199 
39200 
39201 
39202 /* Integer Multi-Dimensional Interpolation */
39203 /* Interpolation Kernel Code */
39204 /* Generated by cgen */
39205 /* Copyright 2000 - 2002 Graeme W. Gill */
39206 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
39207 
39208 /* see the Licence.txt file for licencing details.*/
39209 
39210 
39211 /*
39212    Interpolation kernel specs:
39213 
39214    Input channels per pixel = 8
39215    Input channel 0 bits = 16
39216    Input channel 0 increment = 8
39217    Input channel 1 bits = 16
39218    Input channel 1 increment = 8
39219    Input channel 2 bits = 16
39220    Input channel 2 increment = 8
39221    Input channel 3 bits = 16
39222    Input channel 3 increment = 8
39223    Input channel 4 bits = 16
39224    Input channel 4 increment = 8
39225    Input channel 5 bits = 16
39226    Input channel 5 increment = 8
39227    Input channel 6 bits = 16
39228    Input channel 6 increment = 8
39229    Input channel 7 bits = 16
39230    Input channel 7 increment = 8
39231    Input is channel interleaved
39232    Input channels are separate words
39233    Input value extraction is done in input table lookup
39234 
39235    Output channels per pixel = 3
39236    Output channel 0 bits = 16
39237    Output channel 0 increment = 3
39238    Output channel 1 bits = 16
39239    Output channel 1 increment = 3
39240    Output channel 2 bits = 16
39241    Output channel 2 increment = 3
39242    Output is channel interleaved
39243 
39244    Output channels are separate words
39245    Weight+voffset bits       = 32
39246    Interpolation table index bits = 32
39247    Interpolation table max resolution = 16
39248  */
39249 
39250 /*
39251    Machine architecture specs:
39252 
39253    Little endian
39254    Reading and writing pixel values separately
39255    Pointer size = 32 bits
39256 
39257    Ordinal size  8 bits is known as 'unsigned char'
39258    Ordinal size 16 bits is known as 'unsigned short'
39259    Ordinal size 32 bits is known as 'unsigned int'
39260    Natural ordinal is 'unsigned int'
39261 
39262    Integer size  8 bits is known as 'signed char'
39263    Integer size 16 bits is known as 'short'
39264    Integer size 32 bits is known as 'int'
39265    Natural integer is 'int'
39266 
39267  */
39268 
39269 #ifndef  IMDI_INCLUDED
39270 #include <memory.h>
39271 #include "imdi_imp.h"
39272 #define  IMDI_INCLUDED
39273 #endif  /* IMDI_INCLUDED */
39274 
39275 #ifndef DEFINED_pointer
39276 #define DEFINED_pointer
39277 typedef unsigned char * pointer;
39278 #endif
39279 
39280 /* Input table interp. index */
39281 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
39282 
39283 /* Input table input weighting enty */
39284 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
39285 
39286 /* Input table input offset value enty */
39287 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
39288 
39289 /* Conditional exchange for sorting */
39290 #define CEX(A, AA, B, BB) if (A < B) { \
39291             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
39292 
39293 /* Interpolation multi-dim. table access */
39294 #define IM_O(off) ((off) * 6)
39295 
39296 /* Interpolation table - get vertex values */
39297 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
39298 
39299 /* Output table indexes */
39300 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
39301 
39302 void
imdi_k112(imdi * s,void ** outp,void ** inp,unsigned int npix)39303 imdi_k112(
39304 imdi *s,			/* imdi context */
39305 void **outp,		/* pointer to output pointers */
39306 void **inp,		/* pointer to input pointers */
39307 unsigned int npix	/* Number of pixels to process */
39308 ) {
39309 	imdi_imp *p = (imdi_imp *)(s->impl);
39310 	unsigned short *ip0 = (unsigned short *)inp[0];
39311 	unsigned short *op0 = (unsigned short *)outp[0];
39312 	unsigned short *ep = ip0 + npix * 8 ;
39313 	pointer it0 = (pointer)p->in_tables[0];
39314 	pointer it1 = (pointer)p->in_tables[1];
39315 	pointer it2 = (pointer)p->in_tables[2];
39316 	pointer it3 = (pointer)p->in_tables[3];
39317 	pointer it4 = (pointer)p->in_tables[4];
39318 	pointer it5 = (pointer)p->in_tables[5];
39319 	pointer it6 = (pointer)p->in_tables[6];
39320 	pointer it7 = (pointer)p->in_tables[7];
39321 	pointer ot0 = (pointer)p->out_tables[0];
39322 	pointer ot1 = (pointer)p->out_tables[1];
39323 	pointer ot2 = (pointer)p->out_tables[2];
39324 	pointer im_base = (pointer)p->im_table;
39325 
39326 	for(;ip0 < ep; ip0 += 8, op0 += 3) {
39327 		unsigned int ova0;	/* Output value accumulator */
39328 		unsigned int ova1;	/* Output value accumulator */
39329 		unsigned int ova2;	/* Output value accumulator */
39330 		{
39331 			pointer imp;
39332 			unsigned int we0;	/* Weighting value variable */
39333 			unsigned int vo0;	/* Vertex offset variable */
39334 			unsigned int we1;	/* Weighting value variable */
39335 			unsigned int vo1;	/* Vertex offset variable */
39336 			unsigned int we2;	/* Weighting value variable */
39337 			unsigned int vo2;	/* Vertex offset variable */
39338 			unsigned int we3;	/* Weighting value variable */
39339 			unsigned int vo3;	/* Vertex offset variable */
39340 			unsigned int we4;	/* Weighting value variable */
39341 			unsigned int vo4;	/* Vertex offset variable */
39342 			unsigned int we5;	/* Weighting value variable */
39343 			unsigned int vo5;	/* Vertex offset variable */
39344 			unsigned int we6;	/* Weighting value variable */
39345 			unsigned int vo6;	/* Vertex offset variable */
39346 			unsigned int we7;	/* Weighting value variable */
39347 			unsigned int vo7;	/* Vertex offset variable */
39348 			{
39349 				unsigned int ti_i;	/* Interpolation index variable */
39350 
39351 				ti_i  = IT_IX(it0, ip0[0]);
39352 				we0   = IT_WE(it0, ip0[0]);
39353 				vo0   = IT_VO(it0, ip0[0]);
39354 				ti_i += IT_IX(it1, ip0[1]);
39355 				we1   = IT_WE(it1, ip0[1]);
39356 				vo1   = IT_VO(it1, ip0[1]);
39357 				ti_i += IT_IX(it2, ip0[2]);
39358 				we2   = IT_WE(it2, ip0[2]);
39359 				vo2   = IT_VO(it2, ip0[2]);
39360 				ti_i += IT_IX(it3, ip0[3]);
39361 				we3   = IT_WE(it3, ip0[3]);
39362 				vo3   = IT_VO(it3, ip0[3]);
39363 				ti_i += IT_IX(it4, ip0[4]);
39364 				we4   = IT_WE(it4, ip0[4]);
39365 				vo4   = IT_VO(it4, ip0[4]);
39366 				ti_i += IT_IX(it5, ip0[5]);
39367 				we5   = IT_WE(it5, ip0[5]);
39368 				vo5   = IT_VO(it5, ip0[5]);
39369 				ti_i += IT_IX(it6, ip0[6]);
39370 				we6   = IT_WE(it6, ip0[6]);
39371 				vo6   = IT_VO(it6, ip0[6]);
39372 				ti_i += IT_IX(it7, ip0[7]);
39373 				we7   = IT_WE(it7, ip0[7]);
39374 				vo7   = IT_VO(it7, ip0[7]);
39375 
39376 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
39377 
39378 				/* Sort weighting values and vertex offset values */
39379 				CEX(we0, vo0, we1, vo1);
39380 				CEX(we0, vo0, we2, vo2);
39381 				CEX(we0, vo0, we3, vo3);
39382 				CEX(we0, vo0, we4, vo4);
39383 				CEX(we0, vo0, we5, vo5);
39384 				CEX(we0, vo0, we6, vo6);
39385 				CEX(we0, vo0, we7, vo7);
39386 				CEX(we1, vo1, we2, vo2);
39387 				CEX(we1, vo1, we3, vo3);
39388 				CEX(we1, vo1, we4, vo4);
39389 				CEX(we1, vo1, we5, vo5);
39390 				CEX(we1, vo1, we6, vo6);
39391 				CEX(we1, vo1, we7, vo7);
39392 				CEX(we2, vo2, we3, vo3);
39393 				CEX(we2, vo2, we4, vo4);
39394 				CEX(we2, vo2, we5, vo5);
39395 				CEX(we2, vo2, we6, vo6);
39396 				CEX(we2, vo2, we7, vo7);
39397 				CEX(we3, vo3, we4, vo4);
39398 				CEX(we3, vo3, we5, vo5);
39399 				CEX(we3, vo3, we6, vo6);
39400 				CEX(we3, vo3, we7, vo7);
39401 				CEX(we4, vo4, we5, vo5);
39402 				CEX(we4, vo4, we6, vo6);
39403 				CEX(we4, vo4, we7, vo7);
39404 				CEX(we5, vo5, we6, vo6);
39405 				CEX(we5, vo5, we7, vo7);
39406 				CEX(we6, vo6, we7, vo7);
39407 			}
39408 			{
39409 				unsigned int vof;	/* Vertex offset value */
39410 				unsigned int vwe;	/* Vertex weighting */
39411 
39412 				vof = 0;				/* First vertex offset is 0 */
39413 				vwe = 65536 - we0;		/* Baricentric weighting */
39414 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
39415 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
39416 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
39417 				vof += vo0;			/* Move to next vertex */
39418 				vwe = we0 - we1;		/* Baricentric weighting */
39419 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
39420 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
39421 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
39422 				vof += vo1;			/* Move to next vertex */
39423 				vwe = we1 - we2;		/* Baricentric weighting */
39424 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
39425 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
39426 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
39427 				vof += vo2;			/* Move to next vertex */
39428 				vwe = we2 - we3;		/* Baricentric weighting */
39429 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
39430 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
39431 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
39432 				vof += vo3;			/* Move to next vertex */
39433 				vwe = we3 - we4;		/* Baricentric weighting */
39434 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
39435 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
39436 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
39437 				vof += vo4;			/* Move to next vertex */
39438 				vwe = we4 - we5;		/* Baricentric weighting */
39439 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
39440 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
39441 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
39442 				vof += vo5;			/* Move to next vertex */
39443 				vwe = we5 - we6;		/* Baricentric weighting */
39444 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
39445 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
39446 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
39447 				vof += vo6;			/* Move to next vertex */
39448 				vwe = we6 - we7;		/* Baricentric weighting */
39449 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
39450 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
39451 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
39452 				vof += vo7;			/* Move to next vertex */
39453 				vwe = we7;				/* Baricentric weighting */
39454 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
39455 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
39456 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
39457 			}
39458 		}
39459 		{
39460 			unsigned int oti;	/* Vertex offset value */
39461 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
39462 			op0[0] = OT_E(ot0, oti);	/* Write result */
39463 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
39464 			op0[1] = OT_E(ot1, oti);	/* Write result */
39465 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
39466 			op0[2] = OT_E(ot2, oti);	/* Write result */
39467 		}
39468 	}
39469 }
39470 #undef IT_WE
39471 #undef IT_VO
39472 #undef IT_IX
39473 #undef CEX
39474 #undef IM_O
39475 #undef IM_FE
39476 #undef OT_E
39477 
39478 void
imdi_k112_gen(genspec * g)39479 imdi_k112_gen(
39480 genspec *g			/* structure to be initialised */
39481 ) {
39482 	static unsigned char data[] = {
39483 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
39484 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
39485 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39486 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39487 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39488 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39489 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39490 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
39491 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
39492 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
39493 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
39494 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39495 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39496 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39497 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39498 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39499 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39500 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39501 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39502 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39503 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39504 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39505 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39506 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39507 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
39508 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
39509 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
39510 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
39511 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39512 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39513 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39514 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39515 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39516 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39517 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39518 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39519 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39520 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39521 		0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39522 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
39523 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
39524 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
39525 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
39526 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
39527 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
39528 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
39529 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
39530 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
39531 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39532 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
39533 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
39534 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x33, 0x5f,
39535 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
39536 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
39537 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
39538 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
39539 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
39540 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
39541 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
39542 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39543 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39544 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39545 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39546 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
39547 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x31,
39548 		0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39549 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39550 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
39551 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
39552 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
39553 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
39554 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
39555 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
39556 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
39557 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
39558 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
39559 		0x00, 0xf0, 0x04, 0x08
39560 	};	/* Structure image */
39561 
39562 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
39563 }
39564 
39565 void
imdi_k112_tab(tabspec * t)39566 imdi_k112_tab(
39567 tabspec *t			/* structure to be initialised */
39568 ) {
39569 	static unsigned char data[] = {
39570 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39571 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39572 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39573 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
39574 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
39575 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
39576 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
39577 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
39578 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
39579 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39580 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
39581 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
39582 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
39583 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
39584 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
39585 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39586 		0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
39587 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
39588 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39589 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39590 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39591 		0x02, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
39592 		0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x00,
39593 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
39594 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39595 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39596 		0xf4, 0xd5, 0x83, 0xbf, 0x52, 0xca, 0x04, 0x08,
39597 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
39598 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39599 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39600 		0x14, 0xda, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
39601 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
39602 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
39603 	};	/* Structure image */
39604 
39605 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
39606 }
39607 
39608 
39609 
39610 
39611 
39612 
39613 /* Integer Multi-Dimensional Interpolation */
39614 /* Interpolation Kernel Code */
39615 /* Generated by cgen */
39616 /* Copyright 2000 - 2002 Graeme W. Gill */
39617 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
39618 
39619 /* see the Licence.txt file for licencing details.*/
39620 
39621 
39622 /*
39623    Interpolation kernel specs:
39624 
39625    Input channels per pixel = 1
39626    Input channel 0 bits = 16
39627    Input channel 0 increment = 1
39628    Input is channel interleaved
39629    Input channels are separate words
39630    Input value extraction is done in input table lookup
39631 
39632    Output channels per pixel = 4
39633    Output channel 0 bits = 16
39634    Output channel 0 increment = 4
39635    Output channel 1 bits = 16
39636    Output channel 1 increment = 4
39637    Output channel 2 bits = 16
39638    Output channel 2 increment = 4
39639    Output channel 3 bits = 16
39640    Output channel 3 increment = 4
39641    Output is channel interleaved
39642 
39643    Output channels are separate words
39644    Weight+voffset bits       = 32
39645    Interpolation table index bits = 12
39646    Interpolation table max resolution = 4095
39647  */
39648 
39649 /*
39650    Machine architecture specs:
39651 
39652    Little endian
39653    Reading and writing pixel values separately
39654    Pointer size = 32 bits
39655 
39656    Ordinal size  8 bits is known as 'unsigned char'
39657    Ordinal size 16 bits is known as 'unsigned short'
39658    Ordinal size 32 bits is known as 'unsigned int'
39659    Natural ordinal is 'unsigned int'
39660 
39661    Integer size  8 bits is known as 'signed char'
39662    Integer size 16 bits is known as 'short'
39663    Integer size 32 bits is known as 'int'
39664    Natural integer is 'int'
39665 
39666  */
39667 
39668 #ifndef  IMDI_INCLUDED
39669 #include <memory.h>
39670 #include "imdi_imp.h"
39671 #define  IMDI_INCLUDED
39672 #endif  /* IMDI_INCLUDED */
39673 
39674 #ifndef DEFINED_pointer
39675 #define DEFINED_pointer
39676 typedef unsigned char * pointer;
39677 #endif
39678 
39679 /* Input table interp index, weighting and vertex offset */
39680 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
39681 
39682 /* Conditional exchange for sorting */
39683 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
39684 
39685 /* Interpolation multi-dim. table access */
39686 #define IM_O(off) ((off) * 8)
39687 
39688 /* Interpolation table - get vertex values */
39689 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 8 + (c) * 2)))
39690 
39691 /* Output table indexes */
39692 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
39693 
39694 void
imdi_k113(imdi * s,void ** outp,void ** inp,unsigned int npix)39695 imdi_k113(
39696 imdi *s,			/* imdi context */
39697 void **outp,		/* pointer to output pointers */
39698 void **inp,		/* pointer to input pointers */
39699 unsigned int npix	/* Number of pixels to process */
39700 ) {
39701 	imdi_imp *p = (imdi_imp *)(s->impl);
39702 	unsigned short *ip0 = (unsigned short *)inp[0];
39703 	unsigned short *op0 = (unsigned short *)outp[0];
39704 	unsigned short *ep = ip0 + npix * 1 ;
39705 	pointer it0 = (pointer)p->in_tables[0];
39706 	pointer ot0 = (pointer)p->out_tables[0];
39707 	pointer ot1 = (pointer)p->out_tables[1];
39708 	pointer ot2 = (pointer)p->out_tables[2];
39709 	pointer ot3 = (pointer)p->out_tables[3];
39710 	pointer im_base = (pointer)p->im_table;
39711 
39712 	for(;ip0 < ep; ip0 += 1, op0 += 4) {
39713 		unsigned int ova0;	/* Output value accumulator */
39714 		unsigned int ova1;	/* Output value accumulator */
39715 		unsigned int ova2;	/* Output value accumulator */
39716 		unsigned int ova3;	/* Output value accumulator */
39717 		{
39718 			pointer imp;
39719 			unsigned int wo0;	/* Weighting value and vertex offset variable */
39720 			{
39721 				unsigned int ti;		/* Input table entry variable */
39722 				unsigned int ti_i;	/* Interpolation index variable */
39723 
39724 				ti = IT_IT(it0, ip0[0]);
39725 				wo0   = (ti & 0xfffff);	/* Extract weighting/vertex offset value */
39726 				ti_i  = (ti >> 20);	/* Extract interpolation table value */
39727 
39728 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
39729 
39730 				/* Sort weighting values and vertex offset values */
39731 			}
39732 			{
39733 				unsigned int nvof;	/* Next vertex offset value */
39734 				unsigned int vof;	/* Vertex offset value */
39735 				unsigned int vwe;	/* Vertex weighting */
39736 
39737 				vof = 0;				/* First vertex offset is 0 */
39738 				nvof = (wo0 & 0x7);	/* Extract offset value */
39739 				wo0 = (wo0 >> 3);		/* Extract weighting value */
39740 				vwe = 65536 - wo0;		/* Baricentric weighting */
39741 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
39742 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
39743 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
39744 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
39745 				vof += nvof;			/* Move to next vertex */
39746 				vwe = wo0;				/* Baricentric weighting */
39747 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
39748 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
39749 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
39750 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
39751 			}
39752 		}
39753 		{
39754 			unsigned int oti;	/* Vertex offset value */
39755 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
39756 			op0[0] = OT_E(ot0, oti);	/* Write result */
39757 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
39758 			op0[1] = OT_E(ot1, oti);	/* Write result */
39759 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
39760 			op0[2] = OT_E(ot2, oti);	/* Write result */
39761 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
39762 			op0[3] = OT_E(ot3, oti);	/* Write result */
39763 		}
39764 	}
39765 }
39766 #undef IT_IT
39767 #undef CEX
39768 #undef IM_O
39769 #undef IM_FE
39770 #undef OT_E
39771 
39772 void
imdi_k113_gen(genspec * g)39773 imdi_k113_gen(
39774 genspec *g			/* structure to be initialised */
39775 ) {
39776 	static unsigned char data[] = {
39777 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39778 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
39779 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39780 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39781 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39782 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39783 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39784 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39785 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
39786 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
39787 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
39788 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39789 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39790 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39791 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39792 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39793 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39794 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39795 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39796 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39797 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39798 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39799 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39800 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39801 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
39802 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
39803 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
39804 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
39805 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39806 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39807 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39808 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39809 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39810 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39811 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39812 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39813 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39814 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39815 		0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39816 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
39817 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
39818 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
39819 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
39820 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
39821 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
39822 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
39823 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
39824 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
39825 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39826 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
39827 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
39828 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x34, 0x5f,
39829 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
39830 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
39831 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
39832 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
39833 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
39834 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
39835 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
39836 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39837 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39838 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39839 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39840 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
39841 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x31,
39842 		0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39843 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39844 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
39845 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
39846 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
39847 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
39848 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
39849 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
39850 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
39851 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
39852 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
39853 		0x00, 0xf0, 0x04, 0x08
39854 	};	/* Structure image */
39855 
39856 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
39857 }
39858 
39859 void
imdi_k113_tab(tabspec * t)39860 imdi_k113_tab(
39861 tabspec *t			/* structure to be initialised */
39862 ) {
39863 	static unsigned char data[] = {
39864 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39865 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39866 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39867 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
39868 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
39869 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
39870 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
39871 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
39872 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
39873 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39874 		0x14, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
39875 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
39876 		0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
39877 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
39878 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
39879 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39880 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
39881 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
39882 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39883 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39884 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
39885 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
39886 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
39887 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
39888 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39889 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39890 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
39891 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
39892 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39893 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
39894 		0x10, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
39895 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
39896 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
39897 	};	/* Structure image */
39898 
39899 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
39900 }
39901 
39902 
39903 
39904 
39905 
39906 
39907 /* Integer Multi-Dimensional Interpolation */
39908 /* Interpolation Kernel Code */
39909 /* Generated by cgen */
39910 /* Copyright 2000 - 2002 Graeme W. Gill */
39911 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
39912 
39913 /* see the Licence.txt file for licencing details.*/
39914 
39915 
39916 /*
39917    Interpolation kernel specs:
39918 
39919    Input channels per pixel = 3
39920    Input channel 0 bits = 16
39921    Input channel 0 increment = 3
39922    Input channel 1 bits = 16
39923    Input channel 1 increment = 3
39924    Input channel 2 bits = 16
39925    Input channel 2 increment = 3
39926    Input is channel interleaved
39927    Input channels are separate words
39928    Input value extraction is done in input table lookup
39929 
39930    Output channels per pixel = 4
39931    Output channel 0 bits = 16
39932    Output channel 0 increment = 4
39933    Output channel 1 bits = 16
39934    Output channel 1 increment = 4
39935    Output channel 2 bits = 16
39936    Output channel 2 increment = 4
39937    Output channel 3 bits = 16
39938    Output channel 3 increment = 4
39939    Output is channel interleaved
39940 
39941    Output channels are separate words
39942    Weight+voffset bits       = 32
39943    Interpolation table index bits = 16
39944    Interpolation table max resolution = 40
39945  */
39946 
39947 /*
39948    Machine architecture specs:
39949 
39950    Little endian
39951    Reading and writing pixel values separately
39952    Pointer size = 32 bits
39953 
39954    Ordinal size  8 bits is known as 'unsigned char'
39955    Ordinal size 16 bits is known as 'unsigned short'
39956    Ordinal size 32 bits is known as 'unsigned int'
39957    Natural ordinal is 'unsigned int'
39958 
39959    Integer size  8 bits is known as 'signed char'
39960    Integer size 16 bits is known as 'short'
39961    Integer size 32 bits is known as 'int'
39962    Natural integer is 'int'
39963 
39964  */
39965 
39966 #ifndef  IMDI_INCLUDED
39967 #include <memory.h>
39968 #include "imdi_imp.h"
39969 #define  IMDI_INCLUDED
39970 #endif  /* IMDI_INCLUDED */
39971 
39972 #ifndef DEFINED_pointer
39973 #define DEFINED_pointer
39974 typedef unsigned char * pointer;
39975 #endif
39976 
39977 /* Input table interp. index */
39978 #define IT_IX(p, off) *((unsigned short *)((p) + 0 + (off) * 6))
39979 
39980 /* Input table input weighting/offset value enty */
39981 #define IT_WO(p, off) *((unsigned int *)((p) + 2 + (off) * 6))
39982 
39983 /* Conditional exchange for sorting */
39984 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
39985 
39986 /* Interpolation multi-dim. table access */
39987 #define IM_O(off) ((off) * 8)
39988 
39989 /* Interpolation table - get vertex values */
39990 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 8 + (c) * 2)))
39991 
39992 /* Output table indexes */
39993 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
39994 
39995 void
imdi_k114(imdi * s,void ** outp,void ** inp,unsigned int npix)39996 imdi_k114(
39997 imdi *s,			/* imdi context */
39998 void **outp,		/* pointer to output pointers */
39999 void **inp,		/* pointer to input pointers */
40000 unsigned int npix	/* Number of pixels to process */
40001 ) {
40002 	imdi_imp *p = (imdi_imp *)(s->impl);
40003 	unsigned short *ip0 = (unsigned short *)inp[0];
40004 	unsigned short *op0 = (unsigned short *)outp[0];
40005 	unsigned short *ep = ip0 + npix * 3 ;
40006 	pointer it0 = (pointer)p->in_tables[0];
40007 	pointer it1 = (pointer)p->in_tables[1];
40008 	pointer it2 = (pointer)p->in_tables[2];
40009 	pointer ot0 = (pointer)p->out_tables[0];
40010 	pointer ot1 = (pointer)p->out_tables[1];
40011 	pointer ot2 = (pointer)p->out_tables[2];
40012 	pointer ot3 = (pointer)p->out_tables[3];
40013 	pointer im_base = (pointer)p->im_table;
40014 
40015 	for(;ip0 < ep; ip0 += 3, op0 += 4) {
40016 		unsigned int ova0;	/* Output value accumulator */
40017 		unsigned int ova1;	/* Output value accumulator */
40018 		unsigned int ova2;	/* Output value accumulator */
40019 		unsigned int ova3;	/* Output value accumulator */
40020 		{
40021 			pointer imp;
40022 			unsigned int wo0;	/* Weighting value and vertex offset variable */
40023 			unsigned int wo1;	/* Weighting value and vertex offset variable */
40024 			unsigned int wo2;	/* Weighting value and vertex offset variable */
40025 			{
40026 				unsigned int ti_i;	/* Interpolation index variable */
40027 
40028 				ti_i  = IT_IX(it0, ip0[0]);
40029 				wo0   = IT_WO(it0, ip0[0]);
40030 				ti_i += IT_IX(it1, ip0[1]);
40031 				wo1   = IT_WO(it1, ip0[1]);
40032 				ti_i += IT_IX(it2, ip0[2]);
40033 				wo2   = IT_WO(it2, ip0[2]);
40034 
40035 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
40036 
40037 				/* Sort weighting values and vertex offset values */
40038 				CEX(wo0, wo1);
40039 				CEX(wo0, wo2);
40040 				CEX(wo1, wo2);
40041 			}
40042 			{
40043 				unsigned int nvof;	/* Next vertex offset value */
40044 				unsigned int vof;	/* Vertex offset value */
40045 				unsigned int vwe;	/* Vertex weighting */
40046 
40047 				vof = 0;				/* First vertex offset is 0 */
40048 				nvof = (wo0 & 0x7fff);	/* Extract offset value */
40049 				wo0 = (wo0 >> 15);		/* Extract weighting value */
40050 				vwe = 65536 - wo0;		/* Baricentric weighting */
40051 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
40052 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
40053 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
40054 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
40055 				vof += nvof;			/* Move to next vertex */
40056 				nvof = (wo1 & 0x7fff);	/* Extract offset value */
40057 				wo1 = (wo1 >> 15);		/* Extract weighting value */
40058 				vwe = wo0 - wo1;		/* Baricentric weighting */
40059 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
40060 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
40061 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
40062 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
40063 				vof += nvof;			/* Move to next vertex */
40064 				nvof = (wo2 & 0x7fff);	/* Extract offset value */
40065 				wo2 = (wo2 >> 15);		/* Extract weighting value */
40066 				vwe = wo1 - wo2;		/* Baricentric weighting */
40067 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
40068 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
40069 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
40070 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
40071 				vof += nvof;			/* Move to next vertex */
40072 				vwe = wo2;				/* Baricentric weighting */
40073 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
40074 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
40075 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
40076 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
40077 			}
40078 		}
40079 		{
40080 			unsigned int oti;	/* Vertex offset value */
40081 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
40082 			op0[0] = OT_E(ot0, oti);	/* Write result */
40083 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
40084 			op0[1] = OT_E(ot1, oti);	/* Write result */
40085 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
40086 			op0[2] = OT_E(ot2, oti);	/* Write result */
40087 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
40088 			op0[3] = OT_E(ot3, oti);	/* Write result */
40089 		}
40090 	}
40091 }
40092 #undef IT_WO
40093 #undef IT_IX
40094 #undef CEX
40095 #undef IM_O
40096 #undef IM_FE
40097 #undef OT_E
40098 
40099 void
imdi_k114_gen(genspec * g)40100 imdi_k114_gen(
40101 genspec *g			/* structure to be initialised */
40102 ) {
40103 	static unsigned char data[] = {
40104 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
40105 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
40106 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40107 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40108 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40109 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40110 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40111 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
40112 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
40113 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
40114 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
40115 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40116 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40117 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40118 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40119 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40120 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40121 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40122 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40123 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40124 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40125 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40126 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40127 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40128 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
40129 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
40130 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
40131 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
40132 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40133 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40134 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40135 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40136 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40137 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40138 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40139 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40140 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40141 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40142 		0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40143 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
40144 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
40145 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
40146 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
40147 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
40148 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
40149 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
40150 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
40151 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
40152 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40153 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
40154 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
40155 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x34, 0x5f,
40156 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
40157 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
40158 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
40159 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
40160 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
40161 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
40162 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
40163 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40164 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40165 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40166 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40167 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
40168 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x31,
40169 		0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40170 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40171 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
40172 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
40173 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
40174 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
40175 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
40176 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
40177 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
40178 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
40179 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
40180 		0x00, 0xf0, 0x04, 0x08
40181 	};	/* Structure image */
40182 
40183 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
40184 }
40185 
40186 void
imdi_k114_tab(tabspec * t)40187 imdi_k114_tab(
40188 tabspec *t			/* structure to be initialised */
40189 ) {
40190 	static unsigned char data[] = {
40191 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40192 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40193 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40194 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
40195 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
40196 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
40197 		0x20, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
40198 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
40199 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
40200 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40201 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
40202 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
40203 		0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
40204 		0x04, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
40205 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
40206 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40207 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
40208 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
40209 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40210 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40211 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40212 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
40213 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
40214 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
40215 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40216 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40217 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
40218 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
40219 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40220 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40221 		0x10, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
40222 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
40223 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
40224 	};	/* Structure image */
40225 
40226 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
40227 }
40228 
40229 
40230 
40231 
40232 
40233 
40234 /* Integer Multi-Dimensional Interpolation */
40235 /* Interpolation Kernel Code */
40236 /* Generated by cgen */
40237 /* Copyright 2000 - 2002 Graeme W. Gill */
40238 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
40239 
40240 /* see the Licence.txt file for licencing details.*/
40241 
40242 
40243 /*
40244    Interpolation kernel specs:
40245 
40246    Input channels per pixel = 4
40247    Input channel 0 bits = 16
40248    Input channel 0 increment = 4
40249    Input channel 1 bits = 16
40250    Input channel 1 increment = 4
40251    Input channel 2 bits = 16
40252    Input channel 2 increment = 4
40253    Input channel 3 bits = 16
40254    Input channel 3 increment = 4
40255    Input is channel interleaved
40256    Input channels are separate words
40257    Input value extraction is done in input table lookup
40258 
40259    Output channels per pixel = 4
40260    Output channel 0 bits = 16
40261    Output channel 0 increment = 4
40262    Output channel 1 bits = 16
40263    Output channel 1 increment = 4
40264    Output channel 2 bits = 16
40265    Output channel 2 increment = 4
40266    Output channel 3 bits = 16
40267    Output channel 3 increment = 4
40268    Output is channel interleaved
40269 
40270    Output channels are separate words
40271    Weight+voffset bits       = 32
40272    Interpolation table index bits = 32
40273    Interpolation table max resolution = 31
40274  */
40275 
40276 /*
40277    Machine architecture specs:
40278 
40279    Little endian
40280    Reading and writing pixel values separately
40281    Pointer size = 32 bits
40282 
40283    Ordinal size  8 bits is known as 'unsigned char'
40284    Ordinal size 16 bits is known as 'unsigned short'
40285    Ordinal size 32 bits is known as 'unsigned int'
40286    Natural ordinal is 'unsigned int'
40287 
40288    Integer size  8 bits is known as 'signed char'
40289    Integer size 16 bits is known as 'short'
40290    Integer size 32 bits is known as 'int'
40291    Natural integer is 'int'
40292 
40293  */
40294 
40295 #ifndef  IMDI_INCLUDED
40296 #include <memory.h>
40297 #include "imdi_imp.h"
40298 #define  IMDI_INCLUDED
40299 #endif  /* IMDI_INCLUDED */
40300 
40301 #ifndef DEFINED_pointer
40302 #define DEFINED_pointer
40303 typedef unsigned char * pointer;
40304 #endif
40305 
40306 /* Input table interp. index */
40307 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
40308 
40309 /* Input table input weighting/offset value enty */
40310 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
40311 
40312 /* Conditional exchange for sorting */
40313 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
40314 
40315 /* Interpolation multi-dim. table access */
40316 #define IM_O(off) ((off) * 8)
40317 
40318 /* Interpolation table - get vertex values */
40319 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 8 + (c) * 2)))
40320 
40321 /* Output table indexes */
40322 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
40323 
40324 void
imdi_k115(imdi * s,void ** outp,void ** inp,unsigned int npix)40325 imdi_k115(
40326 imdi *s,			/* imdi context */
40327 void **outp,		/* pointer to output pointers */
40328 void **inp,		/* pointer to input pointers */
40329 unsigned int npix	/* Number of pixels to process */
40330 ) {
40331 	imdi_imp *p = (imdi_imp *)(s->impl);
40332 	unsigned short *ip0 = (unsigned short *)inp[0];
40333 	unsigned short *op0 = (unsigned short *)outp[0];
40334 	unsigned short *ep = ip0 + npix * 4 ;
40335 	pointer it0 = (pointer)p->in_tables[0];
40336 	pointer it1 = (pointer)p->in_tables[1];
40337 	pointer it2 = (pointer)p->in_tables[2];
40338 	pointer it3 = (pointer)p->in_tables[3];
40339 	pointer ot0 = (pointer)p->out_tables[0];
40340 	pointer ot1 = (pointer)p->out_tables[1];
40341 	pointer ot2 = (pointer)p->out_tables[2];
40342 	pointer ot3 = (pointer)p->out_tables[3];
40343 	pointer im_base = (pointer)p->im_table;
40344 
40345 	for(;ip0 < ep; ip0 += 4, op0 += 4) {
40346 		unsigned int ova0;	/* Output value accumulator */
40347 		unsigned int ova1;	/* Output value accumulator */
40348 		unsigned int ova2;	/* Output value accumulator */
40349 		unsigned int ova3;	/* Output value accumulator */
40350 		{
40351 			pointer imp;
40352 			unsigned int wo0;	/* Weighting value and vertex offset variable */
40353 			unsigned int wo1;	/* Weighting value and vertex offset variable */
40354 			unsigned int wo2;	/* Weighting value and vertex offset variable */
40355 			unsigned int wo3;	/* Weighting value and vertex offset variable */
40356 			{
40357 				unsigned int ti_i;	/* Interpolation index variable */
40358 
40359 				ti_i  = IT_IX(it0, ip0[0]);
40360 				wo0   = IT_WO(it0, ip0[0]);
40361 				ti_i += IT_IX(it1, ip0[1]);
40362 				wo1   = IT_WO(it1, ip0[1]);
40363 				ti_i += IT_IX(it2, ip0[2]);
40364 				wo2   = IT_WO(it2, ip0[2]);
40365 				ti_i += IT_IX(it3, ip0[3]);
40366 				wo3   = IT_WO(it3, ip0[3]);
40367 
40368 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
40369 
40370 				/* Sort weighting values and vertex offset values */
40371 				CEX(wo0, wo1);
40372 				CEX(wo0, wo2);
40373 				CEX(wo0, wo3);
40374 				CEX(wo1, wo2);
40375 				CEX(wo1, wo3);
40376 				CEX(wo2, wo3);
40377 			}
40378 			{
40379 				unsigned int nvof;	/* Next vertex offset value */
40380 				unsigned int vof;	/* Vertex offset value */
40381 				unsigned int vwe;	/* Vertex weighting */
40382 
40383 				vof = 0;				/* First vertex offset is 0 */
40384 				nvof = (wo0 & 0x7fff);	/* Extract offset value */
40385 				wo0 = (wo0 >> 15);		/* Extract weighting value */
40386 				vwe = 65536 - wo0;		/* Baricentric weighting */
40387 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
40388 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
40389 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
40390 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
40391 				vof += nvof;			/* Move to next vertex */
40392 				nvof = (wo1 & 0x7fff);	/* Extract offset value */
40393 				wo1 = (wo1 >> 15);		/* Extract weighting value */
40394 				vwe = wo0 - wo1;		/* Baricentric weighting */
40395 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
40396 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
40397 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
40398 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
40399 				vof += nvof;			/* Move to next vertex */
40400 				nvof = (wo2 & 0x7fff);	/* Extract offset value */
40401 				wo2 = (wo2 >> 15);		/* Extract weighting value */
40402 				vwe = wo1 - wo2;		/* Baricentric weighting */
40403 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
40404 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
40405 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
40406 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
40407 				vof += nvof;			/* Move to next vertex */
40408 				nvof = (wo3 & 0x7fff);	/* Extract offset value */
40409 				wo3 = (wo3 >> 15);		/* Extract weighting value */
40410 				vwe = wo2 - wo3;		/* Baricentric weighting */
40411 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
40412 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
40413 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
40414 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
40415 				vof += nvof;			/* Move to next vertex */
40416 				vwe = wo3;				/* Baricentric weighting */
40417 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
40418 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
40419 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
40420 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
40421 			}
40422 		}
40423 		{
40424 			unsigned int oti;	/* Vertex offset value */
40425 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
40426 			op0[0] = OT_E(ot0, oti);	/* Write result */
40427 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
40428 			op0[1] = OT_E(ot1, oti);	/* Write result */
40429 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
40430 			op0[2] = OT_E(ot2, oti);	/* Write result */
40431 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
40432 			op0[3] = OT_E(ot3, oti);	/* Write result */
40433 		}
40434 	}
40435 }
40436 #undef IT_WO
40437 #undef IT_IX
40438 #undef CEX
40439 #undef IM_O
40440 #undef IM_FE
40441 #undef OT_E
40442 
40443 void
imdi_k115_gen(genspec * g)40444 imdi_k115_gen(
40445 genspec *g			/* structure to be initialised */
40446 ) {
40447 	static unsigned char data[] = {
40448 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
40449 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
40450 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40451 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40452 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40453 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40454 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40455 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
40456 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
40457 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
40458 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
40459 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40460 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40461 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40462 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40463 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40464 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40465 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40466 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40467 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40468 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40469 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40470 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40471 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40472 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
40473 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
40474 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
40475 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
40476 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40477 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40478 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40479 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40480 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40481 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40482 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40483 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40484 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40485 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40486 		0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40487 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
40488 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
40489 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
40490 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
40491 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
40492 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
40493 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
40494 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
40495 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
40496 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40497 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
40498 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
40499 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x34, 0x5f,
40500 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
40501 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
40502 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
40503 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
40504 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
40505 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
40506 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
40507 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40508 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40509 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40510 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40511 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
40512 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x31,
40513 		0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40514 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40515 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
40516 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
40517 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
40518 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
40519 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
40520 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
40521 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
40522 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
40523 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
40524 		0x00, 0xf0, 0x04, 0x08
40525 	};	/* Structure image */
40526 
40527 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
40528 }
40529 
40530 void
imdi_k115_tab(tabspec * t)40531 imdi_k115_tab(
40532 tabspec *t			/* structure to be initialised */
40533 ) {
40534 	static unsigned char data[] = {
40535 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40536 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40537 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40538 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
40539 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
40540 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
40541 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
40542 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
40543 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
40544 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40545 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
40546 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
40547 		0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
40548 		0x04, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
40549 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
40550 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40551 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
40552 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
40553 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40554 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40555 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40556 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
40557 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
40558 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
40559 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40560 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40561 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
40562 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
40563 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40564 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40565 		0x10, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
40566 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
40567 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
40568 	};	/* Structure image */
40569 
40570 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
40571 }
40572 
40573 
40574 
40575 
40576 
40577 
40578 /* Integer Multi-Dimensional Interpolation */
40579 /* Interpolation Kernel Code */
40580 /* Generated by cgen */
40581 /* Copyright 2000 - 2002 Graeme W. Gill */
40582 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
40583 
40584 /* see the Licence.txt file for licencing details.*/
40585 
40586 
40587 /*
40588    Interpolation kernel specs:
40589 
40590    Input channels per pixel = 5
40591    Input channel 0 bits = 16
40592    Input channel 0 increment = 5
40593    Input channel 1 bits = 16
40594    Input channel 1 increment = 5
40595    Input channel 2 bits = 16
40596    Input channel 2 increment = 5
40597    Input channel 3 bits = 16
40598    Input channel 3 increment = 5
40599    Input channel 4 bits = 16
40600    Input channel 4 increment = 5
40601    Input is channel interleaved
40602    Input channels are separate words
40603    Input value extraction is done in input table lookup
40604 
40605    Output channels per pixel = 4
40606    Output channel 0 bits = 16
40607    Output channel 0 increment = 4
40608    Output channel 1 bits = 16
40609    Output channel 1 increment = 4
40610    Output channel 2 bits = 16
40611    Output channel 2 increment = 4
40612    Output channel 3 bits = 16
40613    Output channel 3 increment = 4
40614    Output is channel interleaved
40615 
40616    Output channels are separate words
40617    Weight+voffset bits       = 32
40618    Interpolation table index bits = 32
40619    Interpolation table max resolution = 84
40620  */
40621 
40622 /*
40623    Machine architecture specs:
40624 
40625    Little endian
40626    Reading and writing pixel values separately
40627    Pointer size = 32 bits
40628 
40629    Ordinal size  8 bits is known as 'unsigned char'
40630    Ordinal size 16 bits is known as 'unsigned short'
40631    Ordinal size 32 bits is known as 'unsigned int'
40632    Natural ordinal is 'unsigned int'
40633 
40634    Integer size  8 bits is known as 'signed char'
40635    Integer size 16 bits is known as 'short'
40636    Integer size 32 bits is known as 'int'
40637    Natural integer is 'int'
40638 
40639  */
40640 
40641 #ifndef  IMDI_INCLUDED
40642 #include <memory.h>
40643 #include "imdi_imp.h"
40644 #define  IMDI_INCLUDED
40645 #endif  /* IMDI_INCLUDED */
40646 
40647 #ifndef DEFINED_pointer
40648 #define DEFINED_pointer
40649 typedef unsigned char * pointer;
40650 #endif
40651 
40652 /* Input table interp. index */
40653 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
40654 
40655 /* Input table input weighting enty */
40656 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
40657 
40658 /* Input table input offset value enty */
40659 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
40660 
40661 /* Conditional exchange for sorting */
40662 #define CEX(A, AA, B, BB) if (A < B) { \
40663             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
40664 
40665 /* Interpolation multi-dim. table access */
40666 #define IM_O(off) ((off) * 8)
40667 
40668 /* Interpolation table - get vertex values */
40669 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 8 + (c) * 2)))
40670 
40671 /* Output table indexes */
40672 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
40673 
40674 void
imdi_k116(imdi * s,void ** outp,void ** inp,unsigned int npix)40675 imdi_k116(
40676 imdi *s,			/* imdi context */
40677 void **outp,		/* pointer to output pointers */
40678 void **inp,		/* pointer to input pointers */
40679 unsigned int npix	/* Number of pixels to process */
40680 ) {
40681 	imdi_imp *p = (imdi_imp *)(s->impl);
40682 	unsigned short *ip0 = (unsigned short *)inp[0];
40683 	unsigned short *op0 = (unsigned short *)outp[0];
40684 	unsigned short *ep = ip0 + npix * 5 ;
40685 	pointer it0 = (pointer)p->in_tables[0];
40686 	pointer it1 = (pointer)p->in_tables[1];
40687 	pointer it2 = (pointer)p->in_tables[2];
40688 	pointer it3 = (pointer)p->in_tables[3];
40689 	pointer it4 = (pointer)p->in_tables[4];
40690 	pointer ot0 = (pointer)p->out_tables[0];
40691 	pointer ot1 = (pointer)p->out_tables[1];
40692 	pointer ot2 = (pointer)p->out_tables[2];
40693 	pointer ot3 = (pointer)p->out_tables[3];
40694 	pointer im_base = (pointer)p->im_table;
40695 
40696 	for(;ip0 < ep; ip0 += 5, op0 += 4) {
40697 		unsigned int ova0;	/* Output value accumulator */
40698 		unsigned int ova1;	/* Output value accumulator */
40699 		unsigned int ova2;	/* Output value accumulator */
40700 		unsigned int ova3;	/* Output value accumulator */
40701 		{
40702 			pointer imp;
40703 			unsigned int we0;	/* Weighting value variable */
40704 			unsigned int vo0;	/* Vertex offset variable */
40705 			unsigned int we1;	/* Weighting value variable */
40706 			unsigned int vo1;	/* Vertex offset variable */
40707 			unsigned int we2;	/* Weighting value variable */
40708 			unsigned int vo2;	/* Vertex offset variable */
40709 			unsigned int we3;	/* Weighting value variable */
40710 			unsigned int vo3;	/* Vertex offset variable */
40711 			unsigned int we4;	/* Weighting value variable */
40712 			unsigned int vo4;	/* Vertex offset variable */
40713 			{
40714 				unsigned int ti_i;	/* Interpolation index variable */
40715 
40716 				ti_i  = IT_IX(it0, ip0[0]);
40717 				we0   = IT_WE(it0, ip0[0]);
40718 				vo0   = IT_VO(it0, ip0[0]);
40719 				ti_i += IT_IX(it1, ip0[1]);
40720 				we1   = IT_WE(it1, ip0[1]);
40721 				vo1   = IT_VO(it1, ip0[1]);
40722 				ti_i += IT_IX(it2, ip0[2]);
40723 				we2   = IT_WE(it2, ip0[2]);
40724 				vo2   = IT_VO(it2, ip0[2]);
40725 				ti_i += IT_IX(it3, ip0[3]);
40726 				we3   = IT_WE(it3, ip0[3]);
40727 				vo3   = IT_VO(it3, ip0[3]);
40728 				ti_i += IT_IX(it4, ip0[4]);
40729 				we4   = IT_WE(it4, ip0[4]);
40730 				vo4   = IT_VO(it4, ip0[4]);
40731 
40732 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
40733 
40734 				/* Sort weighting values and vertex offset values */
40735 				CEX(we0, vo0, we1, vo1);
40736 				CEX(we0, vo0, we2, vo2);
40737 				CEX(we0, vo0, we3, vo3);
40738 				CEX(we0, vo0, we4, vo4);
40739 				CEX(we1, vo1, we2, vo2);
40740 				CEX(we1, vo1, we3, vo3);
40741 				CEX(we1, vo1, we4, vo4);
40742 				CEX(we2, vo2, we3, vo3);
40743 				CEX(we2, vo2, we4, vo4);
40744 				CEX(we3, vo3, we4, vo4);
40745 			}
40746 			{
40747 				unsigned int vof;	/* Vertex offset value */
40748 				unsigned int vwe;	/* Vertex weighting */
40749 
40750 				vof = 0;				/* First vertex offset is 0 */
40751 				vwe = 65536 - we0;		/* Baricentric weighting */
40752 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
40753 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
40754 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
40755 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
40756 				vof += vo0;			/* Move to next vertex */
40757 				vwe = we0 - we1;		/* Baricentric weighting */
40758 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
40759 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
40760 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
40761 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
40762 				vof += vo1;			/* Move to next vertex */
40763 				vwe = we1 - we2;		/* Baricentric weighting */
40764 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
40765 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
40766 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
40767 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
40768 				vof += vo2;			/* Move to next vertex */
40769 				vwe = we2 - we3;		/* Baricentric weighting */
40770 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
40771 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
40772 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
40773 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
40774 				vof += vo3;			/* Move to next vertex */
40775 				vwe = we3 - we4;		/* Baricentric weighting */
40776 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
40777 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
40778 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
40779 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
40780 				vof += vo4;			/* Move to next vertex */
40781 				vwe = we4;				/* Baricentric weighting */
40782 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
40783 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
40784 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
40785 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
40786 			}
40787 		}
40788 		{
40789 			unsigned int oti;	/* Vertex offset value */
40790 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
40791 			op0[0] = OT_E(ot0, oti);	/* Write result */
40792 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
40793 			op0[1] = OT_E(ot1, oti);	/* Write result */
40794 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
40795 			op0[2] = OT_E(ot2, oti);	/* Write result */
40796 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
40797 			op0[3] = OT_E(ot3, oti);	/* Write result */
40798 		}
40799 	}
40800 }
40801 #undef IT_WE
40802 #undef IT_VO
40803 #undef IT_IX
40804 #undef CEX
40805 #undef IM_O
40806 #undef IM_FE
40807 #undef OT_E
40808 
40809 void
imdi_k116_gen(genspec * g)40810 imdi_k116_gen(
40811 genspec *g			/* structure to be initialised */
40812 ) {
40813 	static unsigned char data[] = {
40814 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
40815 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
40816 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40817 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40818 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40819 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40820 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40821 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
40822 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
40823 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
40824 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
40825 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40826 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40827 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40828 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40829 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40830 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40831 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40832 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40833 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40834 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40835 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40836 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40837 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40838 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
40839 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
40840 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
40841 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
40842 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40843 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40844 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40845 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40846 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40847 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40848 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40849 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40850 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40851 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40852 		0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40853 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
40854 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
40855 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
40856 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
40857 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
40858 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
40859 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
40860 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
40861 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
40862 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40863 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
40864 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
40865 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x34, 0x5f,
40866 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
40867 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
40868 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
40869 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
40870 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
40871 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
40872 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
40873 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40874 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40875 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40876 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40877 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
40878 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x31,
40879 		0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40880 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40881 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
40882 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
40883 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
40884 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
40885 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
40886 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
40887 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
40888 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
40889 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
40890 		0x00, 0xf0, 0x04, 0x08
40891 	};	/* Structure image */
40892 
40893 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
40894 }
40895 
40896 void
imdi_k116_tab(tabspec * t)40897 imdi_k116_tab(
40898 tabspec *t			/* structure to be initialised */
40899 ) {
40900 	static unsigned char data[] = {
40901 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40902 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40903 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40904 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
40905 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
40906 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
40907 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
40908 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
40909 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
40910 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40911 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
40912 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
40913 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
40914 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
40915 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
40916 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40917 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
40918 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
40919 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40920 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40921 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40922 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
40923 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
40924 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
40925 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40926 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40927 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
40928 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
40929 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40930 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
40931 		0x10, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
40932 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
40933 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
40934 	};	/* Structure image */
40935 
40936 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
40937 }
40938 
40939 
40940 
40941 
40942 
40943 
40944 /* Integer Multi-Dimensional Interpolation */
40945 /* Interpolation Kernel Code */
40946 /* Generated by cgen */
40947 /* Copyright 2000 - 2002 Graeme W. Gill */
40948 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
40949 
40950 /* see the Licence.txt file for licencing details.*/
40951 
40952 
40953 /*
40954    Interpolation kernel specs:
40955 
40956    Input channels per pixel = 6
40957    Input channel 0 bits = 16
40958    Input channel 0 increment = 6
40959    Input channel 1 bits = 16
40960    Input channel 1 increment = 6
40961    Input channel 2 bits = 16
40962    Input channel 2 increment = 6
40963    Input channel 3 bits = 16
40964    Input channel 3 increment = 6
40965    Input channel 4 bits = 16
40966    Input channel 4 increment = 6
40967    Input channel 5 bits = 16
40968    Input channel 5 increment = 6
40969    Input is channel interleaved
40970    Input channels are separate words
40971    Input value extraction is done in input table lookup
40972 
40973    Output channels per pixel = 4
40974    Output channel 0 bits = 16
40975    Output channel 0 increment = 4
40976    Output channel 1 bits = 16
40977    Output channel 1 increment = 4
40978    Output channel 2 bits = 16
40979    Output channel 2 increment = 4
40980    Output channel 3 bits = 16
40981    Output channel 3 increment = 4
40982    Output is channel interleaved
40983 
40984    Output channels are separate words
40985    Weight+voffset bits       = 32
40986    Interpolation table index bits = 32
40987    Interpolation table max resolution = 40
40988  */
40989 
40990 /*
40991    Machine architecture specs:
40992 
40993    Little endian
40994    Reading and writing pixel values separately
40995    Pointer size = 32 bits
40996 
40997    Ordinal size  8 bits is known as 'unsigned char'
40998    Ordinal size 16 bits is known as 'unsigned short'
40999    Ordinal size 32 bits is known as 'unsigned int'
41000    Natural ordinal is 'unsigned int'
41001 
41002    Integer size  8 bits is known as 'signed char'
41003    Integer size 16 bits is known as 'short'
41004    Integer size 32 bits is known as 'int'
41005    Natural integer is 'int'
41006 
41007  */
41008 
41009 #ifndef  IMDI_INCLUDED
41010 #include <memory.h>
41011 #include "imdi_imp.h"
41012 #define  IMDI_INCLUDED
41013 #endif  /* IMDI_INCLUDED */
41014 
41015 #ifndef DEFINED_pointer
41016 #define DEFINED_pointer
41017 typedef unsigned char * pointer;
41018 #endif
41019 
41020 /* Input table interp. index */
41021 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
41022 
41023 /* Input table input weighting enty */
41024 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
41025 
41026 /* Input table input offset value enty */
41027 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
41028 
41029 /* Conditional exchange for sorting */
41030 #define CEX(A, AA, B, BB) if (A < B) { \
41031             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
41032 
41033 /* Interpolation multi-dim. table access */
41034 #define IM_O(off) ((off) * 8)
41035 
41036 /* Interpolation table - get vertex values */
41037 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 8 + (c) * 2)))
41038 
41039 /* Output table indexes */
41040 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
41041 
41042 void
imdi_k117(imdi * s,void ** outp,void ** inp,unsigned int npix)41043 imdi_k117(
41044 imdi *s,			/* imdi context */
41045 void **outp,		/* pointer to output pointers */
41046 void **inp,		/* pointer to input pointers */
41047 unsigned int npix	/* Number of pixels to process */
41048 ) {
41049 	imdi_imp *p = (imdi_imp *)(s->impl);
41050 	unsigned short *ip0 = (unsigned short *)inp[0];
41051 	unsigned short *op0 = (unsigned short *)outp[0];
41052 	unsigned short *ep = ip0 + npix * 6 ;
41053 	pointer it0 = (pointer)p->in_tables[0];
41054 	pointer it1 = (pointer)p->in_tables[1];
41055 	pointer it2 = (pointer)p->in_tables[2];
41056 	pointer it3 = (pointer)p->in_tables[3];
41057 	pointer it4 = (pointer)p->in_tables[4];
41058 	pointer it5 = (pointer)p->in_tables[5];
41059 	pointer ot0 = (pointer)p->out_tables[0];
41060 	pointer ot1 = (pointer)p->out_tables[1];
41061 	pointer ot2 = (pointer)p->out_tables[2];
41062 	pointer ot3 = (pointer)p->out_tables[3];
41063 	pointer im_base = (pointer)p->im_table;
41064 
41065 	for(;ip0 < ep; ip0 += 6, op0 += 4) {
41066 		unsigned int ova0;	/* Output value accumulator */
41067 		unsigned int ova1;	/* Output value accumulator */
41068 		unsigned int ova2;	/* Output value accumulator */
41069 		unsigned int ova3;	/* Output value accumulator */
41070 		{
41071 			pointer imp;
41072 			unsigned int we0;	/* Weighting value variable */
41073 			unsigned int vo0;	/* Vertex offset variable */
41074 			unsigned int we1;	/* Weighting value variable */
41075 			unsigned int vo1;	/* Vertex offset variable */
41076 			unsigned int we2;	/* Weighting value variable */
41077 			unsigned int vo2;	/* Vertex offset variable */
41078 			unsigned int we3;	/* Weighting value variable */
41079 			unsigned int vo3;	/* Vertex offset variable */
41080 			unsigned int we4;	/* Weighting value variable */
41081 			unsigned int vo4;	/* Vertex offset variable */
41082 			unsigned int we5;	/* Weighting value variable */
41083 			unsigned int vo5;	/* Vertex offset variable */
41084 			{
41085 				unsigned int ti_i;	/* Interpolation index variable */
41086 
41087 				ti_i  = IT_IX(it0, ip0[0]);
41088 				we0   = IT_WE(it0, ip0[0]);
41089 				vo0   = IT_VO(it0, ip0[0]);
41090 				ti_i += IT_IX(it1, ip0[1]);
41091 				we1   = IT_WE(it1, ip0[1]);
41092 				vo1   = IT_VO(it1, ip0[1]);
41093 				ti_i += IT_IX(it2, ip0[2]);
41094 				we2   = IT_WE(it2, ip0[2]);
41095 				vo2   = IT_VO(it2, ip0[2]);
41096 				ti_i += IT_IX(it3, ip0[3]);
41097 				we3   = IT_WE(it3, ip0[3]);
41098 				vo3   = IT_VO(it3, ip0[3]);
41099 				ti_i += IT_IX(it4, ip0[4]);
41100 				we4   = IT_WE(it4, ip0[4]);
41101 				vo4   = IT_VO(it4, ip0[4]);
41102 				ti_i += IT_IX(it5, ip0[5]);
41103 				we5   = IT_WE(it5, ip0[5]);
41104 				vo5   = IT_VO(it5, ip0[5]);
41105 
41106 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
41107 
41108 				/* Sort weighting values and vertex offset values */
41109 				CEX(we0, vo0, we1, vo1);
41110 				CEX(we0, vo0, we2, vo2);
41111 				CEX(we0, vo0, we3, vo3);
41112 				CEX(we0, vo0, we4, vo4);
41113 				CEX(we0, vo0, we5, vo5);
41114 				CEX(we1, vo1, we2, vo2);
41115 				CEX(we1, vo1, we3, vo3);
41116 				CEX(we1, vo1, we4, vo4);
41117 				CEX(we1, vo1, we5, vo5);
41118 				CEX(we2, vo2, we3, vo3);
41119 				CEX(we2, vo2, we4, vo4);
41120 				CEX(we2, vo2, we5, vo5);
41121 				CEX(we3, vo3, we4, vo4);
41122 				CEX(we3, vo3, we5, vo5);
41123 				CEX(we4, vo4, we5, vo5);
41124 			}
41125 			{
41126 				unsigned int vof;	/* Vertex offset value */
41127 				unsigned int vwe;	/* Vertex weighting */
41128 
41129 				vof = 0;				/* First vertex offset is 0 */
41130 				vwe = 65536 - we0;		/* Baricentric weighting */
41131 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41132 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41133 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41134 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41135 				vof += vo0;			/* Move to next vertex */
41136 				vwe = we0 - we1;		/* Baricentric weighting */
41137 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41138 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41139 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41140 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41141 				vof += vo1;			/* Move to next vertex */
41142 				vwe = we1 - we2;		/* Baricentric weighting */
41143 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41144 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41145 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41146 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41147 				vof += vo2;			/* Move to next vertex */
41148 				vwe = we2 - we3;		/* Baricentric weighting */
41149 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41150 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41151 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41152 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41153 				vof += vo3;			/* Move to next vertex */
41154 				vwe = we3 - we4;		/* Baricentric weighting */
41155 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41156 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41157 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41158 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41159 				vof += vo4;			/* Move to next vertex */
41160 				vwe = we4 - we5;		/* Baricentric weighting */
41161 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41162 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41163 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41164 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41165 				vof += vo5;			/* Move to next vertex */
41166 				vwe = we5;				/* Baricentric weighting */
41167 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41168 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41169 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41170 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41171 			}
41172 		}
41173 		{
41174 			unsigned int oti;	/* Vertex offset value */
41175 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
41176 			op0[0] = OT_E(ot0, oti);	/* Write result */
41177 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
41178 			op0[1] = OT_E(ot1, oti);	/* Write result */
41179 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
41180 			op0[2] = OT_E(ot2, oti);	/* Write result */
41181 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
41182 			op0[3] = OT_E(ot3, oti);	/* Write result */
41183 		}
41184 	}
41185 }
41186 #undef IT_WE
41187 #undef IT_VO
41188 #undef IT_IX
41189 #undef CEX
41190 #undef IM_O
41191 #undef IM_FE
41192 #undef OT_E
41193 
41194 void
imdi_k117_gen(genspec * g)41195 imdi_k117_gen(
41196 genspec *g			/* structure to be initialised */
41197 ) {
41198 	static unsigned char data[] = {
41199 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
41200 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
41201 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41202 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41203 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41204 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41205 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41206 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
41207 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
41208 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
41209 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
41210 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41211 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41212 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41213 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41214 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41215 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41216 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41217 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41218 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
41219 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41220 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41221 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41222 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41223 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
41224 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
41225 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
41226 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
41227 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41228 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41229 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41230 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41231 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41232 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41233 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41234 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41235 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
41236 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
41237 		0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41238 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
41239 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
41240 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
41241 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
41242 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
41243 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
41244 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
41245 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
41246 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
41247 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41248 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
41249 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
41250 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x34, 0x5f,
41251 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
41252 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
41253 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
41254 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
41255 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
41256 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
41257 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
41258 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41259 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41260 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41261 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41262 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
41263 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x31,
41264 		0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41265 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41266 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
41267 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
41268 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
41269 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
41270 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
41271 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
41272 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
41273 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
41274 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
41275 		0x00, 0xf0, 0x04, 0x08
41276 	};	/* Structure image */
41277 
41278 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
41279 }
41280 
41281 void
imdi_k117_tab(tabspec * t)41282 imdi_k117_tab(
41283 tabspec *t			/* structure to be initialised */
41284 ) {
41285 	static unsigned char data[] = {
41286 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
41287 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
41288 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
41289 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
41290 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
41291 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
41292 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
41293 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
41294 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
41295 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41296 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
41297 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
41298 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
41299 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
41300 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
41301 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41302 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
41303 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
41304 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41305 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41306 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
41307 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
41308 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
41309 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
41310 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41311 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41312 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
41313 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
41314 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41315 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41316 		0x10, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
41317 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
41318 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
41319 	};	/* Structure image */
41320 
41321 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
41322 }
41323 
41324 
41325 
41326 
41327 
41328 
41329 /* Integer Multi-Dimensional Interpolation */
41330 /* Interpolation Kernel Code */
41331 /* Generated by cgen */
41332 /* Copyright 2000 - 2002 Graeme W. Gill */
41333 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
41334 
41335 /* see the Licence.txt file for licencing details.*/
41336 
41337 
41338 /*
41339    Interpolation kernel specs:
41340 
41341    Input channels per pixel = 7
41342    Input channel 0 bits = 16
41343    Input channel 0 increment = 7
41344    Input channel 1 bits = 16
41345    Input channel 1 increment = 7
41346    Input channel 2 bits = 16
41347    Input channel 2 increment = 7
41348    Input channel 3 bits = 16
41349    Input channel 3 increment = 7
41350    Input channel 4 bits = 16
41351    Input channel 4 increment = 7
41352    Input channel 5 bits = 16
41353    Input channel 5 increment = 7
41354    Input channel 6 bits = 16
41355    Input channel 6 increment = 7
41356    Input is channel interleaved
41357    Input channels are separate words
41358    Input value extraction is done in input table lookup
41359 
41360    Output channels per pixel = 4
41361    Output channel 0 bits = 16
41362    Output channel 0 increment = 4
41363    Output channel 1 bits = 16
41364    Output channel 1 increment = 4
41365    Output channel 2 bits = 16
41366    Output channel 2 increment = 4
41367    Output channel 3 bits = 16
41368    Output channel 3 increment = 4
41369    Output is channel interleaved
41370 
41371    Output channels are separate words
41372    Weight+voffset bits       = 32
41373    Interpolation table index bits = 32
41374    Interpolation table max resolution = 23
41375  */
41376 
41377 /*
41378    Machine architecture specs:
41379 
41380    Little endian
41381    Reading and writing pixel values separately
41382    Pointer size = 32 bits
41383 
41384    Ordinal size  8 bits is known as 'unsigned char'
41385    Ordinal size 16 bits is known as 'unsigned short'
41386    Ordinal size 32 bits is known as 'unsigned int'
41387    Natural ordinal is 'unsigned int'
41388 
41389    Integer size  8 bits is known as 'signed char'
41390    Integer size 16 bits is known as 'short'
41391    Integer size 32 bits is known as 'int'
41392    Natural integer is 'int'
41393 
41394  */
41395 
41396 #ifndef  IMDI_INCLUDED
41397 #include <memory.h>
41398 #include "imdi_imp.h"
41399 #define  IMDI_INCLUDED
41400 #endif  /* IMDI_INCLUDED */
41401 
41402 #ifndef DEFINED_pointer
41403 #define DEFINED_pointer
41404 typedef unsigned char * pointer;
41405 #endif
41406 
41407 /* Input table interp. index */
41408 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
41409 
41410 /* Input table input weighting enty */
41411 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
41412 
41413 /* Input table input offset value enty */
41414 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
41415 
41416 /* Conditional exchange for sorting */
41417 #define CEX(A, AA, B, BB) if (A < B) { \
41418             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
41419 
41420 /* Interpolation multi-dim. table access */
41421 #define IM_O(off) ((off) * 8)
41422 
41423 /* Interpolation table - get vertex values */
41424 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 8 + (c) * 2)))
41425 
41426 /* Output table indexes */
41427 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
41428 
41429 void
imdi_k118(imdi * s,void ** outp,void ** inp,unsigned int npix)41430 imdi_k118(
41431 imdi *s,			/* imdi context */
41432 void **outp,		/* pointer to output pointers */
41433 void **inp,		/* pointer to input pointers */
41434 unsigned int npix	/* Number of pixels to process */
41435 ) {
41436 	imdi_imp *p = (imdi_imp *)(s->impl);
41437 	unsigned short *ip0 = (unsigned short *)inp[0];
41438 	unsigned short *op0 = (unsigned short *)outp[0];
41439 	unsigned short *ep = ip0 + npix * 7 ;
41440 	pointer it0 = (pointer)p->in_tables[0];
41441 	pointer it1 = (pointer)p->in_tables[1];
41442 	pointer it2 = (pointer)p->in_tables[2];
41443 	pointer it3 = (pointer)p->in_tables[3];
41444 	pointer it4 = (pointer)p->in_tables[4];
41445 	pointer it5 = (pointer)p->in_tables[5];
41446 	pointer it6 = (pointer)p->in_tables[6];
41447 	pointer ot0 = (pointer)p->out_tables[0];
41448 	pointer ot1 = (pointer)p->out_tables[1];
41449 	pointer ot2 = (pointer)p->out_tables[2];
41450 	pointer ot3 = (pointer)p->out_tables[3];
41451 	pointer im_base = (pointer)p->im_table;
41452 
41453 	for(;ip0 < ep; ip0 += 7, op0 += 4) {
41454 		unsigned int ova0;	/* Output value accumulator */
41455 		unsigned int ova1;	/* Output value accumulator */
41456 		unsigned int ova2;	/* Output value accumulator */
41457 		unsigned int ova3;	/* Output value accumulator */
41458 		{
41459 			pointer imp;
41460 			unsigned int we0;	/* Weighting value variable */
41461 			unsigned int vo0;	/* Vertex offset variable */
41462 			unsigned int we1;	/* Weighting value variable */
41463 			unsigned int vo1;	/* Vertex offset variable */
41464 			unsigned int we2;	/* Weighting value variable */
41465 			unsigned int vo2;	/* Vertex offset variable */
41466 			unsigned int we3;	/* Weighting value variable */
41467 			unsigned int vo3;	/* Vertex offset variable */
41468 			unsigned int we4;	/* Weighting value variable */
41469 			unsigned int vo4;	/* Vertex offset variable */
41470 			unsigned int we5;	/* Weighting value variable */
41471 			unsigned int vo5;	/* Vertex offset variable */
41472 			unsigned int we6;	/* Weighting value variable */
41473 			unsigned int vo6;	/* Vertex offset variable */
41474 			{
41475 				unsigned int ti_i;	/* Interpolation index variable */
41476 
41477 				ti_i  = IT_IX(it0, ip0[0]);
41478 				we0   = IT_WE(it0, ip0[0]);
41479 				vo0   = IT_VO(it0, ip0[0]);
41480 				ti_i += IT_IX(it1, ip0[1]);
41481 				we1   = IT_WE(it1, ip0[1]);
41482 				vo1   = IT_VO(it1, ip0[1]);
41483 				ti_i += IT_IX(it2, ip0[2]);
41484 				we2   = IT_WE(it2, ip0[2]);
41485 				vo2   = IT_VO(it2, ip0[2]);
41486 				ti_i += IT_IX(it3, ip0[3]);
41487 				we3   = IT_WE(it3, ip0[3]);
41488 				vo3   = IT_VO(it3, ip0[3]);
41489 				ti_i += IT_IX(it4, ip0[4]);
41490 				we4   = IT_WE(it4, ip0[4]);
41491 				vo4   = IT_VO(it4, ip0[4]);
41492 				ti_i += IT_IX(it5, ip0[5]);
41493 				we5   = IT_WE(it5, ip0[5]);
41494 				vo5   = IT_VO(it5, ip0[5]);
41495 				ti_i += IT_IX(it6, ip0[6]);
41496 				we6   = IT_WE(it6, ip0[6]);
41497 				vo6   = IT_VO(it6, ip0[6]);
41498 
41499 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
41500 
41501 				/* Sort weighting values and vertex offset values */
41502 				CEX(we0, vo0, we1, vo1);
41503 				CEX(we0, vo0, we2, vo2);
41504 				CEX(we0, vo0, we3, vo3);
41505 				CEX(we0, vo0, we4, vo4);
41506 				CEX(we0, vo0, we5, vo5);
41507 				CEX(we0, vo0, we6, vo6);
41508 				CEX(we1, vo1, we2, vo2);
41509 				CEX(we1, vo1, we3, vo3);
41510 				CEX(we1, vo1, we4, vo4);
41511 				CEX(we1, vo1, we5, vo5);
41512 				CEX(we1, vo1, we6, vo6);
41513 				CEX(we2, vo2, we3, vo3);
41514 				CEX(we2, vo2, we4, vo4);
41515 				CEX(we2, vo2, we5, vo5);
41516 				CEX(we2, vo2, we6, vo6);
41517 				CEX(we3, vo3, we4, vo4);
41518 				CEX(we3, vo3, we5, vo5);
41519 				CEX(we3, vo3, we6, vo6);
41520 				CEX(we4, vo4, we5, vo5);
41521 				CEX(we4, vo4, we6, vo6);
41522 				CEX(we5, vo5, we6, vo6);
41523 			}
41524 			{
41525 				unsigned int vof;	/* Vertex offset value */
41526 				unsigned int vwe;	/* Vertex weighting */
41527 
41528 				vof = 0;				/* First vertex offset is 0 */
41529 				vwe = 65536 - we0;		/* Baricentric weighting */
41530 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41531 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41532 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41533 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41534 				vof += vo0;			/* Move to next vertex */
41535 				vwe = we0 - we1;		/* Baricentric weighting */
41536 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41537 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41538 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41539 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41540 				vof += vo1;			/* Move to next vertex */
41541 				vwe = we1 - we2;		/* Baricentric weighting */
41542 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41543 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41544 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41545 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41546 				vof += vo2;			/* Move to next vertex */
41547 				vwe = we2 - we3;		/* Baricentric weighting */
41548 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41549 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41550 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41551 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41552 				vof += vo3;			/* Move to next vertex */
41553 				vwe = we3 - we4;		/* Baricentric weighting */
41554 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41555 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41556 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41557 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41558 				vof += vo4;			/* Move to next vertex */
41559 				vwe = we4 - we5;		/* Baricentric weighting */
41560 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41561 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41562 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41563 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41564 				vof += vo5;			/* Move to next vertex */
41565 				vwe = we5 - we6;		/* Baricentric weighting */
41566 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41567 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41568 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41569 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41570 				vof += vo6;			/* Move to next vertex */
41571 				vwe = we6;				/* Baricentric weighting */
41572 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41573 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41574 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41575 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41576 			}
41577 		}
41578 		{
41579 			unsigned int oti;	/* Vertex offset value */
41580 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
41581 			op0[0] = OT_E(ot0, oti);	/* Write result */
41582 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
41583 			op0[1] = OT_E(ot1, oti);	/* Write result */
41584 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
41585 			op0[2] = OT_E(ot2, oti);	/* Write result */
41586 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
41587 			op0[3] = OT_E(ot3, oti);	/* Write result */
41588 		}
41589 	}
41590 }
41591 #undef IT_WE
41592 #undef IT_VO
41593 #undef IT_IX
41594 #undef CEX
41595 #undef IM_O
41596 #undef IM_FE
41597 #undef OT_E
41598 
41599 void
imdi_k118_gen(genspec * g)41600 imdi_k118_gen(
41601 genspec *g			/* structure to be initialised */
41602 ) {
41603 	static unsigned char data[] = {
41604 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
41605 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
41606 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41607 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41608 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41609 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41610 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41611 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
41612 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
41613 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
41614 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
41615 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41616 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41617 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41618 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41619 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41620 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41621 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41622 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41623 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
41624 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41625 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41626 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41627 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41628 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
41629 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
41630 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
41631 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
41632 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41633 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41634 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41635 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41636 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41637 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41638 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41639 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41640 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
41641 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
41642 		0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41643 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
41644 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
41645 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
41646 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
41647 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
41648 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
41649 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
41650 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
41651 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
41652 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41653 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
41654 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
41655 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x34, 0x5f,
41656 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
41657 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
41658 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
41659 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
41660 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
41661 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
41662 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
41663 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41664 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41665 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41666 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41667 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
41668 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x31,
41669 		0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41670 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41671 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
41672 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
41673 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
41674 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
41675 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
41676 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
41677 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
41678 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
41679 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
41680 		0x00, 0xf0, 0x04, 0x08
41681 	};	/* Structure image */
41682 
41683 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
41684 }
41685 
41686 void
imdi_k118_tab(tabspec * t)41687 imdi_k118_tab(
41688 tabspec *t			/* structure to be initialised */
41689 ) {
41690 	static unsigned char data[] = {
41691 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
41692 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
41693 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
41694 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
41695 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
41696 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
41697 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
41698 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
41699 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
41700 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41701 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
41702 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
41703 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
41704 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
41705 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
41706 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41707 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
41708 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
41709 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41710 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41711 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
41712 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
41713 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
41714 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
41715 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41716 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41717 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
41718 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
41719 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41720 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
41721 		0x10, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
41722 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
41723 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
41724 	};	/* Structure image */
41725 
41726 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
41727 }
41728 
41729 
41730 
41731 
41732 
41733 
41734 /* Integer Multi-Dimensional Interpolation */
41735 /* Interpolation Kernel Code */
41736 /* Generated by cgen */
41737 /* Copyright 2000 - 2002 Graeme W. Gill */
41738 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
41739 
41740 /* see the Licence.txt file for licencing details.*/
41741 
41742 
41743 /*
41744    Interpolation kernel specs:
41745 
41746    Input channels per pixel = 8
41747    Input channel 0 bits = 16
41748    Input channel 0 increment = 8
41749    Input channel 1 bits = 16
41750    Input channel 1 increment = 8
41751    Input channel 2 bits = 16
41752    Input channel 2 increment = 8
41753    Input channel 3 bits = 16
41754    Input channel 3 increment = 8
41755    Input channel 4 bits = 16
41756    Input channel 4 increment = 8
41757    Input channel 5 bits = 16
41758    Input channel 5 increment = 8
41759    Input channel 6 bits = 16
41760    Input channel 6 increment = 8
41761    Input channel 7 bits = 16
41762    Input channel 7 increment = 8
41763    Input is channel interleaved
41764    Input channels are separate words
41765    Input value extraction is done in input table lookup
41766 
41767    Output channels per pixel = 4
41768    Output channel 0 bits = 16
41769    Output channel 0 increment = 4
41770    Output channel 1 bits = 16
41771    Output channel 1 increment = 4
41772    Output channel 2 bits = 16
41773    Output channel 2 increment = 4
41774    Output channel 3 bits = 16
41775    Output channel 3 increment = 4
41776    Output is channel interleaved
41777 
41778    Output channels are separate words
41779    Weight+voffset bits       = 32
41780    Interpolation table index bits = 32
41781    Interpolation table max resolution = 16
41782  */
41783 
41784 /*
41785    Machine architecture specs:
41786 
41787    Little endian
41788    Reading and writing pixel values separately
41789    Pointer size = 32 bits
41790 
41791    Ordinal size  8 bits is known as 'unsigned char'
41792    Ordinal size 16 bits is known as 'unsigned short'
41793    Ordinal size 32 bits is known as 'unsigned int'
41794    Natural ordinal is 'unsigned int'
41795 
41796    Integer size  8 bits is known as 'signed char'
41797    Integer size 16 bits is known as 'short'
41798    Integer size 32 bits is known as 'int'
41799    Natural integer is 'int'
41800 
41801  */
41802 
41803 #ifndef  IMDI_INCLUDED
41804 #include <memory.h>
41805 #include "imdi_imp.h"
41806 #define  IMDI_INCLUDED
41807 #endif  /* IMDI_INCLUDED */
41808 
41809 #ifndef DEFINED_pointer
41810 #define DEFINED_pointer
41811 typedef unsigned char * pointer;
41812 #endif
41813 
41814 /* Input table interp. index */
41815 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
41816 
41817 /* Input table input weighting enty */
41818 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
41819 
41820 /* Input table input offset value enty */
41821 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
41822 
41823 /* Conditional exchange for sorting */
41824 #define CEX(A, AA, B, BB) if (A < B) { \
41825             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
41826 
41827 /* Interpolation multi-dim. table access */
41828 #define IM_O(off) ((off) * 8)
41829 
41830 /* Interpolation table - get vertex values */
41831 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 8 + (c) * 2)))
41832 
41833 /* Output table indexes */
41834 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
41835 
41836 void
imdi_k119(imdi * s,void ** outp,void ** inp,unsigned int npix)41837 imdi_k119(
41838 imdi *s,			/* imdi context */
41839 void **outp,		/* pointer to output pointers */
41840 void **inp,		/* pointer to input pointers */
41841 unsigned int npix	/* Number of pixels to process */
41842 ) {
41843 	imdi_imp *p = (imdi_imp *)(s->impl);
41844 	unsigned short *ip0 = (unsigned short *)inp[0];
41845 	unsigned short *op0 = (unsigned short *)outp[0];
41846 	unsigned short *ep = ip0 + npix * 8 ;
41847 	pointer it0 = (pointer)p->in_tables[0];
41848 	pointer it1 = (pointer)p->in_tables[1];
41849 	pointer it2 = (pointer)p->in_tables[2];
41850 	pointer it3 = (pointer)p->in_tables[3];
41851 	pointer it4 = (pointer)p->in_tables[4];
41852 	pointer it5 = (pointer)p->in_tables[5];
41853 	pointer it6 = (pointer)p->in_tables[6];
41854 	pointer it7 = (pointer)p->in_tables[7];
41855 	pointer ot0 = (pointer)p->out_tables[0];
41856 	pointer ot1 = (pointer)p->out_tables[1];
41857 	pointer ot2 = (pointer)p->out_tables[2];
41858 	pointer ot3 = (pointer)p->out_tables[3];
41859 	pointer im_base = (pointer)p->im_table;
41860 
41861 	for(;ip0 < ep; ip0 += 8, op0 += 4) {
41862 		unsigned int ova0;	/* Output value accumulator */
41863 		unsigned int ova1;	/* Output value accumulator */
41864 		unsigned int ova2;	/* Output value accumulator */
41865 		unsigned int ova3;	/* Output value accumulator */
41866 		{
41867 			pointer imp;
41868 			unsigned int we0;	/* Weighting value variable */
41869 			unsigned int vo0;	/* Vertex offset variable */
41870 			unsigned int we1;	/* Weighting value variable */
41871 			unsigned int vo1;	/* Vertex offset variable */
41872 			unsigned int we2;	/* Weighting value variable */
41873 			unsigned int vo2;	/* Vertex offset variable */
41874 			unsigned int we3;	/* Weighting value variable */
41875 			unsigned int vo3;	/* Vertex offset variable */
41876 			unsigned int we4;	/* Weighting value variable */
41877 			unsigned int vo4;	/* Vertex offset variable */
41878 			unsigned int we5;	/* Weighting value variable */
41879 			unsigned int vo5;	/* Vertex offset variable */
41880 			unsigned int we6;	/* Weighting value variable */
41881 			unsigned int vo6;	/* Vertex offset variable */
41882 			unsigned int we7;	/* Weighting value variable */
41883 			unsigned int vo7;	/* Vertex offset variable */
41884 			{
41885 				unsigned int ti_i;	/* Interpolation index variable */
41886 
41887 				ti_i  = IT_IX(it0, ip0[0]);
41888 				we0   = IT_WE(it0, ip0[0]);
41889 				vo0   = IT_VO(it0, ip0[0]);
41890 				ti_i += IT_IX(it1, ip0[1]);
41891 				we1   = IT_WE(it1, ip0[1]);
41892 				vo1   = IT_VO(it1, ip0[1]);
41893 				ti_i += IT_IX(it2, ip0[2]);
41894 				we2   = IT_WE(it2, ip0[2]);
41895 				vo2   = IT_VO(it2, ip0[2]);
41896 				ti_i += IT_IX(it3, ip0[3]);
41897 				we3   = IT_WE(it3, ip0[3]);
41898 				vo3   = IT_VO(it3, ip0[3]);
41899 				ti_i += IT_IX(it4, ip0[4]);
41900 				we4   = IT_WE(it4, ip0[4]);
41901 				vo4   = IT_VO(it4, ip0[4]);
41902 				ti_i += IT_IX(it5, ip0[5]);
41903 				we5   = IT_WE(it5, ip0[5]);
41904 				vo5   = IT_VO(it5, ip0[5]);
41905 				ti_i += IT_IX(it6, ip0[6]);
41906 				we6   = IT_WE(it6, ip0[6]);
41907 				vo6   = IT_VO(it6, ip0[6]);
41908 				ti_i += IT_IX(it7, ip0[7]);
41909 				we7   = IT_WE(it7, ip0[7]);
41910 				vo7   = IT_VO(it7, ip0[7]);
41911 
41912 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
41913 
41914 				/* Sort weighting values and vertex offset values */
41915 				CEX(we0, vo0, we1, vo1);
41916 				CEX(we0, vo0, we2, vo2);
41917 				CEX(we0, vo0, we3, vo3);
41918 				CEX(we0, vo0, we4, vo4);
41919 				CEX(we0, vo0, we5, vo5);
41920 				CEX(we0, vo0, we6, vo6);
41921 				CEX(we0, vo0, we7, vo7);
41922 				CEX(we1, vo1, we2, vo2);
41923 				CEX(we1, vo1, we3, vo3);
41924 				CEX(we1, vo1, we4, vo4);
41925 				CEX(we1, vo1, we5, vo5);
41926 				CEX(we1, vo1, we6, vo6);
41927 				CEX(we1, vo1, we7, vo7);
41928 				CEX(we2, vo2, we3, vo3);
41929 				CEX(we2, vo2, we4, vo4);
41930 				CEX(we2, vo2, we5, vo5);
41931 				CEX(we2, vo2, we6, vo6);
41932 				CEX(we2, vo2, we7, vo7);
41933 				CEX(we3, vo3, we4, vo4);
41934 				CEX(we3, vo3, we5, vo5);
41935 				CEX(we3, vo3, we6, vo6);
41936 				CEX(we3, vo3, we7, vo7);
41937 				CEX(we4, vo4, we5, vo5);
41938 				CEX(we4, vo4, we6, vo6);
41939 				CEX(we4, vo4, we7, vo7);
41940 				CEX(we5, vo5, we6, vo6);
41941 				CEX(we5, vo5, we7, vo7);
41942 				CEX(we6, vo6, we7, vo7);
41943 			}
41944 			{
41945 				unsigned int vof;	/* Vertex offset value */
41946 				unsigned int vwe;	/* Vertex weighting */
41947 
41948 				vof = 0;				/* First vertex offset is 0 */
41949 				vwe = 65536 - we0;		/* Baricentric weighting */
41950 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41951 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41952 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41953 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41954 				vof += vo0;			/* Move to next vertex */
41955 				vwe = we0 - we1;		/* Baricentric weighting */
41956 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41957 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41958 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41959 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41960 				vof += vo1;			/* Move to next vertex */
41961 				vwe = we1 - we2;		/* Baricentric weighting */
41962 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41963 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41964 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41965 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41966 				vof += vo2;			/* Move to next vertex */
41967 				vwe = we2 - we3;		/* Baricentric weighting */
41968 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41969 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41970 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41971 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41972 				vof += vo3;			/* Move to next vertex */
41973 				vwe = we3 - we4;		/* Baricentric weighting */
41974 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41975 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41976 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41977 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41978 				vof += vo4;			/* Move to next vertex */
41979 				vwe = we4 - we5;		/* Baricentric weighting */
41980 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41981 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41982 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41983 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41984 				vof += vo5;			/* Move to next vertex */
41985 				vwe = we5 - we6;		/* Baricentric weighting */
41986 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41987 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41988 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41989 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41990 				vof += vo6;			/* Move to next vertex */
41991 				vwe = we6 - we7;		/* Baricentric weighting */
41992 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41993 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
41994 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
41995 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
41996 				vof += vo7;			/* Move to next vertex */
41997 				vwe = we7;				/* Baricentric weighting */
41998 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
41999 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
42000 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
42001 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
42002 			}
42003 		}
42004 		{
42005 			unsigned int oti;	/* Vertex offset value */
42006 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
42007 			op0[0] = OT_E(ot0, oti);	/* Write result */
42008 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
42009 			op0[1] = OT_E(ot1, oti);	/* Write result */
42010 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
42011 			op0[2] = OT_E(ot2, oti);	/* Write result */
42012 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
42013 			op0[3] = OT_E(ot3, oti);	/* Write result */
42014 		}
42015 	}
42016 }
42017 #undef IT_WE
42018 #undef IT_VO
42019 #undef IT_IX
42020 #undef CEX
42021 #undef IM_O
42022 #undef IM_FE
42023 #undef OT_E
42024 
42025 void
imdi_k119_gen(genspec * g)42026 imdi_k119_gen(
42027 genspec *g			/* structure to be initialised */
42028 ) {
42029 	static unsigned char data[] = {
42030 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
42031 		0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
42032 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42033 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42034 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42035 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42036 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42037 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
42038 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
42039 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
42040 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
42041 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42042 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42043 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42044 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42045 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42046 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42047 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42048 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42049 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42050 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42051 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42052 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42053 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42054 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
42055 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
42056 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
42057 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
42058 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42059 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42060 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42061 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42062 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42063 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42064 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42065 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42066 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42067 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42068 		0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42069 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
42070 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
42071 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
42072 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
42073 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
42074 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
42075 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
42076 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
42077 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
42078 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42079 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
42080 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
42081 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x34, 0x5f,
42082 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
42083 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
42084 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
42085 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
42086 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
42087 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
42088 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
42089 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42090 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42091 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42092 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42093 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
42094 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x31,
42095 		0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42096 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42097 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
42098 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
42099 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
42100 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
42101 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
42102 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
42103 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
42104 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
42105 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
42106 		0x00, 0xf0, 0x04, 0x08
42107 	};	/* Structure image */
42108 
42109 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
42110 }
42111 
42112 void
imdi_k119_tab(tabspec * t)42113 imdi_k119_tab(
42114 tabspec *t			/* structure to be initialised */
42115 ) {
42116 	static unsigned char data[] = {
42117 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42118 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42119 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42120 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
42121 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
42122 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
42123 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
42124 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
42125 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
42126 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42127 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
42128 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
42129 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
42130 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
42131 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
42132 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42133 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
42134 		0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
42135 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42136 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42137 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42138 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
42139 		0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00,
42140 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
42141 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42142 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42143 		0x00, 0x00, 0x00, 0x00, 0x52, 0xca, 0x04, 0x08,
42144 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
42145 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42146 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42147 		0x10, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
42148 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
42149 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
42150 	};	/* Structure image */
42151 
42152 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
42153 }
42154 
42155 
42156 
42157 
42158 
42159 
42160 /* Integer Multi-Dimensional Interpolation */
42161 /* Interpolation Kernel Code */
42162 /* Generated by cgen */
42163 /* Copyright 2000 - 2002 Graeme W. Gill */
42164 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
42165 
42166 /* see the Licence.txt file for licencing details.*/
42167 
42168 
42169 /*
42170    Interpolation kernel specs:
42171 
42172    Input channels per pixel = 1
42173    Input channel 0 bits = 16
42174    Input channel 0 increment = 1
42175    Input is channel interleaved
42176    Input channels are separate words
42177    Input value extraction is done in input table lookup
42178 
42179    Output channels per pixel = 5
42180    Output channel 0 bits = 16
42181    Output channel 0 increment = 5
42182    Output channel 1 bits = 16
42183    Output channel 1 increment = 5
42184    Output channel 2 bits = 16
42185    Output channel 2 increment = 5
42186    Output channel 3 bits = 16
42187    Output channel 3 increment = 5
42188    Output channel 4 bits = 16
42189    Output channel 4 increment = 5
42190    Output is channel interleaved
42191 
42192    Output channels are separate words
42193    Weight+voffset bits       = 32
42194    Interpolation table index bits = 10
42195    Interpolation table max resolution = 1024
42196  */
42197 
42198 /*
42199    Machine architecture specs:
42200 
42201    Little endian
42202    Reading and writing pixel values separately
42203    Pointer size = 32 bits
42204 
42205    Ordinal size  8 bits is known as 'unsigned char'
42206    Ordinal size 16 bits is known as 'unsigned short'
42207    Ordinal size 32 bits is known as 'unsigned int'
42208    Natural ordinal is 'unsigned int'
42209 
42210    Integer size  8 bits is known as 'signed char'
42211    Integer size 16 bits is known as 'short'
42212    Integer size 32 bits is known as 'int'
42213    Natural integer is 'int'
42214 
42215  */
42216 
42217 #ifndef  IMDI_INCLUDED
42218 #include <memory.h>
42219 #include "imdi_imp.h"
42220 #define  IMDI_INCLUDED
42221 #endif  /* IMDI_INCLUDED */
42222 
42223 #ifndef DEFINED_pointer
42224 #define DEFINED_pointer
42225 typedef unsigned char * pointer;
42226 #endif
42227 
42228 /* Input table interp index, weighting and vertex offset */
42229 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
42230 
42231 /* Conditional exchange for sorting */
42232 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
42233 
42234 /* Interpolation multi-dim. table access */
42235 #define IM_O(off) ((off) * 10)
42236 
42237 /* Interpolation table - get vertex values */
42238 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
42239 
42240 /* Output table indexes */
42241 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
42242 
42243 void
imdi_k120(imdi * s,void ** outp,void ** inp,unsigned int npix)42244 imdi_k120(
42245 imdi *s,			/* imdi context */
42246 void **outp,		/* pointer to output pointers */
42247 void **inp,		/* pointer to input pointers */
42248 unsigned int npix	/* Number of pixels to process */
42249 ) {
42250 	imdi_imp *p = (imdi_imp *)(s->impl);
42251 	unsigned short *ip0 = (unsigned short *)inp[0];
42252 	unsigned short *op0 = (unsigned short *)outp[0];
42253 	unsigned short *ep = ip0 + npix * 1 ;
42254 	pointer it0 = (pointer)p->in_tables[0];
42255 	pointer ot0 = (pointer)p->out_tables[0];
42256 	pointer ot1 = (pointer)p->out_tables[1];
42257 	pointer ot2 = (pointer)p->out_tables[2];
42258 	pointer ot3 = (pointer)p->out_tables[3];
42259 	pointer ot4 = (pointer)p->out_tables[4];
42260 	pointer im_base = (pointer)p->im_table;
42261 
42262 	for(;ip0 < ep; ip0 += 1, op0 += 5) {
42263 		unsigned int ova0;	/* Output value accumulator */
42264 		unsigned int ova1;	/* Output value accumulator */
42265 		unsigned int ova2;	/* Output value accumulator */
42266 		unsigned int ova3;	/* Output value accumulator */
42267 		unsigned int ova4;	/* Output value accumulator */
42268 		{
42269 			pointer imp;
42270 			unsigned int wo0;	/* Weighting value and vertex offset variable */
42271 			{
42272 				unsigned int ti;		/* Input table entry variable */
42273 				unsigned int ti_i;	/* Interpolation index variable */
42274 
42275 				ti = IT_IT(it0, ip0[0]);
42276 				wo0   = (ti & 0x3fffff);	/* Extract weighting/vertex offset value */
42277 				ti_i  = (ti >> 22);	/* Extract interpolation table value */
42278 
42279 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
42280 
42281 				/* Sort weighting values and vertex offset values */
42282 			}
42283 			{
42284 				unsigned int nvof;	/* Next vertex offset value */
42285 				unsigned int vof;	/* Vertex offset value */
42286 				unsigned int vwe;	/* Vertex weighting */
42287 
42288 				vof = 0;				/* First vertex offset is 0 */
42289 				nvof = (wo0 & 0x1f);	/* Extract offset value */
42290 				wo0 = (wo0 >> 5);		/* Extract weighting value */
42291 				vwe = 65536 - wo0;		/* Baricentric weighting */
42292 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
42293 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
42294 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
42295 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
42296 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
42297 				vof += nvof;			/* Move to next vertex */
42298 				vwe = wo0;				/* Baricentric weighting */
42299 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
42300 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
42301 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
42302 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
42303 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
42304 			}
42305 		}
42306 		{
42307 			unsigned int oti;	/* Vertex offset value */
42308 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
42309 			op0[0] = OT_E(ot0, oti);	/* Write result */
42310 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
42311 			op0[1] = OT_E(ot1, oti);	/* Write result */
42312 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
42313 			op0[2] = OT_E(ot2, oti);	/* Write result */
42314 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
42315 			op0[3] = OT_E(ot3, oti);	/* Write result */
42316 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
42317 			op0[4] = OT_E(ot4, oti);	/* Write result */
42318 		}
42319 	}
42320 }
42321 #undef IT_IT
42322 #undef CEX
42323 #undef IM_O
42324 #undef IM_FE
42325 #undef OT_E
42326 
42327 void
imdi_k120_gen(genspec * g)42328 imdi_k120_gen(
42329 genspec *g			/* structure to be initialised */
42330 ) {
42331 	static unsigned char data[] = {
42332 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42333 		0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
42334 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42335 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42336 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42337 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42338 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42339 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42340 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
42341 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
42342 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
42343 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42344 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42345 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42346 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42347 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42348 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42349 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42350 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42351 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42352 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42353 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42354 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42355 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42356 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
42357 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
42358 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
42359 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
42360 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42361 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42362 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42363 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42364 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42365 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42366 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42367 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42368 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42369 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42370 		0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42371 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
42372 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
42373 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
42374 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
42375 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
42376 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
42377 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
42378 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
42379 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
42380 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42381 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
42382 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
42383 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x35, 0x5f,
42384 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
42385 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
42386 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
42387 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
42388 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
42389 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
42390 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
42391 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42392 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42393 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42394 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42395 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
42396 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x32,
42397 		0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42398 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42399 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
42400 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
42401 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
42402 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
42403 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
42404 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
42405 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
42406 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
42407 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
42408 		0x00, 0xf0, 0x04, 0x08
42409 	};	/* Structure image */
42410 
42411 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
42412 }
42413 
42414 void
imdi_k120_tab(tabspec * t)42415 imdi_k120_tab(
42416 tabspec *t			/* structure to be initialised */
42417 ) {
42418 	static unsigned char data[] = {
42419 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42420 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42421 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42422 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
42423 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
42424 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
42425 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
42426 		0x0a, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
42427 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
42428 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42429 		0x14, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00,
42430 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
42431 		0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
42432 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
42433 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
42434 		0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42435 		0x0a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
42436 		0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
42437 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42438 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42439 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42440 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
42441 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42442 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
42443 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42444 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42445 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42446 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
42447 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42448 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42449 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42450 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
42451 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
42452 	};	/* Structure image */
42453 
42454 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
42455 }
42456 
42457 
42458 
42459 
42460 
42461 
42462 /* Integer Multi-Dimensional Interpolation */
42463 /* Interpolation Kernel Code */
42464 /* Generated by cgen */
42465 /* Copyright 2000 - 2002 Graeme W. Gill */
42466 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
42467 
42468 /* see the Licence.txt file for licencing details.*/
42469 
42470 
42471 /*
42472    Interpolation kernel specs:
42473 
42474    Input channels per pixel = 3
42475    Input channel 0 bits = 16
42476    Input channel 0 increment = 3
42477    Input channel 1 bits = 16
42478    Input channel 1 increment = 3
42479    Input channel 2 bits = 16
42480    Input channel 2 increment = 3
42481    Input is channel interleaved
42482    Input channels are separate words
42483    Input value extraction is done in input table lookup
42484 
42485    Output channels per pixel = 5
42486    Output channel 0 bits = 16
42487    Output channel 0 increment = 5
42488    Output channel 1 bits = 16
42489    Output channel 1 increment = 5
42490    Output channel 2 bits = 16
42491    Output channel 2 increment = 5
42492    Output channel 3 bits = 16
42493    Output channel 3 increment = 5
42494    Output channel 4 bits = 16
42495    Output channel 4 increment = 5
42496    Output is channel interleaved
42497 
42498    Output channels are separate words
42499    Weight+voffset bits       = 32
42500    Interpolation table index bits = 16
42501    Interpolation table max resolution = 40
42502  */
42503 
42504 /*
42505    Machine architecture specs:
42506 
42507    Little endian
42508    Reading and writing pixel values separately
42509    Pointer size = 32 bits
42510 
42511    Ordinal size  8 bits is known as 'unsigned char'
42512    Ordinal size 16 bits is known as 'unsigned short'
42513    Ordinal size 32 bits is known as 'unsigned int'
42514    Natural ordinal is 'unsigned int'
42515 
42516    Integer size  8 bits is known as 'signed char'
42517    Integer size 16 bits is known as 'short'
42518    Integer size 32 bits is known as 'int'
42519    Natural integer is 'int'
42520 
42521  */
42522 
42523 #ifndef  IMDI_INCLUDED
42524 #include <memory.h>
42525 #include "imdi_imp.h"
42526 #define  IMDI_INCLUDED
42527 #endif  /* IMDI_INCLUDED */
42528 
42529 #ifndef DEFINED_pointer
42530 #define DEFINED_pointer
42531 typedef unsigned char * pointer;
42532 #endif
42533 
42534 /* Input table interp. index */
42535 #define IT_IX(p, off) *((unsigned short *)((p) + 0 + (off) * 6))
42536 
42537 /* Input table input weighting/offset value enty */
42538 #define IT_WO(p, off) *((unsigned int *)((p) + 2 + (off) * 6))
42539 
42540 /* Conditional exchange for sorting */
42541 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
42542 
42543 /* Interpolation multi-dim. table access */
42544 #define IM_O(off) ((off) * 10)
42545 
42546 /* Interpolation table - get vertex values */
42547 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
42548 
42549 /* Output table indexes */
42550 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
42551 
42552 void
imdi_k121(imdi * s,void ** outp,void ** inp,unsigned int npix)42553 imdi_k121(
42554 imdi *s,			/* imdi context */
42555 void **outp,		/* pointer to output pointers */
42556 void **inp,		/* pointer to input pointers */
42557 unsigned int npix	/* Number of pixels to process */
42558 ) {
42559 	imdi_imp *p = (imdi_imp *)(s->impl);
42560 	unsigned short *ip0 = (unsigned short *)inp[0];
42561 	unsigned short *op0 = (unsigned short *)outp[0];
42562 	unsigned short *ep = ip0 + npix * 3 ;
42563 	pointer it0 = (pointer)p->in_tables[0];
42564 	pointer it1 = (pointer)p->in_tables[1];
42565 	pointer it2 = (pointer)p->in_tables[2];
42566 	pointer ot0 = (pointer)p->out_tables[0];
42567 	pointer ot1 = (pointer)p->out_tables[1];
42568 	pointer ot2 = (pointer)p->out_tables[2];
42569 	pointer ot3 = (pointer)p->out_tables[3];
42570 	pointer ot4 = (pointer)p->out_tables[4];
42571 	pointer im_base = (pointer)p->im_table;
42572 
42573 	for(;ip0 < ep; ip0 += 3, op0 += 5) {
42574 		unsigned int ova0;	/* Output value accumulator */
42575 		unsigned int ova1;	/* Output value accumulator */
42576 		unsigned int ova2;	/* Output value accumulator */
42577 		unsigned int ova3;	/* Output value accumulator */
42578 		unsigned int ova4;	/* Output value accumulator */
42579 		{
42580 			pointer imp;
42581 			unsigned int wo0;	/* Weighting value and vertex offset variable */
42582 			unsigned int wo1;	/* Weighting value and vertex offset variable */
42583 			unsigned int wo2;	/* Weighting value and vertex offset variable */
42584 			{
42585 				unsigned int ti_i;	/* Interpolation index variable */
42586 
42587 				ti_i  = IT_IX(it0, ip0[0]);
42588 				wo0   = IT_WO(it0, ip0[0]);
42589 				ti_i += IT_IX(it1, ip0[1]);
42590 				wo1   = IT_WO(it1, ip0[1]);
42591 				ti_i += IT_IX(it2, ip0[2]);
42592 				wo2   = IT_WO(it2, ip0[2]);
42593 
42594 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
42595 
42596 				/* Sort weighting values and vertex offset values */
42597 				CEX(wo0, wo1);
42598 				CEX(wo0, wo2);
42599 				CEX(wo1, wo2);
42600 			}
42601 			{
42602 				unsigned int nvof;	/* Next vertex offset value */
42603 				unsigned int vof;	/* Vertex offset value */
42604 				unsigned int vwe;	/* Vertex weighting */
42605 
42606 				vof = 0;				/* First vertex offset is 0 */
42607 				nvof = (wo0 & 0x7fff);	/* Extract offset value */
42608 				wo0 = (wo0 >> 15);		/* Extract weighting value */
42609 				vwe = 65536 - wo0;		/* Baricentric weighting */
42610 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
42611 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
42612 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
42613 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
42614 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
42615 				vof += nvof;			/* Move to next vertex */
42616 				nvof = (wo1 & 0x7fff);	/* Extract offset value */
42617 				wo1 = (wo1 >> 15);		/* Extract weighting value */
42618 				vwe = wo0 - wo1;		/* Baricentric weighting */
42619 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
42620 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
42621 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
42622 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
42623 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
42624 				vof += nvof;			/* Move to next vertex */
42625 				nvof = (wo2 & 0x7fff);	/* Extract offset value */
42626 				wo2 = (wo2 >> 15);		/* Extract weighting value */
42627 				vwe = wo1 - wo2;		/* Baricentric weighting */
42628 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
42629 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
42630 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
42631 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
42632 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
42633 				vof += nvof;			/* Move to next vertex */
42634 				vwe = wo2;				/* Baricentric weighting */
42635 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
42636 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
42637 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
42638 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
42639 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
42640 			}
42641 		}
42642 		{
42643 			unsigned int oti;	/* Vertex offset value */
42644 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
42645 			op0[0] = OT_E(ot0, oti);	/* Write result */
42646 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
42647 			op0[1] = OT_E(ot1, oti);	/* Write result */
42648 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
42649 			op0[2] = OT_E(ot2, oti);	/* Write result */
42650 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
42651 			op0[3] = OT_E(ot3, oti);	/* Write result */
42652 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
42653 			op0[4] = OT_E(ot4, oti);	/* Write result */
42654 		}
42655 	}
42656 }
42657 #undef IT_WO
42658 #undef IT_IX
42659 #undef CEX
42660 #undef IM_O
42661 #undef IM_FE
42662 #undef OT_E
42663 
42664 void
imdi_k121_gen(genspec * g)42665 imdi_k121_gen(
42666 genspec *g			/* structure to be initialised */
42667 ) {
42668 	static unsigned char data[] = {
42669 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
42670 		0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
42671 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42672 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42673 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42674 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42675 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42676 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
42677 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
42678 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
42679 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
42680 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42681 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42682 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42683 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42684 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42685 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42686 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42687 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42688 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42689 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42690 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42691 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42692 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42693 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
42694 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
42695 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
42696 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
42697 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42698 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42699 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42700 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42701 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42702 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42703 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42704 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42705 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42706 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42707 		0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42708 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
42709 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
42710 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
42711 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
42712 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
42713 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
42714 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
42715 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
42716 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
42717 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42718 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
42719 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
42720 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x35, 0x5f,
42721 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
42722 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
42723 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
42724 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
42725 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
42726 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
42727 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
42728 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42729 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42730 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42731 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42732 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
42733 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x32,
42734 		0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42735 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42736 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
42737 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
42738 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
42739 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
42740 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
42741 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
42742 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
42743 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
42744 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
42745 		0x00, 0xf0, 0x04, 0x08
42746 	};	/* Structure image */
42747 
42748 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
42749 }
42750 
42751 void
imdi_k121_tab(tabspec * t)42752 imdi_k121_tab(
42753 tabspec *t			/* structure to be initialised */
42754 ) {
42755 	static unsigned char data[] = {
42756 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42757 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42758 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42759 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
42760 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
42761 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
42762 		0x20, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
42763 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
42764 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
42765 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42766 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
42767 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
42768 		0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
42769 		0x04, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
42770 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
42771 		0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42772 		0x0a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
42773 		0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
42774 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42775 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42776 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
42777 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
42778 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42779 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
42780 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42781 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42782 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42783 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
42784 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42785 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42786 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
42787 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
42788 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
42789 	};	/* Structure image */
42790 
42791 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
42792 }
42793 
42794 
42795 
42796 
42797 
42798 
42799 /* Integer Multi-Dimensional Interpolation */
42800 /* Interpolation Kernel Code */
42801 /* Generated by cgen */
42802 /* Copyright 2000 - 2002 Graeme W. Gill */
42803 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
42804 
42805 /* see the Licence.txt file for licencing details.*/
42806 
42807 
42808 /*
42809    Interpolation kernel specs:
42810 
42811    Input channels per pixel = 4
42812    Input channel 0 bits = 16
42813    Input channel 0 increment = 4
42814    Input channel 1 bits = 16
42815    Input channel 1 increment = 4
42816    Input channel 2 bits = 16
42817    Input channel 2 increment = 4
42818    Input channel 3 bits = 16
42819    Input channel 3 increment = 4
42820    Input is channel interleaved
42821    Input channels are separate words
42822    Input value extraction is done in input table lookup
42823 
42824    Output channels per pixel = 5
42825    Output channel 0 bits = 16
42826    Output channel 0 increment = 5
42827    Output channel 1 bits = 16
42828    Output channel 1 increment = 5
42829    Output channel 2 bits = 16
42830    Output channel 2 increment = 5
42831    Output channel 3 bits = 16
42832    Output channel 3 increment = 5
42833    Output channel 4 bits = 16
42834    Output channel 4 increment = 5
42835    Output is channel interleaved
42836 
42837    Output channels are separate words
42838    Weight+voffset bits       = 32
42839    Interpolation table index bits = 32
42840    Interpolation table max resolution = 18
42841  */
42842 
42843 /*
42844    Machine architecture specs:
42845 
42846    Little endian
42847    Reading and writing pixel values separately
42848    Pointer size = 32 bits
42849 
42850    Ordinal size  8 bits is known as 'unsigned char'
42851    Ordinal size 16 bits is known as 'unsigned short'
42852    Ordinal size 32 bits is known as 'unsigned int'
42853    Natural ordinal is 'unsigned int'
42854 
42855    Integer size  8 bits is known as 'signed char'
42856    Integer size 16 bits is known as 'short'
42857    Integer size 32 bits is known as 'int'
42858    Natural integer is 'int'
42859 
42860  */
42861 
42862 #ifndef  IMDI_INCLUDED
42863 #include <memory.h>
42864 #include "imdi_imp.h"
42865 #define  IMDI_INCLUDED
42866 #endif  /* IMDI_INCLUDED */
42867 
42868 #ifndef DEFINED_pointer
42869 #define DEFINED_pointer
42870 typedef unsigned char * pointer;
42871 #endif
42872 
42873 /* Input table interp. index */
42874 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
42875 
42876 /* Input table input weighting/offset value enty */
42877 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
42878 
42879 /* Conditional exchange for sorting */
42880 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
42881 
42882 /* Interpolation multi-dim. table access */
42883 #define IM_O(off) ((off) * 10)
42884 
42885 /* Interpolation table - get vertex values */
42886 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
42887 
42888 /* Output table indexes */
42889 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
42890 
42891 void
imdi_k122(imdi * s,void ** outp,void ** inp,unsigned int npix)42892 imdi_k122(
42893 imdi *s,			/* imdi context */
42894 void **outp,		/* pointer to output pointers */
42895 void **inp,		/* pointer to input pointers */
42896 unsigned int npix	/* Number of pixels to process */
42897 ) {
42898 	imdi_imp *p = (imdi_imp *)(s->impl);
42899 	unsigned short *ip0 = (unsigned short *)inp[0];
42900 	unsigned short *op0 = (unsigned short *)outp[0];
42901 	unsigned short *ep = ip0 + npix * 4 ;
42902 	pointer it0 = (pointer)p->in_tables[0];
42903 	pointer it1 = (pointer)p->in_tables[1];
42904 	pointer it2 = (pointer)p->in_tables[2];
42905 	pointer it3 = (pointer)p->in_tables[3];
42906 	pointer ot0 = (pointer)p->out_tables[0];
42907 	pointer ot1 = (pointer)p->out_tables[1];
42908 	pointer ot2 = (pointer)p->out_tables[2];
42909 	pointer ot3 = (pointer)p->out_tables[3];
42910 	pointer ot4 = (pointer)p->out_tables[4];
42911 	pointer im_base = (pointer)p->im_table;
42912 
42913 	for(;ip0 < ep; ip0 += 4, op0 += 5) {
42914 		unsigned int ova0;	/* Output value accumulator */
42915 		unsigned int ova1;	/* Output value accumulator */
42916 		unsigned int ova2;	/* Output value accumulator */
42917 		unsigned int ova3;	/* Output value accumulator */
42918 		unsigned int ova4;	/* Output value accumulator */
42919 		{
42920 			pointer imp;
42921 			unsigned int wo0;	/* Weighting value and vertex offset variable */
42922 			unsigned int wo1;	/* Weighting value and vertex offset variable */
42923 			unsigned int wo2;	/* Weighting value and vertex offset variable */
42924 			unsigned int wo3;	/* Weighting value and vertex offset variable */
42925 			{
42926 				unsigned int ti_i;	/* Interpolation index variable */
42927 
42928 				ti_i  = IT_IX(it0, ip0[0]);
42929 				wo0   = IT_WO(it0, ip0[0]);
42930 				ti_i += IT_IX(it1, ip0[1]);
42931 				wo1   = IT_WO(it1, ip0[1]);
42932 				ti_i += IT_IX(it2, ip0[2]);
42933 				wo2   = IT_WO(it2, ip0[2]);
42934 				ti_i += IT_IX(it3, ip0[3]);
42935 				wo3   = IT_WO(it3, ip0[3]);
42936 
42937 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
42938 
42939 				/* Sort weighting values and vertex offset values */
42940 				CEX(wo0, wo1);
42941 				CEX(wo0, wo2);
42942 				CEX(wo0, wo3);
42943 				CEX(wo1, wo2);
42944 				CEX(wo1, wo3);
42945 				CEX(wo2, wo3);
42946 			}
42947 			{
42948 				unsigned int nvof;	/* Next vertex offset value */
42949 				unsigned int vof;	/* Vertex offset value */
42950 				unsigned int vwe;	/* Vertex weighting */
42951 
42952 				vof = 0;				/* First vertex offset is 0 */
42953 				nvof = (wo0 & 0x7fff);	/* Extract offset value */
42954 				wo0 = (wo0 >> 15);		/* Extract weighting value */
42955 				vwe = 65536 - wo0;		/* Baricentric weighting */
42956 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
42957 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
42958 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
42959 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
42960 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
42961 				vof += nvof;			/* Move to next vertex */
42962 				nvof = (wo1 & 0x7fff);	/* Extract offset value */
42963 				wo1 = (wo1 >> 15);		/* Extract weighting value */
42964 				vwe = wo0 - wo1;		/* Baricentric weighting */
42965 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
42966 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
42967 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
42968 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
42969 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
42970 				vof += nvof;			/* Move to next vertex */
42971 				nvof = (wo2 & 0x7fff);	/* Extract offset value */
42972 				wo2 = (wo2 >> 15);		/* Extract weighting value */
42973 				vwe = wo1 - wo2;		/* Baricentric weighting */
42974 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
42975 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
42976 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
42977 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
42978 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
42979 				vof += nvof;			/* Move to next vertex */
42980 				nvof = (wo3 & 0x7fff);	/* Extract offset value */
42981 				wo3 = (wo3 >> 15);		/* Extract weighting value */
42982 				vwe = wo2 - wo3;		/* Baricentric weighting */
42983 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
42984 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
42985 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
42986 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
42987 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
42988 				vof += nvof;			/* Move to next vertex */
42989 				vwe = wo3;				/* Baricentric weighting */
42990 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
42991 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
42992 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
42993 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
42994 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
42995 			}
42996 		}
42997 		{
42998 			unsigned int oti;	/* Vertex offset value */
42999 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
43000 			op0[0] = OT_E(ot0, oti);	/* Write result */
43001 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
43002 			op0[1] = OT_E(ot1, oti);	/* Write result */
43003 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
43004 			op0[2] = OT_E(ot2, oti);	/* Write result */
43005 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
43006 			op0[3] = OT_E(ot3, oti);	/* Write result */
43007 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
43008 			op0[4] = OT_E(ot4, oti);	/* Write result */
43009 		}
43010 	}
43011 }
43012 #undef IT_WO
43013 #undef IT_IX
43014 #undef CEX
43015 #undef IM_O
43016 #undef IM_FE
43017 #undef OT_E
43018 
43019 void
imdi_k122_gen(genspec * g)43020 imdi_k122_gen(
43021 genspec *g			/* structure to be initialised */
43022 ) {
43023 	static unsigned char data[] = {
43024 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
43025 		0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
43026 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43027 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43028 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43029 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43030 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43031 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
43032 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
43033 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
43034 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
43035 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43036 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43037 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43038 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43039 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43040 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43041 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43042 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43043 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43044 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43045 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43046 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43047 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43048 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43049 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43050 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43051 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
43052 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43053 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43054 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43055 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43056 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43057 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43058 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43059 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43060 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43061 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43062 		0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43063 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
43064 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
43065 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
43066 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
43067 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
43068 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
43069 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
43070 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
43071 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
43072 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43073 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
43074 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
43075 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x35, 0x5f,
43076 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
43077 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
43078 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
43079 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
43080 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
43081 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
43082 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
43083 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43084 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43085 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43086 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43087 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
43088 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x32,
43089 		0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43090 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43091 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
43092 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
43093 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
43094 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
43095 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
43096 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
43097 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
43098 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
43099 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
43100 		0x00, 0xf0, 0x04, 0x08
43101 	};	/* Structure image */
43102 
43103 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
43104 }
43105 
43106 void
imdi_k122_tab(tabspec * t)43107 imdi_k122_tab(
43108 tabspec *t			/* structure to be initialised */
43109 ) {
43110 	static unsigned char data[] = {
43111 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43112 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43113 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43114 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
43115 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43116 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
43117 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
43118 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
43119 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
43120 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43121 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
43122 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
43123 		0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
43124 		0x04, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
43125 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
43126 		0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43127 		0x0a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
43128 		0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43129 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43130 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43131 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43132 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
43133 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43134 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
43135 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43136 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43137 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43138 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
43139 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43140 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43141 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43142 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
43143 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
43144 	};	/* Structure image */
43145 
43146 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
43147 }
43148 
43149 
43150 
43151 
43152 
43153 
43154 /* Integer Multi-Dimensional Interpolation */
43155 /* Interpolation Kernel Code */
43156 /* Generated by cgen */
43157 /* Copyright 2000 - 2002 Graeme W. Gill */
43158 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
43159 
43160 /* see the Licence.txt file for licencing details.*/
43161 
43162 
43163 /*
43164    Interpolation kernel specs:
43165 
43166    Input channels per pixel = 5
43167    Input channel 0 bits = 16
43168    Input channel 0 increment = 5
43169    Input channel 1 bits = 16
43170    Input channel 1 increment = 5
43171    Input channel 2 bits = 16
43172    Input channel 2 increment = 5
43173    Input channel 3 bits = 16
43174    Input channel 3 increment = 5
43175    Input channel 4 bits = 16
43176    Input channel 4 increment = 5
43177    Input is channel interleaved
43178    Input channels are separate words
43179    Input value extraction is done in input table lookup
43180 
43181    Output channels per pixel = 5
43182    Output channel 0 bits = 16
43183    Output channel 0 increment = 5
43184    Output channel 1 bits = 16
43185    Output channel 1 increment = 5
43186    Output channel 2 bits = 16
43187    Output channel 2 increment = 5
43188    Output channel 3 bits = 16
43189    Output channel 3 increment = 5
43190    Output channel 4 bits = 16
43191    Output channel 4 increment = 5
43192    Output is channel interleaved
43193 
43194    Output channels are separate words
43195    Weight+voffset bits       = 32
43196    Interpolation table index bits = 32
43197    Interpolation table max resolution = 84
43198  */
43199 
43200 /*
43201    Machine architecture specs:
43202 
43203    Little endian
43204    Reading and writing pixel values separately
43205    Pointer size = 32 bits
43206 
43207    Ordinal size  8 bits is known as 'unsigned char'
43208    Ordinal size 16 bits is known as 'unsigned short'
43209    Ordinal size 32 bits is known as 'unsigned int'
43210    Natural ordinal is 'unsigned int'
43211 
43212    Integer size  8 bits is known as 'signed char'
43213    Integer size 16 bits is known as 'short'
43214    Integer size 32 bits is known as 'int'
43215    Natural integer is 'int'
43216 
43217  */
43218 
43219 #ifndef  IMDI_INCLUDED
43220 #include <memory.h>
43221 #include "imdi_imp.h"
43222 #define  IMDI_INCLUDED
43223 #endif  /* IMDI_INCLUDED */
43224 
43225 #ifndef DEFINED_pointer
43226 #define DEFINED_pointer
43227 typedef unsigned char * pointer;
43228 #endif
43229 
43230 /* Input table interp. index */
43231 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
43232 
43233 /* Input table input weighting enty */
43234 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
43235 
43236 /* Input table input offset value enty */
43237 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
43238 
43239 /* Conditional exchange for sorting */
43240 #define CEX(A, AA, B, BB) if (A < B) { \
43241             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
43242 
43243 /* Interpolation multi-dim. table access */
43244 #define IM_O(off) ((off) * 10)
43245 
43246 /* Interpolation table - get vertex values */
43247 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
43248 
43249 /* Output table indexes */
43250 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
43251 
43252 void
imdi_k123(imdi * s,void ** outp,void ** inp,unsigned int npix)43253 imdi_k123(
43254 imdi *s,			/* imdi context */
43255 void **outp,		/* pointer to output pointers */
43256 void **inp,		/* pointer to input pointers */
43257 unsigned int npix	/* Number of pixels to process */
43258 ) {
43259 	imdi_imp *p = (imdi_imp *)(s->impl);
43260 	unsigned short *ip0 = (unsigned short *)inp[0];
43261 	unsigned short *op0 = (unsigned short *)outp[0];
43262 	unsigned short *ep = ip0 + npix * 5 ;
43263 	pointer it0 = (pointer)p->in_tables[0];
43264 	pointer it1 = (pointer)p->in_tables[1];
43265 	pointer it2 = (pointer)p->in_tables[2];
43266 	pointer it3 = (pointer)p->in_tables[3];
43267 	pointer it4 = (pointer)p->in_tables[4];
43268 	pointer ot0 = (pointer)p->out_tables[0];
43269 	pointer ot1 = (pointer)p->out_tables[1];
43270 	pointer ot2 = (pointer)p->out_tables[2];
43271 	pointer ot3 = (pointer)p->out_tables[3];
43272 	pointer ot4 = (pointer)p->out_tables[4];
43273 	pointer im_base = (pointer)p->im_table;
43274 
43275 	for(;ip0 < ep; ip0 += 5, op0 += 5) {
43276 		unsigned int ova0;	/* Output value accumulator */
43277 		unsigned int ova1;	/* Output value accumulator */
43278 		unsigned int ova2;	/* Output value accumulator */
43279 		unsigned int ova3;	/* Output value accumulator */
43280 		unsigned int ova4;	/* Output value accumulator */
43281 		{
43282 			pointer imp;
43283 			unsigned int we0;	/* Weighting value variable */
43284 			unsigned int vo0;	/* Vertex offset variable */
43285 			unsigned int we1;	/* Weighting value variable */
43286 			unsigned int vo1;	/* Vertex offset variable */
43287 			unsigned int we2;	/* Weighting value variable */
43288 			unsigned int vo2;	/* Vertex offset variable */
43289 			unsigned int we3;	/* Weighting value variable */
43290 			unsigned int vo3;	/* Vertex offset variable */
43291 			unsigned int we4;	/* Weighting value variable */
43292 			unsigned int vo4;	/* Vertex offset variable */
43293 			{
43294 				unsigned int ti_i;	/* Interpolation index variable */
43295 
43296 				ti_i  = IT_IX(it0, ip0[0]);
43297 				we0   = IT_WE(it0, ip0[0]);
43298 				vo0   = IT_VO(it0, ip0[0]);
43299 				ti_i += IT_IX(it1, ip0[1]);
43300 				we1   = IT_WE(it1, ip0[1]);
43301 				vo1   = IT_VO(it1, ip0[1]);
43302 				ti_i += IT_IX(it2, ip0[2]);
43303 				we2   = IT_WE(it2, ip0[2]);
43304 				vo2   = IT_VO(it2, ip0[2]);
43305 				ti_i += IT_IX(it3, ip0[3]);
43306 				we3   = IT_WE(it3, ip0[3]);
43307 				vo3   = IT_VO(it3, ip0[3]);
43308 				ti_i += IT_IX(it4, ip0[4]);
43309 				we4   = IT_WE(it4, ip0[4]);
43310 				vo4   = IT_VO(it4, ip0[4]);
43311 
43312 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
43313 
43314 				/* Sort weighting values and vertex offset values */
43315 				CEX(we0, vo0, we1, vo1);
43316 				CEX(we0, vo0, we2, vo2);
43317 				CEX(we0, vo0, we3, vo3);
43318 				CEX(we0, vo0, we4, vo4);
43319 				CEX(we1, vo1, we2, vo2);
43320 				CEX(we1, vo1, we3, vo3);
43321 				CEX(we1, vo1, we4, vo4);
43322 				CEX(we2, vo2, we3, vo3);
43323 				CEX(we2, vo2, we4, vo4);
43324 				CEX(we3, vo3, we4, vo4);
43325 			}
43326 			{
43327 				unsigned int vof;	/* Vertex offset value */
43328 				unsigned int vwe;	/* Vertex weighting */
43329 
43330 				vof = 0;				/* First vertex offset is 0 */
43331 				vwe = 65536 - we0;		/* Baricentric weighting */
43332 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
43333 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
43334 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
43335 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
43336 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
43337 				vof += vo0;			/* Move to next vertex */
43338 				vwe = we0 - we1;		/* Baricentric weighting */
43339 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
43340 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
43341 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
43342 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
43343 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
43344 				vof += vo1;			/* Move to next vertex */
43345 				vwe = we1 - we2;		/* Baricentric weighting */
43346 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
43347 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
43348 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
43349 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
43350 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
43351 				vof += vo2;			/* Move to next vertex */
43352 				vwe = we2 - we3;		/* Baricentric weighting */
43353 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
43354 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
43355 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
43356 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
43357 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
43358 				vof += vo3;			/* Move to next vertex */
43359 				vwe = we3 - we4;		/* Baricentric weighting */
43360 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
43361 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
43362 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
43363 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
43364 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
43365 				vof += vo4;			/* Move to next vertex */
43366 				vwe = we4;				/* Baricentric weighting */
43367 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
43368 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
43369 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
43370 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
43371 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
43372 			}
43373 		}
43374 		{
43375 			unsigned int oti;	/* Vertex offset value */
43376 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
43377 			op0[0] = OT_E(ot0, oti);	/* Write result */
43378 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
43379 			op0[1] = OT_E(ot1, oti);	/* Write result */
43380 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
43381 			op0[2] = OT_E(ot2, oti);	/* Write result */
43382 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
43383 			op0[3] = OT_E(ot3, oti);	/* Write result */
43384 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
43385 			op0[4] = OT_E(ot4, oti);	/* Write result */
43386 		}
43387 	}
43388 }
43389 #undef IT_WE
43390 #undef IT_VO
43391 #undef IT_IX
43392 #undef CEX
43393 #undef IM_O
43394 #undef IM_FE
43395 #undef OT_E
43396 
43397 void
imdi_k123_gen(genspec * g)43398 imdi_k123_gen(
43399 genspec *g			/* structure to be initialised */
43400 ) {
43401 	static unsigned char data[] = {
43402 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43403 		0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
43404 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43405 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43406 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43407 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43408 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43409 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43410 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43411 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43412 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
43413 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43414 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43415 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43416 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43417 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43418 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43419 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43420 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43421 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43422 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43423 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43424 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43425 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43426 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43427 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43428 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43429 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
43430 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43431 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43432 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43433 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43434 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43435 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43436 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43437 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43438 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43439 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43440 		0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43441 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
43442 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
43443 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
43444 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
43445 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
43446 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
43447 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
43448 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
43449 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
43450 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43451 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
43452 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
43453 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x35, 0x5f,
43454 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
43455 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
43456 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
43457 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
43458 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
43459 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
43460 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
43461 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43462 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43463 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43464 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43465 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
43466 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x32,
43467 		0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43468 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43469 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
43470 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
43471 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
43472 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
43473 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
43474 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
43475 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
43476 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
43477 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
43478 		0x00, 0xf0, 0x04, 0x08
43479 	};	/* Structure image */
43480 
43481 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
43482 }
43483 
43484 void
imdi_k123_tab(tabspec * t)43485 imdi_k123_tab(
43486 tabspec *t			/* structure to be initialised */
43487 ) {
43488 	static unsigned char data[] = {
43489 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43490 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43491 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43492 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
43493 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43494 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
43495 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
43496 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
43497 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
43498 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43499 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
43500 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
43501 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
43502 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
43503 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
43504 		0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43505 		0x0a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
43506 		0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43507 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43508 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43509 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43510 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
43511 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43512 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
43513 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43514 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43515 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43516 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
43517 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43518 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43519 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43520 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
43521 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
43522 	};	/* Structure image */
43523 
43524 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
43525 }
43526 
43527 
43528 
43529 
43530 
43531 
43532 /* Integer Multi-Dimensional Interpolation */
43533 /* Interpolation Kernel Code */
43534 /* Generated by cgen */
43535 /* Copyright 2000 - 2002 Graeme W. Gill */
43536 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
43537 
43538 /* see the Licence.txt file for licencing details.*/
43539 
43540 
43541 /*
43542    Interpolation kernel specs:
43543 
43544    Input channels per pixel = 6
43545    Input channel 0 bits = 16
43546    Input channel 0 increment = 6
43547    Input channel 1 bits = 16
43548    Input channel 1 increment = 6
43549    Input channel 2 bits = 16
43550    Input channel 2 increment = 6
43551    Input channel 3 bits = 16
43552    Input channel 3 increment = 6
43553    Input channel 4 bits = 16
43554    Input channel 4 increment = 6
43555    Input channel 5 bits = 16
43556    Input channel 5 increment = 6
43557    Input is channel interleaved
43558    Input channels are separate words
43559    Input value extraction is done in input table lookup
43560 
43561    Output channels per pixel = 5
43562    Output channel 0 bits = 16
43563    Output channel 0 increment = 5
43564    Output channel 1 bits = 16
43565    Output channel 1 increment = 5
43566    Output channel 2 bits = 16
43567    Output channel 2 increment = 5
43568    Output channel 3 bits = 16
43569    Output channel 3 increment = 5
43570    Output channel 4 bits = 16
43571    Output channel 4 increment = 5
43572    Output is channel interleaved
43573 
43574    Output channels are separate words
43575    Weight+voffset bits       = 32
43576    Interpolation table index bits = 32
43577    Interpolation table max resolution = 40
43578  */
43579 
43580 /*
43581    Machine architecture specs:
43582 
43583    Little endian
43584    Reading and writing pixel values separately
43585    Pointer size = 32 bits
43586 
43587    Ordinal size  8 bits is known as 'unsigned char'
43588    Ordinal size 16 bits is known as 'unsigned short'
43589    Ordinal size 32 bits is known as 'unsigned int'
43590    Natural ordinal is 'unsigned int'
43591 
43592    Integer size  8 bits is known as 'signed char'
43593    Integer size 16 bits is known as 'short'
43594    Integer size 32 bits is known as 'int'
43595    Natural integer is 'int'
43596 
43597  */
43598 
43599 #ifndef  IMDI_INCLUDED
43600 #include <memory.h>
43601 #include "imdi_imp.h"
43602 #define  IMDI_INCLUDED
43603 #endif  /* IMDI_INCLUDED */
43604 
43605 #ifndef DEFINED_pointer
43606 #define DEFINED_pointer
43607 typedef unsigned char * pointer;
43608 #endif
43609 
43610 /* Input table interp. index */
43611 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
43612 
43613 /* Input table input weighting enty */
43614 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
43615 
43616 /* Input table input offset value enty */
43617 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
43618 
43619 /* Conditional exchange for sorting */
43620 #define CEX(A, AA, B, BB) if (A < B) { \
43621             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
43622 
43623 /* Interpolation multi-dim. table access */
43624 #define IM_O(off) ((off) * 10)
43625 
43626 /* Interpolation table - get vertex values */
43627 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
43628 
43629 /* Output table indexes */
43630 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
43631 
43632 void
imdi_k124(imdi * s,void ** outp,void ** inp,unsigned int npix)43633 imdi_k124(
43634 imdi *s,			/* imdi context */
43635 void **outp,		/* pointer to output pointers */
43636 void **inp,		/* pointer to input pointers */
43637 unsigned int npix	/* Number of pixels to process */
43638 ) {
43639 	imdi_imp *p = (imdi_imp *)(s->impl);
43640 	unsigned short *ip0 = (unsigned short *)inp[0];
43641 	unsigned short *op0 = (unsigned short *)outp[0];
43642 	unsigned short *ep = ip0 + npix * 6 ;
43643 	pointer it0 = (pointer)p->in_tables[0];
43644 	pointer it1 = (pointer)p->in_tables[1];
43645 	pointer it2 = (pointer)p->in_tables[2];
43646 	pointer it3 = (pointer)p->in_tables[3];
43647 	pointer it4 = (pointer)p->in_tables[4];
43648 	pointer it5 = (pointer)p->in_tables[5];
43649 	pointer ot0 = (pointer)p->out_tables[0];
43650 	pointer ot1 = (pointer)p->out_tables[1];
43651 	pointer ot2 = (pointer)p->out_tables[2];
43652 	pointer ot3 = (pointer)p->out_tables[3];
43653 	pointer ot4 = (pointer)p->out_tables[4];
43654 	pointer im_base = (pointer)p->im_table;
43655 
43656 	for(;ip0 < ep; ip0 += 6, op0 += 5) {
43657 		unsigned int ova0;	/* Output value accumulator */
43658 		unsigned int ova1;	/* Output value accumulator */
43659 		unsigned int ova2;	/* Output value accumulator */
43660 		unsigned int ova3;	/* Output value accumulator */
43661 		unsigned int ova4;	/* Output value accumulator */
43662 		{
43663 			pointer imp;
43664 			unsigned int we0;	/* Weighting value variable */
43665 			unsigned int vo0;	/* Vertex offset variable */
43666 			unsigned int we1;	/* Weighting value variable */
43667 			unsigned int vo1;	/* Vertex offset variable */
43668 			unsigned int we2;	/* Weighting value variable */
43669 			unsigned int vo2;	/* Vertex offset variable */
43670 			unsigned int we3;	/* Weighting value variable */
43671 			unsigned int vo3;	/* Vertex offset variable */
43672 			unsigned int we4;	/* Weighting value variable */
43673 			unsigned int vo4;	/* Vertex offset variable */
43674 			unsigned int we5;	/* Weighting value variable */
43675 			unsigned int vo5;	/* Vertex offset variable */
43676 			{
43677 				unsigned int ti_i;	/* Interpolation index variable */
43678 
43679 				ti_i  = IT_IX(it0, ip0[0]);
43680 				we0   = IT_WE(it0, ip0[0]);
43681 				vo0   = IT_VO(it0, ip0[0]);
43682 				ti_i += IT_IX(it1, ip0[1]);
43683 				we1   = IT_WE(it1, ip0[1]);
43684 				vo1   = IT_VO(it1, ip0[1]);
43685 				ti_i += IT_IX(it2, ip0[2]);
43686 				we2   = IT_WE(it2, ip0[2]);
43687 				vo2   = IT_VO(it2, ip0[2]);
43688 				ti_i += IT_IX(it3, ip0[3]);
43689 				we3   = IT_WE(it3, ip0[3]);
43690 				vo3   = IT_VO(it3, ip0[3]);
43691 				ti_i += IT_IX(it4, ip0[4]);
43692 				we4   = IT_WE(it4, ip0[4]);
43693 				vo4   = IT_VO(it4, ip0[4]);
43694 				ti_i += IT_IX(it5, ip0[5]);
43695 				we5   = IT_WE(it5, ip0[5]);
43696 				vo5   = IT_VO(it5, ip0[5]);
43697 
43698 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
43699 
43700 				/* Sort weighting values and vertex offset values */
43701 				CEX(we0, vo0, we1, vo1);
43702 				CEX(we0, vo0, we2, vo2);
43703 				CEX(we0, vo0, we3, vo3);
43704 				CEX(we0, vo0, we4, vo4);
43705 				CEX(we0, vo0, we5, vo5);
43706 				CEX(we1, vo1, we2, vo2);
43707 				CEX(we1, vo1, we3, vo3);
43708 				CEX(we1, vo1, we4, vo4);
43709 				CEX(we1, vo1, we5, vo5);
43710 				CEX(we2, vo2, we3, vo3);
43711 				CEX(we2, vo2, we4, vo4);
43712 				CEX(we2, vo2, we5, vo5);
43713 				CEX(we3, vo3, we4, vo4);
43714 				CEX(we3, vo3, we5, vo5);
43715 				CEX(we4, vo4, we5, vo5);
43716 			}
43717 			{
43718 				unsigned int vof;	/* Vertex offset value */
43719 				unsigned int vwe;	/* Vertex weighting */
43720 
43721 				vof = 0;				/* First vertex offset is 0 */
43722 				vwe = 65536 - we0;		/* Baricentric weighting */
43723 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
43724 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
43725 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
43726 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
43727 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
43728 				vof += vo0;			/* Move to next vertex */
43729 				vwe = we0 - we1;		/* Baricentric weighting */
43730 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
43731 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
43732 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
43733 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
43734 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
43735 				vof += vo1;			/* Move to next vertex */
43736 				vwe = we1 - we2;		/* Baricentric weighting */
43737 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
43738 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
43739 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
43740 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
43741 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
43742 				vof += vo2;			/* Move to next vertex */
43743 				vwe = we2 - we3;		/* Baricentric weighting */
43744 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
43745 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
43746 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
43747 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
43748 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
43749 				vof += vo3;			/* Move to next vertex */
43750 				vwe = we3 - we4;		/* Baricentric weighting */
43751 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
43752 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
43753 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
43754 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
43755 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
43756 				vof += vo4;			/* Move to next vertex */
43757 				vwe = we4 - we5;		/* Baricentric weighting */
43758 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
43759 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
43760 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
43761 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
43762 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
43763 				vof += vo5;			/* Move to next vertex */
43764 				vwe = we5;				/* Baricentric weighting */
43765 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
43766 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
43767 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
43768 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
43769 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
43770 			}
43771 		}
43772 		{
43773 			unsigned int oti;	/* Vertex offset value */
43774 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
43775 			op0[0] = OT_E(ot0, oti);	/* Write result */
43776 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
43777 			op0[1] = OT_E(ot1, oti);	/* Write result */
43778 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
43779 			op0[2] = OT_E(ot2, oti);	/* Write result */
43780 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
43781 			op0[3] = OT_E(ot3, oti);	/* Write result */
43782 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
43783 			op0[4] = OT_E(ot4, oti);	/* Write result */
43784 		}
43785 	}
43786 }
43787 #undef IT_WE
43788 #undef IT_VO
43789 #undef IT_IX
43790 #undef CEX
43791 #undef IM_O
43792 #undef IM_FE
43793 #undef OT_E
43794 
43795 void
imdi_k124_gen(genspec * g)43796 imdi_k124_gen(
43797 genspec *g			/* structure to be initialised */
43798 ) {
43799 	static unsigned char data[] = {
43800 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
43801 		0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
43802 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43803 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43804 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43805 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43806 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43807 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
43808 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
43809 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
43810 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
43811 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43812 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43813 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43814 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43815 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43816 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43817 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43818 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43819 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43820 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43821 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43822 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43823 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43824 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43825 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43826 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43827 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
43828 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43829 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43830 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43831 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43832 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43833 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43834 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43835 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43836 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43837 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43838 		0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43839 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
43840 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
43841 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
43842 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
43843 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
43844 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
43845 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
43846 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
43847 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
43848 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43849 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
43850 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
43851 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x35, 0x5f,
43852 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
43853 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
43854 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
43855 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
43856 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
43857 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
43858 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
43859 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43860 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43861 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43862 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43863 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
43864 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x32,
43865 		0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43866 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43867 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
43868 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
43869 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
43870 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
43871 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
43872 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
43873 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
43874 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
43875 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
43876 		0x00, 0xf0, 0x04, 0x08
43877 	};	/* Structure image */
43878 
43879 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
43880 }
43881 
43882 void
imdi_k124_tab(tabspec * t)43883 imdi_k124_tab(
43884 tabspec *t			/* structure to be initialised */
43885 ) {
43886 	static unsigned char data[] = {
43887 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43888 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43889 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43890 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
43891 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43892 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
43893 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
43894 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
43895 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
43896 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43897 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
43898 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
43899 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
43900 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
43901 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
43902 		0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43903 		0x0a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
43904 		0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43905 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43906 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43907 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
43908 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
43909 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43910 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
43911 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43912 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43913 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43914 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
43915 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43916 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43917 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
43918 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
43919 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
43920 	};	/* Structure image */
43921 
43922 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
43923 }
43924 
43925 
43926 
43927 
43928 
43929 
43930 /* Integer Multi-Dimensional Interpolation */
43931 /* Interpolation Kernel Code */
43932 /* Generated by cgen */
43933 /* Copyright 2000 - 2002 Graeme W. Gill */
43934 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
43935 
43936 /* see the Licence.txt file for licencing details.*/
43937 
43938 
43939 /*
43940    Interpolation kernel specs:
43941 
43942    Input channels per pixel = 7
43943    Input channel 0 bits = 16
43944    Input channel 0 increment = 7
43945    Input channel 1 bits = 16
43946    Input channel 1 increment = 7
43947    Input channel 2 bits = 16
43948    Input channel 2 increment = 7
43949    Input channel 3 bits = 16
43950    Input channel 3 increment = 7
43951    Input channel 4 bits = 16
43952    Input channel 4 increment = 7
43953    Input channel 5 bits = 16
43954    Input channel 5 increment = 7
43955    Input channel 6 bits = 16
43956    Input channel 6 increment = 7
43957    Input is channel interleaved
43958    Input channels are separate words
43959    Input value extraction is done in input table lookup
43960 
43961    Output channels per pixel = 5
43962    Output channel 0 bits = 16
43963    Output channel 0 increment = 5
43964    Output channel 1 bits = 16
43965    Output channel 1 increment = 5
43966    Output channel 2 bits = 16
43967    Output channel 2 increment = 5
43968    Output channel 3 bits = 16
43969    Output channel 3 increment = 5
43970    Output channel 4 bits = 16
43971    Output channel 4 increment = 5
43972    Output is channel interleaved
43973 
43974    Output channels are separate words
43975    Weight+voffset bits       = 32
43976    Interpolation table index bits = 32
43977    Interpolation table max resolution = 23
43978  */
43979 
43980 /*
43981    Machine architecture specs:
43982 
43983    Little endian
43984    Reading and writing pixel values separately
43985    Pointer size = 32 bits
43986 
43987    Ordinal size  8 bits is known as 'unsigned char'
43988    Ordinal size 16 bits is known as 'unsigned short'
43989    Ordinal size 32 bits is known as 'unsigned int'
43990    Natural ordinal is 'unsigned int'
43991 
43992    Integer size  8 bits is known as 'signed char'
43993    Integer size 16 bits is known as 'short'
43994    Integer size 32 bits is known as 'int'
43995    Natural integer is 'int'
43996 
43997  */
43998 
43999 #ifndef  IMDI_INCLUDED
44000 #include <memory.h>
44001 #include "imdi_imp.h"
44002 #define  IMDI_INCLUDED
44003 #endif  /* IMDI_INCLUDED */
44004 
44005 #ifndef DEFINED_pointer
44006 #define DEFINED_pointer
44007 typedef unsigned char * pointer;
44008 #endif
44009 
44010 /* Input table interp. index */
44011 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
44012 
44013 /* Input table input weighting enty */
44014 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
44015 
44016 /* Input table input offset value enty */
44017 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
44018 
44019 /* Conditional exchange for sorting */
44020 #define CEX(A, AA, B, BB) if (A < B) { \
44021             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
44022 
44023 /* Interpolation multi-dim. table access */
44024 #define IM_O(off) ((off) * 10)
44025 
44026 /* Interpolation table - get vertex values */
44027 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
44028 
44029 /* Output table indexes */
44030 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
44031 
44032 void
imdi_k125(imdi * s,void ** outp,void ** inp,unsigned int npix)44033 imdi_k125(
44034 imdi *s,			/* imdi context */
44035 void **outp,		/* pointer to output pointers */
44036 void **inp,		/* pointer to input pointers */
44037 unsigned int npix	/* Number of pixels to process */
44038 ) {
44039 	imdi_imp *p = (imdi_imp *)(s->impl);
44040 	unsigned short *ip0 = (unsigned short *)inp[0];
44041 	unsigned short *op0 = (unsigned short *)outp[0];
44042 	unsigned short *ep = ip0 + npix * 7 ;
44043 	pointer it0 = (pointer)p->in_tables[0];
44044 	pointer it1 = (pointer)p->in_tables[1];
44045 	pointer it2 = (pointer)p->in_tables[2];
44046 	pointer it3 = (pointer)p->in_tables[3];
44047 	pointer it4 = (pointer)p->in_tables[4];
44048 	pointer it5 = (pointer)p->in_tables[5];
44049 	pointer it6 = (pointer)p->in_tables[6];
44050 	pointer ot0 = (pointer)p->out_tables[0];
44051 	pointer ot1 = (pointer)p->out_tables[1];
44052 	pointer ot2 = (pointer)p->out_tables[2];
44053 	pointer ot3 = (pointer)p->out_tables[3];
44054 	pointer ot4 = (pointer)p->out_tables[4];
44055 	pointer im_base = (pointer)p->im_table;
44056 
44057 	for(;ip0 < ep; ip0 += 7, op0 += 5) {
44058 		unsigned int ova0;	/* Output value accumulator */
44059 		unsigned int ova1;	/* Output value accumulator */
44060 		unsigned int ova2;	/* Output value accumulator */
44061 		unsigned int ova3;	/* Output value accumulator */
44062 		unsigned int ova4;	/* Output value accumulator */
44063 		{
44064 			pointer imp;
44065 			unsigned int we0;	/* Weighting value variable */
44066 			unsigned int vo0;	/* Vertex offset variable */
44067 			unsigned int we1;	/* Weighting value variable */
44068 			unsigned int vo1;	/* Vertex offset variable */
44069 			unsigned int we2;	/* Weighting value variable */
44070 			unsigned int vo2;	/* Vertex offset variable */
44071 			unsigned int we3;	/* Weighting value variable */
44072 			unsigned int vo3;	/* Vertex offset variable */
44073 			unsigned int we4;	/* Weighting value variable */
44074 			unsigned int vo4;	/* Vertex offset variable */
44075 			unsigned int we5;	/* Weighting value variable */
44076 			unsigned int vo5;	/* Vertex offset variable */
44077 			unsigned int we6;	/* Weighting value variable */
44078 			unsigned int vo6;	/* Vertex offset variable */
44079 			{
44080 				unsigned int ti_i;	/* Interpolation index variable */
44081 
44082 				ti_i  = IT_IX(it0, ip0[0]);
44083 				we0   = IT_WE(it0, ip0[0]);
44084 				vo0   = IT_VO(it0, ip0[0]);
44085 				ti_i += IT_IX(it1, ip0[1]);
44086 				we1   = IT_WE(it1, ip0[1]);
44087 				vo1   = IT_VO(it1, ip0[1]);
44088 				ti_i += IT_IX(it2, ip0[2]);
44089 				we2   = IT_WE(it2, ip0[2]);
44090 				vo2   = IT_VO(it2, ip0[2]);
44091 				ti_i += IT_IX(it3, ip0[3]);
44092 				we3   = IT_WE(it3, ip0[3]);
44093 				vo3   = IT_VO(it3, ip0[3]);
44094 				ti_i += IT_IX(it4, ip0[4]);
44095 				we4   = IT_WE(it4, ip0[4]);
44096 				vo4   = IT_VO(it4, ip0[4]);
44097 				ti_i += IT_IX(it5, ip0[5]);
44098 				we5   = IT_WE(it5, ip0[5]);
44099 				vo5   = IT_VO(it5, ip0[5]);
44100 				ti_i += IT_IX(it6, ip0[6]);
44101 				we6   = IT_WE(it6, ip0[6]);
44102 				vo6   = IT_VO(it6, ip0[6]);
44103 
44104 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
44105 
44106 				/* Sort weighting values and vertex offset values */
44107 				CEX(we0, vo0, we1, vo1);
44108 				CEX(we0, vo0, we2, vo2);
44109 				CEX(we0, vo0, we3, vo3);
44110 				CEX(we0, vo0, we4, vo4);
44111 				CEX(we0, vo0, we5, vo5);
44112 				CEX(we0, vo0, we6, vo6);
44113 				CEX(we1, vo1, we2, vo2);
44114 				CEX(we1, vo1, we3, vo3);
44115 				CEX(we1, vo1, we4, vo4);
44116 				CEX(we1, vo1, we5, vo5);
44117 				CEX(we1, vo1, we6, vo6);
44118 				CEX(we2, vo2, we3, vo3);
44119 				CEX(we2, vo2, we4, vo4);
44120 				CEX(we2, vo2, we5, vo5);
44121 				CEX(we2, vo2, we6, vo6);
44122 				CEX(we3, vo3, we4, vo4);
44123 				CEX(we3, vo3, we5, vo5);
44124 				CEX(we3, vo3, we6, vo6);
44125 				CEX(we4, vo4, we5, vo5);
44126 				CEX(we4, vo4, we6, vo6);
44127 				CEX(we5, vo5, we6, vo6);
44128 			}
44129 			{
44130 				unsigned int vof;	/* Vertex offset value */
44131 				unsigned int vwe;	/* Vertex weighting */
44132 
44133 				vof = 0;				/* First vertex offset is 0 */
44134 				vwe = 65536 - we0;		/* Baricentric weighting */
44135 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
44136 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
44137 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
44138 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
44139 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
44140 				vof += vo0;			/* Move to next vertex */
44141 				vwe = we0 - we1;		/* Baricentric weighting */
44142 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
44143 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
44144 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
44145 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
44146 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
44147 				vof += vo1;			/* Move to next vertex */
44148 				vwe = we1 - we2;		/* Baricentric weighting */
44149 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
44150 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
44151 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
44152 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
44153 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
44154 				vof += vo2;			/* Move to next vertex */
44155 				vwe = we2 - we3;		/* Baricentric weighting */
44156 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
44157 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
44158 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
44159 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
44160 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
44161 				vof += vo3;			/* Move to next vertex */
44162 				vwe = we3 - we4;		/* Baricentric weighting */
44163 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
44164 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
44165 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
44166 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
44167 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
44168 				vof += vo4;			/* Move to next vertex */
44169 				vwe = we4 - we5;		/* Baricentric weighting */
44170 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
44171 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
44172 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
44173 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
44174 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
44175 				vof += vo5;			/* Move to next vertex */
44176 				vwe = we5 - we6;		/* Baricentric weighting */
44177 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
44178 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
44179 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
44180 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
44181 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
44182 				vof += vo6;			/* Move to next vertex */
44183 				vwe = we6;				/* Baricentric weighting */
44184 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
44185 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
44186 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
44187 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
44188 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
44189 			}
44190 		}
44191 		{
44192 			unsigned int oti;	/* Vertex offset value */
44193 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
44194 			op0[0] = OT_E(ot0, oti);	/* Write result */
44195 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
44196 			op0[1] = OT_E(ot1, oti);	/* Write result */
44197 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
44198 			op0[2] = OT_E(ot2, oti);	/* Write result */
44199 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
44200 			op0[3] = OT_E(ot3, oti);	/* Write result */
44201 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
44202 			op0[4] = OT_E(ot4, oti);	/* Write result */
44203 		}
44204 	}
44205 }
44206 #undef IT_WE
44207 #undef IT_VO
44208 #undef IT_IX
44209 #undef CEX
44210 #undef IM_O
44211 #undef IM_FE
44212 #undef OT_E
44213 
44214 void
imdi_k125_gen(genspec * g)44215 imdi_k125_gen(
44216 genspec *g			/* structure to be initialised */
44217 ) {
44218 	static unsigned char data[] = {
44219 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
44220 		0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
44221 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44222 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44223 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44224 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44225 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44226 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
44227 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
44228 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
44229 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
44230 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44231 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44232 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44233 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44234 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44235 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44236 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44237 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44238 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
44239 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44240 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44241 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44242 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44243 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
44244 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
44245 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
44246 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
44247 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44248 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44249 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44250 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44251 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44252 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44253 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44254 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44255 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
44256 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
44257 		0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44258 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
44259 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
44260 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
44261 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
44262 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
44263 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
44264 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
44265 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
44266 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
44267 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44268 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
44269 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
44270 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x35, 0x5f,
44271 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
44272 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
44273 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
44274 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
44275 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
44276 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
44277 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
44278 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44279 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44280 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44281 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44282 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
44283 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x32,
44284 		0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44285 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44286 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
44287 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
44288 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
44289 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
44290 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
44291 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
44292 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
44293 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
44294 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
44295 		0x00, 0xf0, 0x04, 0x08
44296 	};	/* Structure image */
44297 
44298 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
44299 }
44300 
44301 void
imdi_k125_tab(tabspec * t)44302 imdi_k125_tab(
44303 tabspec *t			/* structure to be initialised */
44304 ) {
44305 	static unsigned char data[] = {
44306 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
44307 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
44308 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
44309 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
44310 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
44311 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
44312 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
44313 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
44314 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
44315 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44316 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
44317 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
44318 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
44319 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
44320 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
44321 		0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44322 		0x0a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
44323 		0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
44324 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44325 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44326 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
44327 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
44328 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44329 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
44330 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44331 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44332 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44333 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
44334 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44335 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44336 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44337 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
44338 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
44339 	};	/* Structure image */
44340 
44341 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
44342 }
44343 
44344 
44345 
44346 
44347 
44348 
44349 /* Integer Multi-Dimensional Interpolation */
44350 /* Interpolation Kernel Code */
44351 /* Generated by cgen */
44352 /* Copyright 2000 - 2002 Graeme W. Gill */
44353 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
44354 
44355 /* see the Licence.txt file for licencing details.*/
44356 
44357 
44358 /*
44359    Interpolation kernel specs:
44360 
44361    Input channels per pixel = 8
44362    Input channel 0 bits = 16
44363    Input channel 0 increment = 8
44364    Input channel 1 bits = 16
44365    Input channel 1 increment = 8
44366    Input channel 2 bits = 16
44367    Input channel 2 increment = 8
44368    Input channel 3 bits = 16
44369    Input channel 3 increment = 8
44370    Input channel 4 bits = 16
44371    Input channel 4 increment = 8
44372    Input channel 5 bits = 16
44373    Input channel 5 increment = 8
44374    Input channel 6 bits = 16
44375    Input channel 6 increment = 8
44376    Input channel 7 bits = 16
44377    Input channel 7 increment = 8
44378    Input is channel interleaved
44379    Input channels are separate words
44380    Input value extraction is done in input table lookup
44381 
44382    Output channels per pixel = 5
44383    Output channel 0 bits = 16
44384    Output channel 0 increment = 5
44385    Output channel 1 bits = 16
44386    Output channel 1 increment = 5
44387    Output channel 2 bits = 16
44388    Output channel 2 increment = 5
44389    Output channel 3 bits = 16
44390    Output channel 3 increment = 5
44391    Output channel 4 bits = 16
44392    Output channel 4 increment = 5
44393    Output is channel interleaved
44394 
44395    Output channels are separate words
44396    Weight+voffset bits       = 32
44397    Interpolation table index bits = 32
44398    Interpolation table max resolution = 16
44399  */
44400 
44401 /*
44402    Machine architecture specs:
44403 
44404    Little endian
44405    Reading and writing pixel values separately
44406    Pointer size = 32 bits
44407 
44408    Ordinal size  8 bits is known as 'unsigned char'
44409    Ordinal size 16 bits is known as 'unsigned short'
44410    Ordinal size 32 bits is known as 'unsigned int'
44411    Natural ordinal is 'unsigned int'
44412 
44413    Integer size  8 bits is known as 'signed char'
44414    Integer size 16 bits is known as 'short'
44415    Integer size 32 bits is known as 'int'
44416    Natural integer is 'int'
44417 
44418  */
44419 
44420 #ifndef  IMDI_INCLUDED
44421 #include <memory.h>
44422 #include "imdi_imp.h"
44423 #define  IMDI_INCLUDED
44424 #endif  /* IMDI_INCLUDED */
44425 
44426 #ifndef DEFINED_pointer
44427 #define DEFINED_pointer
44428 typedef unsigned char * pointer;
44429 #endif
44430 
44431 /* Input table interp. index */
44432 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
44433 
44434 /* Input table input weighting enty */
44435 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
44436 
44437 /* Input table input offset value enty */
44438 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
44439 
44440 /* Conditional exchange for sorting */
44441 #define CEX(A, AA, B, BB) if (A < B) { \
44442             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
44443 
44444 /* Interpolation multi-dim. table access */
44445 #define IM_O(off) ((off) * 10)
44446 
44447 /* Interpolation table - get vertex values */
44448 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
44449 
44450 /* Output table indexes */
44451 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
44452 
44453 void
imdi_k126(imdi * s,void ** outp,void ** inp,unsigned int npix)44454 imdi_k126(
44455 imdi *s,			/* imdi context */
44456 void **outp,		/* pointer to output pointers */
44457 void **inp,		/* pointer to input pointers */
44458 unsigned int npix	/* Number of pixels to process */
44459 ) {
44460 	imdi_imp *p = (imdi_imp *)(s->impl);
44461 	unsigned short *ip0 = (unsigned short *)inp[0];
44462 	unsigned short *op0 = (unsigned short *)outp[0];
44463 	unsigned short *ep = ip0 + npix * 8 ;
44464 	pointer it0 = (pointer)p->in_tables[0];
44465 	pointer it1 = (pointer)p->in_tables[1];
44466 	pointer it2 = (pointer)p->in_tables[2];
44467 	pointer it3 = (pointer)p->in_tables[3];
44468 	pointer it4 = (pointer)p->in_tables[4];
44469 	pointer it5 = (pointer)p->in_tables[5];
44470 	pointer it6 = (pointer)p->in_tables[6];
44471 	pointer it7 = (pointer)p->in_tables[7];
44472 	pointer ot0 = (pointer)p->out_tables[0];
44473 	pointer ot1 = (pointer)p->out_tables[1];
44474 	pointer ot2 = (pointer)p->out_tables[2];
44475 	pointer ot3 = (pointer)p->out_tables[3];
44476 	pointer ot4 = (pointer)p->out_tables[4];
44477 	pointer im_base = (pointer)p->im_table;
44478 
44479 	for(;ip0 < ep; ip0 += 8, op0 += 5) {
44480 		unsigned int ova0;	/* Output value accumulator */
44481 		unsigned int ova1;	/* Output value accumulator */
44482 		unsigned int ova2;	/* Output value accumulator */
44483 		unsigned int ova3;	/* Output value accumulator */
44484 		unsigned int ova4;	/* Output value accumulator */
44485 		{
44486 			pointer imp;
44487 			unsigned int we0;	/* Weighting value variable */
44488 			unsigned int vo0;	/* Vertex offset variable */
44489 			unsigned int we1;	/* Weighting value variable */
44490 			unsigned int vo1;	/* Vertex offset variable */
44491 			unsigned int we2;	/* Weighting value variable */
44492 			unsigned int vo2;	/* Vertex offset variable */
44493 			unsigned int we3;	/* Weighting value variable */
44494 			unsigned int vo3;	/* Vertex offset variable */
44495 			unsigned int we4;	/* Weighting value variable */
44496 			unsigned int vo4;	/* Vertex offset variable */
44497 			unsigned int we5;	/* Weighting value variable */
44498 			unsigned int vo5;	/* Vertex offset variable */
44499 			unsigned int we6;	/* Weighting value variable */
44500 			unsigned int vo6;	/* Vertex offset variable */
44501 			unsigned int we7;	/* Weighting value variable */
44502 			unsigned int vo7;	/* Vertex offset variable */
44503 			{
44504 				unsigned int ti_i;	/* Interpolation index variable */
44505 
44506 				ti_i  = IT_IX(it0, ip0[0]);
44507 				we0   = IT_WE(it0, ip0[0]);
44508 				vo0   = IT_VO(it0, ip0[0]);
44509 				ti_i += IT_IX(it1, ip0[1]);
44510 				we1   = IT_WE(it1, ip0[1]);
44511 				vo1   = IT_VO(it1, ip0[1]);
44512 				ti_i += IT_IX(it2, ip0[2]);
44513 				we2   = IT_WE(it2, ip0[2]);
44514 				vo2   = IT_VO(it2, ip0[2]);
44515 				ti_i += IT_IX(it3, ip0[3]);
44516 				we3   = IT_WE(it3, ip0[3]);
44517 				vo3   = IT_VO(it3, ip0[3]);
44518 				ti_i += IT_IX(it4, ip0[4]);
44519 				we4   = IT_WE(it4, ip0[4]);
44520 				vo4   = IT_VO(it4, ip0[4]);
44521 				ti_i += IT_IX(it5, ip0[5]);
44522 				we5   = IT_WE(it5, ip0[5]);
44523 				vo5   = IT_VO(it5, ip0[5]);
44524 				ti_i += IT_IX(it6, ip0[6]);
44525 				we6   = IT_WE(it6, ip0[6]);
44526 				vo6   = IT_VO(it6, ip0[6]);
44527 				ti_i += IT_IX(it7, ip0[7]);
44528 				we7   = IT_WE(it7, ip0[7]);
44529 				vo7   = IT_VO(it7, ip0[7]);
44530 
44531 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
44532 
44533 				/* Sort weighting values and vertex offset values */
44534 				CEX(we0, vo0, we1, vo1);
44535 				CEX(we0, vo0, we2, vo2);
44536 				CEX(we0, vo0, we3, vo3);
44537 				CEX(we0, vo0, we4, vo4);
44538 				CEX(we0, vo0, we5, vo5);
44539 				CEX(we0, vo0, we6, vo6);
44540 				CEX(we0, vo0, we7, vo7);
44541 				CEX(we1, vo1, we2, vo2);
44542 				CEX(we1, vo1, we3, vo3);
44543 				CEX(we1, vo1, we4, vo4);
44544 				CEX(we1, vo1, we5, vo5);
44545 				CEX(we1, vo1, we6, vo6);
44546 				CEX(we1, vo1, we7, vo7);
44547 				CEX(we2, vo2, we3, vo3);
44548 				CEX(we2, vo2, we4, vo4);
44549 				CEX(we2, vo2, we5, vo5);
44550 				CEX(we2, vo2, we6, vo6);
44551 				CEX(we2, vo2, we7, vo7);
44552 				CEX(we3, vo3, we4, vo4);
44553 				CEX(we3, vo3, we5, vo5);
44554 				CEX(we3, vo3, we6, vo6);
44555 				CEX(we3, vo3, we7, vo7);
44556 				CEX(we4, vo4, we5, vo5);
44557 				CEX(we4, vo4, we6, vo6);
44558 				CEX(we4, vo4, we7, vo7);
44559 				CEX(we5, vo5, we6, vo6);
44560 				CEX(we5, vo5, we7, vo7);
44561 				CEX(we6, vo6, we7, vo7);
44562 			}
44563 			{
44564 				unsigned int vof;	/* Vertex offset value */
44565 				unsigned int vwe;	/* Vertex weighting */
44566 
44567 				vof = 0;				/* First vertex offset is 0 */
44568 				vwe = 65536 - we0;		/* Baricentric weighting */
44569 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
44570 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
44571 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
44572 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
44573 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
44574 				vof += vo0;			/* Move to next vertex */
44575 				vwe = we0 - we1;		/* Baricentric weighting */
44576 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
44577 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
44578 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
44579 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
44580 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
44581 				vof += vo1;			/* Move to next vertex */
44582 				vwe = we1 - we2;		/* Baricentric weighting */
44583 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
44584 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
44585 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
44586 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
44587 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
44588 				vof += vo2;			/* Move to next vertex */
44589 				vwe = we2 - we3;		/* Baricentric weighting */
44590 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
44591 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
44592 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
44593 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
44594 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
44595 				vof += vo3;			/* Move to next vertex */
44596 				vwe = we3 - we4;		/* Baricentric weighting */
44597 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
44598 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
44599 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
44600 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
44601 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
44602 				vof += vo4;			/* Move to next vertex */
44603 				vwe = we4 - we5;		/* Baricentric weighting */
44604 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
44605 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
44606 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
44607 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
44608 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
44609 				vof += vo5;			/* Move to next vertex */
44610 				vwe = we5 - we6;		/* Baricentric weighting */
44611 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
44612 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
44613 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
44614 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
44615 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
44616 				vof += vo6;			/* Move to next vertex */
44617 				vwe = we6 - we7;		/* Baricentric weighting */
44618 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
44619 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
44620 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
44621 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
44622 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
44623 				vof += vo7;			/* Move to next vertex */
44624 				vwe = we7;				/* Baricentric weighting */
44625 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
44626 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
44627 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
44628 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
44629 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
44630 			}
44631 		}
44632 		{
44633 			unsigned int oti;	/* Vertex offset value */
44634 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
44635 			op0[0] = OT_E(ot0, oti);	/* Write result */
44636 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
44637 			op0[1] = OT_E(ot1, oti);	/* Write result */
44638 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
44639 			op0[2] = OT_E(ot2, oti);	/* Write result */
44640 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
44641 			op0[3] = OT_E(ot3, oti);	/* Write result */
44642 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
44643 			op0[4] = OT_E(ot4, oti);	/* Write result */
44644 		}
44645 	}
44646 }
44647 #undef IT_WE
44648 #undef IT_VO
44649 #undef IT_IX
44650 #undef CEX
44651 #undef IM_O
44652 #undef IM_FE
44653 #undef OT_E
44654 
44655 void
imdi_k126_gen(genspec * g)44656 imdi_k126_gen(
44657 genspec *g			/* structure to be initialised */
44658 ) {
44659 	static unsigned char data[] = {
44660 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
44661 		0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
44662 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44663 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44664 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44665 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44666 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44667 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
44668 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
44669 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
44670 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
44671 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44672 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44673 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44674 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44675 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44676 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44677 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44678 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44679 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
44680 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44681 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44682 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44683 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44684 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
44685 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
44686 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
44687 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
44688 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44689 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44690 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44691 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44692 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44693 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44694 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44695 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44696 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
44697 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
44698 		0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44699 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
44700 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
44701 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
44702 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
44703 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
44704 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
44705 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
44706 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
44707 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
44708 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44709 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
44710 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
44711 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x35, 0x5f,
44712 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
44713 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
44714 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
44715 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
44716 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
44717 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
44718 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
44719 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44720 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44721 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44722 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44723 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
44724 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x32,
44725 		0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44726 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44727 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
44728 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
44729 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
44730 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
44731 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
44732 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
44733 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
44734 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
44735 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
44736 		0x00, 0xf0, 0x04, 0x08
44737 	};	/* Structure image */
44738 
44739 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
44740 }
44741 
44742 void
imdi_k126_tab(tabspec * t)44743 imdi_k126_tab(
44744 tabspec *t			/* structure to be initialised */
44745 ) {
44746 	static unsigned char data[] = {
44747 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
44748 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
44749 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
44750 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
44751 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
44752 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
44753 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
44754 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
44755 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
44756 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44757 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
44758 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
44759 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
44760 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
44761 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
44762 		0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44763 		0x0a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
44764 		0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
44765 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44766 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44767 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
44768 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
44769 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44770 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
44771 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44772 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44773 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44774 		0xdc, 0xd6, 0x83, 0xbf, 0x14, 0xda, 0x83, 0xbf,
44775 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44776 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44777 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44778 		0x22, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff,
44779 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
44780 	};	/* Structure image */
44781 
44782 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
44783 }
44784 
44785 
44786 
44787 
44788 
44789 
44790 /* Integer Multi-Dimensional Interpolation */
44791 /* Interpolation Kernel Code */
44792 /* Generated by cgen */
44793 /* Copyright 2000 - 2002 Graeme W. Gill */
44794 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
44795 
44796 /* see the Licence.txt file for licencing details.*/
44797 
44798 
44799 /*
44800    Interpolation kernel specs:
44801 
44802    Input channels per pixel = 1
44803    Input channel 0 bits = 16
44804    Input channel 0 increment = 1
44805    Input is channel interleaved
44806    Input channels are separate words
44807    Input value extraction is done in input table lookup
44808 
44809    Output channels per pixel = 6
44810    Output channel 0 bits = 16
44811    Output channel 0 increment = 6
44812    Output channel 1 bits = 16
44813    Output channel 1 increment = 6
44814    Output channel 2 bits = 16
44815    Output channel 2 increment = 6
44816    Output channel 3 bits = 16
44817    Output channel 3 increment = 6
44818    Output channel 4 bits = 16
44819    Output channel 4 increment = 6
44820    Output channel 5 bits = 16
44821    Output channel 5 increment = 6
44822    Output is channel interleaved
44823 
44824    Output channels are separate words
44825    Weight+voffset bits       = 32
44826    Interpolation table index bits = 11
44827    Interpolation table max resolution = 2048
44828  */
44829 
44830 /*
44831    Machine architecture specs:
44832 
44833    Little endian
44834    Reading and writing pixel values separately
44835    Pointer size = 32 bits
44836 
44837    Ordinal size  8 bits is known as 'unsigned char'
44838    Ordinal size 16 bits is known as 'unsigned short'
44839    Ordinal size 32 bits is known as 'unsigned int'
44840    Natural ordinal is 'unsigned int'
44841 
44842    Integer size  8 bits is known as 'signed char'
44843    Integer size 16 bits is known as 'short'
44844    Integer size 32 bits is known as 'int'
44845    Natural integer is 'int'
44846 
44847  */
44848 
44849 #ifndef  IMDI_INCLUDED
44850 #include <memory.h>
44851 #include "imdi_imp.h"
44852 #define  IMDI_INCLUDED
44853 #endif  /* IMDI_INCLUDED */
44854 
44855 #ifndef DEFINED_pointer
44856 #define DEFINED_pointer
44857 typedef unsigned char * pointer;
44858 #endif
44859 
44860 /* Input table interp index, weighting and vertex offset */
44861 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
44862 
44863 /* Conditional exchange for sorting */
44864 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
44865 
44866 /* Interpolation multi-dim. table access */
44867 #define IM_O(off) ((off) * 12)
44868 
44869 /* Interpolation table - get vertex values */
44870 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 4 + (c) * 2)))
44871 
44872 /* Output table indexes */
44873 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
44874 
44875 void
imdi_k127(imdi * s,void ** outp,void ** inp,unsigned int npix)44876 imdi_k127(
44877 imdi *s,			/* imdi context */
44878 void **outp,		/* pointer to output pointers */
44879 void **inp,		/* pointer to input pointers */
44880 unsigned int npix	/* Number of pixels to process */
44881 ) {
44882 	imdi_imp *p = (imdi_imp *)(s->impl);
44883 	unsigned short *ip0 = (unsigned short *)inp[0];
44884 	unsigned short *op0 = (unsigned short *)outp[0];
44885 	unsigned short *ep = ip0 + npix * 1 ;
44886 	pointer it0 = (pointer)p->in_tables[0];
44887 	pointer ot0 = (pointer)p->out_tables[0];
44888 	pointer ot1 = (pointer)p->out_tables[1];
44889 	pointer ot2 = (pointer)p->out_tables[2];
44890 	pointer ot3 = (pointer)p->out_tables[3];
44891 	pointer ot4 = (pointer)p->out_tables[4];
44892 	pointer ot5 = (pointer)p->out_tables[5];
44893 	pointer im_base = (pointer)p->im_table;
44894 
44895 	for(;ip0 < ep; ip0 += 1, op0 += 6) {
44896 		unsigned int ova0;	/* Output value accumulator */
44897 		unsigned int ova1;	/* Output value accumulator */
44898 		unsigned int ova2;	/* Output value accumulator */
44899 		unsigned int ova3;	/* Output value accumulator */
44900 		unsigned int ova4;	/* Output value accumulator */
44901 		unsigned int ova5;	/* Output value accumulator */
44902 		{
44903 			pointer imp;
44904 			unsigned int wo0;	/* Weighting value and vertex offset variable */
44905 			{
44906 				unsigned int ti;		/* Input table entry variable */
44907 				unsigned int ti_i;	/* Interpolation index variable */
44908 
44909 				ti = IT_IT(it0, ip0[0]);
44910 				wo0   = (ti & 0x1fffff);	/* Extract weighting/vertex offset value */
44911 				ti_i  = (ti >> 21);	/* Extract interpolation table value */
44912 
44913 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
44914 
44915 				/* Sort weighting values and vertex offset values */
44916 			}
44917 			{
44918 				unsigned int nvof;	/* Next vertex offset value */
44919 				unsigned int vof;	/* Vertex offset value */
44920 				unsigned int vwe;	/* Vertex weighting */
44921 
44922 				vof = 0;				/* First vertex offset is 0 */
44923 				nvof = (wo0 & 0xf);	/* Extract offset value */
44924 				wo0 = (wo0 >> 4);		/* Extract weighting value */
44925 				vwe = 65536 - wo0;		/* Baricentric weighting */
44926 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
44927 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
44928 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
44929 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
44930 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
44931 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
44932 				vof += nvof;			/* Move to next vertex */
44933 				vwe = wo0;				/* Baricentric weighting */
44934 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
44935 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
44936 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
44937 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
44938 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
44939 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
44940 			}
44941 		}
44942 		{
44943 			unsigned int oti;	/* Vertex offset value */
44944 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
44945 			op0[0] = OT_E(ot0, oti);	/* Write result */
44946 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
44947 			op0[1] = OT_E(ot1, oti);	/* Write result */
44948 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
44949 			op0[2] = OT_E(ot2, oti);	/* Write result */
44950 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
44951 			op0[3] = OT_E(ot3, oti);	/* Write result */
44952 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
44953 			op0[4] = OT_E(ot4, oti);	/* Write result */
44954 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
44955 			op0[5] = OT_E(ot5, oti);	/* Write result */
44956 		}
44957 	}
44958 }
44959 #undef IT_IT
44960 #undef CEX
44961 #undef IM_O
44962 #undef IM_FE
44963 #undef OT_E
44964 
44965 void
imdi_k127_gen(genspec * g)44966 imdi_k127_gen(
44967 genspec *g			/* structure to be initialised */
44968 ) {
44969 	static unsigned char data[] = {
44970 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
44971 		0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
44972 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44973 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44974 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44975 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44976 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44977 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
44978 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
44979 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
44980 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
44981 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44982 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44983 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44984 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44985 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44986 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44987 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44988 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44989 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
44990 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44991 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44992 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44993 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
44994 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
44995 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
44996 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
44997 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
44998 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44999 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45000 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45001 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45002 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45003 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45004 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45005 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45006 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
45007 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
45008 		0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45009 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
45010 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
45011 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
45012 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
45013 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
45014 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
45015 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
45016 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
45017 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
45018 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45019 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
45020 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
45021 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x36, 0x5f,
45022 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
45023 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
45024 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
45025 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
45026 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
45027 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
45028 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
45029 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45030 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45031 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45032 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45033 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
45034 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x32,
45035 		0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45036 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45037 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
45038 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
45039 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
45040 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
45041 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
45042 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
45043 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
45044 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
45045 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
45046 		0x00, 0xf0, 0x04, 0x08
45047 	};	/* Structure image */
45048 
45049 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
45050 }
45051 
45052 void
imdi_k127_tab(tabspec * t)45053 imdi_k127_tab(
45054 tabspec *t			/* structure to be initialised */
45055 ) {
45056 	static unsigned char data[] = {
45057 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45058 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
45059 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
45060 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
45061 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
45062 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
45063 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
45064 		0x0b, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
45065 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
45066 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45067 		0x14, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
45068 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
45069 		0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
45070 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
45071 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
45072 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45073 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
45074 		0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
45075 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45076 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45077 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
45078 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
45079 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
45080 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
45081 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45082 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45083 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45084 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
45085 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45086 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45087 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45088 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
45089 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
45090 	};	/* Structure image */
45091 
45092 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
45093 }
45094 
45095 
45096 
45097 
45098 
45099 
45100 /* Integer Multi-Dimensional Interpolation */
45101 /* Interpolation Kernel Code */
45102 /* Generated by cgen */
45103 /* Copyright 2000 - 2002 Graeme W. Gill */
45104 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
45105 
45106 /* see the Licence.txt file for licencing details.*/
45107 
45108 
45109 /*
45110    Interpolation kernel specs:
45111 
45112    Input channels per pixel = 3
45113    Input channel 0 bits = 16
45114    Input channel 0 increment = 3
45115    Input channel 1 bits = 16
45116    Input channel 1 increment = 3
45117    Input channel 2 bits = 16
45118    Input channel 2 increment = 3
45119    Input is channel interleaved
45120    Input channels are separate words
45121    Input value extraction is done in input table lookup
45122 
45123    Output channels per pixel = 6
45124    Output channel 0 bits = 16
45125    Output channel 0 increment = 6
45126    Output channel 1 bits = 16
45127    Output channel 1 increment = 6
45128    Output channel 2 bits = 16
45129    Output channel 2 increment = 6
45130    Output channel 3 bits = 16
45131    Output channel 3 increment = 6
45132    Output channel 4 bits = 16
45133    Output channel 4 increment = 6
45134    Output channel 5 bits = 16
45135    Output channel 5 increment = 6
45136    Output is channel interleaved
45137 
45138    Output channels are separate words
45139    Weight+voffset bits       = 32
45140    Interpolation table index bits = 16
45141    Interpolation table max resolution = 40
45142  */
45143 
45144 /*
45145    Machine architecture specs:
45146 
45147    Little endian
45148    Reading and writing pixel values separately
45149    Pointer size = 32 bits
45150 
45151    Ordinal size  8 bits is known as 'unsigned char'
45152    Ordinal size 16 bits is known as 'unsigned short'
45153    Ordinal size 32 bits is known as 'unsigned int'
45154    Natural ordinal is 'unsigned int'
45155 
45156    Integer size  8 bits is known as 'signed char'
45157    Integer size 16 bits is known as 'short'
45158    Integer size 32 bits is known as 'int'
45159    Natural integer is 'int'
45160 
45161  */
45162 
45163 #ifndef  IMDI_INCLUDED
45164 #include <memory.h>
45165 #include "imdi_imp.h"
45166 #define  IMDI_INCLUDED
45167 #endif  /* IMDI_INCLUDED */
45168 
45169 #ifndef DEFINED_pointer
45170 #define DEFINED_pointer
45171 typedef unsigned char * pointer;
45172 #endif
45173 
45174 /* Input table interp. index */
45175 #define IT_IX(p, off) *((unsigned short *)((p) + 0 + (off) * 6))
45176 
45177 /* Input table input weighting/offset value enty */
45178 #define IT_WO(p, off) *((unsigned int *)((p) + 2 + (off) * 6))
45179 
45180 /* Conditional exchange for sorting */
45181 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
45182 
45183 /* Interpolation multi-dim. table access */
45184 #define IM_O(off) ((off) * 12)
45185 
45186 /* Interpolation table - get vertex values */
45187 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 4 + (c) * 2)))
45188 
45189 /* Output table indexes */
45190 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
45191 
45192 void
imdi_k128(imdi * s,void ** outp,void ** inp,unsigned int npix)45193 imdi_k128(
45194 imdi *s,			/* imdi context */
45195 void **outp,		/* pointer to output pointers */
45196 void **inp,		/* pointer to input pointers */
45197 unsigned int npix	/* Number of pixels to process */
45198 ) {
45199 	imdi_imp *p = (imdi_imp *)(s->impl);
45200 	unsigned short *ip0 = (unsigned short *)inp[0];
45201 	unsigned short *op0 = (unsigned short *)outp[0];
45202 	unsigned short *ep = ip0 + npix * 3 ;
45203 	pointer it0 = (pointer)p->in_tables[0];
45204 	pointer it1 = (pointer)p->in_tables[1];
45205 	pointer it2 = (pointer)p->in_tables[2];
45206 	pointer ot0 = (pointer)p->out_tables[0];
45207 	pointer ot1 = (pointer)p->out_tables[1];
45208 	pointer ot2 = (pointer)p->out_tables[2];
45209 	pointer ot3 = (pointer)p->out_tables[3];
45210 	pointer ot4 = (pointer)p->out_tables[4];
45211 	pointer ot5 = (pointer)p->out_tables[5];
45212 	pointer im_base = (pointer)p->im_table;
45213 
45214 	for(;ip0 < ep; ip0 += 3, op0 += 6) {
45215 		unsigned int ova0;	/* Output value accumulator */
45216 		unsigned int ova1;	/* Output value accumulator */
45217 		unsigned int ova2;	/* Output value accumulator */
45218 		unsigned int ova3;	/* Output value accumulator */
45219 		unsigned int ova4;	/* Output value accumulator */
45220 		unsigned int ova5;	/* Output value accumulator */
45221 		{
45222 			pointer imp;
45223 			unsigned int wo0;	/* Weighting value and vertex offset variable */
45224 			unsigned int wo1;	/* Weighting value and vertex offset variable */
45225 			unsigned int wo2;	/* Weighting value and vertex offset variable */
45226 			{
45227 				unsigned int ti_i;	/* Interpolation index variable */
45228 
45229 				ti_i  = IT_IX(it0, ip0[0]);
45230 				wo0   = IT_WO(it0, ip0[0]);
45231 				ti_i += IT_IX(it1, ip0[1]);
45232 				wo1   = IT_WO(it1, ip0[1]);
45233 				ti_i += IT_IX(it2, ip0[2]);
45234 				wo2   = IT_WO(it2, ip0[2]);
45235 
45236 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
45237 
45238 				/* Sort weighting values and vertex offset values */
45239 				CEX(wo0, wo1);
45240 				CEX(wo0, wo2);
45241 				CEX(wo1, wo2);
45242 			}
45243 			{
45244 				unsigned int nvof;	/* Next vertex offset value */
45245 				unsigned int vof;	/* Vertex offset value */
45246 				unsigned int vwe;	/* Vertex weighting */
45247 
45248 				vof = 0;				/* First vertex offset is 0 */
45249 				nvof = (wo0 & 0x7fff);	/* Extract offset value */
45250 				wo0 = (wo0 >> 15);		/* Extract weighting value */
45251 				vwe = 65536 - wo0;		/* Baricentric weighting */
45252 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
45253 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
45254 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
45255 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
45256 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
45257 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
45258 				vof += nvof;			/* Move to next vertex */
45259 				nvof = (wo1 & 0x7fff);	/* Extract offset value */
45260 				wo1 = (wo1 >> 15);		/* Extract weighting value */
45261 				vwe = wo0 - wo1;		/* Baricentric weighting */
45262 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
45263 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
45264 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
45265 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
45266 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
45267 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
45268 				vof += nvof;			/* Move to next vertex */
45269 				nvof = (wo2 & 0x7fff);	/* Extract offset value */
45270 				wo2 = (wo2 >> 15);		/* Extract weighting value */
45271 				vwe = wo1 - wo2;		/* Baricentric weighting */
45272 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
45273 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
45274 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
45275 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
45276 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
45277 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
45278 				vof += nvof;			/* Move to next vertex */
45279 				vwe = wo2;				/* Baricentric weighting */
45280 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
45281 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
45282 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
45283 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
45284 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
45285 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
45286 			}
45287 		}
45288 		{
45289 			unsigned int oti;	/* Vertex offset value */
45290 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
45291 			op0[0] = OT_E(ot0, oti);	/* Write result */
45292 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
45293 			op0[1] = OT_E(ot1, oti);	/* Write result */
45294 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
45295 			op0[2] = OT_E(ot2, oti);	/* Write result */
45296 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
45297 			op0[3] = OT_E(ot3, oti);	/* Write result */
45298 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
45299 			op0[4] = OT_E(ot4, oti);	/* Write result */
45300 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
45301 			op0[5] = OT_E(ot5, oti);	/* Write result */
45302 		}
45303 	}
45304 }
45305 #undef IT_WO
45306 #undef IT_IX
45307 #undef CEX
45308 #undef IM_O
45309 #undef IM_FE
45310 #undef OT_E
45311 
45312 void
imdi_k128_gen(genspec * g)45313 imdi_k128_gen(
45314 genspec *g			/* structure to be initialised */
45315 ) {
45316 	static unsigned char data[] = {
45317 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
45318 		0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
45319 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45320 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45321 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45322 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45323 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45324 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
45325 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
45326 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
45327 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
45328 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45329 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45330 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45331 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45332 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45333 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45334 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45335 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45336 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
45337 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45338 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45339 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45340 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45341 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
45342 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
45343 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
45344 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
45345 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45346 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45347 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45348 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45349 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45350 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45351 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45352 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45353 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
45354 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
45355 		0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45356 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
45357 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
45358 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
45359 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
45360 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
45361 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
45362 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
45363 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
45364 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
45365 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45366 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
45367 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
45368 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x36, 0x5f,
45369 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
45370 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
45371 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
45372 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
45373 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
45374 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
45375 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
45376 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45377 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45378 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45379 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45380 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
45381 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x32,
45382 		0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45383 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45384 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
45385 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
45386 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
45387 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
45388 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
45389 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
45390 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
45391 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
45392 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
45393 		0x00, 0xf0, 0x04, 0x08
45394 	};	/* Structure image */
45395 
45396 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
45397 }
45398 
45399 void
imdi_k128_tab(tabspec * t)45400 imdi_k128_tab(
45401 tabspec *t			/* structure to be initialised */
45402 ) {
45403 	static unsigned char data[] = {
45404 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
45405 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
45406 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
45407 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
45408 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
45409 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
45410 		0x20, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
45411 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
45412 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
45413 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45414 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
45415 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
45416 		0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
45417 		0x04, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
45418 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
45419 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45420 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
45421 		0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
45422 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45423 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45424 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
45425 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
45426 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
45427 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
45428 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45429 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45430 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45431 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
45432 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45433 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45434 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45435 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
45436 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
45437 	};	/* Structure image */
45438 
45439 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
45440 }
45441 
45442 
45443 
45444 
45445 
45446 
45447 /* Integer Multi-Dimensional Interpolation */
45448 /* Interpolation Kernel Code */
45449 /* Generated by cgen */
45450 /* Copyright 2000 - 2002 Graeme W. Gill */
45451 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
45452 
45453 /* see the Licence.txt file for licencing details.*/
45454 
45455 
45456 /*
45457    Interpolation kernel specs:
45458 
45459    Input channels per pixel = 4
45460    Input channel 0 bits = 16
45461    Input channel 0 increment = 4
45462    Input channel 1 bits = 16
45463    Input channel 1 increment = 4
45464    Input channel 2 bits = 16
45465    Input channel 2 increment = 4
45466    Input channel 3 bits = 16
45467    Input channel 3 increment = 4
45468    Input is channel interleaved
45469    Input channels are separate words
45470    Input value extraction is done in input table lookup
45471 
45472    Output channels per pixel = 6
45473    Output channel 0 bits = 16
45474    Output channel 0 increment = 6
45475    Output channel 1 bits = 16
45476    Output channel 1 increment = 6
45477    Output channel 2 bits = 16
45478    Output channel 2 increment = 6
45479    Output channel 3 bits = 16
45480    Output channel 3 increment = 6
45481    Output channel 4 bits = 16
45482    Output channel 4 increment = 6
45483    Output channel 5 bits = 16
45484    Output channel 5 increment = 6
45485    Output is channel interleaved
45486 
45487    Output channels are separate words
45488    Weight+voffset bits       = 32
45489    Interpolation table index bits = 32
45490    Interpolation table max resolution = 21
45491  */
45492 
45493 /*
45494    Machine architecture specs:
45495 
45496    Little endian
45497    Reading and writing pixel values separately
45498    Pointer size = 32 bits
45499 
45500    Ordinal size  8 bits is known as 'unsigned char'
45501    Ordinal size 16 bits is known as 'unsigned short'
45502    Ordinal size 32 bits is known as 'unsigned int'
45503    Natural ordinal is 'unsigned int'
45504 
45505    Integer size  8 bits is known as 'signed char'
45506    Integer size 16 bits is known as 'short'
45507    Integer size 32 bits is known as 'int'
45508    Natural integer is 'int'
45509 
45510  */
45511 
45512 #ifndef  IMDI_INCLUDED
45513 #include <memory.h>
45514 #include "imdi_imp.h"
45515 #define  IMDI_INCLUDED
45516 #endif  /* IMDI_INCLUDED */
45517 
45518 #ifndef DEFINED_pointer
45519 #define DEFINED_pointer
45520 typedef unsigned char * pointer;
45521 #endif
45522 
45523 /* Input table interp. index */
45524 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
45525 
45526 /* Input table input weighting/offset value enty */
45527 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
45528 
45529 /* Conditional exchange for sorting */
45530 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
45531 
45532 /* Interpolation multi-dim. table access */
45533 #define IM_O(off) ((off) * 12)
45534 
45535 /* Interpolation table - get vertex values */
45536 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 4 + (c) * 2)))
45537 
45538 /* Output table indexes */
45539 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
45540 
45541 void
imdi_k129(imdi * s,void ** outp,void ** inp,unsigned int npix)45542 imdi_k129(
45543 imdi *s,			/* imdi context */
45544 void **outp,		/* pointer to output pointers */
45545 void **inp,		/* pointer to input pointers */
45546 unsigned int npix	/* Number of pixels to process */
45547 ) {
45548 	imdi_imp *p = (imdi_imp *)(s->impl);
45549 	unsigned short *ip0 = (unsigned short *)inp[0];
45550 	unsigned short *op0 = (unsigned short *)outp[0];
45551 	unsigned short *ep = ip0 + npix * 4 ;
45552 	pointer it0 = (pointer)p->in_tables[0];
45553 	pointer it1 = (pointer)p->in_tables[1];
45554 	pointer it2 = (pointer)p->in_tables[2];
45555 	pointer it3 = (pointer)p->in_tables[3];
45556 	pointer ot0 = (pointer)p->out_tables[0];
45557 	pointer ot1 = (pointer)p->out_tables[1];
45558 	pointer ot2 = (pointer)p->out_tables[2];
45559 	pointer ot3 = (pointer)p->out_tables[3];
45560 	pointer ot4 = (pointer)p->out_tables[4];
45561 	pointer ot5 = (pointer)p->out_tables[5];
45562 	pointer im_base = (pointer)p->im_table;
45563 
45564 	for(;ip0 < ep; ip0 += 4, op0 += 6) {
45565 		unsigned int ova0;	/* Output value accumulator */
45566 		unsigned int ova1;	/* Output value accumulator */
45567 		unsigned int ova2;	/* Output value accumulator */
45568 		unsigned int ova3;	/* Output value accumulator */
45569 		unsigned int ova4;	/* Output value accumulator */
45570 		unsigned int ova5;	/* Output value accumulator */
45571 		{
45572 			pointer imp;
45573 			unsigned int wo0;	/* Weighting value and vertex offset variable */
45574 			unsigned int wo1;	/* Weighting value and vertex offset variable */
45575 			unsigned int wo2;	/* Weighting value and vertex offset variable */
45576 			unsigned int wo3;	/* Weighting value and vertex offset variable */
45577 			{
45578 				unsigned int ti_i;	/* Interpolation index variable */
45579 
45580 				ti_i  = IT_IX(it0, ip0[0]);
45581 				wo0   = IT_WO(it0, ip0[0]);
45582 				ti_i += IT_IX(it1, ip0[1]);
45583 				wo1   = IT_WO(it1, ip0[1]);
45584 				ti_i += IT_IX(it2, ip0[2]);
45585 				wo2   = IT_WO(it2, ip0[2]);
45586 				ti_i += IT_IX(it3, ip0[3]);
45587 				wo3   = IT_WO(it3, ip0[3]);
45588 
45589 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
45590 
45591 				/* Sort weighting values and vertex offset values */
45592 				CEX(wo0, wo1);
45593 				CEX(wo0, wo2);
45594 				CEX(wo0, wo3);
45595 				CEX(wo1, wo2);
45596 				CEX(wo1, wo3);
45597 				CEX(wo2, wo3);
45598 			}
45599 			{
45600 				unsigned int nvof;	/* Next vertex offset value */
45601 				unsigned int vof;	/* Vertex offset value */
45602 				unsigned int vwe;	/* Vertex weighting */
45603 
45604 				vof = 0;				/* First vertex offset is 0 */
45605 				nvof = (wo0 & 0x7fff);	/* Extract offset value */
45606 				wo0 = (wo0 >> 15);		/* Extract weighting value */
45607 				vwe = 65536 - wo0;		/* Baricentric weighting */
45608 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
45609 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
45610 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
45611 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
45612 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
45613 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
45614 				vof += nvof;			/* Move to next vertex */
45615 				nvof = (wo1 & 0x7fff);	/* Extract offset value */
45616 				wo1 = (wo1 >> 15);		/* Extract weighting value */
45617 				vwe = wo0 - wo1;		/* Baricentric weighting */
45618 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
45619 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
45620 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
45621 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
45622 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
45623 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
45624 				vof += nvof;			/* Move to next vertex */
45625 				nvof = (wo2 & 0x7fff);	/* Extract offset value */
45626 				wo2 = (wo2 >> 15);		/* Extract weighting value */
45627 				vwe = wo1 - wo2;		/* Baricentric weighting */
45628 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
45629 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
45630 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
45631 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
45632 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
45633 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
45634 				vof += nvof;			/* Move to next vertex */
45635 				nvof = (wo3 & 0x7fff);	/* Extract offset value */
45636 				wo3 = (wo3 >> 15);		/* Extract weighting value */
45637 				vwe = wo2 - wo3;		/* Baricentric weighting */
45638 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
45639 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
45640 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
45641 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
45642 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
45643 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
45644 				vof += nvof;			/* Move to next vertex */
45645 				vwe = wo3;				/* Baricentric weighting */
45646 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
45647 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
45648 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
45649 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
45650 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
45651 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
45652 			}
45653 		}
45654 		{
45655 			unsigned int oti;	/* Vertex offset value */
45656 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
45657 			op0[0] = OT_E(ot0, oti);	/* Write result */
45658 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
45659 			op0[1] = OT_E(ot1, oti);	/* Write result */
45660 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
45661 			op0[2] = OT_E(ot2, oti);	/* Write result */
45662 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
45663 			op0[3] = OT_E(ot3, oti);	/* Write result */
45664 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
45665 			op0[4] = OT_E(ot4, oti);	/* Write result */
45666 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
45667 			op0[5] = OT_E(ot5, oti);	/* Write result */
45668 		}
45669 	}
45670 }
45671 #undef IT_WO
45672 #undef IT_IX
45673 #undef CEX
45674 #undef IM_O
45675 #undef IM_FE
45676 #undef OT_E
45677 
45678 void
imdi_k129_gen(genspec * g)45679 imdi_k129_gen(
45680 genspec *g			/* structure to be initialised */
45681 ) {
45682 	static unsigned char data[] = {
45683 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
45684 		0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
45685 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45686 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45687 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45688 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45689 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45690 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
45691 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
45692 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
45693 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
45694 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45695 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45696 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45697 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45698 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45699 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45700 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45701 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45702 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
45703 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45704 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45705 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45706 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45707 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
45708 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
45709 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
45710 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
45711 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45712 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45713 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45714 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45715 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45716 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45717 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45718 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45719 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
45720 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
45721 		0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45722 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
45723 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
45724 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
45725 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
45726 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
45727 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
45728 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
45729 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
45730 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
45731 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45732 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
45733 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
45734 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x36, 0x5f,
45735 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
45736 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
45737 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
45738 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
45739 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
45740 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
45741 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
45742 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45743 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45744 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45745 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45746 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
45747 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x32,
45748 		0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45749 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45750 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
45751 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
45752 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
45753 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
45754 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
45755 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
45756 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
45757 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
45758 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
45759 		0x00, 0xf0, 0x04, 0x08
45760 	};	/* Structure image */
45761 
45762 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
45763 }
45764 
45765 void
imdi_k129_tab(tabspec * t)45766 imdi_k129_tab(
45767 tabspec *t			/* structure to be initialised */
45768 ) {
45769 	static unsigned char data[] = {
45770 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
45771 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
45772 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
45773 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
45774 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
45775 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
45776 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
45777 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
45778 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
45779 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45780 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
45781 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
45782 		0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
45783 		0x04, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
45784 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
45785 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45786 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
45787 		0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
45788 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45789 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45790 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
45791 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
45792 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
45793 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
45794 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45795 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45796 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45797 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
45798 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45799 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45800 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
45801 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
45802 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
45803 	};	/* Structure image */
45804 
45805 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
45806 }
45807 
45808 
45809 
45810 
45811 
45812 
45813 /* Integer Multi-Dimensional Interpolation */
45814 /* Interpolation Kernel Code */
45815 /* Generated by cgen */
45816 /* Copyright 2000 - 2002 Graeme W. Gill */
45817 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
45818 
45819 /* see the Licence.txt file for licencing details.*/
45820 
45821 
45822 /*
45823    Interpolation kernel specs:
45824 
45825    Input channels per pixel = 5
45826    Input channel 0 bits = 16
45827    Input channel 0 increment = 5
45828    Input channel 1 bits = 16
45829    Input channel 1 increment = 5
45830    Input channel 2 bits = 16
45831    Input channel 2 increment = 5
45832    Input channel 3 bits = 16
45833    Input channel 3 increment = 5
45834    Input channel 4 bits = 16
45835    Input channel 4 increment = 5
45836    Input is channel interleaved
45837    Input channels are separate words
45838    Input value extraction is done in input table lookup
45839 
45840    Output channels per pixel = 6
45841    Output channel 0 bits = 16
45842    Output channel 0 increment = 6
45843    Output channel 1 bits = 16
45844    Output channel 1 increment = 6
45845    Output channel 2 bits = 16
45846    Output channel 2 increment = 6
45847    Output channel 3 bits = 16
45848    Output channel 3 increment = 6
45849    Output channel 4 bits = 16
45850    Output channel 4 increment = 6
45851    Output channel 5 bits = 16
45852    Output channel 5 increment = 6
45853    Output is channel interleaved
45854 
45855    Output channels are separate words
45856    Weight+voffset bits       = 32
45857    Interpolation table index bits = 32
45858    Interpolation table max resolution = 84
45859  */
45860 
45861 /*
45862    Machine architecture specs:
45863 
45864    Little endian
45865    Reading and writing pixel values separately
45866    Pointer size = 32 bits
45867 
45868    Ordinal size  8 bits is known as 'unsigned char'
45869    Ordinal size 16 bits is known as 'unsigned short'
45870    Ordinal size 32 bits is known as 'unsigned int'
45871    Natural ordinal is 'unsigned int'
45872 
45873    Integer size  8 bits is known as 'signed char'
45874    Integer size 16 bits is known as 'short'
45875    Integer size 32 bits is known as 'int'
45876    Natural integer is 'int'
45877 
45878  */
45879 
45880 #ifndef  IMDI_INCLUDED
45881 #include <memory.h>
45882 #include "imdi_imp.h"
45883 #define  IMDI_INCLUDED
45884 #endif  /* IMDI_INCLUDED */
45885 
45886 #ifndef DEFINED_pointer
45887 #define DEFINED_pointer
45888 typedef unsigned char * pointer;
45889 #endif
45890 
45891 /* Input table interp. index */
45892 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
45893 
45894 /* Input table input weighting enty */
45895 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
45896 
45897 /* Input table input offset value enty */
45898 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
45899 
45900 /* Conditional exchange for sorting */
45901 #define CEX(A, AA, B, BB) if (A < B) { \
45902             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
45903 
45904 /* Interpolation multi-dim. table access */
45905 #define IM_O(off) ((off) * 12)
45906 
45907 /* Interpolation table - get vertex values */
45908 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 4 + (c) * 2)))
45909 
45910 /* Output table indexes */
45911 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
45912 
45913 void
imdi_k130(imdi * s,void ** outp,void ** inp,unsigned int npix)45914 imdi_k130(
45915 imdi *s,			/* imdi context */
45916 void **outp,		/* pointer to output pointers */
45917 void **inp,		/* pointer to input pointers */
45918 unsigned int npix	/* Number of pixels to process */
45919 ) {
45920 	imdi_imp *p = (imdi_imp *)(s->impl);
45921 	unsigned short *ip0 = (unsigned short *)inp[0];
45922 	unsigned short *op0 = (unsigned short *)outp[0];
45923 	unsigned short *ep = ip0 + npix * 5 ;
45924 	pointer it0 = (pointer)p->in_tables[0];
45925 	pointer it1 = (pointer)p->in_tables[1];
45926 	pointer it2 = (pointer)p->in_tables[2];
45927 	pointer it3 = (pointer)p->in_tables[3];
45928 	pointer it4 = (pointer)p->in_tables[4];
45929 	pointer ot0 = (pointer)p->out_tables[0];
45930 	pointer ot1 = (pointer)p->out_tables[1];
45931 	pointer ot2 = (pointer)p->out_tables[2];
45932 	pointer ot3 = (pointer)p->out_tables[3];
45933 	pointer ot4 = (pointer)p->out_tables[4];
45934 	pointer ot5 = (pointer)p->out_tables[5];
45935 	pointer im_base = (pointer)p->im_table;
45936 
45937 	for(;ip0 < ep; ip0 += 5, op0 += 6) {
45938 		unsigned int ova0;	/* Output value accumulator */
45939 		unsigned int ova1;	/* Output value accumulator */
45940 		unsigned int ova2;	/* Output value accumulator */
45941 		unsigned int ova3;	/* Output value accumulator */
45942 		unsigned int ova4;	/* Output value accumulator */
45943 		unsigned int ova5;	/* Output value accumulator */
45944 		{
45945 			pointer imp;
45946 			unsigned int we0;	/* Weighting value variable */
45947 			unsigned int vo0;	/* Vertex offset variable */
45948 			unsigned int we1;	/* Weighting value variable */
45949 			unsigned int vo1;	/* Vertex offset variable */
45950 			unsigned int we2;	/* Weighting value variable */
45951 			unsigned int vo2;	/* Vertex offset variable */
45952 			unsigned int we3;	/* Weighting value variable */
45953 			unsigned int vo3;	/* Vertex offset variable */
45954 			unsigned int we4;	/* Weighting value variable */
45955 			unsigned int vo4;	/* Vertex offset variable */
45956 			{
45957 				unsigned int ti_i;	/* Interpolation index variable */
45958 
45959 				ti_i  = IT_IX(it0, ip0[0]);
45960 				we0   = IT_WE(it0, ip0[0]);
45961 				vo0   = IT_VO(it0, ip0[0]);
45962 				ti_i += IT_IX(it1, ip0[1]);
45963 				we1   = IT_WE(it1, ip0[1]);
45964 				vo1   = IT_VO(it1, ip0[1]);
45965 				ti_i += IT_IX(it2, ip0[2]);
45966 				we2   = IT_WE(it2, ip0[2]);
45967 				vo2   = IT_VO(it2, ip0[2]);
45968 				ti_i += IT_IX(it3, ip0[3]);
45969 				we3   = IT_WE(it3, ip0[3]);
45970 				vo3   = IT_VO(it3, ip0[3]);
45971 				ti_i += IT_IX(it4, ip0[4]);
45972 				we4   = IT_WE(it4, ip0[4]);
45973 				vo4   = IT_VO(it4, ip0[4]);
45974 
45975 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
45976 
45977 				/* Sort weighting values and vertex offset values */
45978 				CEX(we0, vo0, we1, vo1);
45979 				CEX(we0, vo0, we2, vo2);
45980 				CEX(we0, vo0, we3, vo3);
45981 				CEX(we0, vo0, we4, vo4);
45982 				CEX(we1, vo1, we2, vo2);
45983 				CEX(we1, vo1, we3, vo3);
45984 				CEX(we1, vo1, we4, vo4);
45985 				CEX(we2, vo2, we3, vo3);
45986 				CEX(we2, vo2, we4, vo4);
45987 				CEX(we3, vo3, we4, vo4);
45988 			}
45989 			{
45990 				unsigned int vof;	/* Vertex offset value */
45991 				unsigned int vwe;	/* Vertex weighting */
45992 
45993 				vof = 0;				/* First vertex offset is 0 */
45994 				vwe = 65536 - we0;		/* Baricentric weighting */
45995 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
45996 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
45997 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
45998 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
45999 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46000 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46001 				vof += vo0;			/* Move to next vertex */
46002 				vwe = we0 - we1;		/* Baricentric weighting */
46003 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46004 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46005 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46006 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46007 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46008 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46009 				vof += vo1;			/* Move to next vertex */
46010 				vwe = we1 - we2;		/* Baricentric weighting */
46011 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46012 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46013 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46014 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46015 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46016 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46017 				vof += vo2;			/* Move to next vertex */
46018 				vwe = we2 - we3;		/* Baricentric weighting */
46019 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46020 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46021 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46022 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46023 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46024 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46025 				vof += vo3;			/* Move to next vertex */
46026 				vwe = we3 - we4;		/* Baricentric weighting */
46027 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46028 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46029 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46030 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46031 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46032 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46033 				vof += vo4;			/* Move to next vertex */
46034 				vwe = we4;				/* Baricentric weighting */
46035 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46036 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46037 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46038 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46039 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46040 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46041 			}
46042 		}
46043 		{
46044 			unsigned int oti;	/* Vertex offset value */
46045 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
46046 			op0[0] = OT_E(ot0, oti);	/* Write result */
46047 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
46048 			op0[1] = OT_E(ot1, oti);	/* Write result */
46049 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
46050 			op0[2] = OT_E(ot2, oti);	/* Write result */
46051 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
46052 			op0[3] = OT_E(ot3, oti);	/* Write result */
46053 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
46054 			op0[4] = OT_E(ot4, oti);	/* Write result */
46055 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
46056 			op0[5] = OT_E(ot5, oti);	/* Write result */
46057 		}
46058 	}
46059 }
46060 #undef IT_WE
46061 #undef IT_VO
46062 #undef IT_IX
46063 #undef CEX
46064 #undef IM_O
46065 #undef IM_FE
46066 #undef OT_E
46067 
46068 void
imdi_k130_gen(genspec * g)46069 imdi_k130_gen(
46070 genspec *g			/* structure to be initialised */
46071 ) {
46072 	static unsigned char data[] = {
46073 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
46074 		0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
46075 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46076 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46077 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46078 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46079 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46080 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
46081 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
46082 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
46083 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
46084 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46085 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46086 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46087 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46088 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46089 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46090 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46091 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46092 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
46093 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46094 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46095 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46096 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46097 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
46098 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
46099 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
46100 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
46101 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46102 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46103 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46104 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46105 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46106 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46107 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46108 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46109 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
46110 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
46111 		0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46112 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
46113 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
46114 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
46115 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
46116 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
46117 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
46118 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
46119 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
46120 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
46121 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46122 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
46123 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
46124 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x36, 0x5f,
46125 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
46126 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
46127 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
46128 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
46129 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
46130 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
46131 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
46132 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46133 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46134 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46135 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46136 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
46137 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x33,
46138 		0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46139 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46140 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
46141 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
46142 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
46143 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
46144 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
46145 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
46146 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
46147 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
46148 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
46149 		0x00, 0xf0, 0x04, 0x08
46150 	};	/* Structure image */
46151 
46152 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
46153 }
46154 
46155 void
imdi_k130_tab(tabspec * t)46156 imdi_k130_tab(
46157 tabspec *t			/* structure to be initialised */
46158 ) {
46159 	static unsigned char data[] = {
46160 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
46161 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
46162 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
46163 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
46164 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
46165 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
46166 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
46167 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
46168 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
46169 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46170 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
46171 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
46172 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
46173 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
46174 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
46175 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46176 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
46177 		0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
46178 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46179 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46180 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
46181 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
46182 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
46183 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
46184 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46185 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46186 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46187 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
46188 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46189 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46190 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46191 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
46192 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
46193 	};	/* Structure image */
46194 
46195 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
46196 }
46197 
46198 
46199 
46200 
46201 
46202 
46203 /* Integer Multi-Dimensional Interpolation */
46204 /* Interpolation Kernel Code */
46205 /* Generated by cgen */
46206 /* Copyright 2000 - 2002 Graeme W. Gill */
46207 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
46208 
46209 /* see the Licence.txt file for licencing details.*/
46210 
46211 
46212 /*
46213    Interpolation kernel specs:
46214 
46215    Input channels per pixel = 6
46216    Input channel 0 bits = 16
46217    Input channel 0 increment = 6
46218    Input channel 1 bits = 16
46219    Input channel 1 increment = 6
46220    Input channel 2 bits = 16
46221    Input channel 2 increment = 6
46222    Input channel 3 bits = 16
46223    Input channel 3 increment = 6
46224    Input channel 4 bits = 16
46225    Input channel 4 increment = 6
46226    Input channel 5 bits = 16
46227    Input channel 5 increment = 6
46228    Input is channel interleaved
46229    Input channels are separate words
46230    Input value extraction is done in input table lookup
46231 
46232    Output channels per pixel = 6
46233    Output channel 0 bits = 16
46234    Output channel 0 increment = 6
46235    Output channel 1 bits = 16
46236    Output channel 1 increment = 6
46237    Output channel 2 bits = 16
46238    Output channel 2 increment = 6
46239    Output channel 3 bits = 16
46240    Output channel 3 increment = 6
46241    Output channel 4 bits = 16
46242    Output channel 4 increment = 6
46243    Output channel 5 bits = 16
46244    Output channel 5 increment = 6
46245    Output is channel interleaved
46246 
46247    Output channels are separate words
46248    Weight+voffset bits       = 32
46249    Interpolation table index bits = 32
46250    Interpolation table max resolution = 40
46251  */
46252 
46253 /*
46254    Machine architecture specs:
46255 
46256    Little endian
46257    Reading and writing pixel values separately
46258    Pointer size = 32 bits
46259 
46260    Ordinal size  8 bits is known as 'unsigned char'
46261    Ordinal size 16 bits is known as 'unsigned short'
46262    Ordinal size 32 bits is known as 'unsigned int'
46263    Natural ordinal is 'unsigned int'
46264 
46265    Integer size  8 bits is known as 'signed char'
46266    Integer size 16 bits is known as 'short'
46267    Integer size 32 bits is known as 'int'
46268    Natural integer is 'int'
46269 
46270  */
46271 
46272 #ifndef  IMDI_INCLUDED
46273 #include <memory.h>
46274 #include "imdi_imp.h"
46275 #define  IMDI_INCLUDED
46276 #endif  /* IMDI_INCLUDED */
46277 
46278 #ifndef DEFINED_pointer
46279 #define DEFINED_pointer
46280 typedef unsigned char * pointer;
46281 #endif
46282 
46283 /* Input table interp. index */
46284 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
46285 
46286 /* Input table input weighting enty */
46287 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
46288 
46289 /* Input table input offset value enty */
46290 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
46291 
46292 /* Conditional exchange for sorting */
46293 #define CEX(A, AA, B, BB) if (A < B) { \
46294             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
46295 
46296 /* Interpolation multi-dim. table access */
46297 #define IM_O(off) ((off) * 12)
46298 
46299 /* Interpolation table - get vertex values */
46300 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 4 + (c) * 2)))
46301 
46302 /* Output table indexes */
46303 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
46304 
46305 void
imdi_k131(imdi * s,void ** outp,void ** inp,unsigned int npix)46306 imdi_k131(
46307 imdi *s,			/* imdi context */
46308 void **outp,		/* pointer to output pointers */
46309 void **inp,		/* pointer to input pointers */
46310 unsigned int npix	/* Number of pixels to process */
46311 ) {
46312 	imdi_imp *p = (imdi_imp *)(s->impl);
46313 	unsigned short *ip0 = (unsigned short *)inp[0];
46314 	unsigned short *op0 = (unsigned short *)outp[0];
46315 	unsigned short *ep = ip0 + npix * 6 ;
46316 	pointer it0 = (pointer)p->in_tables[0];
46317 	pointer it1 = (pointer)p->in_tables[1];
46318 	pointer it2 = (pointer)p->in_tables[2];
46319 	pointer it3 = (pointer)p->in_tables[3];
46320 	pointer it4 = (pointer)p->in_tables[4];
46321 	pointer it5 = (pointer)p->in_tables[5];
46322 	pointer ot0 = (pointer)p->out_tables[0];
46323 	pointer ot1 = (pointer)p->out_tables[1];
46324 	pointer ot2 = (pointer)p->out_tables[2];
46325 	pointer ot3 = (pointer)p->out_tables[3];
46326 	pointer ot4 = (pointer)p->out_tables[4];
46327 	pointer ot5 = (pointer)p->out_tables[5];
46328 	pointer im_base = (pointer)p->im_table;
46329 
46330 	for(;ip0 < ep; ip0 += 6, op0 += 6) {
46331 		unsigned int ova0;	/* Output value accumulator */
46332 		unsigned int ova1;	/* Output value accumulator */
46333 		unsigned int ova2;	/* Output value accumulator */
46334 		unsigned int ova3;	/* Output value accumulator */
46335 		unsigned int ova4;	/* Output value accumulator */
46336 		unsigned int ova5;	/* Output value accumulator */
46337 		{
46338 			pointer imp;
46339 			unsigned int we0;	/* Weighting value variable */
46340 			unsigned int vo0;	/* Vertex offset variable */
46341 			unsigned int we1;	/* Weighting value variable */
46342 			unsigned int vo1;	/* Vertex offset variable */
46343 			unsigned int we2;	/* Weighting value variable */
46344 			unsigned int vo2;	/* Vertex offset variable */
46345 			unsigned int we3;	/* Weighting value variable */
46346 			unsigned int vo3;	/* Vertex offset variable */
46347 			unsigned int we4;	/* Weighting value variable */
46348 			unsigned int vo4;	/* Vertex offset variable */
46349 			unsigned int we5;	/* Weighting value variable */
46350 			unsigned int vo5;	/* Vertex offset variable */
46351 			{
46352 				unsigned int ti_i;	/* Interpolation index variable */
46353 
46354 				ti_i  = IT_IX(it0, ip0[0]);
46355 				we0   = IT_WE(it0, ip0[0]);
46356 				vo0   = IT_VO(it0, ip0[0]);
46357 				ti_i += IT_IX(it1, ip0[1]);
46358 				we1   = IT_WE(it1, ip0[1]);
46359 				vo1   = IT_VO(it1, ip0[1]);
46360 				ti_i += IT_IX(it2, ip0[2]);
46361 				we2   = IT_WE(it2, ip0[2]);
46362 				vo2   = IT_VO(it2, ip0[2]);
46363 				ti_i += IT_IX(it3, ip0[3]);
46364 				we3   = IT_WE(it3, ip0[3]);
46365 				vo3   = IT_VO(it3, ip0[3]);
46366 				ti_i += IT_IX(it4, ip0[4]);
46367 				we4   = IT_WE(it4, ip0[4]);
46368 				vo4   = IT_VO(it4, ip0[4]);
46369 				ti_i += IT_IX(it5, ip0[5]);
46370 				we5   = IT_WE(it5, ip0[5]);
46371 				vo5   = IT_VO(it5, ip0[5]);
46372 
46373 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
46374 
46375 				/* Sort weighting values and vertex offset values */
46376 				CEX(we0, vo0, we1, vo1);
46377 				CEX(we0, vo0, we2, vo2);
46378 				CEX(we0, vo0, we3, vo3);
46379 				CEX(we0, vo0, we4, vo4);
46380 				CEX(we0, vo0, we5, vo5);
46381 				CEX(we1, vo1, we2, vo2);
46382 				CEX(we1, vo1, we3, vo3);
46383 				CEX(we1, vo1, we4, vo4);
46384 				CEX(we1, vo1, we5, vo5);
46385 				CEX(we2, vo2, we3, vo3);
46386 				CEX(we2, vo2, we4, vo4);
46387 				CEX(we2, vo2, we5, vo5);
46388 				CEX(we3, vo3, we4, vo4);
46389 				CEX(we3, vo3, we5, vo5);
46390 				CEX(we4, vo4, we5, vo5);
46391 			}
46392 			{
46393 				unsigned int vof;	/* Vertex offset value */
46394 				unsigned int vwe;	/* Vertex weighting */
46395 
46396 				vof = 0;				/* First vertex offset is 0 */
46397 				vwe = 65536 - we0;		/* Baricentric weighting */
46398 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46399 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46400 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46401 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46402 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46403 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46404 				vof += vo0;			/* Move to next vertex */
46405 				vwe = we0 - we1;		/* Baricentric weighting */
46406 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46407 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46408 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46409 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46410 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46411 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46412 				vof += vo1;			/* Move to next vertex */
46413 				vwe = we1 - we2;		/* Baricentric weighting */
46414 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46415 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46416 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46417 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46418 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46419 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46420 				vof += vo2;			/* Move to next vertex */
46421 				vwe = we2 - we3;		/* Baricentric weighting */
46422 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46423 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46424 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46425 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46426 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46427 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46428 				vof += vo3;			/* Move to next vertex */
46429 				vwe = we3 - we4;		/* Baricentric weighting */
46430 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46431 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46432 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46433 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46434 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46435 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46436 				vof += vo4;			/* Move to next vertex */
46437 				vwe = we4 - we5;		/* Baricentric weighting */
46438 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46439 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46440 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46441 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46442 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46443 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46444 				vof += vo5;			/* Move to next vertex */
46445 				vwe = we5;				/* Baricentric weighting */
46446 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46447 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46448 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46449 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46450 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46451 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46452 			}
46453 		}
46454 		{
46455 			unsigned int oti;	/* Vertex offset value */
46456 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
46457 			op0[0] = OT_E(ot0, oti);	/* Write result */
46458 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
46459 			op0[1] = OT_E(ot1, oti);	/* Write result */
46460 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
46461 			op0[2] = OT_E(ot2, oti);	/* Write result */
46462 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
46463 			op0[3] = OT_E(ot3, oti);	/* Write result */
46464 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
46465 			op0[4] = OT_E(ot4, oti);	/* Write result */
46466 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
46467 			op0[5] = OT_E(ot5, oti);	/* Write result */
46468 		}
46469 	}
46470 }
46471 #undef IT_WE
46472 #undef IT_VO
46473 #undef IT_IX
46474 #undef CEX
46475 #undef IM_O
46476 #undef IM_FE
46477 #undef OT_E
46478 
46479 void
imdi_k131_gen(genspec * g)46480 imdi_k131_gen(
46481 genspec *g			/* structure to be initialised */
46482 ) {
46483 	static unsigned char data[] = {
46484 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
46485 		0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
46486 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46487 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46488 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46489 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46490 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46491 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
46492 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
46493 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
46494 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
46495 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46496 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46497 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46498 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46499 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46500 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46501 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46502 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46503 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
46504 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46505 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46506 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46507 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46508 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
46509 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
46510 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
46511 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
46512 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46513 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46514 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46515 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46516 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46517 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46518 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46519 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46520 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
46521 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
46522 		0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46523 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
46524 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
46525 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
46526 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
46527 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
46528 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
46529 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
46530 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
46531 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
46532 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46533 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
46534 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
46535 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x36, 0x5f,
46536 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
46537 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
46538 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
46539 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
46540 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
46541 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
46542 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
46543 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46544 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46545 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46546 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46547 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
46548 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x33,
46549 		0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46550 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46551 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
46552 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
46553 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
46554 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
46555 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
46556 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
46557 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
46558 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
46559 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
46560 		0x00, 0xf0, 0x04, 0x08
46561 	};	/* Structure image */
46562 
46563 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
46564 }
46565 
46566 void
imdi_k131_tab(tabspec * t)46567 imdi_k131_tab(
46568 tabspec *t			/* structure to be initialised */
46569 ) {
46570 	static unsigned char data[] = {
46571 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
46572 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
46573 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
46574 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
46575 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
46576 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
46577 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
46578 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
46579 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
46580 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46581 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
46582 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
46583 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
46584 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
46585 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
46586 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46587 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
46588 		0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
46589 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46590 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46591 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
46592 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
46593 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
46594 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
46595 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46596 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46597 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46598 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
46599 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46600 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46601 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46602 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
46603 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
46604 	};	/* Structure image */
46605 
46606 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
46607 }
46608 
46609 
46610 
46611 
46612 
46613 
46614 /* Integer Multi-Dimensional Interpolation */
46615 /* Interpolation Kernel Code */
46616 /* Generated by cgen */
46617 /* Copyright 2000 - 2002 Graeme W. Gill */
46618 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
46619 
46620 /* see the Licence.txt file for licencing details.*/
46621 
46622 
46623 /*
46624    Interpolation kernel specs:
46625 
46626    Input channels per pixel = 7
46627    Input channel 0 bits = 16
46628    Input channel 0 increment = 7
46629    Input channel 1 bits = 16
46630    Input channel 1 increment = 7
46631    Input channel 2 bits = 16
46632    Input channel 2 increment = 7
46633    Input channel 3 bits = 16
46634    Input channel 3 increment = 7
46635    Input channel 4 bits = 16
46636    Input channel 4 increment = 7
46637    Input channel 5 bits = 16
46638    Input channel 5 increment = 7
46639    Input channel 6 bits = 16
46640    Input channel 6 increment = 7
46641    Input is channel interleaved
46642    Input channels are separate words
46643    Input value extraction is done in input table lookup
46644 
46645    Output channels per pixel = 6
46646    Output channel 0 bits = 16
46647    Output channel 0 increment = 6
46648    Output channel 1 bits = 16
46649    Output channel 1 increment = 6
46650    Output channel 2 bits = 16
46651    Output channel 2 increment = 6
46652    Output channel 3 bits = 16
46653    Output channel 3 increment = 6
46654    Output channel 4 bits = 16
46655    Output channel 4 increment = 6
46656    Output channel 5 bits = 16
46657    Output channel 5 increment = 6
46658    Output is channel interleaved
46659 
46660    Output channels are separate words
46661    Weight+voffset bits       = 32
46662    Interpolation table index bits = 32
46663    Interpolation table max resolution = 23
46664  */
46665 
46666 /*
46667    Machine architecture specs:
46668 
46669    Little endian
46670    Reading and writing pixel values separately
46671    Pointer size = 32 bits
46672 
46673    Ordinal size  8 bits is known as 'unsigned char'
46674    Ordinal size 16 bits is known as 'unsigned short'
46675    Ordinal size 32 bits is known as 'unsigned int'
46676    Natural ordinal is 'unsigned int'
46677 
46678    Integer size  8 bits is known as 'signed char'
46679    Integer size 16 bits is known as 'short'
46680    Integer size 32 bits is known as 'int'
46681    Natural integer is 'int'
46682 
46683  */
46684 
46685 #ifndef  IMDI_INCLUDED
46686 #include <memory.h>
46687 #include "imdi_imp.h"
46688 #define  IMDI_INCLUDED
46689 #endif  /* IMDI_INCLUDED */
46690 
46691 #ifndef DEFINED_pointer
46692 #define DEFINED_pointer
46693 typedef unsigned char * pointer;
46694 #endif
46695 
46696 /* Input table interp. index */
46697 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
46698 
46699 /* Input table input weighting enty */
46700 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
46701 
46702 /* Input table input offset value enty */
46703 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
46704 
46705 /* Conditional exchange for sorting */
46706 #define CEX(A, AA, B, BB) if (A < B) { \
46707             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
46708 
46709 /* Interpolation multi-dim. table access */
46710 #define IM_O(off) ((off) * 12)
46711 
46712 /* Interpolation table - get vertex values */
46713 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 4 + (c) * 2)))
46714 
46715 /* Output table indexes */
46716 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
46717 
46718 void
imdi_k132(imdi * s,void ** outp,void ** inp,unsigned int npix)46719 imdi_k132(
46720 imdi *s,			/* imdi context */
46721 void **outp,		/* pointer to output pointers */
46722 void **inp,		/* pointer to input pointers */
46723 unsigned int npix	/* Number of pixels to process */
46724 ) {
46725 	imdi_imp *p = (imdi_imp *)(s->impl);
46726 	unsigned short *ip0 = (unsigned short *)inp[0];
46727 	unsigned short *op0 = (unsigned short *)outp[0];
46728 	unsigned short *ep = ip0 + npix * 7 ;
46729 	pointer it0 = (pointer)p->in_tables[0];
46730 	pointer it1 = (pointer)p->in_tables[1];
46731 	pointer it2 = (pointer)p->in_tables[2];
46732 	pointer it3 = (pointer)p->in_tables[3];
46733 	pointer it4 = (pointer)p->in_tables[4];
46734 	pointer it5 = (pointer)p->in_tables[5];
46735 	pointer it6 = (pointer)p->in_tables[6];
46736 	pointer ot0 = (pointer)p->out_tables[0];
46737 	pointer ot1 = (pointer)p->out_tables[1];
46738 	pointer ot2 = (pointer)p->out_tables[2];
46739 	pointer ot3 = (pointer)p->out_tables[3];
46740 	pointer ot4 = (pointer)p->out_tables[4];
46741 	pointer ot5 = (pointer)p->out_tables[5];
46742 	pointer im_base = (pointer)p->im_table;
46743 
46744 	for(;ip0 < ep; ip0 += 7, op0 += 6) {
46745 		unsigned int ova0;	/* Output value accumulator */
46746 		unsigned int ova1;	/* Output value accumulator */
46747 		unsigned int ova2;	/* Output value accumulator */
46748 		unsigned int ova3;	/* Output value accumulator */
46749 		unsigned int ova4;	/* Output value accumulator */
46750 		unsigned int ova5;	/* Output value accumulator */
46751 		{
46752 			pointer imp;
46753 			unsigned int we0;	/* Weighting value variable */
46754 			unsigned int vo0;	/* Vertex offset variable */
46755 			unsigned int we1;	/* Weighting value variable */
46756 			unsigned int vo1;	/* Vertex offset variable */
46757 			unsigned int we2;	/* Weighting value variable */
46758 			unsigned int vo2;	/* Vertex offset variable */
46759 			unsigned int we3;	/* Weighting value variable */
46760 			unsigned int vo3;	/* Vertex offset variable */
46761 			unsigned int we4;	/* Weighting value variable */
46762 			unsigned int vo4;	/* Vertex offset variable */
46763 			unsigned int we5;	/* Weighting value variable */
46764 			unsigned int vo5;	/* Vertex offset variable */
46765 			unsigned int we6;	/* Weighting value variable */
46766 			unsigned int vo6;	/* Vertex offset variable */
46767 			{
46768 				unsigned int ti_i;	/* Interpolation index variable */
46769 
46770 				ti_i  = IT_IX(it0, ip0[0]);
46771 				we0   = IT_WE(it0, ip0[0]);
46772 				vo0   = IT_VO(it0, ip0[0]);
46773 				ti_i += IT_IX(it1, ip0[1]);
46774 				we1   = IT_WE(it1, ip0[1]);
46775 				vo1   = IT_VO(it1, ip0[1]);
46776 				ti_i += IT_IX(it2, ip0[2]);
46777 				we2   = IT_WE(it2, ip0[2]);
46778 				vo2   = IT_VO(it2, ip0[2]);
46779 				ti_i += IT_IX(it3, ip0[3]);
46780 				we3   = IT_WE(it3, ip0[3]);
46781 				vo3   = IT_VO(it3, ip0[3]);
46782 				ti_i += IT_IX(it4, ip0[4]);
46783 				we4   = IT_WE(it4, ip0[4]);
46784 				vo4   = IT_VO(it4, ip0[4]);
46785 				ti_i += IT_IX(it5, ip0[5]);
46786 				we5   = IT_WE(it5, ip0[5]);
46787 				vo5   = IT_VO(it5, ip0[5]);
46788 				ti_i += IT_IX(it6, ip0[6]);
46789 				we6   = IT_WE(it6, ip0[6]);
46790 				vo6   = IT_VO(it6, ip0[6]);
46791 
46792 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
46793 
46794 				/* Sort weighting values and vertex offset values */
46795 				CEX(we0, vo0, we1, vo1);
46796 				CEX(we0, vo0, we2, vo2);
46797 				CEX(we0, vo0, we3, vo3);
46798 				CEX(we0, vo0, we4, vo4);
46799 				CEX(we0, vo0, we5, vo5);
46800 				CEX(we0, vo0, we6, vo6);
46801 				CEX(we1, vo1, we2, vo2);
46802 				CEX(we1, vo1, we3, vo3);
46803 				CEX(we1, vo1, we4, vo4);
46804 				CEX(we1, vo1, we5, vo5);
46805 				CEX(we1, vo1, we6, vo6);
46806 				CEX(we2, vo2, we3, vo3);
46807 				CEX(we2, vo2, we4, vo4);
46808 				CEX(we2, vo2, we5, vo5);
46809 				CEX(we2, vo2, we6, vo6);
46810 				CEX(we3, vo3, we4, vo4);
46811 				CEX(we3, vo3, we5, vo5);
46812 				CEX(we3, vo3, we6, vo6);
46813 				CEX(we4, vo4, we5, vo5);
46814 				CEX(we4, vo4, we6, vo6);
46815 				CEX(we5, vo5, we6, vo6);
46816 			}
46817 			{
46818 				unsigned int vof;	/* Vertex offset value */
46819 				unsigned int vwe;	/* Vertex weighting */
46820 
46821 				vof = 0;				/* First vertex offset is 0 */
46822 				vwe = 65536 - we0;		/* Baricentric weighting */
46823 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46824 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46825 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46826 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46827 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46828 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46829 				vof += vo0;			/* Move to next vertex */
46830 				vwe = we0 - we1;		/* Baricentric weighting */
46831 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46832 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46833 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46834 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46835 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46836 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46837 				vof += vo1;			/* Move to next vertex */
46838 				vwe = we1 - we2;		/* Baricentric weighting */
46839 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46840 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46841 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46842 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46843 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46844 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46845 				vof += vo2;			/* Move to next vertex */
46846 				vwe = we2 - we3;		/* Baricentric weighting */
46847 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46848 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46849 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46850 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46851 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46852 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46853 				vof += vo3;			/* Move to next vertex */
46854 				vwe = we3 - we4;		/* Baricentric weighting */
46855 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46856 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46857 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46858 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46859 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46860 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46861 				vof += vo4;			/* Move to next vertex */
46862 				vwe = we4 - we5;		/* Baricentric weighting */
46863 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46864 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46865 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46866 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46867 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46868 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46869 				vof += vo5;			/* Move to next vertex */
46870 				vwe = we5 - we6;		/* Baricentric weighting */
46871 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46872 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46873 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46874 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46875 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46876 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46877 				vof += vo6;			/* Move to next vertex */
46878 				vwe = we6;				/* Baricentric weighting */
46879 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
46880 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
46881 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
46882 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
46883 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
46884 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
46885 			}
46886 		}
46887 		{
46888 			unsigned int oti;	/* Vertex offset value */
46889 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
46890 			op0[0] = OT_E(ot0, oti);	/* Write result */
46891 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
46892 			op0[1] = OT_E(ot1, oti);	/* Write result */
46893 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
46894 			op0[2] = OT_E(ot2, oti);	/* Write result */
46895 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
46896 			op0[3] = OT_E(ot3, oti);	/* Write result */
46897 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
46898 			op0[4] = OT_E(ot4, oti);	/* Write result */
46899 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
46900 			op0[5] = OT_E(ot5, oti);	/* Write result */
46901 		}
46902 	}
46903 }
46904 #undef IT_WE
46905 #undef IT_VO
46906 #undef IT_IX
46907 #undef CEX
46908 #undef IM_O
46909 #undef IM_FE
46910 #undef OT_E
46911 
46912 void
imdi_k132_gen(genspec * g)46913 imdi_k132_gen(
46914 genspec *g			/* structure to be initialised */
46915 ) {
46916 	static unsigned char data[] = {
46917 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
46918 		0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
46919 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46920 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46921 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46922 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46923 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46924 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
46925 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
46926 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
46927 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
46928 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46929 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46930 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46931 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46932 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46933 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46934 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46935 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46936 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
46937 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46938 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46939 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46940 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46941 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
46942 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
46943 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
46944 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
46945 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46946 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46947 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46948 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46949 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46950 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46951 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46952 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
46953 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
46954 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
46955 		0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46956 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
46957 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
46958 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
46959 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
46960 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
46961 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
46962 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
46963 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
46964 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
46965 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46966 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
46967 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
46968 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x36, 0x5f,
46969 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
46970 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
46971 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
46972 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
46973 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
46974 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
46975 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
46976 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46977 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46978 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46979 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46980 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
46981 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x33,
46982 		0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46983 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46984 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
46985 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
46986 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
46987 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
46988 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
46989 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
46990 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
46991 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
46992 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
46993 		0x00, 0xf0, 0x04, 0x08
46994 	};	/* Structure image */
46995 
46996 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
46997 }
46998 
46999 void
imdi_k132_tab(tabspec * t)47000 imdi_k132_tab(
47001 tabspec *t			/* structure to be initialised */
47002 ) {
47003 	static unsigned char data[] = {
47004 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
47005 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
47006 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
47007 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
47008 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
47009 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
47010 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
47011 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
47012 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
47013 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47014 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
47015 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
47016 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
47017 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
47018 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
47019 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47020 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
47021 		0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
47022 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47023 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47024 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
47025 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
47026 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
47027 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
47028 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47029 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47030 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47031 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
47032 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47033 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47034 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47035 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
47036 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
47037 	};	/* Structure image */
47038 
47039 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
47040 }
47041 
47042 
47043 
47044 
47045 
47046 
47047 /* Integer Multi-Dimensional Interpolation */
47048 /* Interpolation Kernel Code */
47049 /* Generated by cgen */
47050 /* Copyright 2000 - 2002 Graeme W. Gill */
47051 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
47052 
47053 /* see the Licence.txt file for licencing details.*/
47054 
47055 
47056 /*
47057    Interpolation kernel specs:
47058 
47059    Input channels per pixel = 8
47060    Input channel 0 bits = 16
47061    Input channel 0 increment = 8
47062    Input channel 1 bits = 16
47063    Input channel 1 increment = 8
47064    Input channel 2 bits = 16
47065    Input channel 2 increment = 8
47066    Input channel 3 bits = 16
47067    Input channel 3 increment = 8
47068    Input channel 4 bits = 16
47069    Input channel 4 increment = 8
47070    Input channel 5 bits = 16
47071    Input channel 5 increment = 8
47072    Input channel 6 bits = 16
47073    Input channel 6 increment = 8
47074    Input channel 7 bits = 16
47075    Input channel 7 increment = 8
47076    Input is channel interleaved
47077    Input channels are separate words
47078    Input value extraction is done in input table lookup
47079 
47080    Output channels per pixel = 6
47081    Output channel 0 bits = 16
47082    Output channel 0 increment = 6
47083    Output channel 1 bits = 16
47084    Output channel 1 increment = 6
47085    Output channel 2 bits = 16
47086    Output channel 2 increment = 6
47087    Output channel 3 bits = 16
47088    Output channel 3 increment = 6
47089    Output channel 4 bits = 16
47090    Output channel 4 increment = 6
47091    Output channel 5 bits = 16
47092    Output channel 5 increment = 6
47093    Output is channel interleaved
47094 
47095    Output channels are separate words
47096    Weight+voffset bits       = 32
47097    Interpolation table index bits = 32
47098    Interpolation table max resolution = 16
47099  */
47100 
47101 /*
47102    Machine architecture specs:
47103 
47104    Little endian
47105    Reading and writing pixel values separately
47106    Pointer size = 32 bits
47107 
47108    Ordinal size  8 bits is known as 'unsigned char'
47109    Ordinal size 16 bits is known as 'unsigned short'
47110    Ordinal size 32 bits is known as 'unsigned int'
47111    Natural ordinal is 'unsigned int'
47112 
47113    Integer size  8 bits is known as 'signed char'
47114    Integer size 16 bits is known as 'short'
47115    Integer size 32 bits is known as 'int'
47116    Natural integer is 'int'
47117 
47118  */
47119 
47120 #ifndef  IMDI_INCLUDED
47121 #include <memory.h>
47122 #include "imdi_imp.h"
47123 #define  IMDI_INCLUDED
47124 #endif  /* IMDI_INCLUDED */
47125 
47126 #ifndef DEFINED_pointer
47127 #define DEFINED_pointer
47128 typedef unsigned char * pointer;
47129 #endif
47130 
47131 /* Input table interp. index */
47132 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
47133 
47134 /* Input table input weighting enty */
47135 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
47136 
47137 /* Input table input offset value enty */
47138 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
47139 
47140 /* Conditional exchange for sorting */
47141 #define CEX(A, AA, B, BB) if (A < B) { \
47142             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
47143 
47144 /* Interpolation multi-dim. table access */
47145 #define IM_O(off) ((off) * 12)
47146 
47147 /* Interpolation table - get vertex values */
47148 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 4 + (c) * 2)))
47149 
47150 /* Output table indexes */
47151 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
47152 
47153 void
imdi_k133(imdi * s,void ** outp,void ** inp,unsigned int npix)47154 imdi_k133(
47155 imdi *s,			/* imdi context */
47156 void **outp,		/* pointer to output pointers */
47157 void **inp,		/* pointer to input pointers */
47158 unsigned int npix	/* Number of pixels to process */
47159 ) {
47160 	imdi_imp *p = (imdi_imp *)(s->impl);
47161 	unsigned short *ip0 = (unsigned short *)inp[0];
47162 	unsigned short *op0 = (unsigned short *)outp[0];
47163 	unsigned short *ep = ip0 + npix * 8 ;
47164 	pointer it0 = (pointer)p->in_tables[0];
47165 	pointer it1 = (pointer)p->in_tables[1];
47166 	pointer it2 = (pointer)p->in_tables[2];
47167 	pointer it3 = (pointer)p->in_tables[3];
47168 	pointer it4 = (pointer)p->in_tables[4];
47169 	pointer it5 = (pointer)p->in_tables[5];
47170 	pointer it6 = (pointer)p->in_tables[6];
47171 	pointer it7 = (pointer)p->in_tables[7];
47172 	pointer ot0 = (pointer)p->out_tables[0];
47173 	pointer ot1 = (pointer)p->out_tables[1];
47174 	pointer ot2 = (pointer)p->out_tables[2];
47175 	pointer ot3 = (pointer)p->out_tables[3];
47176 	pointer ot4 = (pointer)p->out_tables[4];
47177 	pointer ot5 = (pointer)p->out_tables[5];
47178 	pointer im_base = (pointer)p->im_table;
47179 
47180 	for(;ip0 < ep; ip0 += 8, op0 += 6) {
47181 		unsigned int ova0;	/* Output value accumulator */
47182 		unsigned int ova1;	/* Output value accumulator */
47183 		unsigned int ova2;	/* Output value accumulator */
47184 		unsigned int ova3;	/* Output value accumulator */
47185 		unsigned int ova4;	/* Output value accumulator */
47186 		unsigned int ova5;	/* Output value accumulator */
47187 		{
47188 			pointer imp;
47189 			unsigned int we0;	/* Weighting value variable */
47190 			unsigned int vo0;	/* Vertex offset variable */
47191 			unsigned int we1;	/* Weighting value variable */
47192 			unsigned int vo1;	/* Vertex offset variable */
47193 			unsigned int we2;	/* Weighting value variable */
47194 			unsigned int vo2;	/* Vertex offset variable */
47195 			unsigned int we3;	/* Weighting value variable */
47196 			unsigned int vo3;	/* Vertex offset variable */
47197 			unsigned int we4;	/* Weighting value variable */
47198 			unsigned int vo4;	/* Vertex offset variable */
47199 			unsigned int we5;	/* Weighting value variable */
47200 			unsigned int vo5;	/* Vertex offset variable */
47201 			unsigned int we6;	/* Weighting value variable */
47202 			unsigned int vo6;	/* Vertex offset variable */
47203 			unsigned int we7;	/* Weighting value variable */
47204 			unsigned int vo7;	/* Vertex offset variable */
47205 			{
47206 				unsigned int ti_i;	/* Interpolation index variable */
47207 
47208 				ti_i  = IT_IX(it0, ip0[0]);
47209 				we0   = IT_WE(it0, ip0[0]);
47210 				vo0   = IT_VO(it0, ip0[0]);
47211 				ti_i += IT_IX(it1, ip0[1]);
47212 				we1   = IT_WE(it1, ip0[1]);
47213 				vo1   = IT_VO(it1, ip0[1]);
47214 				ti_i += IT_IX(it2, ip0[2]);
47215 				we2   = IT_WE(it2, ip0[2]);
47216 				vo2   = IT_VO(it2, ip0[2]);
47217 				ti_i += IT_IX(it3, ip0[3]);
47218 				we3   = IT_WE(it3, ip0[3]);
47219 				vo3   = IT_VO(it3, ip0[3]);
47220 				ti_i += IT_IX(it4, ip0[4]);
47221 				we4   = IT_WE(it4, ip0[4]);
47222 				vo4   = IT_VO(it4, ip0[4]);
47223 				ti_i += IT_IX(it5, ip0[5]);
47224 				we5   = IT_WE(it5, ip0[5]);
47225 				vo5   = IT_VO(it5, ip0[5]);
47226 				ti_i += IT_IX(it6, ip0[6]);
47227 				we6   = IT_WE(it6, ip0[6]);
47228 				vo6   = IT_VO(it6, ip0[6]);
47229 				ti_i += IT_IX(it7, ip0[7]);
47230 				we7   = IT_WE(it7, ip0[7]);
47231 				vo7   = IT_VO(it7, ip0[7]);
47232 
47233 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
47234 
47235 				/* Sort weighting values and vertex offset values */
47236 				CEX(we0, vo0, we1, vo1);
47237 				CEX(we0, vo0, we2, vo2);
47238 				CEX(we0, vo0, we3, vo3);
47239 				CEX(we0, vo0, we4, vo4);
47240 				CEX(we0, vo0, we5, vo5);
47241 				CEX(we0, vo0, we6, vo6);
47242 				CEX(we0, vo0, we7, vo7);
47243 				CEX(we1, vo1, we2, vo2);
47244 				CEX(we1, vo1, we3, vo3);
47245 				CEX(we1, vo1, we4, vo4);
47246 				CEX(we1, vo1, we5, vo5);
47247 				CEX(we1, vo1, we6, vo6);
47248 				CEX(we1, vo1, we7, vo7);
47249 				CEX(we2, vo2, we3, vo3);
47250 				CEX(we2, vo2, we4, vo4);
47251 				CEX(we2, vo2, we5, vo5);
47252 				CEX(we2, vo2, we6, vo6);
47253 				CEX(we2, vo2, we7, vo7);
47254 				CEX(we3, vo3, we4, vo4);
47255 				CEX(we3, vo3, we5, vo5);
47256 				CEX(we3, vo3, we6, vo6);
47257 				CEX(we3, vo3, we7, vo7);
47258 				CEX(we4, vo4, we5, vo5);
47259 				CEX(we4, vo4, we6, vo6);
47260 				CEX(we4, vo4, we7, vo7);
47261 				CEX(we5, vo5, we6, vo6);
47262 				CEX(we5, vo5, we7, vo7);
47263 				CEX(we6, vo6, we7, vo7);
47264 			}
47265 			{
47266 				unsigned int vof;	/* Vertex offset value */
47267 				unsigned int vwe;	/* Vertex weighting */
47268 
47269 				vof = 0;				/* First vertex offset is 0 */
47270 				vwe = 65536 - we0;		/* Baricentric weighting */
47271 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
47272 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
47273 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
47274 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
47275 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
47276 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
47277 				vof += vo0;			/* Move to next vertex */
47278 				vwe = we0 - we1;		/* Baricentric weighting */
47279 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
47280 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
47281 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
47282 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
47283 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
47284 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
47285 				vof += vo1;			/* Move to next vertex */
47286 				vwe = we1 - we2;		/* Baricentric weighting */
47287 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
47288 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
47289 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
47290 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
47291 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
47292 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
47293 				vof += vo2;			/* Move to next vertex */
47294 				vwe = we2 - we3;		/* Baricentric weighting */
47295 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
47296 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
47297 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
47298 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
47299 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
47300 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
47301 				vof += vo3;			/* Move to next vertex */
47302 				vwe = we3 - we4;		/* Baricentric weighting */
47303 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
47304 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
47305 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
47306 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
47307 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
47308 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
47309 				vof += vo4;			/* Move to next vertex */
47310 				vwe = we4 - we5;		/* Baricentric weighting */
47311 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
47312 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
47313 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
47314 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
47315 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
47316 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
47317 				vof += vo5;			/* Move to next vertex */
47318 				vwe = we5 - we6;		/* Baricentric weighting */
47319 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
47320 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
47321 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
47322 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
47323 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
47324 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
47325 				vof += vo6;			/* Move to next vertex */
47326 				vwe = we6 - we7;		/* Baricentric weighting */
47327 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
47328 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
47329 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
47330 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
47331 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
47332 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
47333 				vof += vo7;			/* Move to next vertex */
47334 				vwe = we7;				/* Baricentric weighting */
47335 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
47336 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
47337 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
47338 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
47339 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
47340 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
47341 			}
47342 		}
47343 		{
47344 			unsigned int oti;	/* Vertex offset value */
47345 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
47346 			op0[0] = OT_E(ot0, oti);	/* Write result */
47347 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
47348 			op0[1] = OT_E(ot1, oti);	/* Write result */
47349 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
47350 			op0[2] = OT_E(ot2, oti);	/* Write result */
47351 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
47352 			op0[3] = OT_E(ot3, oti);	/* Write result */
47353 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
47354 			op0[4] = OT_E(ot4, oti);	/* Write result */
47355 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
47356 			op0[5] = OT_E(ot5, oti);	/* Write result */
47357 		}
47358 	}
47359 }
47360 #undef IT_WE
47361 #undef IT_VO
47362 #undef IT_IX
47363 #undef CEX
47364 #undef IM_O
47365 #undef IM_FE
47366 #undef OT_E
47367 
47368 void
imdi_k133_gen(genspec * g)47369 imdi_k133_gen(
47370 genspec *g			/* structure to be initialised */
47371 ) {
47372 	static unsigned char data[] = {
47373 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
47374 		0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
47375 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47376 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47377 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47378 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47379 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47380 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
47381 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
47382 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
47383 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
47384 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47385 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47386 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47387 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47388 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47389 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47390 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47391 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47392 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
47393 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47394 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47395 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47396 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47397 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
47398 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
47399 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
47400 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
47401 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47402 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47403 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47404 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47405 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47406 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47407 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47408 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47409 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
47410 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
47411 		0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47412 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
47413 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
47414 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
47415 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
47416 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
47417 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
47418 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
47419 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
47420 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
47421 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47422 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
47423 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
47424 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x36, 0x5f,
47425 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
47426 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
47427 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
47428 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
47429 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
47430 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
47431 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
47432 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47433 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47434 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47435 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47436 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
47437 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x33,
47438 		0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47439 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47440 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
47441 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
47442 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
47443 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
47444 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
47445 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
47446 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
47447 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
47448 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
47449 		0x00, 0xf0, 0x04, 0x08
47450 	};	/* Structure image */
47451 
47452 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
47453 }
47454 
47455 void
imdi_k133_tab(tabspec * t)47456 imdi_k133_tab(
47457 tabspec *t			/* structure to be initialised */
47458 ) {
47459 	static unsigned char data[] = {
47460 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
47461 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
47462 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
47463 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
47464 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
47465 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
47466 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
47467 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
47468 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
47469 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47470 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
47471 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
47472 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
47473 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
47474 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
47475 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47476 		0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
47477 		0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
47478 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47479 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47480 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
47481 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
47482 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
47483 		0xff, 0xff, 0xff, 0xff, 0xdc, 0x60, 0xef, 0xb7,
47484 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47485 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47486 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47487 		0x00, 0x00, 0x00, 0x00, 0x14, 0xda, 0x83, 0xbf,
47488 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47489 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47490 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47491 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
47492 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
47493 	};	/* Structure image */
47494 
47495 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
47496 }
47497 
47498 
47499 
47500 
47501 
47502 
47503 /* Integer Multi-Dimensional Interpolation */
47504 /* Interpolation Kernel Code */
47505 /* Generated by cgen */
47506 /* Copyright 2000 - 2002 Graeme W. Gill */
47507 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
47508 
47509 /* see the Licence.txt file for licencing details.*/
47510 
47511 
47512 /*
47513    Interpolation kernel specs:
47514 
47515    Input channels per pixel = 1
47516    Input channel 0 bits = 16
47517    Input channel 0 increment = 1
47518    Input is channel interleaved
47519    Input channels are separate words
47520    Input value extraction is done in input table lookup
47521 
47522    Output channels per pixel = 7
47523    Output channel 0 bits = 16
47524    Output channel 0 increment = 7
47525    Output channel 1 bits = 16
47526    Output channel 1 increment = 7
47527    Output channel 2 bits = 16
47528    Output channel 2 increment = 7
47529    Output channel 3 bits = 16
47530    Output channel 3 increment = 7
47531    Output channel 4 bits = 16
47532    Output channel 4 increment = 7
47533    Output channel 5 bits = 16
47534    Output channel 5 increment = 7
47535    Output channel 6 bits = 16
47536    Output channel 6 increment = 7
47537    Output is channel interleaved
47538 
47539    Output channels are separate words
47540    Weight+voffset bits       = 32
47541    Interpolation table index bits = 10
47542    Interpolation table max resolution = 1024
47543  */
47544 
47545 /*
47546    Machine architecture specs:
47547 
47548    Little endian
47549    Reading and writing pixel values separately
47550    Pointer size = 32 bits
47551 
47552    Ordinal size  8 bits is known as 'unsigned char'
47553    Ordinal size 16 bits is known as 'unsigned short'
47554    Ordinal size 32 bits is known as 'unsigned int'
47555    Natural ordinal is 'unsigned int'
47556 
47557    Integer size  8 bits is known as 'signed char'
47558    Integer size 16 bits is known as 'short'
47559    Integer size 32 bits is known as 'int'
47560    Natural integer is 'int'
47561 
47562  */
47563 
47564 #ifndef  IMDI_INCLUDED
47565 #include <memory.h>
47566 #include "imdi_imp.h"
47567 #define  IMDI_INCLUDED
47568 #endif  /* IMDI_INCLUDED */
47569 
47570 #ifndef DEFINED_pointer
47571 #define DEFINED_pointer
47572 typedef unsigned char * pointer;
47573 #endif
47574 
47575 /* Input table interp index, weighting and vertex offset */
47576 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
47577 
47578 /* Conditional exchange for sorting */
47579 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
47580 
47581 /* Interpolation multi-dim. table access */
47582 #define IM_O(off) ((off) * 14)
47583 
47584 /* Interpolation table - get vertex values */
47585 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
47586 
47587 /* Output table indexes */
47588 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
47589 
47590 void
imdi_k134(imdi * s,void ** outp,void ** inp,unsigned int npix)47591 imdi_k134(
47592 imdi *s,			/* imdi context */
47593 void **outp,		/* pointer to output pointers */
47594 void **inp,		/* pointer to input pointers */
47595 unsigned int npix	/* Number of pixels to process */
47596 ) {
47597 	imdi_imp *p = (imdi_imp *)(s->impl);
47598 	unsigned short *ip0 = (unsigned short *)inp[0];
47599 	unsigned short *op0 = (unsigned short *)outp[0];
47600 	unsigned short *ep = ip0 + npix * 1 ;
47601 	pointer it0 = (pointer)p->in_tables[0];
47602 	pointer ot0 = (pointer)p->out_tables[0];
47603 	pointer ot1 = (pointer)p->out_tables[1];
47604 	pointer ot2 = (pointer)p->out_tables[2];
47605 	pointer ot3 = (pointer)p->out_tables[3];
47606 	pointer ot4 = (pointer)p->out_tables[4];
47607 	pointer ot5 = (pointer)p->out_tables[5];
47608 	pointer ot6 = (pointer)p->out_tables[6];
47609 	pointer im_base = (pointer)p->im_table;
47610 
47611 	for(;ip0 < ep; ip0 += 1, op0 += 7) {
47612 		unsigned int ova0;	/* Output value accumulator */
47613 		unsigned int ova1;	/* Output value accumulator */
47614 		unsigned int ova2;	/* Output value accumulator */
47615 		unsigned int ova3;	/* Output value accumulator */
47616 		unsigned int ova4;	/* Output value accumulator */
47617 		unsigned int ova5;	/* Output value accumulator */
47618 		unsigned int ova6;	/* Output value accumulator */
47619 		{
47620 			pointer imp;
47621 			unsigned int wo0;	/* Weighting value and vertex offset variable */
47622 			{
47623 				unsigned int ti;		/* Input table entry variable */
47624 				unsigned int ti_i;	/* Interpolation index variable */
47625 
47626 				ti = IT_IT(it0, ip0[0]);
47627 				wo0   = (ti & 0x3fffff);	/* Extract weighting/vertex offset value */
47628 				ti_i  = (ti >> 22);	/* Extract interpolation table value */
47629 
47630 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
47631 
47632 				/* Sort weighting values and vertex offset values */
47633 			}
47634 			{
47635 				unsigned int nvof;	/* Next vertex offset value */
47636 				unsigned int vof;	/* Vertex offset value */
47637 				unsigned int vwe;	/* Vertex weighting */
47638 
47639 				vof = 0;				/* First vertex offset is 0 */
47640 				nvof = (wo0 & 0x1f);	/* Extract offset value */
47641 				wo0 = (wo0 >> 5);		/* Extract weighting value */
47642 				vwe = 65536 - wo0;		/* Baricentric weighting */
47643 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
47644 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
47645 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
47646 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
47647 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
47648 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
47649 				ova6  = IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
47650 				vof += nvof;			/* Move to next vertex */
47651 				vwe = wo0;				/* Baricentric weighting */
47652 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
47653 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
47654 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
47655 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
47656 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
47657 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
47658 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
47659 			}
47660 		}
47661 		{
47662 			unsigned int oti;	/* Vertex offset value */
47663 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
47664 			op0[0] = OT_E(ot0, oti);	/* Write result */
47665 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
47666 			op0[1] = OT_E(ot1, oti);	/* Write result */
47667 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
47668 			op0[2] = OT_E(ot2, oti);	/* Write result */
47669 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
47670 			op0[3] = OT_E(ot3, oti);	/* Write result */
47671 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
47672 			op0[4] = OT_E(ot4, oti);	/* Write result */
47673 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
47674 			op0[5] = OT_E(ot5, oti);	/* Write result */
47675 			oti = ((ova6 >> 16) & 0xffff);	/* Extract integer part of result */
47676 			op0[6] = OT_E(ot6, oti);	/* Write result */
47677 		}
47678 	}
47679 }
47680 #undef IT_IT
47681 #undef CEX
47682 #undef IM_O
47683 #undef IM_FE
47684 #undef OT_E
47685 
47686 void
imdi_k134_gen(genspec * g)47687 imdi_k134_gen(
47688 genspec *g			/* structure to be initialised */
47689 ) {
47690 	static unsigned char data[] = {
47691 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
47692 		0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
47693 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47694 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47695 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47696 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47697 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47698 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
47699 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
47700 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
47701 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
47702 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47703 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47704 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47705 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47706 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47707 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47708 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47709 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47710 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
47711 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47712 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47713 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47714 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47715 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
47716 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
47717 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
47718 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
47719 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47720 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47721 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47722 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47723 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47724 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47725 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47726 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47727 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
47728 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
47729 		0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47730 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
47731 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
47732 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
47733 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
47734 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
47735 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
47736 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
47737 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
47738 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
47739 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47740 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
47741 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
47742 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x37, 0x5f,
47743 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
47744 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
47745 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
47746 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
47747 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
47748 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
47749 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
47750 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47751 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47752 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47753 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47754 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
47755 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x33,
47756 		0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47757 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47758 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
47759 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
47760 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
47761 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
47762 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
47763 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
47764 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
47765 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
47766 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
47767 		0x00, 0xf0, 0x04, 0x08
47768 	};	/* Structure image */
47769 
47770 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
47771 }
47772 
47773 void
imdi_k134_tab(tabspec * t)47774 imdi_k134_tab(
47775 tabspec *t			/* structure to be initialised */
47776 ) {
47777 	static unsigned char data[] = {
47778 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47779 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
47780 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
47781 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
47782 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
47783 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
47784 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
47785 		0x0a, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
47786 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
47787 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47788 		0x14, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00,
47789 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
47790 		0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
47791 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
47792 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
47793 		0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47794 		0x0e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
47795 		0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
47796 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47797 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47798 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
47799 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
47800 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
47801 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
47802 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47803 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47804 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47805 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47806 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47807 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47808 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47809 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
47810 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
47811 	};	/* Structure image */
47812 
47813 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
47814 }
47815 
47816 
47817 
47818 
47819 
47820 
47821 /* Integer Multi-Dimensional Interpolation */
47822 /* Interpolation Kernel Code */
47823 /* Generated by cgen */
47824 /* Copyright 2000 - 2002 Graeme W. Gill */
47825 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
47826 
47827 /* see the Licence.txt file for licencing details.*/
47828 
47829 
47830 /*
47831    Interpolation kernel specs:
47832 
47833    Input channels per pixel = 3
47834    Input channel 0 bits = 16
47835    Input channel 0 increment = 3
47836    Input channel 1 bits = 16
47837    Input channel 1 increment = 3
47838    Input channel 2 bits = 16
47839    Input channel 2 increment = 3
47840    Input is channel interleaved
47841    Input channels are separate words
47842    Input value extraction is done in input table lookup
47843 
47844    Output channels per pixel = 7
47845    Output channel 0 bits = 16
47846    Output channel 0 increment = 7
47847    Output channel 1 bits = 16
47848    Output channel 1 increment = 7
47849    Output channel 2 bits = 16
47850    Output channel 2 increment = 7
47851    Output channel 3 bits = 16
47852    Output channel 3 increment = 7
47853    Output channel 4 bits = 16
47854    Output channel 4 increment = 7
47855    Output channel 5 bits = 16
47856    Output channel 5 increment = 7
47857    Output channel 6 bits = 16
47858    Output channel 6 increment = 7
47859    Output is channel interleaved
47860 
47861    Output channels are separate words
47862    Weight+voffset bits       = 32
47863    Interpolation table index bits = 16
47864    Interpolation table max resolution = 40
47865  */
47866 
47867 /*
47868    Machine architecture specs:
47869 
47870    Little endian
47871    Reading and writing pixel values separately
47872    Pointer size = 32 bits
47873 
47874    Ordinal size  8 bits is known as 'unsigned char'
47875    Ordinal size 16 bits is known as 'unsigned short'
47876    Ordinal size 32 bits is known as 'unsigned int'
47877    Natural ordinal is 'unsigned int'
47878 
47879    Integer size  8 bits is known as 'signed char'
47880    Integer size 16 bits is known as 'short'
47881    Integer size 32 bits is known as 'int'
47882    Natural integer is 'int'
47883 
47884  */
47885 
47886 #ifndef  IMDI_INCLUDED
47887 #include <memory.h>
47888 #include "imdi_imp.h"
47889 #define  IMDI_INCLUDED
47890 #endif  /* IMDI_INCLUDED */
47891 
47892 #ifndef DEFINED_pointer
47893 #define DEFINED_pointer
47894 typedef unsigned char * pointer;
47895 #endif
47896 
47897 /* Input table interp. index */
47898 #define IT_IX(p, off) *((unsigned short *)((p) + 0 + (off) * 6))
47899 
47900 /* Input table input weighting/offset value enty */
47901 #define IT_WO(p, off) *((unsigned int *)((p) + 2 + (off) * 6))
47902 
47903 /* Conditional exchange for sorting */
47904 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
47905 
47906 /* Interpolation multi-dim. table access */
47907 #define IM_O(off) ((off) * 14)
47908 
47909 /* Interpolation table - get vertex values */
47910 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
47911 
47912 /* Output table indexes */
47913 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
47914 
47915 void
imdi_k135(imdi * s,void ** outp,void ** inp,unsigned int npix)47916 imdi_k135(
47917 imdi *s,			/* imdi context */
47918 void **outp,		/* pointer to output pointers */
47919 void **inp,		/* pointer to input pointers */
47920 unsigned int npix	/* Number of pixels to process */
47921 ) {
47922 	imdi_imp *p = (imdi_imp *)(s->impl);
47923 	unsigned short *ip0 = (unsigned short *)inp[0];
47924 	unsigned short *op0 = (unsigned short *)outp[0];
47925 	unsigned short *ep = ip0 + npix * 3 ;
47926 	pointer it0 = (pointer)p->in_tables[0];
47927 	pointer it1 = (pointer)p->in_tables[1];
47928 	pointer it2 = (pointer)p->in_tables[2];
47929 	pointer ot0 = (pointer)p->out_tables[0];
47930 	pointer ot1 = (pointer)p->out_tables[1];
47931 	pointer ot2 = (pointer)p->out_tables[2];
47932 	pointer ot3 = (pointer)p->out_tables[3];
47933 	pointer ot4 = (pointer)p->out_tables[4];
47934 	pointer ot5 = (pointer)p->out_tables[5];
47935 	pointer ot6 = (pointer)p->out_tables[6];
47936 	pointer im_base = (pointer)p->im_table;
47937 
47938 	for(;ip0 < ep; ip0 += 3, op0 += 7) {
47939 		unsigned int ova0;	/* Output value accumulator */
47940 		unsigned int ova1;	/* Output value accumulator */
47941 		unsigned int ova2;	/* Output value accumulator */
47942 		unsigned int ova3;	/* Output value accumulator */
47943 		unsigned int ova4;	/* Output value accumulator */
47944 		unsigned int ova5;	/* Output value accumulator */
47945 		unsigned int ova6;	/* Output value accumulator */
47946 		{
47947 			pointer imp;
47948 			unsigned int wo0;	/* Weighting value and vertex offset variable */
47949 			unsigned int wo1;	/* Weighting value and vertex offset variable */
47950 			unsigned int wo2;	/* Weighting value and vertex offset variable */
47951 			{
47952 				unsigned int ti_i;	/* Interpolation index variable */
47953 
47954 				ti_i  = IT_IX(it0, ip0[0]);
47955 				wo0   = IT_WO(it0, ip0[0]);
47956 				ti_i += IT_IX(it1, ip0[1]);
47957 				wo1   = IT_WO(it1, ip0[1]);
47958 				ti_i += IT_IX(it2, ip0[2]);
47959 				wo2   = IT_WO(it2, ip0[2]);
47960 
47961 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
47962 
47963 				/* Sort weighting values and vertex offset values */
47964 				CEX(wo0, wo1);
47965 				CEX(wo0, wo2);
47966 				CEX(wo1, wo2);
47967 			}
47968 			{
47969 				unsigned int nvof;	/* Next vertex offset value */
47970 				unsigned int vof;	/* Vertex offset value */
47971 				unsigned int vwe;	/* Vertex weighting */
47972 
47973 				vof = 0;				/* First vertex offset is 0 */
47974 				nvof = (wo0 & 0x7fff);	/* Extract offset value */
47975 				wo0 = (wo0 >> 15);		/* Extract weighting value */
47976 				vwe = 65536 - wo0;		/* Baricentric weighting */
47977 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
47978 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
47979 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
47980 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
47981 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
47982 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
47983 				ova6  = IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
47984 				vof += nvof;			/* Move to next vertex */
47985 				nvof = (wo1 & 0x7fff);	/* Extract offset value */
47986 				wo1 = (wo1 >> 15);		/* Extract weighting value */
47987 				vwe = wo0 - wo1;		/* Baricentric weighting */
47988 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
47989 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
47990 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
47991 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
47992 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
47993 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
47994 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
47995 				vof += nvof;			/* Move to next vertex */
47996 				nvof = (wo2 & 0x7fff);	/* Extract offset value */
47997 				wo2 = (wo2 >> 15);		/* Extract weighting value */
47998 				vwe = wo1 - wo2;		/* Baricentric weighting */
47999 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
48000 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
48001 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
48002 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
48003 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
48004 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
48005 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
48006 				vof += nvof;			/* Move to next vertex */
48007 				vwe = wo2;				/* Baricentric weighting */
48008 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
48009 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
48010 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
48011 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
48012 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
48013 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
48014 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
48015 			}
48016 		}
48017 		{
48018 			unsigned int oti;	/* Vertex offset value */
48019 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
48020 			op0[0] = OT_E(ot0, oti);	/* Write result */
48021 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
48022 			op0[1] = OT_E(ot1, oti);	/* Write result */
48023 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
48024 			op0[2] = OT_E(ot2, oti);	/* Write result */
48025 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
48026 			op0[3] = OT_E(ot3, oti);	/* Write result */
48027 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
48028 			op0[4] = OT_E(ot4, oti);	/* Write result */
48029 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
48030 			op0[5] = OT_E(ot5, oti);	/* Write result */
48031 			oti = ((ova6 >> 16) & 0xffff);	/* Extract integer part of result */
48032 			op0[6] = OT_E(ot6, oti);	/* Write result */
48033 		}
48034 	}
48035 }
48036 #undef IT_WO
48037 #undef IT_IX
48038 #undef CEX
48039 #undef IM_O
48040 #undef IM_FE
48041 #undef OT_E
48042 
48043 void
imdi_k135_gen(genspec * g)48044 imdi_k135_gen(
48045 genspec *g			/* structure to be initialised */
48046 ) {
48047 	static unsigned char data[] = {
48048 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
48049 		0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
48050 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48051 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48052 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48053 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48054 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48055 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
48056 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
48057 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
48058 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
48059 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48060 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48061 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48062 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48063 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48064 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48065 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48066 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48067 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48068 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48069 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48070 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48071 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48072 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
48073 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
48074 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
48075 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
48076 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48077 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48078 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48079 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48080 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48081 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48082 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48083 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48084 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48085 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48086 		0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48087 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
48088 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
48089 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
48090 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
48091 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
48092 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
48093 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
48094 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
48095 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
48096 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48097 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
48098 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
48099 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x37, 0x5f,
48100 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
48101 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
48102 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
48103 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
48104 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
48105 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
48106 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
48107 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48108 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48109 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48110 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48111 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
48112 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x33,
48113 		0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48114 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48115 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
48116 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
48117 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
48118 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
48119 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
48120 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
48121 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
48122 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
48123 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
48124 		0x00, 0xf0, 0x04, 0x08
48125 	};	/* Structure image */
48126 
48127 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
48128 }
48129 
48130 void
imdi_k135_tab(tabspec * t)48131 imdi_k135_tab(
48132 tabspec *t			/* structure to be initialised */
48133 ) {
48134 	static unsigned char data[] = {
48135 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48136 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48137 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48138 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
48139 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
48140 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
48141 		0x20, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
48142 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
48143 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
48144 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48145 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
48146 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
48147 		0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
48148 		0x04, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
48149 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
48150 		0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48151 		0x0e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
48152 		0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
48153 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48154 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48155 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48156 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
48157 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
48158 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
48159 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48160 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48161 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48162 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48163 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48164 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48165 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48166 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48167 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
48168 	};	/* Structure image */
48169 
48170 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
48171 }
48172 
48173 
48174 
48175 
48176 
48177 
48178 /* Integer Multi-Dimensional Interpolation */
48179 /* Interpolation Kernel Code */
48180 /* Generated by cgen */
48181 /* Copyright 2000 - 2002 Graeme W. Gill */
48182 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
48183 
48184 /* see the Licence.txt file for licencing details.*/
48185 
48186 
48187 /*
48188    Interpolation kernel specs:
48189 
48190    Input channels per pixel = 4
48191    Input channel 0 bits = 16
48192    Input channel 0 increment = 4
48193    Input channel 1 bits = 16
48194    Input channel 1 increment = 4
48195    Input channel 2 bits = 16
48196    Input channel 2 increment = 4
48197    Input channel 3 bits = 16
48198    Input channel 3 increment = 4
48199    Input is channel interleaved
48200    Input channels are separate words
48201    Input value extraction is done in input table lookup
48202 
48203    Output channels per pixel = 7
48204    Output channel 0 bits = 16
48205    Output channel 0 increment = 7
48206    Output channel 1 bits = 16
48207    Output channel 1 increment = 7
48208    Output channel 2 bits = 16
48209    Output channel 2 increment = 7
48210    Output channel 3 bits = 16
48211    Output channel 3 increment = 7
48212    Output channel 4 bits = 16
48213    Output channel 4 increment = 7
48214    Output channel 5 bits = 16
48215    Output channel 5 increment = 7
48216    Output channel 6 bits = 16
48217    Output channel 6 increment = 7
48218    Output is channel interleaved
48219 
48220    Output channels are separate words
48221    Weight+voffset bits       = 32
48222    Interpolation table index bits = 32
48223    Interpolation table max resolution = 255
48224  */
48225 
48226 /*
48227    Machine architecture specs:
48228 
48229    Little endian
48230    Reading and writing pixel values separately
48231    Pointer size = 32 bits
48232 
48233    Ordinal size  8 bits is known as 'unsigned char'
48234    Ordinal size 16 bits is known as 'unsigned short'
48235    Ordinal size 32 bits is known as 'unsigned int'
48236    Natural ordinal is 'unsigned int'
48237 
48238    Integer size  8 bits is known as 'signed char'
48239    Integer size 16 bits is known as 'short'
48240    Integer size 32 bits is known as 'int'
48241    Natural integer is 'int'
48242 
48243  */
48244 
48245 #ifndef  IMDI_INCLUDED
48246 #include <memory.h>
48247 #include "imdi_imp.h"
48248 #define  IMDI_INCLUDED
48249 #endif  /* IMDI_INCLUDED */
48250 
48251 #ifndef DEFINED_pointer
48252 #define DEFINED_pointer
48253 typedef unsigned char * pointer;
48254 #endif
48255 
48256 /* Input table interp. index */
48257 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
48258 
48259 /* Input table input weighting enty */
48260 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
48261 
48262 /* Input table input offset value enty */
48263 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
48264 
48265 /* Conditional exchange for sorting */
48266 #define CEX(A, AA, B, BB) if (A < B) { \
48267             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
48268 
48269 /* Interpolation multi-dim. table access */
48270 #define IM_O(off) ((off) * 14)
48271 
48272 /* Interpolation table - get vertex values */
48273 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
48274 
48275 /* Output table indexes */
48276 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
48277 
48278 void
imdi_k136(imdi * s,void ** outp,void ** inp,unsigned int npix)48279 imdi_k136(
48280 imdi *s,			/* imdi context */
48281 void **outp,		/* pointer to output pointers */
48282 void **inp,		/* pointer to input pointers */
48283 unsigned int npix	/* Number of pixels to process */
48284 ) {
48285 	imdi_imp *p = (imdi_imp *)(s->impl);
48286 	unsigned short *ip0 = (unsigned short *)inp[0];
48287 	unsigned short *op0 = (unsigned short *)outp[0];
48288 	unsigned short *ep = ip0 + npix * 4 ;
48289 	pointer it0 = (pointer)p->in_tables[0];
48290 	pointer it1 = (pointer)p->in_tables[1];
48291 	pointer it2 = (pointer)p->in_tables[2];
48292 	pointer it3 = (pointer)p->in_tables[3];
48293 	pointer ot0 = (pointer)p->out_tables[0];
48294 	pointer ot1 = (pointer)p->out_tables[1];
48295 	pointer ot2 = (pointer)p->out_tables[2];
48296 	pointer ot3 = (pointer)p->out_tables[3];
48297 	pointer ot4 = (pointer)p->out_tables[4];
48298 	pointer ot5 = (pointer)p->out_tables[5];
48299 	pointer ot6 = (pointer)p->out_tables[6];
48300 	pointer im_base = (pointer)p->im_table;
48301 
48302 	for(;ip0 < ep; ip0 += 4, op0 += 7) {
48303 		unsigned int ova0;	/* Output value accumulator */
48304 		unsigned int ova1;	/* Output value accumulator */
48305 		unsigned int ova2;	/* Output value accumulator */
48306 		unsigned int ova3;	/* Output value accumulator */
48307 		unsigned int ova4;	/* Output value accumulator */
48308 		unsigned int ova5;	/* Output value accumulator */
48309 		unsigned int ova6;	/* Output value accumulator */
48310 		{
48311 			pointer imp;
48312 			unsigned int we0;	/* Weighting value variable */
48313 			unsigned int vo0;	/* Vertex offset variable */
48314 			unsigned int we1;	/* Weighting value variable */
48315 			unsigned int vo1;	/* Vertex offset variable */
48316 			unsigned int we2;	/* Weighting value variable */
48317 			unsigned int vo2;	/* Vertex offset variable */
48318 			unsigned int we3;	/* Weighting value variable */
48319 			unsigned int vo3;	/* Vertex offset variable */
48320 			{
48321 				unsigned int ti_i;	/* Interpolation index variable */
48322 
48323 				ti_i  = IT_IX(it0, ip0[0]);
48324 				we0   = IT_WE(it0, ip0[0]);
48325 				vo0   = IT_VO(it0, ip0[0]);
48326 				ti_i += IT_IX(it1, ip0[1]);
48327 				we1   = IT_WE(it1, ip0[1]);
48328 				vo1   = IT_VO(it1, ip0[1]);
48329 				ti_i += IT_IX(it2, ip0[2]);
48330 				we2   = IT_WE(it2, ip0[2]);
48331 				vo2   = IT_VO(it2, ip0[2]);
48332 				ti_i += IT_IX(it3, ip0[3]);
48333 				we3   = IT_WE(it3, ip0[3]);
48334 				vo3   = IT_VO(it3, ip0[3]);
48335 
48336 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
48337 
48338 				/* Sort weighting values and vertex offset values */
48339 				CEX(we0, vo0, we1, vo1);
48340 				CEX(we0, vo0, we2, vo2);
48341 				CEX(we0, vo0, we3, vo3);
48342 				CEX(we1, vo1, we2, vo2);
48343 				CEX(we1, vo1, we3, vo3);
48344 				CEX(we2, vo2, we3, vo3);
48345 			}
48346 			{
48347 				unsigned int vof;	/* Vertex offset value */
48348 				unsigned int vwe;	/* Vertex weighting */
48349 
48350 				vof = 0;				/* First vertex offset is 0 */
48351 				vwe = 65536 - we0;		/* Baricentric weighting */
48352 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
48353 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
48354 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
48355 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
48356 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
48357 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
48358 				ova6  = IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
48359 				vof += vo0;			/* Move to next vertex */
48360 				vwe = we0 - we1;		/* Baricentric weighting */
48361 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
48362 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
48363 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
48364 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
48365 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
48366 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
48367 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
48368 				vof += vo1;			/* Move to next vertex */
48369 				vwe = we1 - we2;		/* Baricentric weighting */
48370 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
48371 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
48372 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
48373 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
48374 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
48375 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
48376 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
48377 				vof += vo2;			/* Move to next vertex */
48378 				vwe = we2 - we3;		/* Baricentric weighting */
48379 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
48380 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
48381 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
48382 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
48383 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
48384 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
48385 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
48386 				vof += vo3;			/* Move to next vertex */
48387 				vwe = we3;				/* Baricentric weighting */
48388 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
48389 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
48390 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
48391 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
48392 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
48393 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
48394 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
48395 			}
48396 		}
48397 		{
48398 			unsigned int oti;	/* Vertex offset value */
48399 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
48400 			op0[0] = OT_E(ot0, oti);	/* Write result */
48401 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
48402 			op0[1] = OT_E(ot1, oti);	/* Write result */
48403 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
48404 			op0[2] = OT_E(ot2, oti);	/* Write result */
48405 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
48406 			op0[3] = OT_E(ot3, oti);	/* Write result */
48407 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
48408 			op0[4] = OT_E(ot4, oti);	/* Write result */
48409 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
48410 			op0[5] = OT_E(ot5, oti);	/* Write result */
48411 			oti = ((ova6 >> 16) & 0xffff);	/* Extract integer part of result */
48412 			op0[6] = OT_E(ot6, oti);	/* Write result */
48413 		}
48414 	}
48415 }
48416 #undef IT_WE
48417 #undef IT_VO
48418 #undef IT_IX
48419 #undef CEX
48420 #undef IM_O
48421 #undef IM_FE
48422 #undef OT_E
48423 
48424 void
imdi_k136_gen(genspec * g)48425 imdi_k136_gen(
48426 genspec *g			/* structure to be initialised */
48427 ) {
48428 	static unsigned char data[] = {
48429 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
48430 		0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
48431 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48432 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48433 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48434 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48435 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48436 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
48437 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
48438 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
48439 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
48440 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48441 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48442 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48443 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48444 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48445 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48446 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48447 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48448 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48449 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48450 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48451 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48452 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48453 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
48454 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
48455 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
48456 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
48457 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48458 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48459 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48460 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48461 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48462 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48463 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48464 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48465 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48466 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48467 		0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48468 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
48469 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
48470 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
48471 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
48472 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
48473 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
48474 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
48475 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
48476 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
48477 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48478 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
48479 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
48480 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x37, 0x5f,
48481 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
48482 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
48483 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
48484 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
48485 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
48486 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
48487 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
48488 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48489 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48490 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48491 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48492 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
48493 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x33,
48494 		0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48495 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48496 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
48497 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
48498 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
48499 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
48500 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
48501 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
48502 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
48503 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
48504 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
48505 		0x00, 0xf0, 0x04, 0x08
48506 	};	/* Structure image */
48507 
48508 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
48509 }
48510 
48511 void
imdi_k136_tab(tabspec * t)48512 imdi_k136_tab(
48513 tabspec *t			/* structure to be initialised */
48514 ) {
48515 	static unsigned char data[] = {
48516 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48517 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48518 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48519 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
48520 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
48521 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
48522 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
48523 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
48524 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
48525 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48526 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
48527 		0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
48528 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
48529 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
48530 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
48531 		0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48532 		0x0e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
48533 		0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
48534 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48535 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48536 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48537 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
48538 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
48539 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
48540 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48541 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48542 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48543 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48544 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48545 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48546 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48547 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48548 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
48549 	};	/* Structure image */
48550 
48551 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
48552 }
48553 
48554 
48555 
48556 
48557 
48558 
48559 /* Integer Multi-Dimensional Interpolation */
48560 /* Interpolation Kernel Code */
48561 /* Generated by cgen */
48562 /* Copyright 2000 - 2002 Graeme W. Gill */
48563 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
48564 
48565 /* see the Licence.txt file for licencing details.*/
48566 
48567 
48568 /*
48569    Interpolation kernel specs:
48570 
48571    Input channels per pixel = 5
48572    Input channel 0 bits = 16
48573    Input channel 0 increment = 5
48574    Input channel 1 bits = 16
48575    Input channel 1 increment = 5
48576    Input channel 2 bits = 16
48577    Input channel 2 increment = 5
48578    Input channel 3 bits = 16
48579    Input channel 3 increment = 5
48580    Input channel 4 bits = 16
48581    Input channel 4 increment = 5
48582    Input is channel interleaved
48583    Input channels are separate words
48584    Input value extraction is done in input table lookup
48585 
48586    Output channels per pixel = 7
48587    Output channel 0 bits = 16
48588    Output channel 0 increment = 7
48589    Output channel 1 bits = 16
48590    Output channel 1 increment = 7
48591    Output channel 2 bits = 16
48592    Output channel 2 increment = 7
48593    Output channel 3 bits = 16
48594    Output channel 3 increment = 7
48595    Output channel 4 bits = 16
48596    Output channel 4 increment = 7
48597    Output channel 5 bits = 16
48598    Output channel 5 increment = 7
48599    Output channel 6 bits = 16
48600    Output channel 6 increment = 7
48601    Output is channel interleaved
48602 
48603    Output channels are separate words
48604    Weight+voffset bits       = 32
48605    Interpolation table index bits = 32
48606    Interpolation table max resolution = 84
48607  */
48608 
48609 /*
48610    Machine architecture specs:
48611 
48612    Little endian
48613    Reading and writing pixel values separately
48614    Pointer size = 32 bits
48615 
48616    Ordinal size  8 bits is known as 'unsigned char'
48617    Ordinal size 16 bits is known as 'unsigned short'
48618    Ordinal size 32 bits is known as 'unsigned int'
48619    Natural ordinal is 'unsigned int'
48620 
48621    Integer size  8 bits is known as 'signed char'
48622    Integer size 16 bits is known as 'short'
48623    Integer size 32 bits is known as 'int'
48624    Natural integer is 'int'
48625 
48626  */
48627 
48628 #ifndef  IMDI_INCLUDED
48629 #include <memory.h>
48630 #include "imdi_imp.h"
48631 #define  IMDI_INCLUDED
48632 #endif  /* IMDI_INCLUDED */
48633 
48634 #ifndef DEFINED_pointer
48635 #define DEFINED_pointer
48636 typedef unsigned char * pointer;
48637 #endif
48638 
48639 /* Input table interp. index */
48640 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
48641 
48642 /* Input table input weighting enty */
48643 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
48644 
48645 /* Input table input offset value enty */
48646 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
48647 
48648 /* Conditional exchange for sorting */
48649 #define CEX(A, AA, B, BB) if (A < B) { \
48650             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
48651 
48652 /* Interpolation multi-dim. table access */
48653 #define IM_O(off) ((off) * 14)
48654 
48655 /* Interpolation table - get vertex values */
48656 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
48657 
48658 /* Output table indexes */
48659 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
48660 
48661 void
imdi_k137(imdi * s,void ** outp,void ** inp,unsigned int npix)48662 imdi_k137(
48663 imdi *s,			/* imdi context */
48664 void **outp,		/* pointer to output pointers */
48665 void **inp,		/* pointer to input pointers */
48666 unsigned int npix	/* Number of pixels to process */
48667 ) {
48668 	imdi_imp *p = (imdi_imp *)(s->impl);
48669 	unsigned short *ip0 = (unsigned short *)inp[0];
48670 	unsigned short *op0 = (unsigned short *)outp[0];
48671 	unsigned short *ep = ip0 + npix * 5 ;
48672 	pointer it0 = (pointer)p->in_tables[0];
48673 	pointer it1 = (pointer)p->in_tables[1];
48674 	pointer it2 = (pointer)p->in_tables[2];
48675 	pointer it3 = (pointer)p->in_tables[3];
48676 	pointer it4 = (pointer)p->in_tables[4];
48677 	pointer ot0 = (pointer)p->out_tables[0];
48678 	pointer ot1 = (pointer)p->out_tables[1];
48679 	pointer ot2 = (pointer)p->out_tables[2];
48680 	pointer ot3 = (pointer)p->out_tables[3];
48681 	pointer ot4 = (pointer)p->out_tables[4];
48682 	pointer ot5 = (pointer)p->out_tables[5];
48683 	pointer ot6 = (pointer)p->out_tables[6];
48684 	pointer im_base = (pointer)p->im_table;
48685 
48686 	for(;ip0 < ep; ip0 += 5, op0 += 7) {
48687 		unsigned int ova0;	/* Output value accumulator */
48688 		unsigned int ova1;	/* Output value accumulator */
48689 		unsigned int ova2;	/* Output value accumulator */
48690 		unsigned int ova3;	/* Output value accumulator */
48691 		unsigned int ova4;	/* Output value accumulator */
48692 		unsigned int ova5;	/* Output value accumulator */
48693 		unsigned int ova6;	/* Output value accumulator */
48694 		{
48695 			pointer imp;
48696 			unsigned int we0;	/* Weighting value variable */
48697 			unsigned int vo0;	/* Vertex offset variable */
48698 			unsigned int we1;	/* Weighting value variable */
48699 			unsigned int vo1;	/* Vertex offset variable */
48700 			unsigned int we2;	/* Weighting value variable */
48701 			unsigned int vo2;	/* Vertex offset variable */
48702 			unsigned int we3;	/* Weighting value variable */
48703 			unsigned int vo3;	/* Vertex offset variable */
48704 			unsigned int we4;	/* Weighting value variable */
48705 			unsigned int vo4;	/* Vertex offset variable */
48706 			{
48707 				unsigned int ti_i;	/* Interpolation index variable */
48708 
48709 				ti_i  = IT_IX(it0, ip0[0]);
48710 				we0   = IT_WE(it0, ip0[0]);
48711 				vo0   = IT_VO(it0, ip0[0]);
48712 				ti_i += IT_IX(it1, ip0[1]);
48713 				we1   = IT_WE(it1, ip0[1]);
48714 				vo1   = IT_VO(it1, ip0[1]);
48715 				ti_i += IT_IX(it2, ip0[2]);
48716 				we2   = IT_WE(it2, ip0[2]);
48717 				vo2   = IT_VO(it2, ip0[2]);
48718 				ti_i += IT_IX(it3, ip0[3]);
48719 				we3   = IT_WE(it3, ip0[3]);
48720 				vo3   = IT_VO(it3, ip0[3]);
48721 				ti_i += IT_IX(it4, ip0[4]);
48722 				we4   = IT_WE(it4, ip0[4]);
48723 				vo4   = IT_VO(it4, ip0[4]);
48724 
48725 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
48726 
48727 				/* Sort weighting values and vertex offset values */
48728 				CEX(we0, vo0, we1, vo1);
48729 				CEX(we0, vo0, we2, vo2);
48730 				CEX(we0, vo0, we3, vo3);
48731 				CEX(we0, vo0, we4, vo4);
48732 				CEX(we1, vo1, we2, vo2);
48733 				CEX(we1, vo1, we3, vo3);
48734 				CEX(we1, vo1, we4, vo4);
48735 				CEX(we2, vo2, we3, vo3);
48736 				CEX(we2, vo2, we4, vo4);
48737 				CEX(we3, vo3, we4, vo4);
48738 			}
48739 			{
48740 				unsigned int vof;	/* Vertex offset value */
48741 				unsigned int vwe;	/* Vertex weighting */
48742 
48743 				vof = 0;				/* First vertex offset is 0 */
48744 				vwe = 65536 - we0;		/* Baricentric weighting */
48745 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
48746 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
48747 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
48748 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
48749 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
48750 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
48751 				ova6  = IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
48752 				vof += vo0;			/* Move to next vertex */
48753 				vwe = we0 - we1;		/* Baricentric weighting */
48754 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
48755 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
48756 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
48757 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
48758 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
48759 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
48760 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
48761 				vof += vo1;			/* Move to next vertex */
48762 				vwe = we1 - we2;		/* Baricentric weighting */
48763 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
48764 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
48765 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
48766 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
48767 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
48768 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
48769 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
48770 				vof += vo2;			/* Move to next vertex */
48771 				vwe = we2 - we3;		/* Baricentric weighting */
48772 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
48773 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
48774 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
48775 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
48776 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
48777 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
48778 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
48779 				vof += vo3;			/* Move to next vertex */
48780 				vwe = we3 - we4;		/* Baricentric weighting */
48781 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
48782 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
48783 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
48784 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
48785 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
48786 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
48787 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
48788 				vof += vo4;			/* Move to next vertex */
48789 				vwe = we4;				/* Baricentric weighting */
48790 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
48791 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
48792 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
48793 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
48794 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
48795 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
48796 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
48797 			}
48798 		}
48799 		{
48800 			unsigned int oti;	/* Vertex offset value */
48801 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
48802 			op0[0] = OT_E(ot0, oti);	/* Write result */
48803 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
48804 			op0[1] = OT_E(ot1, oti);	/* Write result */
48805 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
48806 			op0[2] = OT_E(ot2, oti);	/* Write result */
48807 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
48808 			op0[3] = OT_E(ot3, oti);	/* Write result */
48809 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
48810 			op0[4] = OT_E(ot4, oti);	/* Write result */
48811 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
48812 			op0[5] = OT_E(ot5, oti);	/* Write result */
48813 			oti = ((ova6 >> 16) & 0xffff);	/* Extract integer part of result */
48814 			op0[6] = OT_E(ot6, oti);	/* Write result */
48815 		}
48816 	}
48817 }
48818 #undef IT_WE
48819 #undef IT_VO
48820 #undef IT_IX
48821 #undef CEX
48822 #undef IM_O
48823 #undef IM_FE
48824 #undef OT_E
48825 
48826 void
imdi_k137_gen(genspec * g)48827 imdi_k137_gen(
48828 genspec *g			/* structure to be initialised */
48829 ) {
48830 	static unsigned char data[] = {
48831 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
48832 		0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
48833 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48834 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48835 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48836 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48837 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48838 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
48839 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
48840 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
48841 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
48842 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48843 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48844 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48845 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48846 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48847 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48848 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48849 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48850 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48851 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48852 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48853 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48854 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48855 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
48856 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
48857 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
48858 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
48859 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48860 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48861 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48862 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48863 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48864 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48865 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48866 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48867 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48868 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48869 		0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48870 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
48871 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
48872 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
48873 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
48874 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
48875 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
48876 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
48877 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
48878 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
48879 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48880 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
48881 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
48882 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x37, 0x5f,
48883 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
48884 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
48885 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
48886 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
48887 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
48888 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
48889 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
48890 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48891 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48892 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48893 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48894 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
48895 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x33,
48896 		0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48897 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48898 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
48899 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
48900 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
48901 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
48902 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
48903 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
48904 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
48905 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
48906 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
48907 		0x00, 0xf0, 0x04, 0x08
48908 	};	/* Structure image */
48909 
48910 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
48911 }
48912 
48913 void
imdi_k137_tab(tabspec * t)48914 imdi_k137_tab(
48915 tabspec *t			/* structure to be initialised */
48916 ) {
48917 	static unsigned char data[] = {
48918 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48919 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48920 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48921 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
48922 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
48923 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
48924 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
48925 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
48926 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
48927 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48928 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
48929 		0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
48930 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
48931 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
48932 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
48933 		0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48934 		0x0e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
48935 		0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
48936 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48937 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48938 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
48939 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
48940 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
48941 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
48942 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48943 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48944 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48945 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48946 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48947 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48948 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48949 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
48950 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
48951 	};	/* Structure image */
48952 
48953 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
48954 }
48955 
48956 
48957 
48958 
48959 
48960 
48961 /* Integer Multi-Dimensional Interpolation */
48962 /* Interpolation Kernel Code */
48963 /* Generated by cgen */
48964 /* Copyright 2000 - 2002 Graeme W. Gill */
48965 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
48966 
48967 /* see the Licence.txt file for licencing details.*/
48968 
48969 
48970 /*
48971    Interpolation kernel specs:
48972 
48973    Input channels per pixel = 6
48974    Input channel 0 bits = 16
48975    Input channel 0 increment = 6
48976    Input channel 1 bits = 16
48977    Input channel 1 increment = 6
48978    Input channel 2 bits = 16
48979    Input channel 2 increment = 6
48980    Input channel 3 bits = 16
48981    Input channel 3 increment = 6
48982    Input channel 4 bits = 16
48983    Input channel 4 increment = 6
48984    Input channel 5 bits = 16
48985    Input channel 5 increment = 6
48986    Input is channel interleaved
48987    Input channels are separate words
48988    Input value extraction is done in input table lookup
48989 
48990    Output channels per pixel = 7
48991    Output channel 0 bits = 16
48992    Output channel 0 increment = 7
48993    Output channel 1 bits = 16
48994    Output channel 1 increment = 7
48995    Output channel 2 bits = 16
48996    Output channel 2 increment = 7
48997    Output channel 3 bits = 16
48998    Output channel 3 increment = 7
48999    Output channel 4 bits = 16
49000    Output channel 4 increment = 7
49001    Output channel 5 bits = 16
49002    Output channel 5 increment = 7
49003    Output channel 6 bits = 16
49004    Output channel 6 increment = 7
49005    Output is channel interleaved
49006 
49007    Output channels are separate words
49008    Weight+voffset bits       = 32
49009    Interpolation table index bits = 32
49010    Interpolation table max resolution = 40
49011  */
49012 
49013 /*
49014    Machine architecture specs:
49015 
49016    Little endian
49017    Reading and writing pixel values separately
49018    Pointer size = 32 bits
49019 
49020    Ordinal size  8 bits is known as 'unsigned char'
49021    Ordinal size 16 bits is known as 'unsigned short'
49022    Ordinal size 32 bits is known as 'unsigned int'
49023    Natural ordinal is 'unsigned int'
49024 
49025    Integer size  8 bits is known as 'signed char'
49026    Integer size 16 bits is known as 'short'
49027    Integer size 32 bits is known as 'int'
49028    Natural integer is 'int'
49029 
49030  */
49031 
49032 #ifndef  IMDI_INCLUDED
49033 #include <memory.h>
49034 #include "imdi_imp.h"
49035 #define  IMDI_INCLUDED
49036 #endif  /* IMDI_INCLUDED */
49037 
49038 #ifndef DEFINED_pointer
49039 #define DEFINED_pointer
49040 typedef unsigned char * pointer;
49041 #endif
49042 
49043 /* Input table interp. index */
49044 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
49045 
49046 /* Input table input weighting enty */
49047 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
49048 
49049 /* Input table input offset value enty */
49050 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
49051 
49052 /* Conditional exchange for sorting */
49053 #define CEX(A, AA, B, BB) if (A < B) { \
49054             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
49055 
49056 /* Interpolation multi-dim. table access */
49057 #define IM_O(off) ((off) * 14)
49058 
49059 /* Interpolation table - get vertex values */
49060 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
49061 
49062 /* Output table indexes */
49063 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
49064 
49065 void
imdi_k138(imdi * s,void ** outp,void ** inp,unsigned int npix)49066 imdi_k138(
49067 imdi *s,			/* imdi context */
49068 void **outp,		/* pointer to output pointers */
49069 void **inp,		/* pointer to input pointers */
49070 unsigned int npix	/* Number of pixels to process */
49071 ) {
49072 	imdi_imp *p = (imdi_imp *)(s->impl);
49073 	unsigned short *ip0 = (unsigned short *)inp[0];
49074 	unsigned short *op0 = (unsigned short *)outp[0];
49075 	unsigned short *ep = ip0 + npix * 6 ;
49076 	pointer it0 = (pointer)p->in_tables[0];
49077 	pointer it1 = (pointer)p->in_tables[1];
49078 	pointer it2 = (pointer)p->in_tables[2];
49079 	pointer it3 = (pointer)p->in_tables[3];
49080 	pointer it4 = (pointer)p->in_tables[4];
49081 	pointer it5 = (pointer)p->in_tables[5];
49082 	pointer ot0 = (pointer)p->out_tables[0];
49083 	pointer ot1 = (pointer)p->out_tables[1];
49084 	pointer ot2 = (pointer)p->out_tables[2];
49085 	pointer ot3 = (pointer)p->out_tables[3];
49086 	pointer ot4 = (pointer)p->out_tables[4];
49087 	pointer ot5 = (pointer)p->out_tables[5];
49088 	pointer ot6 = (pointer)p->out_tables[6];
49089 	pointer im_base = (pointer)p->im_table;
49090 
49091 	for(;ip0 < ep; ip0 += 6, op0 += 7) {
49092 		unsigned int ova0;	/* Output value accumulator */
49093 		unsigned int ova1;	/* Output value accumulator */
49094 		unsigned int ova2;	/* Output value accumulator */
49095 		unsigned int ova3;	/* Output value accumulator */
49096 		unsigned int ova4;	/* Output value accumulator */
49097 		unsigned int ova5;	/* Output value accumulator */
49098 		unsigned int ova6;	/* Output value accumulator */
49099 		{
49100 			pointer imp;
49101 			unsigned int we0;	/* Weighting value variable */
49102 			unsigned int vo0;	/* Vertex offset variable */
49103 			unsigned int we1;	/* Weighting value variable */
49104 			unsigned int vo1;	/* Vertex offset variable */
49105 			unsigned int we2;	/* Weighting value variable */
49106 			unsigned int vo2;	/* Vertex offset variable */
49107 			unsigned int we3;	/* Weighting value variable */
49108 			unsigned int vo3;	/* Vertex offset variable */
49109 			unsigned int we4;	/* Weighting value variable */
49110 			unsigned int vo4;	/* Vertex offset variable */
49111 			unsigned int we5;	/* Weighting value variable */
49112 			unsigned int vo5;	/* Vertex offset variable */
49113 			{
49114 				unsigned int ti_i;	/* Interpolation index variable */
49115 
49116 				ti_i  = IT_IX(it0, ip0[0]);
49117 				we0   = IT_WE(it0, ip0[0]);
49118 				vo0   = IT_VO(it0, ip0[0]);
49119 				ti_i += IT_IX(it1, ip0[1]);
49120 				we1   = IT_WE(it1, ip0[1]);
49121 				vo1   = IT_VO(it1, ip0[1]);
49122 				ti_i += IT_IX(it2, ip0[2]);
49123 				we2   = IT_WE(it2, ip0[2]);
49124 				vo2   = IT_VO(it2, ip0[2]);
49125 				ti_i += IT_IX(it3, ip0[3]);
49126 				we3   = IT_WE(it3, ip0[3]);
49127 				vo3   = IT_VO(it3, ip0[3]);
49128 				ti_i += IT_IX(it4, ip0[4]);
49129 				we4   = IT_WE(it4, ip0[4]);
49130 				vo4   = IT_VO(it4, ip0[4]);
49131 				ti_i += IT_IX(it5, ip0[5]);
49132 				we5   = IT_WE(it5, ip0[5]);
49133 				vo5   = IT_VO(it5, ip0[5]);
49134 
49135 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
49136 
49137 				/* Sort weighting values and vertex offset values */
49138 				CEX(we0, vo0, we1, vo1);
49139 				CEX(we0, vo0, we2, vo2);
49140 				CEX(we0, vo0, we3, vo3);
49141 				CEX(we0, vo0, we4, vo4);
49142 				CEX(we0, vo0, we5, vo5);
49143 				CEX(we1, vo1, we2, vo2);
49144 				CEX(we1, vo1, we3, vo3);
49145 				CEX(we1, vo1, we4, vo4);
49146 				CEX(we1, vo1, we5, vo5);
49147 				CEX(we2, vo2, we3, vo3);
49148 				CEX(we2, vo2, we4, vo4);
49149 				CEX(we2, vo2, we5, vo5);
49150 				CEX(we3, vo3, we4, vo4);
49151 				CEX(we3, vo3, we5, vo5);
49152 				CEX(we4, vo4, we5, vo5);
49153 			}
49154 			{
49155 				unsigned int vof;	/* Vertex offset value */
49156 				unsigned int vwe;	/* Vertex weighting */
49157 
49158 				vof = 0;				/* First vertex offset is 0 */
49159 				vwe = 65536 - we0;		/* Baricentric weighting */
49160 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
49161 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
49162 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
49163 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
49164 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
49165 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
49166 				ova6  = IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
49167 				vof += vo0;			/* Move to next vertex */
49168 				vwe = we0 - we1;		/* Baricentric weighting */
49169 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
49170 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
49171 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
49172 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
49173 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
49174 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
49175 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
49176 				vof += vo1;			/* Move to next vertex */
49177 				vwe = we1 - we2;		/* Baricentric weighting */
49178 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
49179 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
49180 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
49181 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
49182 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
49183 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
49184 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
49185 				vof += vo2;			/* Move to next vertex */
49186 				vwe = we2 - we3;		/* Baricentric weighting */
49187 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
49188 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
49189 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
49190 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
49191 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
49192 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
49193 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
49194 				vof += vo3;			/* Move to next vertex */
49195 				vwe = we3 - we4;		/* Baricentric weighting */
49196 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
49197 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
49198 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
49199 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
49200 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
49201 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
49202 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
49203 				vof += vo4;			/* Move to next vertex */
49204 				vwe = we4 - we5;		/* Baricentric weighting */
49205 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
49206 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
49207 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
49208 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
49209 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
49210 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
49211 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
49212 				vof += vo5;			/* Move to next vertex */
49213 				vwe = we5;				/* Baricentric weighting */
49214 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
49215 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
49216 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
49217 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
49218 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
49219 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
49220 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
49221 			}
49222 		}
49223 		{
49224 			unsigned int oti;	/* Vertex offset value */
49225 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
49226 			op0[0] = OT_E(ot0, oti);	/* Write result */
49227 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
49228 			op0[1] = OT_E(ot1, oti);	/* Write result */
49229 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
49230 			op0[2] = OT_E(ot2, oti);	/* Write result */
49231 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
49232 			op0[3] = OT_E(ot3, oti);	/* Write result */
49233 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
49234 			op0[4] = OT_E(ot4, oti);	/* Write result */
49235 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
49236 			op0[5] = OT_E(ot5, oti);	/* Write result */
49237 			oti = ((ova6 >> 16) & 0xffff);	/* Extract integer part of result */
49238 			op0[6] = OT_E(ot6, oti);	/* Write result */
49239 		}
49240 	}
49241 }
49242 #undef IT_WE
49243 #undef IT_VO
49244 #undef IT_IX
49245 #undef CEX
49246 #undef IM_O
49247 #undef IM_FE
49248 #undef OT_E
49249 
49250 void
imdi_k138_gen(genspec * g)49251 imdi_k138_gen(
49252 genspec *g			/* structure to be initialised */
49253 ) {
49254 	static unsigned char data[] = {
49255 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
49256 		0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
49257 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49258 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49259 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49260 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49261 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49262 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
49263 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
49264 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
49265 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
49266 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49267 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49268 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49269 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49270 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49271 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49272 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49273 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49274 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
49275 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49276 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49277 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49278 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49279 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
49280 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
49281 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
49282 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
49283 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49284 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49285 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49286 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49287 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49288 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49289 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49290 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49291 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
49292 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
49293 		0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49294 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
49295 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
49296 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
49297 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
49298 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
49299 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
49300 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
49301 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
49302 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
49303 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49304 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
49305 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
49306 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x37, 0x5f,
49307 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
49308 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
49309 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
49310 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
49311 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
49312 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
49313 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
49314 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49315 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49316 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49317 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49318 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
49319 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x33,
49320 		0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49321 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49322 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
49323 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
49324 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
49325 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
49326 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
49327 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
49328 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
49329 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
49330 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
49331 		0x00, 0xf0, 0x04, 0x08
49332 	};	/* Structure image */
49333 
49334 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
49335 }
49336 
49337 void
imdi_k138_tab(tabspec * t)49338 imdi_k138_tab(
49339 tabspec *t			/* structure to be initialised */
49340 ) {
49341 	static unsigned char data[] = {
49342 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
49343 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
49344 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
49345 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
49346 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
49347 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
49348 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
49349 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
49350 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
49351 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49352 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
49353 		0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
49354 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
49355 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
49356 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
49357 		0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49358 		0x0e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
49359 		0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
49360 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49361 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49362 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
49363 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
49364 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
49365 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
49366 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49367 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49368 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49369 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49370 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49371 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49372 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49373 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49374 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
49375 	};	/* Structure image */
49376 
49377 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
49378 }
49379 
49380 
49381 
49382 
49383 
49384 
49385 /* Integer Multi-Dimensional Interpolation */
49386 /* Interpolation Kernel Code */
49387 /* Generated by cgen */
49388 /* Copyright 2000 - 2002 Graeme W. Gill */
49389 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
49390 
49391 /* see the Licence.txt file for licencing details.*/
49392 
49393 
49394 /*
49395    Interpolation kernel specs:
49396 
49397    Input channels per pixel = 7
49398    Input channel 0 bits = 16
49399    Input channel 0 increment = 7
49400    Input channel 1 bits = 16
49401    Input channel 1 increment = 7
49402    Input channel 2 bits = 16
49403    Input channel 2 increment = 7
49404    Input channel 3 bits = 16
49405    Input channel 3 increment = 7
49406    Input channel 4 bits = 16
49407    Input channel 4 increment = 7
49408    Input channel 5 bits = 16
49409    Input channel 5 increment = 7
49410    Input channel 6 bits = 16
49411    Input channel 6 increment = 7
49412    Input is channel interleaved
49413    Input channels are separate words
49414    Input value extraction is done in input table lookup
49415 
49416    Output channels per pixel = 7
49417    Output channel 0 bits = 16
49418    Output channel 0 increment = 7
49419    Output channel 1 bits = 16
49420    Output channel 1 increment = 7
49421    Output channel 2 bits = 16
49422    Output channel 2 increment = 7
49423    Output channel 3 bits = 16
49424    Output channel 3 increment = 7
49425    Output channel 4 bits = 16
49426    Output channel 4 increment = 7
49427    Output channel 5 bits = 16
49428    Output channel 5 increment = 7
49429    Output channel 6 bits = 16
49430    Output channel 6 increment = 7
49431    Output is channel interleaved
49432 
49433    Output channels are separate words
49434    Weight+voffset bits       = 32
49435    Interpolation table index bits = 32
49436    Interpolation table max resolution = 23
49437  */
49438 
49439 /*
49440    Machine architecture specs:
49441 
49442    Little endian
49443    Reading and writing pixel values separately
49444    Pointer size = 32 bits
49445 
49446    Ordinal size  8 bits is known as 'unsigned char'
49447    Ordinal size 16 bits is known as 'unsigned short'
49448    Ordinal size 32 bits is known as 'unsigned int'
49449    Natural ordinal is 'unsigned int'
49450 
49451    Integer size  8 bits is known as 'signed char'
49452    Integer size 16 bits is known as 'short'
49453    Integer size 32 bits is known as 'int'
49454    Natural integer is 'int'
49455 
49456  */
49457 
49458 #ifndef  IMDI_INCLUDED
49459 #include <memory.h>
49460 #include "imdi_imp.h"
49461 #define  IMDI_INCLUDED
49462 #endif  /* IMDI_INCLUDED */
49463 
49464 #ifndef DEFINED_pointer
49465 #define DEFINED_pointer
49466 typedef unsigned char * pointer;
49467 #endif
49468 
49469 /* Input table interp. index */
49470 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
49471 
49472 /* Input table input weighting enty */
49473 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
49474 
49475 /* Input table input offset value enty */
49476 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
49477 
49478 /* Conditional exchange for sorting */
49479 #define CEX(A, AA, B, BB) if (A < B) { \
49480             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
49481 
49482 /* Interpolation multi-dim. table access */
49483 #define IM_O(off) ((off) * 14)
49484 
49485 /* Interpolation table - get vertex values */
49486 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
49487 
49488 /* Output table indexes */
49489 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
49490 
49491 void
imdi_k139(imdi * s,void ** outp,void ** inp,unsigned int npix)49492 imdi_k139(
49493 imdi *s,			/* imdi context */
49494 void **outp,		/* pointer to output pointers */
49495 void **inp,		/* pointer to input pointers */
49496 unsigned int npix	/* Number of pixels to process */
49497 ) {
49498 	imdi_imp *p = (imdi_imp *)(s->impl);
49499 	unsigned short *ip0 = (unsigned short *)inp[0];
49500 	unsigned short *op0 = (unsigned short *)outp[0];
49501 	unsigned short *ep = ip0 + npix * 7 ;
49502 	pointer it0 = (pointer)p->in_tables[0];
49503 	pointer it1 = (pointer)p->in_tables[1];
49504 	pointer it2 = (pointer)p->in_tables[2];
49505 	pointer it3 = (pointer)p->in_tables[3];
49506 	pointer it4 = (pointer)p->in_tables[4];
49507 	pointer it5 = (pointer)p->in_tables[5];
49508 	pointer it6 = (pointer)p->in_tables[6];
49509 	pointer ot0 = (pointer)p->out_tables[0];
49510 	pointer ot1 = (pointer)p->out_tables[1];
49511 	pointer ot2 = (pointer)p->out_tables[2];
49512 	pointer ot3 = (pointer)p->out_tables[3];
49513 	pointer ot4 = (pointer)p->out_tables[4];
49514 	pointer ot5 = (pointer)p->out_tables[5];
49515 	pointer ot6 = (pointer)p->out_tables[6];
49516 	pointer im_base = (pointer)p->im_table;
49517 
49518 	for(;ip0 < ep; ip0 += 7, op0 += 7) {
49519 		unsigned int ova0;	/* Output value accumulator */
49520 		unsigned int ova1;	/* Output value accumulator */
49521 		unsigned int ova2;	/* Output value accumulator */
49522 		unsigned int ova3;	/* Output value accumulator */
49523 		unsigned int ova4;	/* Output value accumulator */
49524 		unsigned int ova5;	/* Output value accumulator */
49525 		unsigned int ova6;	/* Output value accumulator */
49526 		{
49527 			pointer imp;
49528 			unsigned int we0;	/* Weighting value variable */
49529 			unsigned int vo0;	/* Vertex offset variable */
49530 			unsigned int we1;	/* Weighting value variable */
49531 			unsigned int vo1;	/* Vertex offset variable */
49532 			unsigned int we2;	/* Weighting value variable */
49533 			unsigned int vo2;	/* Vertex offset variable */
49534 			unsigned int we3;	/* Weighting value variable */
49535 			unsigned int vo3;	/* Vertex offset variable */
49536 			unsigned int we4;	/* Weighting value variable */
49537 			unsigned int vo4;	/* Vertex offset variable */
49538 			unsigned int we5;	/* Weighting value variable */
49539 			unsigned int vo5;	/* Vertex offset variable */
49540 			unsigned int we6;	/* Weighting value variable */
49541 			unsigned int vo6;	/* Vertex offset variable */
49542 			{
49543 				unsigned int ti_i;	/* Interpolation index variable */
49544 
49545 				ti_i  = IT_IX(it0, ip0[0]);
49546 				we0   = IT_WE(it0, ip0[0]);
49547 				vo0   = IT_VO(it0, ip0[0]);
49548 				ti_i += IT_IX(it1, ip0[1]);
49549 				we1   = IT_WE(it1, ip0[1]);
49550 				vo1   = IT_VO(it1, ip0[1]);
49551 				ti_i += IT_IX(it2, ip0[2]);
49552 				we2   = IT_WE(it2, ip0[2]);
49553 				vo2   = IT_VO(it2, ip0[2]);
49554 				ti_i += IT_IX(it3, ip0[3]);
49555 				we3   = IT_WE(it3, ip0[3]);
49556 				vo3   = IT_VO(it3, ip0[3]);
49557 				ti_i += IT_IX(it4, ip0[4]);
49558 				we4   = IT_WE(it4, ip0[4]);
49559 				vo4   = IT_VO(it4, ip0[4]);
49560 				ti_i += IT_IX(it5, ip0[5]);
49561 				we5   = IT_WE(it5, ip0[5]);
49562 				vo5   = IT_VO(it5, ip0[5]);
49563 				ti_i += IT_IX(it6, ip0[6]);
49564 				we6   = IT_WE(it6, ip0[6]);
49565 				vo6   = IT_VO(it6, ip0[6]);
49566 
49567 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
49568 
49569 				/* Sort weighting values and vertex offset values */
49570 				CEX(we0, vo0, we1, vo1);
49571 				CEX(we0, vo0, we2, vo2);
49572 				CEX(we0, vo0, we3, vo3);
49573 				CEX(we0, vo0, we4, vo4);
49574 				CEX(we0, vo0, we5, vo5);
49575 				CEX(we0, vo0, we6, vo6);
49576 				CEX(we1, vo1, we2, vo2);
49577 				CEX(we1, vo1, we3, vo3);
49578 				CEX(we1, vo1, we4, vo4);
49579 				CEX(we1, vo1, we5, vo5);
49580 				CEX(we1, vo1, we6, vo6);
49581 				CEX(we2, vo2, we3, vo3);
49582 				CEX(we2, vo2, we4, vo4);
49583 				CEX(we2, vo2, we5, vo5);
49584 				CEX(we2, vo2, we6, vo6);
49585 				CEX(we3, vo3, we4, vo4);
49586 				CEX(we3, vo3, we5, vo5);
49587 				CEX(we3, vo3, we6, vo6);
49588 				CEX(we4, vo4, we5, vo5);
49589 				CEX(we4, vo4, we6, vo6);
49590 				CEX(we5, vo5, we6, vo6);
49591 			}
49592 			{
49593 				unsigned int vof;	/* Vertex offset value */
49594 				unsigned int vwe;	/* Vertex weighting */
49595 
49596 				vof = 0;				/* First vertex offset is 0 */
49597 				vwe = 65536 - we0;		/* Baricentric weighting */
49598 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
49599 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
49600 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
49601 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
49602 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
49603 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
49604 				ova6  = IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
49605 				vof += vo0;			/* Move to next vertex */
49606 				vwe = we0 - we1;		/* Baricentric weighting */
49607 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
49608 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
49609 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
49610 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
49611 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
49612 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
49613 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
49614 				vof += vo1;			/* Move to next vertex */
49615 				vwe = we1 - we2;		/* Baricentric weighting */
49616 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
49617 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
49618 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
49619 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
49620 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
49621 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
49622 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
49623 				vof += vo2;			/* Move to next vertex */
49624 				vwe = we2 - we3;		/* Baricentric weighting */
49625 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
49626 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
49627 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
49628 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
49629 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
49630 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
49631 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
49632 				vof += vo3;			/* Move to next vertex */
49633 				vwe = we3 - we4;		/* Baricentric weighting */
49634 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
49635 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
49636 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
49637 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
49638 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
49639 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
49640 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
49641 				vof += vo4;			/* Move to next vertex */
49642 				vwe = we4 - we5;		/* Baricentric weighting */
49643 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
49644 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
49645 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
49646 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
49647 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
49648 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
49649 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
49650 				vof += vo5;			/* Move to next vertex */
49651 				vwe = we5 - we6;		/* Baricentric weighting */
49652 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
49653 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
49654 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
49655 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
49656 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
49657 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
49658 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
49659 				vof += vo6;			/* Move to next vertex */
49660 				vwe = we6;				/* Baricentric weighting */
49661 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
49662 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
49663 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
49664 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
49665 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
49666 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
49667 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
49668 			}
49669 		}
49670 		{
49671 			unsigned int oti;	/* Vertex offset value */
49672 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
49673 			op0[0] = OT_E(ot0, oti);	/* Write result */
49674 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
49675 			op0[1] = OT_E(ot1, oti);	/* Write result */
49676 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
49677 			op0[2] = OT_E(ot2, oti);	/* Write result */
49678 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
49679 			op0[3] = OT_E(ot3, oti);	/* Write result */
49680 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
49681 			op0[4] = OT_E(ot4, oti);	/* Write result */
49682 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
49683 			op0[5] = OT_E(ot5, oti);	/* Write result */
49684 			oti = ((ova6 >> 16) & 0xffff);	/* Extract integer part of result */
49685 			op0[6] = OT_E(ot6, oti);	/* Write result */
49686 		}
49687 	}
49688 }
49689 #undef IT_WE
49690 #undef IT_VO
49691 #undef IT_IX
49692 #undef CEX
49693 #undef IM_O
49694 #undef IM_FE
49695 #undef OT_E
49696 
49697 void
imdi_k139_gen(genspec * g)49698 imdi_k139_gen(
49699 genspec *g			/* structure to be initialised */
49700 ) {
49701 	static unsigned char data[] = {
49702 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
49703 		0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
49704 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49705 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49706 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49707 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49708 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49709 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
49710 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
49711 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
49712 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
49713 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49714 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49715 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49716 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49717 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49718 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49719 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49720 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49721 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
49722 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49723 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49724 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49725 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49726 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
49727 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
49728 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
49729 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
49730 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49731 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49732 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49733 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49734 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49735 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49736 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49737 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49738 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
49739 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
49740 		0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49741 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
49742 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
49743 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
49744 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
49745 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
49746 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
49747 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
49748 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
49749 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
49750 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49751 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
49752 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
49753 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x37, 0x5f,
49754 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
49755 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
49756 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
49757 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
49758 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
49759 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
49760 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
49761 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49762 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49763 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49764 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49765 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
49766 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x33,
49767 		0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49768 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49769 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
49770 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
49771 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
49772 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
49773 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
49774 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
49775 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
49776 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
49777 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
49778 		0x00, 0xf0, 0x04, 0x08
49779 	};	/* Structure image */
49780 
49781 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
49782 }
49783 
49784 void
imdi_k139_tab(tabspec * t)49785 imdi_k139_tab(
49786 tabspec *t			/* structure to be initialised */
49787 ) {
49788 	static unsigned char data[] = {
49789 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
49790 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
49791 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
49792 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
49793 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
49794 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
49795 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
49796 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
49797 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
49798 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49799 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
49800 		0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
49801 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
49802 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
49803 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
49804 		0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49805 		0x0e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
49806 		0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
49807 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49808 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49809 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
49810 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
49811 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
49812 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
49813 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49814 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49815 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49816 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49817 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49818 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49819 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49820 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
49821 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
49822 	};	/* Structure image */
49823 
49824 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
49825 }
49826 
49827 
49828 
49829 
49830 
49831 
49832 /* Integer Multi-Dimensional Interpolation */
49833 /* Interpolation Kernel Code */
49834 /* Generated by cgen */
49835 /* Copyright 2000 - 2002 Graeme W. Gill */
49836 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
49837 
49838 /* see the Licence.txt file for licencing details.*/
49839 
49840 
49841 /*
49842    Interpolation kernel specs:
49843 
49844    Input channels per pixel = 8
49845    Input channel 0 bits = 16
49846    Input channel 0 increment = 8
49847    Input channel 1 bits = 16
49848    Input channel 1 increment = 8
49849    Input channel 2 bits = 16
49850    Input channel 2 increment = 8
49851    Input channel 3 bits = 16
49852    Input channel 3 increment = 8
49853    Input channel 4 bits = 16
49854    Input channel 4 increment = 8
49855    Input channel 5 bits = 16
49856    Input channel 5 increment = 8
49857    Input channel 6 bits = 16
49858    Input channel 6 increment = 8
49859    Input channel 7 bits = 16
49860    Input channel 7 increment = 8
49861    Input is channel interleaved
49862    Input channels are separate words
49863    Input value extraction is done in input table lookup
49864 
49865    Output channels per pixel = 7
49866    Output channel 0 bits = 16
49867    Output channel 0 increment = 7
49868    Output channel 1 bits = 16
49869    Output channel 1 increment = 7
49870    Output channel 2 bits = 16
49871    Output channel 2 increment = 7
49872    Output channel 3 bits = 16
49873    Output channel 3 increment = 7
49874    Output channel 4 bits = 16
49875    Output channel 4 increment = 7
49876    Output channel 5 bits = 16
49877    Output channel 5 increment = 7
49878    Output channel 6 bits = 16
49879    Output channel 6 increment = 7
49880    Output is channel interleaved
49881 
49882    Output channels are separate words
49883    Weight+voffset bits       = 32
49884    Interpolation table index bits = 32
49885    Interpolation table max resolution = 16
49886  */
49887 
49888 /*
49889    Machine architecture specs:
49890 
49891    Little endian
49892    Reading and writing pixel values separately
49893    Pointer size = 32 bits
49894 
49895    Ordinal size  8 bits is known as 'unsigned char'
49896    Ordinal size 16 bits is known as 'unsigned short'
49897    Ordinal size 32 bits is known as 'unsigned int'
49898    Natural ordinal is 'unsigned int'
49899 
49900    Integer size  8 bits is known as 'signed char'
49901    Integer size 16 bits is known as 'short'
49902    Integer size 32 bits is known as 'int'
49903    Natural integer is 'int'
49904 
49905  */
49906 
49907 #ifndef  IMDI_INCLUDED
49908 #include <memory.h>
49909 #include "imdi_imp.h"
49910 #define  IMDI_INCLUDED
49911 #endif  /* IMDI_INCLUDED */
49912 
49913 #ifndef DEFINED_pointer
49914 #define DEFINED_pointer
49915 typedef unsigned char * pointer;
49916 #endif
49917 
49918 /* Input table interp. index */
49919 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
49920 
49921 /* Input table input weighting enty */
49922 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
49923 
49924 /* Input table input offset value enty */
49925 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
49926 
49927 /* Conditional exchange for sorting */
49928 #define CEX(A, AA, B, BB) if (A < B) { \
49929             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
49930 
49931 /* Interpolation multi-dim. table access */
49932 #define IM_O(off) ((off) * 14)
49933 
49934 /* Interpolation table - get vertex values */
49935 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 2 + (c) * 2)))
49936 
49937 /* Output table indexes */
49938 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
49939 
49940 void
imdi_k140(imdi * s,void ** outp,void ** inp,unsigned int npix)49941 imdi_k140(
49942 imdi *s,			/* imdi context */
49943 void **outp,		/* pointer to output pointers */
49944 void **inp,		/* pointer to input pointers */
49945 unsigned int npix	/* Number of pixels to process */
49946 ) {
49947 	imdi_imp *p = (imdi_imp *)(s->impl);
49948 	unsigned short *ip0 = (unsigned short *)inp[0];
49949 	unsigned short *op0 = (unsigned short *)outp[0];
49950 	unsigned short *ep = ip0 + npix * 8 ;
49951 	pointer it0 = (pointer)p->in_tables[0];
49952 	pointer it1 = (pointer)p->in_tables[1];
49953 	pointer it2 = (pointer)p->in_tables[2];
49954 	pointer it3 = (pointer)p->in_tables[3];
49955 	pointer it4 = (pointer)p->in_tables[4];
49956 	pointer it5 = (pointer)p->in_tables[5];
49957 	pointer it6 = (pointer)p->in_tables[6];
49958 	pointer it7 = (pointer)p->in_tables[7];
49959 	pointer ot0 = (pointer)p->out_tables[0];
49960 	pointer ot1 = (pointer)p->out_tables[1];
49961 	pointer ot2 = (pointer)p->out_tables[2];
49962 	pointer ot3 = (pointer)p->out_tables[3];
49963 	pointer ot4 = (pointer)p->out_tables[4];
49964 	pointer ot5 = (pointer)p->out_tables[5];
49965 	pointer ot6 = (pointer)p->out_tables[6];
49966 	pointer im_base = (pointer)p->im_table;
49967 
49968 	for(;ip0 < ep; ip0 += 8, op0 += 7) {
49969 		unsigned int ova0;	/* Output value accumulator */
49970 		unsigned int ova1;	/* Output value accumulator */
49971 		unsigned int ova2;	/* Output value accumulator */
49972 		unsigned int ova3;	/* Output value accumulator */
49973 		unsigned int ova4;	/* Output value accumulator */
49974 		unsigned int ova5;	/* Output value accumulator */
49975 		unsigned int ova6;	/* Output value accumulator */
49976 		{
49977 			pointer imp;
49978 			unsigned int we0;	/* Weighting value variable */
49979 			unsigned int vo0;	/* Vertex offset variable */
49980 			unsigned int we1;	/* Weighting value variable */
49981 			unsigned int vo1;	/* Vertex offset variable */
49982 			unsigned int we2;	/* Weighting value variable */
49983 			unsigned int vo2;	/* Vertex offset variable */
49984 			unsigned int we3;	/* Weighting value variable */
49985 			unsigned int vo3;	/* Vertex offset variable */
49986 			unsigned int we4;	/* Weighting value variable */
49987 			unsigned int vo4;	/* Vertex offset variable */
49988 			unsigned int we5;	/* Weighting value variable */
49989 			unsigned int vo5;	/* Vertex offset variable */
49990 			unsigned int we6;	/* Weighting value variable */
49991 			unsigned int vo6;	/* Vertex offset variable */
49992 			unsigned int we7;	/* Weighting value variable */
49993 			unsigned int vo7;	/* Vertex offset variable */
49994 			{
49995 				unsigned int ti_i;	/* Interpolation index variable */
49996 
49997 				ti_i  = IT_IX(it0, ip0[0]);
49998 				we0   = IT_WE(it0, ip0[0]);
49999 				vo0   = IT_VO(it0, ip0[0]);
50000 				ti_i += IT_IX(it1, ip0[1]);
50001 				we1   = IT_WE(it1, ip0[1]);
50002 				vo1   = IT_VO(it1, ip0[1]);
50003 				ti_i += IT_IX(it2, ip0[2]);
50004 				we2   = IT_WE(it2, ip0[2]);
50005 				vo2   = IT_VO(it2, ip0[2]);
50006 				ti_i += IT_IX(it3, ip0[3]);
50007 				we3   = IT_WE(it3, ip0[3]);
50008 				vo3   = IT_VO(it3, ip0[3]);
50009 				ti_i += IT_IX(it4, ip0[4]);
50010 				we4   = IT_WE(it4, ip0[4]);
50011 				vo4   = IT_VO(it4, ip0[4]);
50012 				ti_i += IT_IX(it5, ip0[5]);
50013 				we5   = IT_WE(it5, ip0[5]);
50014 				vo5   = IT_VO(it5, ip0[5]);
50015 				ti_i += IT_IX(it6, ip0[6]);
50016 				we6   = IT_WE(it6, ip0[6]);
50017 				vo6   = IT_VO(it6, ip0[6]);
50018 				ti_i += IT_IX(it7, ip0[7]);
50019 				we7   = IT_WE(it7, ip0[7]);
50020 				vo7   = IT_VO(it7, ip0[7]);
50021 
50022 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
50023 
50024 				/* Sort weighting values and vertex offset values */
50025 				CEX(we0, vo0, we1, vo1);
50026 				CEX(we0, vo0, we2, vo2);
50027 				CEX(we0, vo0, we3, vo3);
50028 				CEX(we0, vo0, we4, vo4);
50029 				CEX(we0, vo0, we5, vo5);
50030 				CEX(we0, vo0, we6, vo6);
50031 				CEX(we0, vo0, we7, vo7);
50032 				CEX(we1, vo1, we2, vo2);
50033 				CEX(we1, vo1, we3, vo3);
50034 				CEX(we1, vo1, we4, vo4);
50035 				CEX(we1, vo1, we5, vo5);
50036 				CEX(we1, vo1, we6, vo6);
50037 				CEX(we1, vo1, we7, vo7);
50038 				CEX(we2, vo2, we3, vo3);
50039 				CEX(we2, vo2, we4, vo4);
50040 				CEX(we2, vo2, we5, vo5);
50041 				CEX(we2, vo2, we6, vo6);
50042 				CEX(we2, vo2, we7, vo7);
50043 				CEX(we3, vo3, we4, vo4);
50044 				CEX(we3, vo3, we5, vo5);
50045 				CEX(we3, vo3, we6, vo6);
50046 				CEX(we3, vo3, we7, vo7);
50047 				CEX(we4, vo4, we5, vo5);
50048 				CEX(we4, vo4, we6, vo6);
50049 				CEX(we4, vo4, we7, vo7);
50050 				CEX(we5, vo5, we6, vo6);
50051 				CEX(we5, vo5, we7, vo7);
50052 				CEX(we6, vo6, we7, vo7);
50053 			}
50054 			{
50055 				unsigned int vof;	/* Vertex offset value */
50056 				unsigned int vwe;	/* Vertex weighting */
50057 
50058 				vof = 0;				/* First vertex offset is 0 */
50059 				vwe = 65536 - we0;		/* Baricentric weighting */
50060 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
50061 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
50062 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
50063 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
50064 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
50065 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
50066 				ova6  = IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
50067 				vof += vo0;			/* Move to next vertex */
50068 				vwe = we0 - we1;		/* Baricentric weighting */
50069 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
50070 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
50071 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
50072 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
50073 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
50074 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
50075 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
50076 				vof += vo1;			/* Move to next vertex */
50077 				vwe = we1 - we2;		/* Baricentric weighting */
50078 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
50079 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
50080 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
50081 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
50082 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
50083 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
50084 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
50085 				vof += vo2;			/* Move to next vertex */
50086 				vwe = we2 - we3;		/* Baricentric weighting */
50087 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
50088 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
50089 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
50090 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
50091 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
50092 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
50093 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
50094 				vof += vo3;			/* Move to next vertex */
50095 				vwe = we3 - we4;		/* Baricentric weighting */
50096 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
50097 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
50098 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
50099 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
50100 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
50101 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
50102 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
50103 				vof += vo4;			/* Move to next vertex */
50104 				vwe = we4 - we5;		/* Baricentric weighting */
50105 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
50106 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
50107 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
50108 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
50109 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
50110 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
50111 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
50112 				vof += vo5;			/* Move to next vertex */
50113 				vwe = we5 - we6;		/* Baricentric weighting */
50114 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
50115 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
50116 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
50117 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
50118 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
50119 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
50120 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
50121 				vof += vo6;			/* Move to next vertex */
50122 				vwe = we6 - we7;		/* Baricentric weighting */
50123 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
50124 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
50125 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
50126 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
50127 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
50128 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
50129 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
50130 				vof += vo7;			/* Move to next vertex */
50131 				vwe = we7;				/* Baricentric weighting */
50132 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
50133 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
50134 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
50135 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
50136 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
50137 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
50138 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
50139 			}
50140 		}
50141 		{
50142 			unsigned int oti;	/* Vertex offset value */
50143 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
50144 			op0[0] = OT_E(ot0, oti);	/* Write result */
50145 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
50146 			op0[1] = OT_E(ot1, oti);	/* Write result */
50147 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
50148 			op0[2] = OT_E(ot2, oti);	/* Write result */
50149 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
50150 			op0[3] = OT_E(ot3, oti);	/* Write result */
50151 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
50152 			op0[4] = OT_E(ot4, oti);	/* Write result */
50153 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
50154 			op0[5] = OT_E(ot5, oti);	/* Write result */
50155 			oti = ((ova6 >> 16) & 0xffff);	/* Extract integer part of result */
50156 			op0[6] = OT_E(ot6, oti);	/* Write result */
50157 		}
50158 	}
50159 }
50160 #undef IT_WE
50161 #undef IT_VO
50162 #undef IT_IX
50163 #undef CEX
50164 #undef IM_O
50165 #undef IM_FE
50166 #undef OT_E
50167 
50168 void
imdi_k140_gen(genspec * g)50169 imdi_k140_gen(
50170 genspec *g			/* structure to be initialised */
50171 ) {
50172 	static unsigned char data[] = {
50173 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50174 		0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
50175 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50176 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50177 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50178 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50179 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50180 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50181 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50182 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50183 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50184 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50185 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50186 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50187 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50188 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50189 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50190 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50191 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50192 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50193 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50194 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50195 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50196 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50197 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
50198 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
50199 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
50200 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
50201 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50202 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50203 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50204 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50205 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50206 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50207 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50208 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50209 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50210 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50211 		0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50212 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
50213 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
50214 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
50215 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
50216 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
50217 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
50218 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
50219 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
50220 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
50221 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50222 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
50223 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
50224 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x37, 0x5f,
50225 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
50226 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
50227 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
50228 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
50229 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
50230 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
50231 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
50232 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50233 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50234 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50235 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50236 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
50237 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x34,
50238 		0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50239 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50240 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
50241 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
50242 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
50243 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
50244 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
50245 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
50246 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
50247 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
50248 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
50249 		0x00, 0xf0, 0x04, 0x08
50250 	};	/* Structure image */
50251 
50252 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
50253 }
50254 
50255 void
imdi_k140_tab(tabspec * t)50256 imdi_k140_tab(
50257 tabspec *t			/* structure to be initialised */
50258 ) {
50259 	static unsigned char data[] = {
50260 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50261 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50262 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50263 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
50264 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
50265 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
50266 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
50267 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
50268 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
50269 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50270 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
50271 		0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
50272 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
50273 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
50274 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50275 		0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50276 		0x0e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
50277 		0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
50278 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50279 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50280 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50281 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
50282 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
50283 		0x06, 0x00, 0x00, 0x00, 0xdc, 0x60, 0xef, 0xb7,
50284 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50285 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50286 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50287 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50288 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50289 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50290 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50291 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50292 		0x14, 0xda, 0x83, 0xbf, 0xff, 0xff, 0xff, 0xff
50293 	};	/* Structure image */
50294 
50295 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
50296 }
50297 
50298 
50299 
50300 
50301 
50302 
50303 /* Integer Multi-Dimensional Interpolation */
50304 /* Interpolation Kernel Code */
50305 /* Generated by cgen */
50306 /* Copyright 2000 - 2002 Graeme W. Gill */
50307 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
50308 
50309 /* see the Licence.txt file for licencing details.*/
50310 
50311 
50312 /*
50313    Interpolation kernel specs:
50314 
50315    Input channels per pixel = 1
50316    Input channel 0 bits = 16
50317    Input channel 0 increment = 1
50318    Input is channel interleaved
50319    Input channels are separate words
50320    Input value extraction is done in input table lookup
50321 
50322    Output channels per pixel = 8
50323    Output channel 0 bits = 16
50324    Output channel 0 increment = 8
50325    Output channel 1 bits = 16
50326    Output channel 1 increment = 8
50327    Output channel 2 bits = 16
50328    Output channel 2 increment = 8
50329    Output channel 3 bits = 16
50330    Output channel 3 increment = 8
50331    Output channel 4 bits = 16
50332    Output channel 4 increment = 8
50333    Output channel 5 bits = 16
50334    Output channel 5 increment = 8
50335    Output channel 6 bits = 16
50336    Output channel 6 increment = 8
50337    Output channel 7 bits = 16
50338    Output channel 7 increment = 8
50339    Output is channel interleaved
50340 
50341    Output channels are separate words
50342    Weight+voffset bits       = 32
50343    Interpolation table index bits = 11
50344    Interpolation table max resolution = 2048
50345  */
50346 
50347 /*
50348    Machine architecture specs:
50349 
50350    Little endian
50351    Reading and writing pixel values separately
50352    Pointer size = 32 bits
50353 
50354    Ordinal size  8 bits is known as 'unsigned char'
50355    Ordinal size 16 bits is known as 'unsigned short'
50356    Ordinal size 32 bits is known as 'unsigned int'
50357    Natural ordinal is 'unsigned int'
50358 
50359    Integer size  8 bits is known as 'signed char'
50360    Integer size 16 bits is known as 'short'
50361    Integer size 32 bits is known as 'int'
50362    Natural integer is 'int'
50363 
50364  */
50365 
50366 #ifndef  IMDI_INCLUDED
50367 #include <memory.h>
50368 #include "imdi_imp.h"
50369 #define  IMDI_INCLUDED
50370 #endif  /* IMDI_INCLUDED */
50371 
50372 #ifndef DEFINED_pointer
50373 #define DEFINED_pointer
50374 typedef unsigned char * pointer;
50375 #endif
50376 
50377 /* Input table interp index, weighting and vertex offset */
50378 #define IT_IT(p, off) *((unsigned int *)((p) + 0 + (off) * 4))
50379 
50380 /* Conditional exchange for sorting */
50381 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
50382 
50383 /* Interpolation multi-dim. table access */
50384 #define IM_O(off) ((off) * 16)
50385 
50386 /* Interpolation table - get vertex values */
50387 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 8 + (c) * 2)))
50388 
50389 /* Output table indexes */
50390 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
50391 
50392 void
imdi_k141(imdi * s,void ** outp,void ** inp,unsigned int npix)50393 imdi_k141(
50394 imdi *s,			/* imdi context */
50395 void **outp,		/* pointer to output pointers */
50396 void **inp,		/* pointer to input pointers */
50397 unsigned int npix	/* Number of pixels to process */
50398 ) {
50399 	imdi_imp *p = (imdi_imp *)(s->impl);
50400 	unsigned short *ip0 = (unsigned short *)inp[0];
50401 	unsigned short *op0 = (unsigned short *)outp[0];
50402 	unsigned short *ep = ip0 + npix * 1 ;
50403 	pointer it0 = (pointer)p->in_tables[0];
50404 	pointer ot0 = (pointer)p->out_tables[0];
50405 	pointer ot1 = (pointer)p->out_tables[1];
50406 	pointer ot2 = (pointer)p->out_tables[2];
50407 	pointer ot3 = (pointer)p->out_tables[3];
50408 	pointer ot4 = (pointer)p->out_tables[4];
50409 	pointer ot5 = (pointer)p->out_tables[5];
50410 	pointer ot6 = (pointer)p->out_tables[6];
50411 	pointer ot7 = (pointer)p->out_tables[7];
50412 	pointer im_base = (pointer)p->im_table;
50413 
50414 	for(;ip0 < ep; ip0 += 1, op0 += 8) {
50415 		unsigned int ova0;	/* Output value accumulator */
50416 		unsigned int ova1;	/* Output value accumulator */
50417 		unsigned int ova2;	/* Output value accumulator */
50418 		unsigned int ova3;	/* Output value accumulator */
50419 		unsigned int ova4;	/* Output value accumulator */
50420 		unsigned int ova5;	/* Output value accumulator */
50421 		unsigned int ova6;	/* Output value accumulator */
50422 		unsigned int ova7;	/* Output value accumulator */
50423 		{
50424 			pointer imp;
50425 			unsigned int wo0;	/* Weighting value and vertex offset variable */
50426 			{
50427 				unsigned int ti;		/* Input table entry variable */
50428 				unsigned int ti_i;	/* Interpolation index variable */
50429 
50430 				ti = IT_IT(it0, ip0[0]);
50431 				wo0   = (ti & 0x1fffff);	/* Extract weighting/vertex offset value */
50432 				ti_i  = (ti >> 21);	/* Extract interpolation table value */
50433 
50434 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
50435 
50436 				/* Sort weighting values and vertex offset values */
50437 			}
50438 			{
50439 				unsigned int nvof;	/* Next vertex offset value */
50440 				unsigned int vof;	/* Vertex offset value */
50441 				unsigned int vwe;	/* Vertex weighting */
50442 
50443 				vof = 0;				/* First vertex offset is 0 */
50444 				nvof = (wo0 & 0xf);	/* Extract offset value */
50445 				wo0 = (wo0 >> 4);		/* Extract weighting value */
50446 				vwe = 65536 - wo0;		/* Baricentric weighting */
50447 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
50448 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
50449 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
50450 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
50451 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
50452 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
50453 				ova6  = IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
50454 				ova7  = IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
50455 				vof += nvof;			/* Move to next vertex */
50456 				vwe = wo0;				/* Baricentric weighting */
50457 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
50458 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
50459 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
50460 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
50461 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
50462 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
50463 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
50464 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
50465 			}
50466 		}
50467 		{
50468 			unsigned int oti;	/* Vertex offset value */
50469 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
50470 			op0[0] = OT_E(ot0, oti);	/* Write result */
50471 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
50472 			op0[1] = OT_E(ot1, oti);	/* Write result */
50473 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
50474 			op0[2] = OT_E(ot2, oti);	/* Write result */
50475 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
50476 			op0[3] = OT_E(ot3, oti);	/* Write result */
50477 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
50478 			op0[4] = OT_E(ot4, oti);	/* Write result */
50479 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
50480 			op0[5] = OT_E(ot5, oti);	/* Write result */
50481 			oti = ((ova6 >> 16) & 0xffff);	/* Extract integer part of result */
50482 			op0[6] = OT_E(ot6, oti);	/* Write result */
50483 			oti = ((ova7 >> 16) & 0xffff);	/* Extract integer part of result */
50484 			op0[7] = OT_E(ot7, oti);	/* Write result */
50485 		}
50486 	}
50487 }
50488 #undef IT_IT
50489 #undef CEX
50490 #undef IM_O
50491 #undef IM_FE
50492 #undef OT_E
50493 
50494 void
imdi_k141_gen(genspec * g)50495 imdi_k141_gen(
50496 genspec *g			/* structure to be initialised */
50497 ) {
50498 	static unsigned char data[] = {
50499 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50500 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
50501 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50502 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50503 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50504 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50505 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50506 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50507 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50508 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50509 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50510 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50511 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50512 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50513 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50514 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50515 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50516 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50517 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50518 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50519 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50520 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50521 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50522 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50523 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50524 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50525 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50526 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50527 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50528 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50529 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50530 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50531 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50532 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50533 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50534 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50535 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50536 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50537 		0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50538 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
50539 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
50540 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
50541 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
50542 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
50543 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
50544 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
50545 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
50546 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
50547 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50548 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
50549 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
50550 		0x2c, 0xf3, 0xdc, 0xb7, 0x31, 0x5f, 0x38, 0x5f,
50551 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
50552 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
50553 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
50554 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
50555 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
50556 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
50557 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
50558 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50559 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50560 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50561 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50562 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
50563 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x34,
50564 		0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50565 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50566 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
50567 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
50568 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
50569 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
50570 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
50571 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
50572 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
50573 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
50574 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
50575 		0x00, 0xf0, 0x04, 0x08
50576 	};	/* Structure image */
50577 
50578 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
50579 }
50580 
50581 void
imdi_k141_tab(tabspec * t)50582 imdi_k141_tab(
50583 tabspec *t			/* structure to be initialised */
50584 ) {
50585 	static unsigned char data[] = {
50586 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50587 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50588 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50589 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
50590 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
50591 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
50592 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
50593 		0x0b, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
50594 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
50595 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50596 		0x14, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
50597 		0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
50598 		0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
50599 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
50600 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50601 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50602 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50603 		0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50604 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50605 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50606 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50607 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
50608 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
50609 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
50610 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50611 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50612 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50613 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50614 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50615 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50616 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50617 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50618 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
50619 	};	/* Structure image */
50620 
50621 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
50622 }
50623 
50624 
50625 
50626 
50627 
50628 
50629 /* Integer Multi-Dimensional Interpolation */
50630 /* Interpolation Kernel Code */
50631 /* Generated by cgen */
50632 /* Copyright 2000 - 2002 Graeme W. Gill */
50633 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
50634 
50635 /* see the Licence.txt file for licencing details.*/
50636 
50637 
50638 /*
50639    Interpolation kernel specs:
50640 
50641    Input channels per pixel = 3
50642    Input channel 0 bits = 16
50643    Input channel 0 increment = 3
50644    Input channel 1 bits = 16
50645    Input channel 1 increment = 3
50646    Input channel 2 bits = 16
50647    Input channel 2 increment = 3
50648    Input is channel interleaved
50649    Input channels are separate words
50650    Input value extraction is done in input table lookup
50651 
50652    Output channels per pixel = 8
50653    Output channel 0 bits = 16
50654    Output channel 0 increment = 8
50655    Output channel 1 bits = 16
50656    Output channel 1 increment = 8
50657    Output channel 2 bits = 16
50658    Output channel 2 increment = 8
50659    Output channel 3 bits = 16
50660    Output channel 3 increment = 8
50661    Output channel 4 bits = 16
50662    Output channel 4 increment = 8
50663    Output channel 5 bits = 16
50664    Output channel 5 increment = 8
50665    Output channel 6 bits = 16
50666    Output channel 6 increment = 8
50667    Output channel 7 bits = 16
50668    Output channel 7 increment = 8
50669    Output is channel interleaved
50670 
50671    Output channels are separate words
50672    Weight+voffset bits       = 32
50673    Interpolation table index bits = 16
50674    Interpolation table max resolution = 40
50675  */
50676 
50677 /*
50678    Machine architecture specs:
50679 
50680    Little endian
50681    Reading and writing pixel values separately
50682    Pointer size = 32 bits
50683 
50684    Ordinal size  8 bits is known as 'unsigned char'
50685    Ordinal size 16 bits is known as 'unsigned short'
50686    Ordinal size 32 bits is known as 'unsigned int'
50687    Natural ordinal is 'unsigned int'
50688 
50689    Integer size  8 bits is known as 'signed char'
50690    Integer size 16 bits is known as 'short'
50691    Integer size 32 bits is known as 'int'
50692    Natural integer is 'int'
50693 
50694  */
50695 
50696 #ifndef  IMDI_INCLUDED
50697 #include <memory.h>
50698 #include "imdi_imp.h"
50699 #define  IMDI_INCLUDED
50700 #endif  /* IMDI_INCLUDED */
50701 
50702 #ifndef DEFINED_pointer
50703 #define DEFINED_pointer
50704 typedef unsigned char * pointer;
50705 #endif
50706 
50707 /* Input table interp. index */
50708 #define IT_IX(p, off) *((unsigned short *)((p) + 0 + (off) * 6))
50709 
50710 /* Input table input weighting/offset value enty */
50711 #define IT_WO(p, off) *((unsigned int *)((p) + 2 + (off) * 6))
50712 
50713 /* Conditional exchange for sorting */
50714 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
50715 
50716 /* Interpolation multi-dim. table access */
50717 #define IM_O(off) ((off) * 16)
50718 
50719 /* Interpolation table - get vertex values */
50720 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 8 + (c) * 2)))
50721 
50722 /* Output table indexes */
50723 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
50724 
50725 void
imdi_k142(imdi * s,void ** outp,void ** inp,unsigned int npix)50726 imdi_k142(
50727 imdi *s,			/* imdi context */
50728 void **outp,		/* pointer to output pointers */
50729 void **inp,		/* pointer to input pointers */
50730 unsigned int npix	/* Number of pixels to process */
50731 ) {
50732 	imdi_imp *p = (imdi_imp *)(s->impl);
50733 	unsigned short *ip0 = (unsigned short *)inp[0];
50734 	unsigned short *op0 = (unsigned short *)outp[0];
50735 	unsigned short *ep = ip0 + npix * 3 ;
50736 	pointer it0 = (pointer)p->in_tables[0];
50737 	pointer it1 = (pointer)p->in_tables[1];
50738 	pointer it2 = (pointer)p->in_tables[2];
50739 	pointer ot0 = (pointer)p->out_tables[0];
50740 	pointer ot1 = (pointer)p->out_tables[1];
50741 	pointer ot2 = (pointer)p->out_tables[2];
50742 	pointer ot3 = (pointer)p->out_tables[3];
50743 	pointer ot4 = (pointer)p->out_tables[4];
50744 	pointer ot5 = (pointer)p->out_tables[5];
50745 	pointer ot6 = (pointer)p->out_tables[6];
50746 	pointer ot7 = (pointer)p->out_tables[7];
50747 	pointer im_base = (pointer)p->im_table;
50748 
50749 	for(;ip0 < ep; ip0 += 3, op0 += 8) {
50750 		unsigned int ova0;	/* Output value accumulator */
50751 		unsigned int ova1;	/* Output value accumulator */
50752 		unsigned int ova2;	/* Output value accumulator */
50753 		unsigned int ova3;	/* Output value accumulator */
50754 		unsigned int ova4;	/* Output value accumulator */
50755 		unsigned int ova5;	/* Output value accumulator */
50756 		unsigned int ova6;	/* Output value accumulator */
50757 		unsigned int ova7;	/* Output value accumulator */
50758 		{
50759 			pointer imp;
50760 			unsigned int wo0;	/* Weighting value and vertex offset variable */
50761 			unsigned int wo1;	/* Weighting value and vertex offset variable */
50762 			unsigned int wo2;	/* Weighting value and vertex offset variable */
50763 			{
50764 				unsigned int ti_i;	/* Interpolation index variable */
50765 
50766 				ti_i  = IT_IX(it0, ip0[0]);
50767 				wo0   = IT_WO(it0, ip0[0]);
50768 				ti_i += IT_IX(it1, ip0[1]);
50769 				wo1   = IT_WO(it1, ip0[1]);
50770 				ti_i += IT_IX(it2, ip0[2]);
50771 				wo2   = IT_WO(it2, ip0[2]);
50772 
50773 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
50774 
50775 				/* Sort weighting values and vertex offset values */
50776 				CEX(wo0, wo1);
50777 				CEX(wo0, wo2);
50778 				CEX(wo1, wo2);
50779 			}
50780 			{
50781 				unsigned int nvof;	/* Next vertex offset value */
50782 				unsigned int vof;	/* Vertex offset value */
50783 				unsigned int vwe;	/* Vertex weighting */
50784 
50785 				vof = 0;				/* First vertex offset is 0 */
50786 				nvof = (wo0 & 0x7fff);	/* Extract offset value */
50787 				wo0 = (wo0 >> 15);		/* Extract weighting value */
50788 				vwe = 65536 - wo0;		/* Baricentric weighting */
50789 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
50790 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
50791 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
50792 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
50793 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
50794 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
50795 				ova6  = IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
50796 				ova7  = IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
50797 				vof += nvof;			/* Move to next vertex */
50798 				nvof = (wo1 & 0x7fff);	/* Extract offset value */
50799 				wo1 = (wo1 >> 15);		/* Extract weighting value */
50800 				vwe = wo0 - wo1;		/* Baricentric weighting */
50801 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
50802 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
50803 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
50804 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
50805 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
50806 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
50807 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
50808 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
50809 				vof += nvof;			/* Move to next vertex */
50810 				nvof = (wo2 & 0x7fff);	/* Extract offset value */
50811 				wo2 = (wo2 >> 15);		/* Extract weighting value */
50812 				vwe = wo1 - wo2;		/* Baricentric weighting */
50813 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
50814 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
50815 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
50816 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
50817 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
50818 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
50819 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
50820 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
50821 				vof += nvof;			/* Move to next vertex */
50822 				vwe = wo2;				/* Baricentric weighting */
50823 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
50824 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
50825 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
50826 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
50827 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
50828 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
50829 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
50830 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
50831 			}
50832 		}
50833 		{
50834 			unsigned int oti;	/* Vertex offset value */
50835 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
50836 			op0[0] = OT_E(ot0, oti);	/* Write result */
50837 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
50838 			op0[1] = OT_E(ot1, oti);	/* Write result */
50839 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
50840 			op0[2] = OT_E(ot2, oti);	/* Write result */
50841 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
50842 			op0[3] = OT_E(ot3, oti);	/* Write result */
50843 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
50844 			op0[4] = OT_E(ot4, oti);	/* Write result */
50845 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
50846 			op0[5] = OT_E(ot5, oti);	/* Write result */
50847 			oti = ((ova6 >> 16) & 0xffff);	/* Extract integer part of result */
50848 			op0[6] = OT_E(ot6, oti);	/* Write result */
50849 			oti = ((ova7 >> 16) & 0xffff);	/* Extract integer part of result */
50850 			op0[7] = OT_E(ot7, oti);	/* Write result */
50851 		}
50852 	}
50853 }
50854 #undef IT_WO
50855 #undef IT_IX
50856 #undef CEX
50857 #undef IM_O
50858 #undef IM_FE
50859 #undef OT_E
50860 
50861 void
imdi_k142_gen(genspec * g)50862 imdi_k142_gen(
50863 genspec *g			/* structure to be initialised */
50864 ) {
50865 	static unsigned char data[] = {
50866 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
50867 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
50868 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50869 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50870 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50871 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50872 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50873 		0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
50874 		0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
50875 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50876 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50877 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50878 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50879 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50880 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50881 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50882 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50883 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50884 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50885 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50886 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50887 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50888 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50889 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50890 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50891 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50892 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50893 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50894 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50895 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50896 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50897 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50898 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50899 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50900 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50901 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50902 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50903 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50904 		0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50905 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
50906 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
50907 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
50908 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
50909 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
50910 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
50911 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
50912 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
50913 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
50914 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50915 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
50916 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
50917 		0x2c, 0xf3, 0xdc, 0xb7, 0x33, 0x5f, 0x38, 0x5f,
50918 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
50919 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
50920 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
50921 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
50922 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
50923 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
50924 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
50925 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50926 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50927 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50928 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50929 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
50930 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x34,
50931 		0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50932 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50933 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
50934 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
50935 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
50936 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
50937 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
50938 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
50939 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
50940 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
50941 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
50942 		0x00, 0xf0, 0x04, 0x08
50943 	};	/* Structure image */
50944 
50945 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
50946 }
50947 
50948 void
imdi_k142_tab(tabspec * t)50949 imdi_k142_tab(
50950 tabspec *t			/* structure to be initialised */
50951 ) {
50952 	static unsigned char data[] = {
50953 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50954 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50955 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50956 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
50957 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
50958 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
50959 		0x20, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
50960 		0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
50961 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
50962 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50963 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
50964 		0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
50965 		0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
50966 		0x04, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
50967 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50968 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50969 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50970 		0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
50971 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50972 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50973 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
50974 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
50975 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
50976 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
50977 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50978 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50979 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50980 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50981 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50982 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50983 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50984 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
50985 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
50986 	};	/* Structure image */
50987 
50988 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
50989 }
50990 
50991 
50992 
50993 
50994 
50995 
50996 /* Integer Multi-Dimensional Interpolation */
50997 /* Interpolation Kernel Code */
50998 /* Generated by cgen */
50999 /* Copyright 2000 - 2002 Graeme W. Gill */
51000 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
51001 
51002 /* see the Licence.txt file for licencing details.*/
51003 
51004 
51005 /*
51006    Interpolation kernel specs:
51007 
51008    Input channels per pixel = 4
51009    Input channel 0 bits = 16
51010    Input channel 0 increment = 4
51011    Input channel 1 bits = 16
51012    Input channel 1 increment = 4
51013    Input channel 2 bits = 16
51014    Input channel 2 increment = 4
51015    Input channel 3 bits = 16
51016    Input channel 3 increment = 4
51017    Input is channel interleaved
51018    Input channels are separate words
51019    Input value extraction is done in input table lookup
51020 
51021    Output channels per pixel = 8
51022    Output channel 0 bits = 16
51023    Output channel 0 increment = 8
51024    Output channel 1 bits = 16
51025    Output channel 1 increment = 8
51026    Output channel 2 bits = 16
51027    Output channel 2 increment = 8
51028    Output channel 3 bits = 16
51029    Output channel 3 increment = 8
51030    Output channel 4 bits = 16
51031    Output channel 4 increment = 8
51032    Output channel 5 bits = 16
51033    Output channel 5 increment = 8
51034    Output channel 6 bits = 16
51035    Output channel 6 increment = 8
51036    Output channel 7 bits = 16
51037    Output channel 7 increment = 8
51038    Output is channel interleaved
51039 
51040    Output channels are separate words
51041    Weight+voffset bits       = 32
51042    Interpolation table index bits = 32
51043    Interpolation table max resolution = 25
51044  */
51045 
51046 /*
51047    Machine architecture specs:
51048 
51049    Little endian
51050    Reading and writing pixel values separately
51051    Pointer size = 32 bits
51052 
51053    Ordinal size  8 bits is known as 'unsigned char'
51054    Ordinal size 16 bits is known as 'unsigned short'
51055    Ordinal size 32 bits is known as 'unsigned int'
51056    Natural ordinal is 'unsigned int'
51057 
51058    Integer size  8 bits is known as 'signed char'
51059    Integer size 16 bits is known as 'short'
51060    Integer size 32 bits is known as 'int'
51061    Natural integer is 'int'
51062 
51063  */
51064 
51065 #ifndef  IMDI_INCLUDED
51066 #include <memory.h>
51067 #include "imdi_imp.h"
51068 #define  IMDI_INCLUDED
51069 #endif  /* IMDI_INCLUDED */
51070 
51071 #ifndef DEFINED_pointer
51072 #define DEFINED_pointer
51073 typedef unsigned char * pointer;
51074 #endif
51075 
51076 /* Input table interp. index */
51077 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 8))
51078 
51079 /* Input table input weighting/offset value enty */
51080 #define IT_WO(p, off) *((unsigned int *)((p) + 4 + (off) * 8))
51081 
51082 /* Conditional exchange for sorting */
51083 #define CEX(A, B) if (A < B) { A ^= B; B ^= A; A ^= B; }
51084 
51085 /* Interpolation multi-dim. table access */
51086 #define IM_O(off) ((off) * 16)
51087 
51088 /* Interpolation table - get vertex values */
51089 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 8 + (c) * 2)))
51090 
51091 /* Output table indexes */
51092 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
51093 
51094 void
imdi_k143(imdi * s,void ** outp,void ** inp,unsigned int npix)51095 imdi_k143(
51096 imdi *s,			/* imdi context */
51097 void **outp,		/* pointer to output pointers */
51098 void **inp,		/* pointer to input pointers */
51099 unsigned int npix	/* Number of pixels to process */
51100 ) {
51101 	imdi_imp *p = (imdi_imp *)(s->impl);
51102 	unsigned short *ip0 = (unsigned short *)inp[0];
51103 	unsigned short *op0 = (unsigned short *)outp[0];
51104 	unsigned short *ep = ip0 + npix * 4 ;
51105 	pointer it0 = (pointer)p->in_tables[0];
51106 	pointer it1 = (pointer)p->in_tables[1];
51107 	pointer it2 = (pointer)p->in_tables[2];
51108 	pointer it3 = (pointer)p->in_tables[3];
51109 	pointer ot0 = (pointer)p->out_tables[0];
51110 	pointer ot1 = (pointer)p->out_tables[1];
51111 	pointer ot2 = (pointer)p->out_tables[2];
51112 	pointer ot3 = (pointer)p->out_tables[3];
51113 	pointer ot4 = (pointer)p->out_tables[4];
51114 	pointer ot5 = (pointer)p->out_tables[5];
51115 	pointer ot6 = (pointer)p->out_tables[6];
51116 	pointer ot7 = (pointer)p->out_tables[7];
51117 	pointer im_base = (pointer)p->im_table;
51118 
51119 	for(;ip0 < ep; ip0 += 4, op0 += 8) {
51120 		unsigned int ova0;	/* Output value accumulator */
51121 		unsigned int ova1;	/* Output value accumulator */
51122 		unsigned int ova2;	/* Output value accumulator */
51123 		unsigned int ova3;	/* Output value accumulator */
51124 		unsigned int ova4;	/* Output value accumulator */
51125 		unsigned int ova5;	/* Output value accumulator */
51126 		unsigned int ova6;	/* Output value accumulator */
51127 		unsigned int ova7;	/* Output value accumulator */
51128 		{
51129 			pointer imp;
51130 			unsigned int wo0;	/* Weighting value and vertex offset variable */
51131 			unsigned int wo1;	/* Weighting value and vertex offset variable */
51132 			unsigned int wo2;	/* Weighting value and vertex offset variable */
51133 			unsigned int wo3;	/* Weighting value and vertex offset variable */
51134 			{
51135 				unsigned int ti_i;	/* Interpolation index variable */
51136 
51137 				ti_i  = IT_IX(it0, ip0[0]);
51138 				wo0   = IT_WO(it0, ip0[0]);
51139 				ti_i += IT_IX(it1, ip0[1]);
51140 				wo1   = IT_WO(it1, ip0[1]);
51141 				ti_i += IT_IX(it2, ip0[2]);
51142 				wo2   = IT_WO(it2, ip0[2]);
51143 				ti_i += IT_IX(it3, ip0[3]);
51144 				wo3   = IT_WO(it3, ip0[3]);
51145 
51146 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
51147 
51148 				/* Sort weighting values and vertex offset values */
51149 				CEX(wo0, wo1);
51150 				CEX(wo0, wo2);
51151 				CEX(wo0, wo3);
51152 				CEX(wo1, wo2);
51153 				CEX(wo1, wo3);
51154 				CEX(wo2, wo3);
51155 			}
51156 			{
51157 				unsigned int nvof;	/* Next vertex offset value */
51158 				unsigned int vof;	/* Vertex offset value */
51159 				unsigned int vwe;	/* Vertex weighting */
51160 
51161 				vof = 0;				/* First vertex offset is 0 */
51162 				nvof = (wo0 & 0x7fff);	/* Extract offset value */
51163 				wo0 = (wo0 >> 15);		/* Extract weighting value */
51164 				vwe = 65536 - wo0;		/* Baricentric weighting */
51165 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
51166 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
51167 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
51168 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
51169 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
51170 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
51171 				ova6  = IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
51172 				ova7  = IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
51173 				vof += nvof;			/* Move to next vertex */
51174 				nvof = (wo1 & 0x7fff);	/* Extract offset value */
51175 				wo1 = (wo1 >> 15);		/* Extract weighting value */
51176 				vwe = wo0 - wo1;		/* Baricentric weighting */
51177 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
51178 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
51179 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
51180 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
51181 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
51182 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
51183 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
51184 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
51185 				vof += nvof;			/* Move to next vertex */
51186 				nvof = (wo2 & 0x7fff);	/* Extract offset value */
51187 				wo2 = (wo2 >> 15);		/* Extract weighting value */
51188 				vwe = wo1 - wo2;		/* Baricentric weighting */
51189 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
51190 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
51191 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
51192 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
51193 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
51194 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
51195 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
51196 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
51197 				vof += nvof;			/* Move to next vertex */
51198 				nvof = (wo3 & 0x7fff);	/* Extract offset value */
51199 				wo3 = (wo3 >> 15);		/* Extract weighting value */
51200 				vwe = wo2 - wo3;		/* Baricentric weighting */
51201 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
51202 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
51203 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
51204 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
51205 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
51206 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
51207 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
51208 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
51209 				vof += nvof;			/* Move to next vertex */
51210 				vwe = wo3;				/* Baricentric weighting */
51211 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
51212 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
51213 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
51214 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
51215 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
51216 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
51217 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
51218 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
51219 			}
51220 		}
51221 		{
51222 			unsigned int oti;	/* Vertex offset value */
51223 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
51224 			op0[0] = OT_E(ot0, oti);	/* Write result */
51225 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
51226 			op0[1] = OT_E(ot1, oti);	/* Write result */
51227 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
51228 			op0[2] = OT_E(ot2, oti);	/* Write result */
51229 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
51230 			op0[3] = OT_E(ot3, oti);	/* Write result */
51231 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
51232 			op0[4] = OT_E(ot4, oti);	/* Write result */
51233 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
51234 			op0[5] = OT_E(ot5, oti);	/* Write result */
51235 			oti = ((ova6 >> 16) & 0xffff);	/* Extract integer part of result */
51236 			op0[6] = OT_E(ot6, oti);	/* Write result */
51237 			oti = ((ova7 >> 16) & 0xffff);	/* Extract integer part of result */
51238 			op0[7] = OT_E(ot7, oti);	/* Write result */
51239 		}
51240 	}
51241 }
51242 #undef IT_WO
51243 #undef IT_IX
51244 #undef CEX
51245 #undef IM_O
51246 #undef IM_FE
51247 #undef OT_E
51248 
51249 void
imdi_k143_gen(genspec * g)51250 imdi_k143_gen(
51251 genspec *g			/* structure to be initialised */
51252 ) {
51253 	static unsigned char data[] = {
51254 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
51255 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
51256 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51257 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51258 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51259 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51260 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51261 		0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
51262 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
51263 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
51264 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
51265 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51266 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51267 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51268 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51269 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51270 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51271 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51272 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51273 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
51274 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51275 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51276 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51277 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51278 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
51279 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
51280 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
51281 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
51282 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51283 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51284 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51285 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51286 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51287 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51288 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51289 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51290 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
51291 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
51292 		0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51293 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
51294 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
51295 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
51296 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
51297 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
51298 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
51299 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
51300 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
51301 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
51302 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51303 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
51304 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
51305 		0x2c, 0xf3, 0xdc, 0xb7, 0x34, 0x5f, 0x38, 0x5f,
51306 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
51307 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
51308 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
51309 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
51310 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
51311 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
51312 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
51313 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51314 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51315 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51316 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51317 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
51318 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x34,
51319 		0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51320 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51321 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
51322 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
51323 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
51324 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
51325 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
51326 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
51327 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
51328 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
51329 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
51330 		0x00, 0xf0, 0x04, 0x08
51331 	};	/* Structure image */
51332 
51333 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
51334 }
51335 
51336 void
imdi_k143_tab(tabspec * t)51337 imdi_k143_tab(
51338 tabspec *t			/* structure to be initialised */
51339 ) {
51340 	static unsigned char data[] = {
51341 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
51342 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
51343 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
51344 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
51345 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
51346 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
51347 		0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
51348 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
51349 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
51350 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51351 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
51352 		0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
51353 		0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
51354 		0x04, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
51355 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
51356 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51357 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
51358 		0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
51359 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51360 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51361 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
51362 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
51363 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
51364 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
51365 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51366 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51367 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51368 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51369 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51370 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51371 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51372 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51373 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
51374 	};	/* Structure image */
51375 
51376 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
51377 }
51378 
51379 
51380 
51381 
51382 
51383 
51384 /* Integer Multi-Dimensional Interpolation */
51385 /* Interpolation Kernel Code */
51386 /* Generated by cgen */
51387 /* Copyright 2000 - 2002 Graeme W. Gill */
51388 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
51389 
51390 /* see the Licence.txt file for licencing details.*/
51391 
51392 
51393 /*
51394    Interpolation kernel specs:
51395 
51396    Input channels per pixel = 5
51397    Input channel 0 bits = 16
51398    Input channel 0 increment = 5
51399    Input channel 1 bits = 16
51400    Input channel 1 increment = 5
51401    Input channel 2 bits = 16
51402    Input channel 2 increment = 5
51403    Input channel 3 bits = 16
51404    Input channel 3 increment = 5
51405    Input channel 4 bits = 16
51406    Input channel 4 increment = 5
51407    Input is channel interleaved
51408    Input channels are separate words
51409    Input value extraction is done in input table lookup
51410 
51411    Output channels per pixel = 8
51412    Output channel 0 bits = 16
51413    Output channel 0 increment = 8
51414    Output channel 1 bits = 16
51415    Output channel 1 increment = 8
51416    Output channel 2 bits = 16
51417    Output channel 2 increment = 8
51418    Output channel 3 bits = 16
51419    Output channel 3 increment = 8
51420    Output channel 4 bits = 16
51421    Output channel 4 increment = 8
51422    Output channel 5 bits = 16
51423    Output channel 5 increment = 8
51424    Output channel 6 bits = 16
51425    Output channel 6 increment = 8
51426    Output channel 7 bits = 16
51427    Output channel 7 increment = 8
51428    Output is channel interleaved
51429 
51430    Output channels are separate words
51431    Weight+voffset bits       = 32
51432    Interpolation table index bits = 32
51433    Interpolation table max resolution = 84
51434  */
51435 
51436 /*
51437    Machine architecture specs:
51438 
51439    Little endian
51440    Reading and writing pixel values separately
51441    Pointer size = 32 bits
51442 
51443    Ordinal size  8 bits is known as 'unsigned char'
51444    Ordinal size 16 bits is known as 'unsigned short'
51445    Ordinal size 32 bits is known as 'unsigned int'
51446    Natural ordinal is 'unsigned int'
51447 
51448    Integer size  8 bits is known as 'signed char'
51449    Integer size 16 bits is known as 'short'
51450    Integer size 32 bits is known as 'int'
51451    Natural integer is 'int'
51452 
51453  */
51454 
51455 #ifndef  IMDI_INCLUDED
51456 #include <memory.h>
51457 #include "imdi_imp.h"
51458 #define  IMDI_INCLUDED
51459 #endif  /* IMDI_INCLUDED */
51460 
51461 #ifndef DEFINED_pointer
51462 #define DEFINED_pointer
51463 typedef unsigned char * pointer;
51464 #endif
51465 
51466 /* Input table interp. index */
51467 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
51468 
51469 /* Input table input weighting enty */
51470 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
51471 
51472 /* Input table input offset value enty */
51473 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
51474 
51475 /* Conditional exchange for sorting */
51476 #define CEX(A, AA, B, BB) if (A < B) { \
51477             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
51478 
51479 /* Interpolation multi-dim. table access */
51480 #define IM_O(off) ((off) * 16)
51481 
51482 /* Interpolation table - get vertex values */
51483 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 8 + (c) * 2)))
51484 
51485 /* Output table indexes */
51486 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
51487 
51488 void
imdi_k144(imdi * s,void ** outp,void ** inp,unsigned int npix)51489 imdi_k144(
51490 imdi *s,			/* imdi context */
51491 void **outp,		/* pointer to output pointers */
51492 void **inp,		/* pointer to input pointers */
51493 unsigned int npix	/* Number of pixels to process */
51494 ) {
51495 	imdi_imp *p = (imdi_imp *)(s->impl);
51496 	unsigned short *ip0 = (unsigned short *)inp[0];
51497 	unsigned short *op0 = (unsigned short *)outp[0];
51498 	unsigned short *ep = ip0 + npix * 5 ;
51499 	pointer it0 = (pointer)p->in_tables[0];
51500 	pointer it1 = (pointer)p->in_tables[1];
51501 	pointer it2 = (pointer)p->in_tables[2];
51502 	pointer it3 = (pointer)p->in_tables[3];
51503 	pointer it4 = (pointer)p->in_tables[4];
51504 	pointer ot0 = (pointer)p->out_tables[0];
51505 	pointer ot1 = (pointer)p->out_tables[1];
51506 	pointer ot2 = (pointer)p->out_tables[2];
51507 	pointer ot3 = (pointer)p->out_tables[3];
51508 	pointer ot4 = (pointer)p->out_tables[4];
51509 	pointer ot5 = (pointer)p->out_tables[5];
51510 	pointer ot6 = (pointer)p->out_tables[6];
51511 	pointer ot7 = (pointer)p->out_tables[7];
51512 	pointer im_base = (pointer)p->im_table;
51513 
51514 	for(;ip0 < ep; ip0 += 5, op0 += 8) {
51515 		unsigned int ova0;	/* Output value accumulator */
51516 		unsigned int ova1;	/* Output value accumulator */
51517 		unsigned int ova2;	/* Output value accumulator */
51518 		unsigned int ova3;	/* Output value accumulator */
51519 		unsigned int ova4;	/* Output value accumulator */
51520 		unsigned int ova5;	/* Output value accumulator */
51521 		unsigned int ova6;	/* Output value accumulator */
51522 		unsigned int ova7;	/* Output value accumulator */
51523 		{
51524 			pointer imp;
51525 			unsigned int we0;	/* Weighting value variable */
51526 			unsigned int vo0;	/* Vertex offset variable */
51527 			unsigned int we1;	/* Weighting value variable */
51528 			unsigned int vo1;	/* Vertex offset variable */
51529 			unsigned int we2;	/* Weighting value variable */
51530 			unsigned int vo2;	/* Vertex offset variable */
51531 			unsigned int we3;	/* Weighting value variable */
51532 			unsigned int vo3;	/* Vertex offset variable */
51533 			unsigned int we4;	/* Weighting value variable */
51534 			unsigned int vo4;	/* Vertex offset variable */
51535 			{
51536 				unsigned int ti_i;	/* Interpolation index variable */
51537 
51538 				ti_i  = IT_IX(it0, ip0[0]);
51539 				we0   = IT_WE(it0, ip0[0]);
51540 				vo0   = IT_VO(it0, ip0[0]);
51541 				ti_i += IT_IX(it1, ip0[1]);
51542 				we1   = IT_WE(it1, ip0[1]);
51543 				vo1   = IT_VO(it1, ip0[1]);
51544 				ti_i += IT_IX(it2, ip0[2]);
51545 				we2   = IT_WE(it2, ip0[2]);
51546 				vo2   = IT_VO(it2, ip0[2]);
51547 				ti_i += IT_IX(it3, ip0[3]);
51548 				we3   = IT_WE(it3, ip0[3]);
51549 				vo3   = IT_VO(it3, ip0[3]);
51550 				ti_i += IT_IX(it4, ip0[4]);
51551 				we4   = IT_WE(it4, ip0[4]);
51552 				vo4   = IT_VO(it4, ip0[4]);
51553 
51554 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
51555 
51556 				/* Sort weighting values and vertex offset values */
51557 				CEX(we0, vo0, we1, vo1);
51558 				CEX(we0, vo0, we2, vo2);
51559 				CEX(we0, vo0, we3, vo3);
51560 				CEX(we0, vo0, we4, vo4);
51561 				CEX(we1, vo1, we2, vo2);
51562 				CEX(we1, vo1, we3, vo3);
51563 				CEX(we1, vo1, we4, vo4);
51564 				CEX(we2, vo2, we3, vo3);
51565 				CEX(we2, vo2, we4, vo4);
51566 				CEX(we3, vo3, we4, vo4);
51567 			}
51568 			{
51569 				unsigned int vof;	/* Vertex offset value */
51570 				unsigned int vwe;	/* Vertex weighting */
51571 
51572 				vof = 0;				/* First vertex offset is 0 */
51573 				vwe = 65536 - we0;		/* Baricentric weighting */
51574 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
51575 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
51576 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
51577 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
51578 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
51579 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
51580 				ova6  = IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
51581 				ova7  = IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
51582 				vof += vo0;			/* Move to next vertex */
51583 				vwe = we0 - we1;		/* Baricentric weighting */
51584 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
51585 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
51586 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
51587 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
51588 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
51589 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
51590 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
51591 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
51592 				vof += vo1;			/* Move to next vertex */
51593 				vwe = we1 - we2;		/* Baricentric weighting */
51594 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
51595 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
51596 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
51597 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
51598 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
51599 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
51600 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
51601 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
51602 				vof += vo2;			/* Move to next vertex */
51603 				vwe = we2 - we3;		/* Baricentric weighting */
51604 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
51605 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
51606 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
51607 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
51608 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
51609 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
51610 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
51611 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
51612 				vof += vo3;			/* Move to next vertex */
51613 				vwe = we3 - we4;		/* Baricentric weighting */
51614 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
51615 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
51616 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
51617 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
51618 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
51619 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
51620 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
51621 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
51622 				vof += vo4;			/* Move to next vertex */
51623 				vwe = we4;				/* Baricentric weighting */
51624 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
51625 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
51626 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
51627 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
51628 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
51629 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
51630 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
51631 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
51632 			}
51633 		}
51634 		{
51635 			unsigned int oti;	/* Vertex offset value */
51636 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
51637 			op0[0] = OT_E(ot0, oti);	/* Write result */
51638 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
51639 			op0[1] = OT_E(ot1, oti);	/* Write result */
51640 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
51641 			op0[2] = OT_E(ot2, oti);	/* Write result */
51642 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
51643 			op0[3] = OT_E(ot3, oti);	/* Write result */
51644 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
51645 			op0[4] = OT_E(ot4, oti);	/* Write result */
51646 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
51647 			op0[5] = OT_E(ot5, oti);	/* Write result */
51648 			oti = ((ova6 >> 16) & 0xffff);	/* Extract integer part of result */
51649 			op0[6] = OT_E(ot6, oti);	/* Write result */
51650 			oti = ((ova7 >> 16) & 0xffff);	/* Extract integer part of result */
51651 			op0[7] = OT_E(ot7, oti);	/* Write result */
51652 		}
51653 	}
51654 }
51655 #undef IT_WE
51656 #undef IT_VO
51657 #undef IT_IX
51658 #undef CEX
51659 #undef IM_O
51660 #undef IM_FE
51661 #undef OT_E
51662 
51663 void
imdi_k144_gen(genspec * g)51664 imdi_k144_gen(
51665 genspec *g			/* structure to be initialised */
51666 ) {
51667 	static unsigned char data[] = {
51668 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
51669 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
51670 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51671 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51672 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51673 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51674 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51675 		0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
51676 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
51677 		0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
51678 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
51679 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51680 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51681 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51682 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51683 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51684 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51685 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51686 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51687 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
51688 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51689 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51690 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51691 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51692 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
51693 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
51694 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
51695 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
51696 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51697 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51698 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51699 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51700 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51701 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51702 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51703 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51704 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
51705 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
51706 		0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51707 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
51708 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
51709 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
51710 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
51711 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
51712 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
51713 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
51714 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
51715 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
51716 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51717 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
51718 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
51719 		0x2c, 0xf3, 0xdc, 0xb7, 0x35, 0x5f, 0x38, 0x5f,
51720 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
51721 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
51722 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
51723 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
51724 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
51725 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
51726 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
51727 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51728 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51729 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51730 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51731 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
51732 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x34,
51733 		0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51734 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51735 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
51736 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
51737 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
51738 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
51739 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
51740 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
51741 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
51742 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
51743 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
51744 		0x00, 0xf0, 0x04, 0x08
51745 	};	/* Structure image */
51746 
51747 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
51748 }
51749 
51750 void
imdi_k144_tab(tabspec * t)51751 imdi_k144_tab(
51752 tabspec *t			/* structure to be initialised */
51753 ) {
51754 	static unsigned char data[] = {
51755 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
51756 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
51757 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
51758 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
51759 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
51760 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
51761 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
51762 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
51763 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
51764 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51765 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
51766 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
51767 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
51768 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
51769 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
51770 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51771 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
51772 		0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
51773 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51774 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51775 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
51776 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
51777 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
51778 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
51779 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51780 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51781 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51782 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51783 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51784 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51785 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51786 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
51787 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
51788 	};	/* Structure image */
51789 
51790 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
51791 }
51792 
51793 
51794 
51795 
51796 
51797 
51798 /* Integer Multi-Dimensional Interpolation */
51799 /* Interpolation Kernel Code */
51800 /* Generated by cgen */
51801 /* Copyright 2000 - 2002 Graeme W. Gill */
51802 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
51803 
51804 /* see the Licence.txt file for licencing details.*/
51805 
51806 
51807 /*
51808    Interpolation kernel specs:
51809 
51810    Input channels per pixel = 6
51811    Input channel 0 bits = 16
51812    Input channel 0 increment = 6
51813    Input channel 1 bits = 16
51814    Input channel 1 increment = 6
51815    Input channel 2 bits = 16
51816    Input channel 2 increment = 6
51817    Input channel 3 bits = 16
51818    Input channel 3 increment = 6
51819    Input channel 4 bits = 16
51820    Input channel 4 increment = 6
51821    Input channel 5 bits = 16
51822    Input channel 5 increment = 6
51823    Input is channel interleaved
51824    Input channels are separate words
51825    Input value extraction is done in input table lookup
51826 
51827    Output channels per pixel = 8
51828    Output channel 0 bits = 16
51829    Output channel 0 increment = 8
51830    Output channel 1 bits = 16
51831    Output channel 1 increment = 8
51832    Output channel 2 bits = 16
51833    Output channel 2 increment = 8
51834    Output channel 3 bits = 16
51835    Output channel 3 increment = 8
51836    Output channel 4 bits = 16
51837    Output channel 4 increment = 8
51838    Output channel 5 bits = 16
51839    Output channel 5 increment = 8
51840    Output channel 6 bits = 16
51841    Output channel 6 increment = 8
51842    Output channel 7 bits = 16
51843    Output channel 7 increment = 8
51844    Output is channel interleaved
51845 
51846    Output channels are separate words
51847    Weight+voffset bits       = 32
51848    Interpolation table index bits = 32
51849    Interpolation table max resolution = 40
51850  */
51851 
51852 /*
51853    Machine architecture specs:
51854 
51855    Little endian
51856    Reading and writing pixel values separately
51857    Pointer size = 32 bits
51858 
51859    Ordinal size  8 bits is known as 'unsigned char'
51860    Ordinal size 16 bits is known as 'unsigned short'
51861    Ordinal size 32 bits is known as 'unsigned int'
51862    Natural ordinal is 'unsigned int'
51863 
51864    Integer size  8 bits is known as 'signed char'
51865    Integer size 16 bits is known as 'short'
51866    Integer size 32 bits is known as 'int'
51867    Natural integer is 'int'
51868 
51869  */
51870 
51871 #ifndef  IMDI_INCLUDED
51872 #include <memory.h>
51873 #include "imdi_imp.h"
51874 #define  IMDI_INCLUDED
51875 #endif  /* IMDI_INCLUDED */
51876 
51877 #ifndef DEFINED_pointer
51878 #define DEFINED_pointer
51879 typedef unsigned char * pointer;
51880 #endif
51881 
51882 /* Input table interp. index */
51883 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
51884 
51885 /* Input table input weighting enty */
51886 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
51887 
51888 /* Input table input offset value enty */
51889 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
51890 
51891 /* Conditional exchange for sorting */
51892 #define CEX(A, AA, B, BB) if (A < B) { \
51893             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
51894 
51895 /* Interpolation multi-dim. table access */
51896 #define IM_O(off) ((off) * 16)
51897 
51898 /* Interpolation table - get vertex values */
51899 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 8 + (c) * 2)))
51900 
51901 /* Output table indexes */
51902 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
51903 
51904 void
imdi_k145(imdi * s,void ** outp,void ** inp,unsigned int npix)51905 imdi_k145(
51906 imdi *s,			/* imdi context */
51907 void **outp,		/* pointer to output pointers */
51908 void **inp,		/* pointer to input pointers */
51909 unsigned int npix	/* Number of pixels to process */
51910 ) {
51911 	imdi_imp *p = (imdi_imp *)(s->impl);
51912 	unsigned short *ip0 = (unsigned short *)inp[0];
51913 	unsigned short *op0 = (unsigned short *)outp[0];
51914 	unsigned short *ep = ip0 + npix * 6 ;
51915 	pointer it0 = (pointer)p->in_tables[0];
51916 	pointer it1 = (pointer)p->in_tables[1];
51917 	pointer it2 = (pointer)p->in_tables[2];
51918 	pointer it3 = (pointer)p->in_tables[3];
51919 	pointer it4 = (pointer)p->in_tables[4];
51920 	pointer it5 = (pointer)p->in_tables[5];
51921 	pointer ot0 = (pointer)p->out_tables[0];
51922 	pointer ot1 = (pointer)p->out_tables[1];
51923 	pointer ot2 = (pointer)p->out_tables[2];
51924 	pointer ot3 = (pointer)p->out_tables[3];
51925 	pointer ot4 = (pointer)p->out_tables[4];
51926 	pointer ot5 = (pointer)p->out_tables[5];
51927 	pointer ot6 = (pointer)p->out_tables[6];
51928 	pointer ot7 = (pointer)p->out_tables[7];
51929 	pointer im_base = (pointer)p->im_table;
51930 
51931 	for(;ip0 < ep; ip0 += 6, op0 += 8) {
51932 		unsigned int ova0;	/* Output value accumulator */
51933 		unsigned int ova1;	/* Output value accumulator */
51934 		unsigned int ova2;	/* Output value accumulator */
51935 		unsigned int ova3;	/* Output value accumulator */
51936 		unsigned int ova4;	/* Output value accumulator */
51937 		unsigned int ova5;	/* Output value accumulator */
51938 		unsigned int ova6;	/* Output value accumulator */
51939 		unsigned int ova7;	/* Output value accumulator */
51940 		{
51941 			pointer imp;
51942 			unsigned int we0;	/* Weighting value variable */
51943 			unsigned int vo0;	/* Vertex offset variable */
51944 			unsigned int we1;	/* Weighting value variable */
51945 			unsigned int vo1;	/* Vertex offset variable */
51946 			unsigned int we2;	/* Weighting value variable */
51947 			unsigned int vo2;	/* Vertex offset variable */
51948 			unsigned int we3;	/* Weighting value variable */
51949 			unsigned int vo3;	/* Vertex offset variable */
51950 			unsigned int we4;	/* Weighting value variable */
51951 			unsigned int vo4;	/* Vertex offset variable */
51952 			unsigned int we5;	/* Weighting value variable */
51953 			unsigned int vo5;	/* Vertex offset variable */
51954 			{
51955 				unsigned int ti_i;	/* Interpolation index variable */
51956 
51957 				ti_i  = IT_IX(it0, ip0[0]);
51958 				we0   = IT_WE(it0, ip0[0]);
51959 				vo0   = IT_VO(it0, ip0[0]);
51960 				ti_i += IT_IX(it1, ip0[1]);
51961 				we1   = IT_WE(it1, ip0[1]);
51962 				vo1   = IT_VO(it1, ip0[1]);
51963 				ti_i += IT_IX(it2, ip0[2]);
51964 				we2   = IT_WE(it2, ip0[2]);
51965 				vo2   = IT_VO(it2, ip0[2]);
51966 				ti_i += IT_IX(it3, ip0[3]);
51967 				we3   = IT_WE(it3, ip0[3]);
51968 				vo3   = IT_VO(it3, ip0[3]);
51969 				ti_i += IT_IX(it4, ip0[4]);
51970 				we4   = IT_WE(it4, ip0[4]);
51971 				vo4   = IT_VO(it4, ip0[4]);
51972 				ti_i += IT_IX(it5, ip0[5]);
51973 				we5   = IT_WE(it5, ip0[5]);
51974 				vo5   = IT_VO(it5, ip0[5]);
51975 
51976 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
51977 
51978 				/* Sort weighting values and vertex offset values */
51979 				CEX(we0, vo0, we1, vo1);
51980 				CEX(we0, vo0, we2, vo2);
51981 				CEX(we0, vo0, we3, vo3);
51982 				CEX(we0, vo0, we4, vo4);
51983 				CEX(we0, vo0, we5, vo5);
51984 				CEX(we1, vo1, we2, vo2);
51985 				CEX(we1, vo1, we3, vo3);
51986 				CEX(we1, vo1, we4, vo4);
51987 				CEX(we1, vo1, we5, vo5);
51988 				CEX(we2, vo2, we3, vo3);
51989 				CEX(we2, vo2, we4, vo4);
51990 				CEX(we2, vo2, we5, vo5);
51991 				CEX(we3, vo3, we4, vo4);
51992 				CEX(we3, vo3, we5, vo5);
51993 				CEX(we4, vo4, we5, vo5);
51994 			}
51995 			{
51996 				unsigned int vof;	/* Vertex offset value */
51997 				unsigned int vwe;	/* Vertex weighting */
51998 
51999 				vof = 0;				/* First vertex offset is 0 */
52000 				vwe = 65536 - we0;		/* Baricentric weighting */
52001 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52002 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52003 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52004 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52005 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52006 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52007 				ova6  = IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52008 				ova7  = IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52009 				vof += vo0;			/* Move to next vertex */
52010 				vwe = we0 - we1;		/* Baricentric weighting */
52011 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52012 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52013 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52014 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52015 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52016 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52017 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52018 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52019 				vof += vo1;			/* Move to next vertex */
52020 				vwe = we1 - we2;		/* Baricentric weighting */
52021 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52022 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52023 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52024 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52025 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52026 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52027 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52028 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52029 				vof += vo2;			/* Move to next vertex */
52030 				vwe = we2 - we3;		/* Baricentric weighting */
52031 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52032 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52033 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52034 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52035 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52036 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52037 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52038 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52039 				vof += vo3;			/* Move to next vertex */
52040 				vwe = we3 - we4;		/* Baricentric weighting */
52041 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52042 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52043 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52044 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52045 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52046 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52047 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52048 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52049 				vof += vo4;			/* Move to next vertex */
52050 				vwe = we4 - we5;		/* Baricentric weighting */
52051 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52052 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52053 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52054 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52055 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52056 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52057 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52058 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52059 				vof += vo5;			/* Move to next vertex */
52060 				vwe = we5;				/* Baricentric weighting */
52061 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52062 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52063 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52064 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52065 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52066 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52067 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52068 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52069 			}
52070 		}
52071 		{
52072 			unsigned int oti;	/* Vertex offset value */
52073 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
52074 			op0[0] = OT_E(ot0, oti);	/* Write result */
52075 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
52076 			op0[1] = OT_E(ot1, oti);	/* Write result */
52077 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
52078 			op0[2] = OT_E(ot2, oti);	/* Write result */
52079 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
52080 			op0[3] = OT_E(ot3, oti);	/* Write result */
52081 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
52082 			op0[4] = OT_E(ot4, oti);	/* Write result */
52083 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
52084 			op0[5] = OT_E(ot5, oti);	/* Write result */
52085 			oti = ((ova6 >> 16) & 0xffff);	/* Extract integer part of result */
52086 			op0[6] = OT_E(ot6, oti);	/* Write result */
52087 			oti = ((ova7 >> 16) & 0xffff);	/* Extract integer part of result */
52088 			op0[7] = OT_E(ot7, oti);	/* Write result */
52089 		}
52090 	}
52091 }
52092 #undef IT_WE
52093 #undef IT_VO
52094 #undef IT_IX
52095 #undef CEX
52096 #undef IM_O
52097 #undef IM_FE
52098 #undef OT_E
52099 
52100 void
imdi_k145_gen(genspec * g)52101 imdi_k145_gen(
52102 genspec *g			/* structure to be initialised */
52103 ) {
52104 	static unsigned char data[] = {
52105 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
52106 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
52107 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52108 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52109 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52110 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52111 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52112 		0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
52113 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
52114 		0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
52115 		0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
52116 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52117 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52118 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52119 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52120 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52121 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52122 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52123 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52124 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
52125 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52126 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52127 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52128 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52129 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
52130 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
52131 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
52132 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
52133 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52134 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52135 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52136 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52137 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52138 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52139 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52140 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52141 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
52142 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
52143 		0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52144 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
52145 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
52146 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
52147 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
52148 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
52149 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
52150 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
52151 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
52152 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
52153 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52154 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
52155 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
52156 		0x2c, 0xf3, 0xdc, 0xb7, 0x36, 0x5f, 0x38, 0x5f,
52157 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
52158 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
52159 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
52160 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
52161 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
52162 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
52163 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
52164 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52165 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52166 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52167 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52168 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
52169 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x34,
52170 		0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52171 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52172 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
52173 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
52174 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
52175 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
52176 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
52177 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
52178 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
52179 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
52180 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
52181 		0x00, 0xf0, 0x04, 0x08
52182 	};	/* Structure image */
52183 
52184 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
52185 }
52186 
52187 void
imdi_k145_tab(tabspec * t)52188 imdi_k145_tab(
52189 tabspec *t			/* structure to be initialised */
52190 ) {
52191 	static unsigned char data[] = {
52192 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
52193 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
52194 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
52195 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
52196 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
52197 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
52198 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
52199 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
52200 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
52201 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52202 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
52203 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
52204 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
52205 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
52206 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
52207 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52208 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
52209 		0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
52210 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52211 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52212 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
52213 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
52214 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
52215 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
52216 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52217 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52218 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52219 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52220 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52221 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52222 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52223 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52224 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
52225 	};	/* Structure image */
52226 
52227 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
52228 }
52229 
52230 
52231 
52232 
52233 
52234 
52235 /* Integer Multi-Dimensional Interpolation */
52236 /* Interpolation Kernel Code */
52237 /* Generated by cgen */
52238 /* Copyright 2000 - 2002 Graeme W. Gill */
52239 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
52240 
52241 /* see the Licence.txt file for licencing details.*/
52242 
52243 
52244 /*
52245    Interpolation kernel specs:
52246 
52247    Input channels per pixel = 7
52248    Input channel 0 bits = 16
52249    Input channel 0 increment = 7
52250    Input channel 1 bits = 16
52251    Input channel 1 increment = 7
52252    Input channel 2 bits = 16
52253    Input channel 2 increment = 7
52254    Input channel 3 bits = 16
52255    Input channel 3 increment = 7
52256    Input channel 4 bits = 16
52257    Input channel 4 increment = 7
52258    Input channel 5 bits = 16
52259    Input channel 5 increment = 7
52260    Input channel 6 bits = 16
52261    Input channel 6 increment = 7
52262    Input is channel interleaved
52263    Input channels are separate words
52264    Input value extraction is done in input table lookup
52265 
52266    Output channels per pixel = 8
52267    Output channel 0 bits = 16
52268    Output channel 0 increment = 8
52269    Output channel 1 bits = 16
52270    Output channel 1 increment = 8
52271    Output channel 2 bits = 16
52272    Output channel 2 increment = 8
52273    Output channel 3 bits = 16
52274    Output channel 3 increment = 8
52275    Output channel 4 bits = 16
52276    Output channel 4 increment = 8
52277    Output channel 5 bits = 16
52278    Output channel 5 increment = 8
52279    Output channel 6 bits = 16
52280    Output channel 6 increment = 8
52281    Output channel 7 bits = 16
52282    Output channel 7 increment = 8
52283    Output is channel interleaved
52284 
52285    Output channels are separate words
52286    Weight+voffset bits       = 32
52287    Interpolation table index bits = 32
52288    Interpolation table max resolution = 23
52289  */
52290 
52291 /*
52292    Machine architecture specs:
52293 
52294    Little endian
52295    Reading and writing pixel values separately
52296    Pointer size = 32 bits
52297 
52298    Ordinal size  8 bits is known as 'unsigned char'
52299    Ordinal size 16 bits is known as 'unsigned short'
52300    Ordinal size 32 bits is known as 'unsigned int'
52301    Natural ordinal is 'unsigned int'
52302 
52303    Integer size  8 bits is known as 'signed char'
52304    Integer size 16 bits is known as 'short'
52305    Integer size 32 bits is known as 'int'
52306    Natural integer is 'int'
52307 
52308  */
52309 
52310 #ifndef  IMDI_INCLUDED
52311 #include <memory.h>
52312 #include "imdi_imp.h"
52313 #define  IMDI_INCLUDED
52314 #endif  /* IMDI_INCLUDED */
52315 
52316 #ifndef DEFINED_pointer
52317 #define DEFINED_pointer
52318 typedef unsigned char * pointer;
52319 #endif
52320 
52321 /* Input table interp. index */
52322 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
52323 
52324 /* Input table input weighting enty */
52325 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
52326 
52327 /* Input table input offset value enty */
52328 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
52329 
52330 /* Conditional exchange for sorting */
52331 #define CEX(A, AA, B, BB) if (A < B) { \
52332             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
52333 
52334 /* Interpolation multi-dim. table access */
52335 #define IM_O(off) ((off) * 16)
52336 
52337 /* Interpolation table - get vertex values */
52338 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 8 + (c) * 2)))
52339 
52340 /* Output table indexes */
52341 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
52342 
52343 void
imdi_k146(imdi * s,void ** outp,void ** inp,unsigned int npix)52344 imdi_k146(
52345 imdi *s,			/* imdi context */
52346 void **outp,		/* pointer to output pointers */
52347 void **inp,		/* pointer to input pointers */
52348 unsigned int npix	/* Number of pixels to process */
52349 ) {
52350 	imdi_imp *p = (imdi_imp *)(s->impl);
52351 	unsigned short *ip0 = (unsigned short *)inp[0];
52352 	unsigned short *op0 = (unsigned short *)outp[0];
52353 	unsigned short *ep = ip0 + npix * 7 ;
52354 	pointer it0 = (pointer)p->in_tables[0];
52355 	pointer it1 = (pointer)p->in_tables[1];
52356 	pointer it2 = (pointer)p->in_tables[2];
52357 	pointer it3 = (pointer)p->in_tables[3];
52358 	pointer it4 = (pointer)p->in_tables[4];
52359 	pointer it5 = (pointer)p->in_tables[5];
52360 	pointer it6 = (pointer)p->in_tables[6];
52361 	pointer ot0 = (pointer)p->out_tables[0];
52362 	pointer ot1 = (pointer)p->out_tables[1];
52363 	pointer ot2 = (pointer)p->out_tables[2];
52364 	pointer ot3 = (pointer)p->out_tables[3];
52365 	pointer ot4 = (pointer)p->out_tables[4];
52366 	pointer ot5 = (pointer)p->out_tables[5];
52367 	pointer ot6 = (pointer)p->out_tables[6];
52368 	pointer ot7 = (pointer)p->out_tables[7];
52369 	pointer im_base = (pointer)p->im_table;
52370 
52371 	for(;ip0 < ep; ip0 += 7, op0 += 8) {
52372 		unsigned int ova0;	/* Output value accumulator */
52373 		unsigned int ova1;	/* Output value accumulator */
52374 		unsigned int ova2;	/* Output value accumulator */
52375 		unsigned int ova3;	/* Output value accumulator */
52376 		unsigned int ova4;	/* Output value accumulator */
52377 		unsigned int ova5;	/* Output value accumulator */
52378 		unsigned int ova6;	/* Output value accumulator */
52379 		unsigned int ova7;	/* Output value accumulator */
52380 		{
52381 			pointer imp;
52382 			unsigned int we0;	/* Weighting value variable */
52383 			unsigned int vo0;	/* Vertex offset variable */
52384 			unsigned int we1;	/* Weighting value variable */
52385 			unsigned int vo1;	/* Vertex offset variable */
52386 			unsigned int we2;	/* Weighting value variable */
52387 			unsigned int vo2;	/* Vertex offset variable */
52388 			unsigned int we3;	/* Weighting value variable */
52389 			unsigned int vo3;	/* Vertex offset variable */
52390 			unsigned int we4;	/* Weighting value variable */
52391 			unsigned int vo4;	/* Vertex offset variable */
52392 			unsigned int we5;	/* Weighting value variable */
52393 			unsigned int vo5;	/* Vertex offset variable */
52394 			unsigned int we6;	/* Weighting value variable */
52395 			unsigned int vo6;	/* Vertex offset variable */
52396 			{
52397 				unsigned int ti_i;	/* Interpolation index variable */
52398 
52399 				ti_i  = IT_IX(it0, ip0[0]);
52400 				we0   = IT_WE(it0, ip0[0]);
52401 				vo0   = IT_VO(it0, ip0[0]);
52402 				ti_i += IT_IX(it1, ip0[1]);
52403 				we1   = IT_WE(it1, ip0[1]);
52404 				vo1   = IT_VO(it1, ip0[1]);
52405 				ti_i += IT_IX(it2, ip0[2]);
52406 				we2   = IT_WE(it2, ip0[2]);
52407 				vo2   = IT_VO(it2, ip0[2]);
52408 				ti_i += IT_IX(it3, ip0[3]);
52409 				we3   = IT_WE(it3, ip0[3]);
52410 				vo3   = IT_VO(it3, ip0[3]);
52411 				ti_i += IT_IX(it4, ip0[4]);
52412 				we4   = IT_WE(it4, ip0[4]);
52413 				vo4   = IT_VO(it4, ip0[4]);
52414 				ti_i += IT_IX(it5, ip0[5]);
52415 				we5   = IT_WE(it5, ip0[5]);
52416 				vo5   = IT_VO(it5, ip0[5]);
52417 				ti_i += IT_IX(it6, ip0[6]);
52418 				we6   = IT_WE(it6, ip0[6]);
52419 				vo6   = IT_VO(it6, ip0[6]);
52420 
52421 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
52422 
52423 				/* Sort weighting values and vertex offset values */
52424 				CEX(we0, vo0, we1, vo1);
52425 				CEX(we0, vo0, we2, vo2);
52426 				CEX(we0, vo0, we3, vo3);
52427 				CEX(we0, vo0, we4, vo4);
52428 				CEX(we0, vo0, we5, vo5);
52429 				CEX(we0, vo0, we6, vo6);
52430 				CEX(we1, vo1, we2, vo2);
52431 				CEX(we1, vo1, we3, vo3);
52432 				CEX(we1, vo1, we4, vo4);
52433 				CEX(we1, vo1, we5, vo5);
52434 				CEX(we1, vo1, we6, vo6);
52435 				CEX(we2, vo2, we3, vo3);
52436 				CEX(we2, vo2, we4, vo4);
52437 				CEX(we2, vo2, we5, vo5);
52438 				CEX(we2, vo2, we6, vo6);
52439 				CEX(we3, vo3, we4, vo4);
52440 				CEX(we3, vo3, we5, vo5);
52441 				CEX(we3, vo3, we6, vo6);
52442 				CEX(we4, vo4, we5, vo5);
52443 				CEX(we4, vo4, we6, vo6);
52444 				CEX(we5, vo5, we6, vo6);
52445 			}
52446 			{
52447 				unsigned int vof;	/* Vertex offset value */
52448 				unsigned int vwe;	/* Vertex weighting */
52449 
52450 				vof = 0;				/* First vertex offset is 0 */
52451 				vwe = 65536 - we0;		/* Baricentric weighting */
52452 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52453 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52454 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52455 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52456 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52457 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52458 				ova6  = IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52459 				ova7  = IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52460 				vof += vo0;			/* Move to next vertex */
52461 				vwe = we0 - we1;		/* Baricentric weighting */
52462 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52463 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52464 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52465 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52466 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52467 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52468 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52469 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52470 				vof += vo1;			/* Move to next vertex */
52471 				vwe = we1 - we2;		/* Baricentric weighting */
52472 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52473 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52474 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52475 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52476 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52477 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52478 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52479 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52480 				vof += vo2;			/* Move to next vertex */
52481 				vwe = we2 - we3;		/* Baricentric weighting */
52482 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52483 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52484 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52485 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52486 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52487 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52488 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52489 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52490 				vof += vo3;			/* Move to next vertex */
52491 				vwe = we3 - we4;		/* Baricentric weighting */
52492 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52493 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52494 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52495 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52496 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52497 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52498 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52499 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52500 				vof += vo4;			/* Move to next vertex */
52501 				vwe = we4 - we5;		/* Baricentric weighting */
52502 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52503 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52504 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52505 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52506 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52507 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52508 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52509 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52510 				vof += vo5;			/* Move to next vertex */
52511 				vwe = we5 - we6;		/* Baricentric weighting */
52512 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52513 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52514 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52515 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52516 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52517 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52518 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52519 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52520 				vof += vo6;			/* Move to next vertex */
52521 				vwe = we6;				/* Baricentric weighting */
52522 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52523 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52524 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52525 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52526 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52527 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52528 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52529 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52530 			}
52531 		}
52532 		{
52533 			unsigned int oti;	/* Vertex offset value */
52534 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
52535 			op0[0] = OT_E(ot0, oti);	/* Write result */
52536 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
52537 			op0[1] = OT_E(ot1, oti);	/* Write result */
52538 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
52539 			op0[2] = OT_E(ot2, oti);	/* Write result */
52540 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
52541 			op0[3] = OT_E(ot3, oti);	/* Write result */
52542 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
52543 			op0[4] = OT_E(ot4, oti);	/* Write result */
52544 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
52545 			op0[5] = OT_E(ot5, oti);	/* Write result */
52546 			oti = ((ova6 >> 16) & 0xffff);	/* Extract integer part of result */
52547 			op0[6] = OT_E(ot6, oti);	/* Write result */
52548 			oti = ((ova7 >> 16) & 0xffff);	/* Extract integer part of result */
52549 			op0[7] = OT_E(ot7, oti);	/* Write result */
52550 		}
52551 	}
52552 }
52553 #undef IT_WE
52554 #undef IT_VO
52555 #undef IT_IX
52556 #undef CEX
52557 #undef IM_O
52558 #undef IM_FE
52559 #undef OT_E
52560 
52561 void
imdi_k146_gen(genspec * g)52562 imdi_k146_gen(
52563 genspec *g			/* structure to be initialised */
52564 ) {
52565 	static unsigned char data[] = {
52566 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
52567 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
52568 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52569 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52570 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52571 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52572 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52573 		0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
52574 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
52575 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
52576 		0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
52577 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52578 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52579 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52580 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52581 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52582 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52583 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52584 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52585 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
52586 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52587 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52588 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52589 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52590 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
52591 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
52592 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
52593 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
52594 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52595 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52596 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52597 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52598 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52599 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52600 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52601 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52602 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
52603 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
52604 		0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52605 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
52606 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
52607 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
52608 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
52609 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
52610 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
52611 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
52612 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
52613 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
52614 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52615 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
52616 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
52617 		0x2c, 0xf3, 0xdc, 0xb7, 0x37, 0x5f, 0x38, 0x5f,
52618 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
52619 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
52620 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
52621 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
52622 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
52623 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
52624 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
52625 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52626 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52627 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52628 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52629 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
52630 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x34,
52631 		0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52632 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52633 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
52634 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
52635 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
52636 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
52637 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
52638 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
52639 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
52640 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
52641 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
52642 		0x00, 0xf0, 0x04, 0x08
52643 	};	/* Structure image */
52644 
52645 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
52646 }
52647 
52648 void
imdi_k146_tab(tabspec * t)52649 imdi_k146_tab(
52650 tabspec *t			/* structure to be initialised */
52651 ) {
52652 	static unsigned char data[] = {
52653 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
52654 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
52655 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
52656 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
52657 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
52658 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
52659 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
52660 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
52661 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
52662 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52663 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
52664 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
52665 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
52666 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
52667 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
52668 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52669 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
52670 		0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
52671 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52672 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52673 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
52674 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
52675 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
52676 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
52677 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52678 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52679 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52680 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52681 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52682 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52683 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52684 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
52685 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
52686 	};	/* Structure image */
52687 
52688 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
52689 }
52690 
52691 
52692 
52693 
52694 
52695 
52696 /* Integer Multi-Dimensional Interpolation */
52697 /* Interpolation Kernel Code */
52698 /* Generated by cgen */
52699 /* Copyright 2000 - 2002 Graeme W. Gill */
52700 /* This material is licenced under the GNU GENERAL PUBLIC LICENCE :- */
52701 
52702 /* see the Licence.txt file for licencing details.*/
52703 
52704 
52705 /*
52706    Interpolation kernel specs:
52707 
52708    Input channels per pixel = 8
52709    Input channel 0 bits = 16
52710    Input channel 0 increment = 8
52711    Input channel 1 bits = 16
52712    Input channel 1 increment = 8
52713    Input channel 2 bits = 16
52714    Input channel 2 increment = 8
52715    Input channel 3 bits = 16
52716    Input channel 3 increment = 8
52717    Input channel 4 bits = 16
52718    Input channel 4 increment = 8
52719    Input channel 5 bits = 16
52720    Input channel 5 increment = 8
52721    Input channel 6 bits = 16
52722    Input channel 6 increment = 8
52723    Input channel 7 bits = 16
52724    Input channel 7 increment = 8
52725    Input is channel interleaved
52726    Input channels are separate words
52727    Input value extraction is done in input table lookup
52728 
52729    Output channels per pixel = 8
52730    Output channel 0 bits = 16
52731    Output channel 0 increment = 8
52732    Output channel 1 bits = 16
52733    Output channel 1 increment = 8
52734    Output channel 2 bits = 16
52735    Output channel 2 increment = 8
52736    Output channel 3 bits = 16
52737    Output channel 3 increment = 8
52738    Output channel 4 bits = 16
52739    Output channel 4 increment = 8
52740    Output channel 5 bits = 16
52741    Output channel 5 increment = 8
52742    Output channel 6 bits = 16
52743    Output channel 6 increment = 8
52744    Output channel 7 bits = 16
52745    Output channel 7 increment = 8
52746    Output is channel interleaved
52747 
52748    Output channels are separate words
52749    Weight+voffset bits       = 32
52750    Interpolation table index bits = 32
52751    Interpolation table max resolution = 16
52752  */
52753 
52754 /*
52755    Machine architecture specs:
52756 
52757    Little endian
52758    Reading and writing pixel values separately
52759    Pointer size = 32 bits
52760 
52761    Ordinal size  8 bits is known as 'unsigned char'
52762    Ordinal size 16 bits is known as 'unsigned short'
52763    Ordinal size 32 bits is known as 'unsigned int'
52764    Natural ordinal is 'unsigned int'
52765 
52766    Integer size  8 bits is known as 'signed char'
52767    Integer size 16 bits is known as 'short'
52768    Integer size 32 bits is known as 'int'
52769    Natural integer is 'int'
52770 
52771  */
52772 
52773 #ifndef  IMDI_INCLUDED
52774 #include <memory.h>
52775 #include "imdi_imp.h"
52776 #define  IMDI_INCLUDED
52777 #endif  /* IMDI_INCLUDED */
52778 
52779 #ifndef DEFINED_pointer
52780 #define DEFINED_pointer
52781 typedef unsigned char * pointer;
52782 #endif
52783 
52784 /* Input table interp. index */
52785 #define IT_IX(p, off) *((unsigned int *)((p) + 0 + (off) * 12))
52786 
52787 /* Input table input weighting enty */
52788 #define IT_WE(p, off) *((unsigned int *)((p) + 4 + (off) * 12))
52789 
52790 /* Input table input offset value enty */
52791 #define IT_VO(p, off) *((unsigned int *)((p) + 8 + (off) * 12))
52792 
52793 /* Conditional exchange for sorting */
52794 #define CEX(A, AA, B, BB) if (A < B) { \
52795             A ^= B; B ^= A; A ^= B; AA ^= BB; BB ^= AA; AA ^= BB; }
52796 
52797 /* Interpolation multi-dim. table access */
52798 #define IM_O(off) ((off) * 16)
52799 
52800 /* Interpolation table - get vertex values */
52801 #define IM_FE(p, v, c) ((unsigned int)*((unsigned short *)((p) + (v) * 8 + (c) * 2)))
52802 
52803 /* Output table indexes */
52804 #define OT_E(p, off) *((unsigned short *)((p) + (off) * 2))
52805 
52806 void
imdi_k147(imdi * s,void ** outp,void ** inp,unsigned int npix)52807 imdi_k147(
52808 imdi *s,			/* imdi context */
52809 void **outp,		/* pointer to output pointers */
52810 void **inp,		/* pointer to input pointers */
52811 unsigned int npix	/* Number of pixels to process */
52812 ) {
52813 	imdi_imp *p = (imdi_imp *)(s->impl);
52814 	unsigned short *ip0 = (unsigned short *)inp[0];
52815 	unsigned short *op0 = (unsigned short *)outp[0];
52816 	unsigned short *ep = ip0 + npix * 8 ;
52817 	pointer it0 = (pointer)p->in_tables[0];
52818 	pointer it1 = (pointer)p->in_tables[1];
52819 	pointer it2 = (pointer)p->in_tables[2];
52820 	pointer it3 = (pointer)p->in_tables[3];
52821 	pointer it4 = (pointer)p->in_tables[4];
52822 	pointer it5 = (pointer)p->in_tables[5];
52823 	pointer it6 = (pointer)p->in_tables[6];
52824 	pointer it7 = (pointer)p->in_tables[7];
52825 	pointer ot0 = (pointer)p->out_tables[0];
52826 	pointer ot1 = (pointer)p->out_tables[1];
52827 	pointer ot2 = (pointer)p->out_tables[2];
52828 	pointer ot3 = (pointer)p->out_tables[3];
52829 	pointer ot4 = (pointer)p->out_tables[4];
52830 	pointer ot5 = (pointer)p->out_tables[5];
52831 	pointer ot6 = (pointer)p->out_tables[6];
52832 	pointer ot7 = (pointer)p->out_tables[7];
52833 	pointer im_base = (pointer)p->im_table;
52834 
52835 	for(;ip0 < ep; ip0 += 8, op0 += 8) {
52836 		unsigned int ova0;	/* Output value accumulator */
52837 		unsigned int ova1;	/* Output value accumulator */
52838 		unsigned int ova2;	/* Output value accumulator */
52839 		unsigned int ova3;	/* Output value accumulator */
52840 		unsigned int ova4;	/* Output value accumulator */
52841 		unsigned int ova5;	/* Output value accumulator */
52842 		unsigned int ova6;	/* Output value accumulator */
52843 		unsigned int ova7;	/* Output value accumulator */
52844 		{
52845 			pointer imp;
52846 			unsigned int we0;	/* Weighting value variable */
52847 			unsigned int vo0;	/* Vertex offset variable */
52848 			unsigned int we1;	/* Weighting value variable */
52849 			unsigned int vo1;	/* Vertex offset variable */
52850 			unsigned int we2;	/* Weighting value variable */
52851 			unsigned int vo2;	/* Vertex offset variable */
52852 			unsigned int we3;	/* Weighting value variable */
52853 			unsigned int vo3;	/* Vertex offset variable */
52854 			unsigned int we4;	/* Weighting value variable */
52855 			unsigned int vo4;	/* Vertex offset variable */
52856 			unsigned int we5;	/* Weighting value variable */
52857 			unsigned int vo5;	/* Vertex offset variable */
52858 			unsigned int we6;	/* Weighting value variable */
52859 			unsigned int vo6;	/* Vertex offset variable */
52860 			unsigned int we7;	/* Weighting value variable */
52861 			unsigned int vo7;	/* Vertex offset variable */
52862 			{
52863 				unsigned int ti_i;	/* Interpolation index variable */
52864 
52865 				ti_i  = IT_IX(it0, ip0[0]);
52866 				we0   = IT_WE(it0, ip0[0]);
52867 				vo0   = IT_VO(it0, ip0[0]);
52868 				ti_i += IT_IX(it1, ip0[1]);
52869 				we1   = IT_WE(it1, ip0[1]);
52870 				vo1   = IT_VO(it1, ip0[1]);
52871 				ti_i += IT_IX(it2, ip0[2]);
52872 				we2   = IT_WE(it2, ip0[2]);
52873 				vo2   = IT_VO(it2, ip0[2]);
52874 				ti_i += IT_IX(it3, ip0[3]);
52875 				we3   = IT_WE(it3, ip0[3]);
52876 				vo3   = IT_VO(it3, ip0[3]);
52877 				ti_i += IT_IX(it4, ip0[4]);
52878 				we4   = IT_WE(it4, ip0[4]);
52879 				vo4   = IT_VO(it4, ip0[4]);
52880 				ti_i += IT_IX(it5, ip0[5]);
52881 				we5   = IT_WE(it5, ip0[5]);
52882 				vo5   = IT_VO(it5, ip0[5]);
52883 				ti_i += IT_IX(it6, ip0[6]);
52884 				we6   = IT_WE(it6, ip0[6]);
52885 				vo6   = IT_VO(it6, ip0[6]);
52886 				ti_i += IT_IX(it7, ip0[7]);
52887 				we7   = IT_WE(it7, ip0[7]);
52888 				vo7   = IT_VO(it7, ip0[7]);
52889 
52890 				imp = im_base + IM_O(ti_i);		/* Compute interp. table entry pointer */
52891 
52892 				/* Sort weighting values and vertex offset values */
52893 				CEX(we0, vo0, we1, vo1);
52894 				CEX(we0, vo0, we2, vo2);
52895 				CEX(we0, vo0, we3, vo3);
52896 				CEX(we0, vo0, we4, vo4);
52897 				CEX(we0, vo0, we5, vo5);
52898 				CEX(we0, vo0, we6, vo6);
52899 				CEX(we0, vo0, we7, vo7);
52900 				CEX(we1, vo1, we2, vo2);
52901 				CEX(we1, vo1, we3, vo3);
52902 				CEX(we1, vo1, we4, vo4);
52903 				CEX(we1, vo1, we5, vo5);
52904 				CEX(we1, vo1, we6, vo6);
52905 				CEX(we1, vo1, we7, vo7);
52906 				CEX(we2, vo2, we3, vo3);
52907 				CEX(we2, vo2, we4, vo4);
52908 				CEX(we2, vo2, we5, vo5);
52909 				CEX(we2, vo2, we6, vo6);
52910 				CEX(we2, vo2, we7, vo7);
52911 				CEX(we3, vo3, we4, vo4);
52912 				CEX(we3, vo3, we5, vo5);
52913 				CEX(we3, vo3, we6, vo6);
52914 				CEX(we3, vo3, we7, vo7);
52915 				CEX(we4, vo4, we5, vo5);
52916 				CEX(we4, vo4, we6, vo6);
52917 				CEX(we4, vo4, we7, vo7);
52918 				CEX(we5, vo5, we6, vo6);
52919 				CEX(we5, vo5, we7, vo7);
52920 				CEX(we6, vo6, we7, vo7);
52921 			}
52922 			{
52923 				unsigned int vof;	/* Vertex offset value */
52924 				unsigned int vwe;	/* Vertex weighting */
52925 
52926 				vof = 0;				/* First vertex offset is 0 */
52927 				vwe = 65536 - we0;		/* Baricentric weighting */
52928 				ova0  = IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52929 				ova1  = IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52930 				ova2  = IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52931 				ova3  = IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52932 				ova4  = IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52933 				ova5  = IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52934 				ova6  = IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52935 				ova7  = IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52936 				vof += vo0;			/* Move to next vertex */
52937 				vwe = we0 - we1;		/* Baricentric weighting */
52938 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52939 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52940 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52941 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52942 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52943 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52944 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52945 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52946 				vof += vo1;			/* Move to next vertex */
52947 				vwe = we1 - we2;		/* Baricentric weighting */
52948 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52949 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52950 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52951 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52952 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52953 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52954 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52955 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52956 				vof += vo2;			/* Move to next vertex */
52957 				vwe = we2 - we3;		/* Baricentric weighting */
52958 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52959 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52960 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52961 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52962 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52963 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52964 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52965 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52966 				vof += vo3;			/* Move to next vertex */
52967 				vwe = we3 - we4;		/* Baricentric weighting */
52968 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52969 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52970 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52971 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52972 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52973 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52974 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52975 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52976 				vof += vo4;			/* Move to next vertex */
52977 				vwe = we4 - we5;		/* Baricentric weighting */
52978 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52979 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52980 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52981 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52982 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52983 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52984 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52985 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52986 				vof += vo5;			/* Move to next vertex */
52987 				vwe = we5 - we6;		/* Baricentric weighting */
52988 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52989 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
52990 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
52991 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
52992 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
52993 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
52994 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
52995 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
52996 				vof += vo6;			/* Move to next vertex */
52997 				vwe = we6 - we7;		/* Baricentric weighting */
52998 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
52999 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
53000 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
53001 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
53002 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
53003 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
53004 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
53005 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
53006 				vof += vo7;			/* Move to next vertex */
53007 				vwe = we7;				/* Baricentric weighting */
53008 				ova0 += IM_FE(imp, vof, 0) * vwe;	/* Accumulate weighted output values */
53009 				ova1 += IM_FE(imp, vof, 1) * vwe;	/* Accumulate weighted output values */
53010 				ova2 += IM_FE(imp, vof, 2) * vwe;	/* Accumulate weighted output values */
53011 				ova3 += IM_FE(imp, vof, 3) * vwe;	/* Accumulate weighted output values */
53012 				ova4 += IM_FE(imp, vof, 4) * vwe;	/* Accumulate weighted output values */
53013 				ova5 += IM_FE(imp, vof, 5) * vwe;	/* Accumulate weighted output values */
53014 				ova6 += IM_FE(imp, vof, 6) * vwe;	/* Accumulate weighted output values */
53015 				ova7 += IM_FE(imp, vof, 7) * vwe;	/* Accumulate weighted output values */
53016 			}
53017 		}
53018 		{
53019 			unsigned int oti;	/* Vertex offset value */
53020 			oti = ((ova0 >> 16) & 0xffff);	/* Extract integer part of result */
53021 			op0[0] = OT_E(ot0, oti);	/* Write result */
53022 			oti = ((ova1 >> 16) & 0xffff);	/* Extract integer part of result */
53023 			op0[1] = OT_E(ot1, oti);	/* Write result */
53024 			oti = ((ova2 >> 16) & 0xffff);	/* Extract integer part of result */
53025 			op0[2] = OT_E(ot2, oti);	/* Write result */
53026 			oti = ((ova3 >> 16) & 0xffff);	/* Extract integer part of result */
53027 			op0[3] = OT_E(ot3, oti);	/* Write result */
53028 			oti = ((ova4 >> 16) & 0xffff);	/* Extract integer part of result */
53029 			op0[4] = OT_E(ot4, oti);	/* Write result */
53030 			oti = ((ova5 >> 16) & 0xffff);	/* Extract integer part of result */
53031 			op0[5] = OT_E(ot5, oti);	/* Write result */
53032 			oti = ((ova6 >> 16) & 0xffff);	/* Extract integer part of result */
53033 			op0[6] = OT_E(ot6, oti);	/* Write result */
53034 			oti = ((ova7 >> 16) & 0xffff);	/* Extract integer part of result */
53035 			op0[7] = OT_E(ot7, oti);	/* Write result */
53036 		}
53037 	}
53038 }
53039 #undef IT_WE
53040 #undef IT_VO
53041 #undef IT_IX
53042 #undef CEX
53043 #undef IM_O
53044 #undef IM_FE
53045 #undef OT_E
53046 
53047 void
imdi_k147_gen(genspec * g)53048 imdi_k147_gen(
53049 genspec *g			/* structure to be initialised */
53050 ) {
53051 	static unsigned char data[] = {
53052 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
53053 		0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
53054 		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53055 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53056 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53057 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53058 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53059 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
53060 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
53061 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
53062 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
53063 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53064 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53065 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53066 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53067 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53068 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53069 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53070 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53071 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
53072 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53073 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53074 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53075 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53076 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
53077 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
53078 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
53079 		0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
53080 		0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53081 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53082 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53083 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53084 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53085 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53086 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53087 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53088 		0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
53089 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
53090 		0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53091 		0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
53092 		0x74, 0x20, 0x32, 0x30, 0x30, 0x34, 0x20, 0x47,
53093 		0x72, 0x61, 0x65, 0x6d, 0x65, 0x20, 0x57, 0x2e,
53094 		0x20, 0x47, 0x69, 0x6c, 0x6c, 0x00, 0x04, 0x08,
53095 		0x04, 0xad, 0xf2, 0xb7, 0xc5, 0x83, 0x04, 0x08,
53096 		0x50, 0xad, 0xf2, 0xb7, 0x6c, 0x6c, 0xdd, 0xb7,
53097 		0x34, 0xda, 0x83, 0xbf, 0xf6, 0x35, 0xf3, 0xb7,
53098 		0x8b, 0xca, 0xdd, 0xb7, 0xbb, 0x83, 0x04, 0x08,
53099 		0x31, 0x20, 0x4d, 0x6f, 0x6e, 0x20, 0x46, 0x65,
53100 		0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53101 		0x00, 0x00, 0x00, 0x00, 0x94, 0x07, 0x00, 0x00,
53102 		0x4e, 0xcb, 0xdd, 0xb7, 0xfc, 0x79, 0xdd, 0xb7,
53103 		0x2c, 0xf3, 0xdc, 0xb7, 0x38, 0x5f, 0x38, 0x5f,
53104 		0x69, 0x31, 0x36, 0x5f, 0x69, 0x31, 0x36, 0x5f,
53105 		0x66, 0x00, 0x77, 0x01, 0x9b, 0x83, 0x04, 0x08,
53106 		0x38, 0x18, 0xf4, 0xb7, 0x00, 0x00, 0x00, 0x00,
53107 		0xac, 0xb1, 0xf2, 0xb7, 0xf8, 0xda, 0x83, 0xbf,
53108 		0xc9, 0x37, 0xf3, 0xb7, 0x40, 0x82, 0x04, 0x08,
53109 		0xb4, 0xda, 0x83, 0xbf, 0x58, 0xb1, 0xf2, 0xb7,
53110 		0x02, 0x00, 0x00, 0x00, 0x80, 0xb0, 0xdc, 0xb7,
53111 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53112 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53113 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53114 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53115 		0x00, 0x28, 0x6e, 0x6f, 0xb4, 0xda, 0x83, 0xbf,
53116 		0x69, 0x6d, 0x64, 0x69, 0x5f, 0x6b, 0x31, 0x34,
53117 		0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53118 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53119 		0x00, 0x00, 0x00, 0x00, 0x8e, 0xff, 0x77, 0x01,
53120 		0x20, 0xdb, 0x83, 0xbf, 0x00, 0xb0, 0xf2, 0xb7,
53121 		0x9b, 0x83, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
53122 		0x1b, 0xfa, 0x83, 0xbf, 0xee, 0xb1, 0xec, 0xb7,
53123 		0x98, 0xc8, 0x04, 0x08, 0xe8, 0xf0, 0x04, 0x08,
53124 		0xc8, 0xda, 0x83, 0xbf, 0xdd, 0x84, 0x04, 0x08,
53125 		0xdc, 0x60, 0xef, 0xb7, 0x80, 0xdb, 0x83, 0xbf,
53126 		0xe8, 0xda, 0x83, 0xbf, 0xb3, 0xc8, 0x04, 0x08,
53127 		0x38, 0x18, 0xf4, 0xb7, 0xdc, 0x60, 0xef, 0xb7,
53128 		0x00, 0xf0, 0x04, 0x08
53129 	};	/* Structure image */
53130 
53131 	memcpy(g, data, sizeof(data));	/* Initialise the structure */
53132 }
53133 
53134 void
imdi_k147_tab(tabspec * t)53135 imdi_k147_tab(
53136 tabspec *t			/* structure to be initialised */
53137 ) {
53138 	static unsigned char data[] = {
53139 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
53140 		0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
53141 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
53142 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
53143 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
53144 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
53145 		0x20, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
53146 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
53147 		0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
53148 		0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53149 		0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
53150 		0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
53151 		0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
53152 		0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
53153 		0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
53154 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53155 		0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
53156 		0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
53157 		0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53158 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53159 		0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
53160 		0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
53161 		0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
53162 		0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
53163 		0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53164 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53165 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53166 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53167 		0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53168 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53169 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53170 		0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
53171 		0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
53172 	};	/* Structure image */
53173 
53174 	memcpy(t, data, sizeof(data));	/* Initialise the structure */
53175 }
53176 
53177 
53178 
53179 
53180 
53181 
53182