00001
00002 #define MAXREGRIDSIZE 10000
00003 #include "defs.h"
00004 #include <stdio.h>
00005 #include <stdlib.h>
00006 #include "ana_structures.h"
00007 #include <math.h>
00008 #include <string.h>
00009 #include <sys/types.h>
00010 #include <sys/time.h>
00011 #define ABS(x) ((x)>=0?(x):-(x))
00012 #define MIN(a,b) (((a)<(b))?(a):(b))
00013 #define MAX(a,b) (((a)>(b))?(a):(b))
00014 #define BI_CUBIC_SMOOTH 4
00015 #define BI_CUBIC 3
00016 static int ana_type_size[5]={1,2,4,4,8};
00017 union types_ptr { byte *b; short *w; int *l; float *f; double *d;};
00018 static int nm1, mm1, nm2, mm2, n, data_type, stretchmark_flag;
00019 static float fnm1, fnm5, fmm1, fmm5, xl, yl;
00020 static union types_ptr base, out;
00021 static int regridtypeflag = 0;
00022 static int regrid(void *, int , int ,float *, float *, int , int ,int , int ,void **, int *, int *);
00023 static void bicubic_f(), bicubic_fc();
00024
00025
00026 static int resample_type = BI_CUBIC_SMOOTH;
00027 int image_magrotate(void *,int,int,int,float,float,float,float,void **,int *,int *,int,int,int);
00028
00029 int image_magrotate(
00030
00031
00032
00033
00034 void *array, int nin, int min, int data_type_input,
00035 float theta, float mag, float dx, float dy,
00036 void **outarray, int *nx, int *ny,
00037 int regridtype_input, int stretchmark_flag_input,
00038 int convertnan2zero_flag
00039 )
00040
00041
00042
00043
00044
00045
00046
00047
00048 {
00049 float cx[4], cy[4], xc, yc, cq, sq, cs, magr;
00050 int i, stat, m;
00051
00052
00053 if (convertnan2zero_flag && data_type_input == 2) {
00054 int nn = nin * min;
00055 int *p = (int *) array;
00056 while (nn--) { if (*p == 0x80000000) { *p = 0; } p++; }
00057 }
00058
00059 regridtypeflag = regridtype_input;
00060 stretchmark_flag = stretchmark_flag_input;
00061 data_type = data_type_input;
00062 n = nin; m = min;
00063
00064 cx[0] = 0.0; cx[1] = (float) n; cx[2] = 0.0; cx[3] = (float) n;
00065 cy[0] = 0.0; cy[2] = (float) m; cy[1] = 0.0; cy[3] = (float) m;
00066 xc = 0.5 * (float) (n-1);
00067 yc = 0.5 * (float) (m-1);
00068 magr = 1./mag;
00069
00070
00071
00072 for (i=0;i<4;i++) { cx[i] = (cx[i] - xc)*magr; cy[i] = (cy[i] - yc)*magr; }
00073 theta = theta * 0.01745329252;
00074 cq = cos(theta); sq = sin(theta);
00075
00076 for (i=0;i<4;i++) {
00077 cs = cx[i]; cx[i] = cs*cq + cy[i]*sq + xc;
00078 cy[i] = cy[i]*cq - cs *sq + yc;
00079 }
00080
00081 for (i=0;i<4;i++) { cx[i] = cx[i] - dx; cy[i] = cy[i] - dy; }
00082
00083 stat = regrid(array, n, m, cx, cy, 2, 2, n, m, outarray, nx, ny);
00084 if (stat) { printf("error in regrid\n"); *outarray = 0; nx = ny = 0; return -1; }
00085 return 0;
00086 }
00087
00088 int cutout_corners(int win, int hin, int wout, int hout, float rotang,
00089 float mag, float dx, float dy, float xco, float yco,
00090 float *cx, float *cy)
00091 {
00092 int i; float cs, cq, sq, xc, yc, magr = 1.0/mag;
00093 cx[0] = xco - 0.5*(wout - 1); cx[1] = cx[0] + wout;
00094 cx[2] = cx[0]; cx[3] = cx[1];
00095 cy[0] = yco - 0.5*(hout - 1); cy[2] = cy[0] + hout;
00096 cy[1] = cy[0]; cy[3] = cy[2];
00097
00098 for (i=0; i<4; i++) { cx[i] = cx[i]*magr; cy[i] = cy[i]*magr; }
00099
00100 rotang *= 0.01745329252;
00101 cq = cos(rotang); sq = sin(rotang);
00102 for (i=0; i<4; i++) { cs = cx[i];
00103 cx[i] = cq*cs + sq*cy[i];
00104 cy[i] = cq*cy[i] - sq*cs;
00105 }
00106
00107 xc = 0.5*(win - 1); yc = 0.5*(hin - 1);
00108 for (i=0; i<4; i++) { cx[i] = cx[i] - dx + xc; cy[i] = cy[i] - dy + yc; }
00109
00110 return 0;
00111 }
00112
00113 int image_cutout(
00114
00115 void *array, int nin, int min, int data_type_input,
00116 float theta, float mag, float dx, float dy,
00117 void **outarray, int nout, int mout,
00118 float xcout, float ycout,
00119 int regridtype_input, int stretchmark_flag_input
00120 )
00121 {
00122 float cx[4], cy[4], cq, sq, cs, magr, xc, yc;
00123 int i, stat, nx, ny;
00124 regridtypeflag = regridtype_input;
00125 stretchmark_flag = stretchmark_flag_input;
00126 data_type = data_type_input;
00127 n = nin;
00128
00129
00130
00131
00132 cx[0] = xcout - 0.5*(float) (nout-1); cx[1] = (float) nout + cx[0]; cx[2] = cx[0]; cx[3] = cx[1];
00133 cy[0] = ycout - 0.5*(float) (mout-1); cy[2] = (float) mout + cy[0]; cy[1] = cy[0]; cy[3] = cy[2];
00134 magr = 1./mag;
00135
00136
00137
00138
00139
00140 for (i=0;i<4;i++) { cx[i] = cx[i]*magr; cy[i] = cy[i]*magr; }
00141 theta = theta * 0.01745329252;
00142 cq = cos(theta); sq = sin(theta);
00143
00144
00145 for (i=0;i<4;i++) {
00146 cs = cx[i]; cx[i] = cs*cq + cy[i]*sq;
00147 cy[i] = cy[i]*cq - cs *sq;
00148 }
00149
00150 xc = 0.5 * (float) (nin-1);
00151 yc = 0.5 * (float) (min-1);
00152 for (i=0;i<4;i++) { cx[i] = cx[i] - dx + xc; cy[i] = cy[i] - dy + yc; }
00153
00154
00155 stat = regrid(array, nin, min, cx, cy, 2, 2, nout, mout, outarray, &nx, &ny);
00156
00157 if (stat) { printf("error in regrid\n"); *outarray = 0; nx = ny = 0; return -1; }
00158 return 0;
00159 }
00160
00161 int regrid(
00162 void *array, int n, int m,
00163 float *xgbase, float *ygbase, int ng, int mg,
00164 int ns, int ms,
00165 void **outarray, int *nxout, int *nyout
00166 )
00167
00168 {
00169 int iq, nx, ny, ngrun;
00170 int iprun, jrun, jprun, ig, ic, jc, jq, result_sym;
00171 int i, j, ind;
00172 float fn, fm, yrun, ax, bx, cx, dx, ay, by, cy, dy, xq, beta, xinc, yinc;
00173 float xl0, yl0;
00174 struct ahead *h;
00175 union types_ptr jpbase, jbase, ipbase, bb;
00176 void *bq;
00177 base.l = (int *) array;
00178 fn = (float) n; fm = (float) m;
00179 ngrun = ng;
00180
00181 ng--; mg--;
00182 nx = ng * ns; ny = mg * ms;
00183 *nxout = nx; *nyout = ny;
00184 if ( nx > MAXREGRIDSIZE || ny > MAXREGRIDSIZE ) {
00185 printf("result array in REGRID would be %d by %d\n",nx,ny);
00186 printf("which exceeds current MAXREGRIDSIZE (%d)\n",MAXREGRIDSIZE);
00187 return -1; }
00188
00189 i = ana_type_size[data_type];
00190 bq = malloc(nx * ny * i);
00191 if (!bq) {fprintf(stderr,"$$$$ malloc failed in imrotate $$$$\n"); return(1);}
00192
00193 *outarray = bq;
00194 jpbase.l = (int *) *outarray;
00195 yrun = 1.0/ (float) ms;
00196
00197 iprun = ns * i; jrun = ng * iprun; jprun = ms * jrun;
00198 ind = 0;
00199
00200 switch (regridtypeflag) {
00201 case 0:
00202
00203 while (mg--) {
00204 ipbase.b = jpbase.b; jpbase.b = ipbase.b + jprun;
00205 ig = ng; j = ind;
00206
00207 while (ig--) {
00208
00209 i = j;
00210 ax = xgbase[i]; ay = ygbase[i]; i++;
00211 bx = xgbase[i] - ax; by = ygbase[i] - ay; i += ngrun;
00212 dx = xgbase[i] - ax; dy = ygbase[i] - ay; i--;
00213 cx = xgbase[i] - ax; cy = ygbase[i] - ay;
00214 dx = dx - bx - cx; dy = dy - by - cy; j++;
00215 xq = 1.0 /(float) ns;
00216 bx *= xq; by *= xq; dx *= xq * yrun; dy *= xq * yrun;
00217 cx *= yrun; cy *= yrun;
00218
00219 jbase.b = ipbase.b; ipbase.b = ipbase.b + iprun;
00220 beta = 0.0; jc = ms;
00221 while (jc--) {
00222
00223 out.b = jbase.b; jbase.b = jbase.b + jrun;
00224 xl = ax + beta * cx + 0.5; yl = ay + beta * cy + 0.5;
00225 xinc = (bx + beta * dx); yinc = (by + beta * dy);
00226 ic = ns;
00227
00228 switch (data_type) {
00229 case 0:
00230 while (ic--) {
00231 if ( xl < 0 || xl >= fn || yl < 0 || yl >= fm) *out.b++ = 0;
00232
00233 else { *out.b++ = *(base.b + (int) xl + n * (int) yl); }
00234 xl += xinc; yl += yinc; } break;
00235 case 1:
00236 while (ic--) {
00237 if ( xl < 0 || xl >= fn || yl < 0 || yl >= fm) *out.w++ = 0;
00238 else { *out.w++ = *(base.w + (int) xl + n * (int) yl); }
00239 xl += xinc; yl += yinc; } break;
00240 case 2:
00241 while (ic--) {
00242 if ( xl < 0 || xl >= fn || yl < 0 || yl >= fm) *out.l++ = 0;
00243 else { *out.l++ = *(base.l + (int) xl + n * (int) yl); }
00244 xl += xinc; yl += yinc; } break;
00245 case 3:
00246 while (ic--) {
00247 if ( xl < 0 || xl >= fn || yl < 0 || yl >= fm) *out.f++ = 0;
00248 else { *out.f++ = *(base.f + (int) xl + n * (int) yl); }
00249 xl += xinc; yl += yinc; } break;
00250 case 4:
00251 while (ic--) {
00252 if ( xl < 0 || xl >= fn || yl < 0 || yl >= fm) *out.d++ = 0;
00253 else { *out.d++ = *(base.d + (int) xl + n * (int) yl); }
00254 xl += xinc; yl += yinc; } break;
00255 }
00256 beta++;
00257 }
00258 }
00259 ind += ngrun;
00260 }
00261 break;
00262
00263 case 1:
00264 {
00265 mm1 = m-1; nm1 = n-1; nm2 = n-2; mm2 = m-2;
00266 fnm1 = fn - 1.0; fnm5 = fn -0.5;
00267 fmm1 = fm - 1.0; fmm5 = fm -0.5;
00268
00269 do {
00270 ipbase.b = jpbase.b; jpbase.b = ipbase.b + jprun;
00271 ig = ng; j = ind;
00272
00273 do {
00274
00275 i = j;
00276 ax = xgbase[i]; ay = ygbase[i]; i++;
00277 bx = xgbase[i] - ax; by = ygbase[i] - ay; i += ngrun;
00278 dx = xgbase[i] - ax; dy = ygbase[i] - ay; i--;
00279 cx = xgbase[i] - ax; cy = ygbase[i] - ay;
00280 dx = dx - bx - cx; dy = dy - by - cy; j++;
00281 xq = 1.0 /(float) ns;
00282 bx *= xq; by *= xq; dx *= xq * yrun; dy *= xq * yrun;
00283 cx *= yrun; cy *= yrun;
00284
00285 jbase.b = ipbase.b; ipbase.b = ipbase.b + iprun;
00286 beta = 0.0; jc = ms;
00287
00288
00289 while (jc--) {
00290
00291
00292 yinc = (by + beta * dy);
00293
00294 out.b = jbase.b; jbase.b = jbase.b + jrun;
00295
00296 xl = xl0 = ax+beta*cx; yl = yl0 = ay+beta*cy;
00297 xinc = (bx + beta * dx);
00298 for (ic=0; ic < ns; ic++) {
00299 xl = xl0 + ic*xinc; yl = yl0 + ic*yinc;
00300 switch (resample_type) {
00301 case BI_CUBIC_SMOOTH: bicubic_f(); break;
00302 case BI_CUBIC: bicubic_fc(); break;
00303 }
00304 }
00305 beta++;
00306 }
00307 } while (--ig > 0);
00308 ind += ngrun;
00309 } while (--mg > 0);
00310 } break;
00311
00312 default: { printf("illegal regridtypeflag = %d in regrid\n", regridtypeflag); return -1; }
00313 }
00314
00315 return 0;
00316 }
00317
00318 void bicubic_f()
00319 {
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336 int i1, i2, i3, i4, j1, j2, j3, j4, iq;
00337 float c1, c2, c3, c4, b1, b2, b3, b4, dx0, dx1, dx2, dx3, dx4, xq, yq;
00338 union types_ptr bb;
00339
00340
00341 i2 = (int) xl; j2 = (int) yl;
00342 if ( i2 >= 1 && i2 < nm2 ) {
00343 dx0 = xl - i2; i1 = i2 - 1; i2 = 1; i3 = 2; i4 = 3; }
00344 else {
00345
00346 if (stretchmark_flag == 0) {
00347 if ( xl < -0.5 || xl > fnm5) {
00348 switch (data_type) {
00349 case 0: *out.b++ = 0; break;
00350 case 1: *out.w++ = 0; break;
00351 case 2: *out.l++ = 0; break;
00352 case 3: *out.f++ = 0; break;
00353 case 4: *out.d++ = 0; break;
00354 }
00355 return;
00356 }
00357 }
00358 i2 = MIN(i2, nm1); i2 = MAX( i2, 0);
00359 xq = MIN(xl, fnm1); xq = MAX(xq, 0);
00360 dx0 = xq - i2;
00361 i1 = MIN(i2-1, nm1); i1 = MAX( i1, 0);
00362 i3 = MIN(i2+1, nm1);
00363 i4 = MIN(i2+2, nm1);
00364 i2 = i2 - i1; i3 = i3 - i1; i4 = i4 - i1;
00365 }
00366 dx1 = 1.0 - dx0; dx2 = -dx0 * 0.5; dx3 = dx0 * dx2;
00367 dx4 = 3. * dx0 * dx3;
00368 c1 = dx2*dx1*dx1; c2 = 1.-dx4+5.*dx3; c3 = dx4-(dx2+4.*dx3); c4 = dx3*dx1;
00369 if ( j2 >= 1 && j2 < mm2 ) {
00370 j1 = j2 - 1; dx0 = yl - j2; j3 = n; j2 = n; j4 = n; }
00371 else {
00372
00373 if (stretchmark_flag == 0) {
00374 if ( yl < -0.5 || yl > fmm5) {
00375 switch (data_type) {
00376 case 0: *out.b++ = 0; break;
00377 case 1: *out.w++ = 0; break;
00378 case 2: *out.l++ = 0; break;
00379 case 3: *out.f++ = 0; break;
00380 case 4: *out.d++ = 0; break;
00381 }
00382 return;
00383 }
00384 } j2 = MIN(j2, mm1); j2 = MAX( j2, 0);
00385 xq = MIN(yl, fmm1); xq = MAX(xq, 0);
00386 dx0 = xq - j2;
00387 j1 = MIN(j2-1, mm1); j1 = MAX( j1, 0);
00388 j3 = MIN(j2+1, mm1);
00389 j4 = MIN(j2+2, mm1);
00390 j4 = (j4 - j3) * n; j3 = (j3 - j2) * n; j2 = (j2 - j1) *n;
00391 }
00392 dx1 = 1.0 - dx0; dx2 = -dx0 * 0.5; dx3 = dx0 * dx2;
00393 dx4 = 3. * dx0 * dx3;
00394 b1 = dx2*dx1*dx1; b2 = 1.-dx4+5.*dx3; b3 = dx4-(dx2+4.*dx3); b4 = dx3*dx1;
00395
00396 iq = i1 + j1 * n;
00397 switch (data_type) {
00398 case 0:
00399 bb.b = base.b+iq;
00400 xq = b1*(c1 * *(bb.b) + c2 * *(bb.b+i2)+ c3 * *(bb.b+i3) + c4 * *(bb.b+i4));
00401 bb.b += j2;
00402 xq += b2*(c1 * *(bb.b) + c2 * *(bb.b+i2)+ c3 * *(bb.b+i3) + c4 * *(bb.b+i4));
00403 bb.b += j3;
00404 xq += b3*(c1 * *(bb.b) + c2 * *(bb.b+i2)+ c3 * *(bb.b+i3) + c4 * *(bb.b+i4));
00405 bb.b += j4;
00406 xq += b4*(c1 * *(bb.b) + c2 * *(bb.b+i2)+ c3 * *(bb.b+i3) + c4 * *(bb.b+i4));
00407
00408 xq = MAX( 0, MIN( 255, xq));
00409
00410 *out.b++ = rint(xq); break;
00411 case 1:
00412 bb.w = base.w+iq;
00413 xq = b1*(c1 * *(bb.w) + c2 * *(bb.w+i2)+ c3 * *(bb.w+i3) + c4 * *(bb.w+i4));
00414 bb.w += j2;
00415 xq += b2*(c1 * *(bb.w) + c2 * *(bb.w+i2)+ c3 * *(bb.w+i3) + c4 * *(bb.w+i4));
00416 bb.w += j3;
00417 xq += b3*(c1 * *(bb.w) + c2 * *(bb.w+i2)+ c3 * *(bb.w+i3) + c4 * *(bb.w+i4));
00418 bb.w += j4;
00419 xq += b4*(c1 * *(bb.w) + c2 * *(bb.w+i2)+ c3 * *(bb.w+i3) + c4 * *(bb.w+i4));
00420
00421 *out.w++ = rint(xq); break;
00422 case 2:
00423 bb.l = base.l+iq;
00424 xq = b1*(c1 * *(bb.l) + c2 * *(bb.l+i2)+ c3 * *(bb.l+i3) + c4 * *(bb.l+i4));
00425 bb.l += j2;
00426 xq += b2*(c1 * *(bb.l) + c2 * *(bb.l+i2)+ c3 * *(bb.l+i3) + c4 * *(bb.l+i4));
00427 bb.l += j3;
00428 xq += b3*(c1 * *(bb.l) + c2 * *(bb.l+i2)+ c3 * *(bb.l+i3) + c4 * *(bb.l+i4));
00429 bb.l += j4;
00430 xq += b4*(c1 * *(bb.l) + c2 * *(bb.l+i2)+ c3 * *(bb.l+i3) + c4 * *(bb.l+i4));
00431
00432 *out.l++ = rint(xq); break;
00433 case 3:
00434
00435 bb.f = base.f+iq;
00436 xq = b1*(c1 * *(bb.f) + c2 * *(bb.f+i2)+ c3 * *(bb.f+i3) + c4 * *(bb.f+i4));
00437 bb.f += j2;
00438 xq += b2*(c1 * *(bb.f) + c2 * *(bb.f+i2)+ c3 * *(bb.f+i3) + c4 * *(bb.f+i4));
00439 bb.f += j3;
00440 xq += b3*(c1 * *(bb.f) + c2 * *(bb.f+i2)+ c3 * *(bb.f+i3) + c4 * *(bb.f+i4));
00441 bb.f += j4;
00442 xq += b4*(c1 * *(bb.f) + c2 * *(bb.f+i2)+ c3 * *(bb.f+i3) + c4 * *(bb.f+i4));
00443
00444 *out.f++ = xq; break;
00445 case 4:
00446 bb.d = base.d+iq;
00447 xq = b1*(c1 * *(bb.d) + c2 * *(bb.d+i2)+ c3 * *(bb.d+i3) + c4 * *(bb.d+i4));
00448 bb.d += j2;
00449 xq += b2*(c1 * *(bb.d) + c2 * *(bb.d+i2)+ c3 * *(bb.d+i3) + c4 * *(bb.d+i4));
00450 bb.d += j3;
00451 xq += b3*(c1 * *(bb.d) + c2 * *(bb.d+i2)+ c3 * *(bb.d+i3) + c4 * *(bb.d+i4));
00452 bb.d += j4;
00453 xq += b4*(c1 * *(bb.d) + c2 * *(bb.d+i2)+ c3 * *(bb.d+i3) + c4 * *(bb.d+i4));
00454 *out.d++ = xq; break;
00455 }
00456 return;
00457 }
00458
00459 void bicubic_fc()
00460 {
00461
00462
00463
00464 int i1, i2, i3, i4, j1, j2, j3, j4, iq;
00465 float c1, c2, c3, c4, b1, b2, b3, b4, dx0, dx1, dx2, dx3, dx4, xq, yq;
00466 union types_ptr bb;
00467
00468
00469 i2 = (int) xl; j2 = (int) yl;
00470 if ( i2 >= 1 && i2 < nm2 ) {
00471 dx0 = xl - i2; i1 = i2 - 1; i2 = 1; i3 = 2; i4 = 3; }
00472 else {
00473
00474 if (stretchmark_flag == 0) {
00475 if ( xl < -0.5 || xl > fnm5) {
00476 switch (data_type) {
00477 case 0: *out.b++ = 0; break;
00478 case 1: *out.w++ = 0; break;
00479 case 2: *out.l++ = 0; break;
00480 case 3: *out.f++ = 0; break;
00481 case 4: *out.d++ = 0; break;
00482 }
00483 return;
00484 }
00485 }
00486 i2 = MIN(i2, nm1); i2 = MAX( i2, 0);
00487 xq = MIN(xl, fnm1); xq = MAX(xq, 0);
00488 dx0 = xq - i2;
00489
00490 i1 = MIN(i2-1, nm1); i1 = MAX( i1, 0);
00491 i3 = MIN(i2+1, nm1);
00492 i4 = MIN(i2+2, nm1);
00493 i2 = i2 - i1; i3 = i3 - i1; i4 = i4 - i1;
00494 }
00495
00496 dx1 = 1.0 - dx0; dx4 = -dx0*dx1; c1 = dx4 * dx1; c4 = dx0 * dx4;
00497 dx2 = dx0 * dx0; dx3 = dx0 * dx2; c2 = 1.-2.*dx2+dx3; c3 = dx0*(1.0+dx0-dx2);
00498 if ( j2 >= 1 && j2 < mm2 ) {
00499 j1 = j2 - 1; dx0 = yl - j2; j3 = n; j2 = n; j4 = n; }
00500 else {
00501
00502 if (stretchmark_flag == 0) {
00503 if ( yl < -0.5 || yl > fmm5) {
00504 switch (data_type) {
00505 case 0: *out.b++ = 0; break;
00506 case 1: *out.w++ = 0; break;
00507 case 2: *out.l++ = 0; break;
00508 case 3: *out.f++ = 0; break;
00509 case 4: *out.d++ = 0; break;
00510 }
00511 return;
00512 }
00513 } j2 = MIN(j2, mm1); j2 = MAX( j2, 0);
00514 xq = MIN(yl, fmm1); xq = MAX(xq, 0);
00515 dx0 = xq - j2;
00516 j1 = MIN(j2-1, mm1); j1 = MAX( j1, 0);
00517 j3 = MIN(j2+1, mm1);
00518 j4 = MIN(j2+2, mm1);
00519 j4 = (j4 - j3) * n; j3 = (j3 - j2) * n; j2 = (j2 - j1) *n;
00520 }
00521
00522 dx1 = 1.0 - dx0; dx4 = -dx0*dx1; b1 = dx4 * dx1; b4 = dx0 * dx4;
00523 dx2 = dx0 * dx0; dx3 = dx0 * dx2; b2 = 1.-2.*dx2+dx3; b3 = dx0*(1.0+dx0-dx2);
00524
00525 iq = i1 + j1 * n;
00526 switch (data_type) {
00527 case 0:
00528 bb.b = base.b+iq;
00529 xq = b1*(c1 * *(bb.b) + c2 * *(bb.b+i2)+ c3 * *(bb.b+i3) + c4 * *(bb.b+i4));
00530 bb.b += j2;
00531 xq += b2*(c1 * *(bb.b) + c2 * *(bb.b+i2)+ c3 * *(bb.b+i3) + c4 * *(bb.b+i4));
00532 bb.b += j3;
00533 xq += b3*(c1 * *(bb.b) + c2 * *(bb.b+i2)+ c3 * *(bb.b+i3) + c4 * *(bb.b+i4));
00534 bb.b += j4;
00535 xq += b4*(c1 * *(bb.b) + c2 * *(bb.b+i2)+ c3 * *(bb.b+i3) + c4 * *(bb.b+i4));
00536
00537 xq = MAX( 0, MIN( 255, xq));
00538
00539 *out.b++ = rint(xq); break;
00540 case 1:
00541 bb.w = base.w+iq;
00542 xq = b1*(c1 * *(bb.w) + c2 * *(bb.w+i2)+ c3 * *(bb.w+i3) + c4 * *(bb.w+i4));
00543 bb.w += j2;
00544 xq += b2*(c1 * *(bb.w) + c2 * *(bb.w+i2)+ c3 * *(bb.w+i3) + c4 * *(bb.w+i4));
00545 bb.w += j3;
00546 xq += b3*(c1 * *(bb.w) + c2 * *(bb.w+i2)+ c3 * *(bb.w+i3) + c4 * *(bb.w+i4));
00547 bb.w += j4;
00548 xq += b4*(c1 * *(bb.w) + c2 * *(bb.w+i2)+ c3 * *(bb.w+i3) + c4 * *(bb.w+i4));
00549
00550 *out.w++ = rint(xq); break;
00551 case 2:
00552 bb.l = base.l+iq;
00553 xq = b1*(c1 * *(bb.l) + c2 * *(bb.l+i2)+ c3 * *(bb.l+i3) + c4 * *(bb.l+i4));
00554 bb.l += j2;
00555 xq += b2*(c1 * *(bb.l) + c2 * *(bb.l+i2)+ c3 * *(bb.l+i3) + c4 * *(bb.l+i4));
00556 bb.l += j3;
00557 xq += b3*(c1 * *(bb.l) + c2 * *(bb.l+i2)+ c3 * *(bb.l+i3) + c4 * *(bb.l+i4));
00558 bb.l += j4;
00559 xq += b4*(c1 * *(bb.l) + c2 * *(bb.l+i2)+ c3 * *(bb.l+i3) + c4 * *(bb.l+i4));
00560
00561 *out.l++ = rint(xq); break;
00562 case 3:
00563 bb.f = base.f+iq;
00564 xq = b1*(c1 * *(bb.f) + c2 * *(bb.f+i2)+ c3 * *(bb.f+i3) + c4 * *(bb.f+i4));
00565 bb.f += j2;
00566 xq += b2*(c1 * *(bb.f) + c2 * *(bb.f+i2)+ c3 * *(bb.f+i3) + c4 * *(bb.f+i4));
00567 bb.f += j3;
00568 xq += b3*(c1 * *(bb.f) + c2 * *(bb.f+i2)+ c3 * *(bb.f+i3) + c4 * *(bb.f+i4));
00569 bb.f += j4;
00570 xq += b4*(c1 * *(bb.f) + c2 * *(bb.f+i2)+ c3 * *(bb.f+i3) + c4 * *(bb.f+i4));
00571 *out.f++ = xq; break;
00572 case 4:
00573 bb.d = base.d+iq;
00574 xq = b1*(c1 * *(bb.d) + c2 * *(bb.d+i2)+ c3 * *(bb.d+i3) + c4 * *(bb.d+i4));
00575 bb.d += j2;
00576 xq += b2*(c1 * *(bb.d) + c2 * *(bb.d+i2)+ c3 * *(bb.d+i3) + c4 * *(bb.d+i4));
00577 bb.d += j3;
00578 xq += b3*(c1 * *(bb.d) + c2 * *(bb.d+i2)+ c3 * *(bb.d+i3) + c4 * *(bb.d+i4));
00579 bb.d += j4;
00580 xq += b4*(c1 * *(bb.d) + c2 * *(bb.d+i2)+ c3 * *(bb.d+i3) + c4 * *(bb.d+i4));
00581 *out.d++ = xq; break;
00582 }
00583 return;
00584 }
00585