Changeset 826 for soft/giet_vm/applications/rosenfeld/nrc2/src/nrmem2x.c
- Timestamp:
- Jul 13, 2017, 11:01:58 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/rosenfeld/nrc2/src/nrmem2x.c
r772 r826 10 10 11 11 /* 12 * 2002/06/11 ajout des fonctions endline13 */12 * 2002/06/11 ajout des fonctions endline 13 */ 14 14 #include <stdio.h> 15 15 #include <stddef.h> 16 16 #include <stdlib.h> 17 #include <math.h> // fabs18 17 19 18 #include "mypredef.h" … … 29 28 #include "nrmem2x.h" 30 29 30 31 31 /* ------------------------------------------ */ 32 32 /* --- ATTENTION ---------------------------- */ … … 34 34 /* l'utilisation des fonctions endline */ 35 35 /* necessite l'allocation d'une ligne de plus */ 36 /* (a cause du m[i +1]*/36 /* (a cause du m[i + 1] */ 37 37 /* ------------------------------------------ */ 38 /* ------------------------------------------------------------------------------------ */ 39 IMAGE_EXPORT(void) reset_endline_bmatrix(byte **m, long nrl, long nrh, long ncl, long nch) 40 /* ------------------------------------------------------------------------------------ */ 41 { 42 long i, ncol=nch-ncl+1; 43 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 44 return; 45 } 46 /* --------------------------------------------------------------------------------------- */ 47 IMAGE_EXPORT(void) reset_endline_i16matrix(int16 **m, long nrl, long nrh, long ncl, long nch) 48 /* --------------------------------------------------------------------------------------- */ 49 { 50 long i, ncol=nch-ncl+1; 51 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 52 return; 53 } 54 /* ----------------------------------------------------------------------------------------- */ 55 IMAGE_EXPORT(void) reset_endline_ui16matrix(uint16 **m, long nrl, long nrh, long ncl, long nch) 56 /* ----------------------------------------------------------------------------------------- */ 57 { 58 long i, ncol=nch-ncl+1; 59 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 60 return; 61 } 62 /* ----------------------------------------------------------------------------------- */ 63 IMAGE_EXPORT(void) reset_endline_imatrix(int **m, long nrl, long nrh, long ncl, long nch) 64 /* ----------------------------------------------------------------------------------- */ 65 { 66 long i, ncol=nch-ncl+1; 67 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 68 return; 69 } 70 /* --------------------------------------------------------------------------------------- */ 71 IMAGE_EXPORT(void) reset_endline_i32matrix(int32 **m, long nrl, long nrh, long ncl, long nch) 72 /* --------------------------------------------------------------------------------------- */ 73 { 74 long i, ncol=nch-ncl+1; 75 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 76 return; 77 } 78 /* ----------------------------------------------------------------------------------------- */ 79 IMAGE_EXPORT(void) reset_endline_ui32matrix(uint32 **m, long nrl, long nrh, long ncl, long nch) 80 /* ----------------------------------------------------------------------------------------- */ 81 { 82 long i, ncol=nch-ncl+1; 83 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 84 return; 85 } 86 /* --------------------------------------------------------------------------------------- */ 87 IMAGE_EXPORT(void) reset_endline_i64matrix(int64 **m, long nrl, long nrh, long ncl, long nch) 88 /* --------------------------------------------------------------------------------------- */ 89 { 90 long i, ncol=nch-ncl+1; 91 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 92 return; 93 } 94 95 /* ------------------------------------------------------ */ 96 IMAGE_EXPORT(void) endline_bmatrix(byte **m, long i, long l) 97 /* ------------------------------------------------------ */ 98 { 99 m[i+1] = m[i] + l; 100 } 101 /* --------------------------------------------------------- */ 102 IMAGE_EXPORT(void) endline_i16matrix(int16 **m, long i, long l) 103 /* --------------------------------------------------------- */ 104 { 105 m[i+1] = m[i] + l; 106 } 107 /* ----------------------------------------------------------- */ 108 IMAGE_EXPORT(void) endline_ui16matrix(uint16 **m, long i, long l) 109 /* ----------------------------------------------------------- */ 110 { 111 m[i+1] = m[i] + l; 112 } 113 /* ----------------------------------------------------- */ 114 IMAGE_EXPORT(void) endline_imatrix(int **m, long i, long l) 115 /* ----------------------------------------------------- */ 116 { 117 m[i+1] = m[i] + l; 118 } 119 /* --------------------------------------------------------- */ 120 IMAGE_EXPORT(void) endline_i32matrix(int32 **m, long i, long l) 121 /* --------------------------------------------------------- */ 122 { 123 m[i+1] = m[i] + l; 124 } 125 /* ----------------------------------------------------------- */ 126 IMAGE_EXPORT(void) endline_ui32matrix(uint32 **m, long i, long l) 127 /* ----------------------------------------------------------- */ 128 { 129 m[i+1] = m[i] + l; 130 } 131 /* --------------------------------------------------------- */ 132 IMAGE_EXPORT(void) endline_i64matrix(int64 **m, long i, long l) 133 /* --------------------------------------------------------- */ 134 { 135 m[i+1] = m[i] + l; 136 } 137 /* ----------------------------------------------------------------- */ 138 IMAGE_EXPORT(void) endline0_bmatrix(byte **m, long i, long l, long ncl) 139 /* ----------------------------------------------------------------- */ 140 { 141 m[i+1] = m[i] + l + 1; 142 143 m[i][ncl] = (byte) l; 144 } 145 /* -------------------------------------------------------------------- */ 146 IMAGE_EXPORT(void) endline0_i16matrix(int16 **m, long i, long l, long ncl) 147 /* -------------------------------------------------------------------- */ 148 { 149 m[i+1] = m[i] + l + 1; 150 151 m[i][ncl] = (int16) l; 152 } 153 /* ---------------------------------------------------------------------- */ 154 IMAGE_EXPORT(void) endline0_ui16matrix(uint16 **m, long i, long l, long ncl) 155 /* ---------------------------------------------------------------------- */ 156 { 157 m[i+1] = m[i] + l + 1; 158 159 m[i][ncl] = (uint16) l; 160 } 161 /* ---------------------------------------------------------------- */ 162 IMAGE_EXPORT(void) endline0_imatrix(int **m, long i, long l, long ncl) 163 /* ---------------------------------------------------------------- */ 164 { 165 m[i+1] = m[i] + l + 1; 166 167 m[i][ncl] = (int) l; 168 } 169 /* -------------------------------------------------------------------- */ 170 IMAGE_EXPORT(void) endline0_i32matrix(int32 **m, long i, long l, long ncl) 171 /* -------------------------------------------------------------------- */ 172 { 173 m[i+1] = m[i] + l + 1; 174 175 m[i][ncl] = (int32) l; 176 } 177 /* ---------------------------------------------------------------------- */ 178 IMAGE_EXPORT(void) endline0_ui32matrix(uint32 **m, long i, long l, long ncl) 179 /* ---------------------------------------------------------------------- */ 180 { 181 m[i+1] = m[i] + l + 1; 182 183 m[i][ncl] = (uint32) l; 184 } 185 /* -------------------------------------------------------------------- */ 186 IMAGE_EXPORT(void) endline0_i64matrix(int64 **m, long i, long l, long ncl) 187 /* -------------------------------------------------------------------- */ 188 { 189 m[i+1] = m[i] + l + 1; 190 191 m[i][ncl] = (int64) l; 192 } 193 /* ----------------------------------------------------------------- */ 194 IMAGE_EXPORT(void) endline1_bmatrix(byte **m, long i, long l, long ncl) 195 /* ----------------------------------------------------------------- */ 196 { 197 m[i+1] = m[i] + l + 1; 198 199 m[i][ncl-1] = (byte) l; 200 } 201 /* -------------------------------------------------------------------- */ 202 IMAGE_EXPORT(void) endline1_i16matrix(int16 **m, long i, long l, long ncl) 203 /* -------------------------------------------------------------------- */ 204 { 205 m[i+1] = m[i] + l + 1; 206 207 m[i][ncl-1] = (int16) l; 208 } 209 /* ---------------------------------------------------------------------- */ 210 IMAGE_EXPORT(void) endline1_ui16matrix(uint16 **m, long i, long l, long ncl) 211 /* ---------------------------------------------------------------------- */ 212 { 213 m[i+1] = m[i] + l + 1; 214 215 m[i][ncl-1] = (uint16) l; 216 } 217 /* ---------------------------------------------------------------- */ 218 IMAGE_EXPORT(void) endline1_imatrix(int **m, long i, long l, long ncl) 219 /* ---------------------------------------------------------------- */ 220 { 221 m[i+1] = m[i] + l + 1; 222 223 m[i][ncl-1] = (int) l; 224 } 225 /* -------------------------------------------------------------------- */ 226 IMAGE_EXPORT(void) endline1_i32matrix(int32 **m, long i, long l, long ncl) 227 /* -------------------------------------------------------------------- */ 228 { 229 m[i+1] = m[i] + l + 1; 230 231 m[i][ncl-1] = (int32) l; 232 } 233 /* ---------------------------------------------------------------------- */ 234 IMAGE_EXPORT(void) endline1_ui32matrix(uint32 **m, long i, long l, long ncl) 235 /* ---------------------------------------------------------------------- */ 236 { 237 m[i+1] = m[i] + l + 1; 238 239 m[i][ncl-1] = (uint32) l; 240 } 241 /* -------------------------------------------------------------------- */ 242 IMAGE_EXPORT(void) endline1_i64matrix(int64 **m, long i, long l, long ncl) 243 /* -------------------------------------------------------------------- */ 244 { 245 m[i+1] = m[i] + l + 1; 246 247 m[i][ncl-1] = (int64) l; 248 } 249 250 /* -------------------------------------------------------------------------------------- */ 251 IMAGE_EXPORT(void) resize_si16Pmatrix(si16Point **m, long nrl, long nrh, long ncl, long nch) 252 /* -------------------------------------------------------------------------------------- */ 253 { 254 long i, ncol=nch-ncl+1; 255 256 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 257 } 258 /* -------------------------------------------------------------------------------------- */ 259 IMAGE_EXPORT(void) resize_ui16Pmatrix(ui16Point **m, long nrl, long nrh, long ncl, long nch) 260 /* -------------------------------------------------------------------------------------- */ 261 { 262 long i, ncol=nch-ncl+1; 263 264 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 265 } 266 /* -------------------------------------------------------------------------------------- */ 267 IMAGE_EXPORT(void) resize_si32Pmatrix(si32Point **m, long nrl, long nrh, long ncl, long nch) 268 /* -------------------------------------------------------------------------------------- */ 269 { 270 long i, ncol=nch-ncl+1; 271 272 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 273 } 274 /* -------------------------------------------------------------------------------------- */ 275 IMAGE_EXPORT(void) resize_ui32Pmatrix(ui32Point **m, long nrl, long nrh, long ncl, long nch) 276 /* -------------------------------------------------------------------------------------- */ 277 { 278 long i, ncol=nch-ncl+1; 279 280 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 281 } 282 /* ------------------------------------------------------------------------------------ */ 283 IMAGE_EXPORT(void) resize_f32Pmatrix(f32Point **m, long nrl, long nrh, long ncl, long nch) 284 /* ------------------------------------------------------------------------------------ */ 285 { 286 long i, ncol=nch-ncl+1; 287 288 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 289 } 290 // Triplet Matrix 291 /* ---------------------------------------------------------------------------------------- */ 292 IMAGE_EXPORT(void) resize_si16Tmatrix(si16Triplet **m, long nrl, long nrh, long ncl, long nch) 293 /* ---------------------------------------------------------------------------------------- */ 294 { 295 long i, ncol=nch-ncl+1; 296 297 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 298 } 299 /* ---------------------------------------------------------------------------------------- */ 300 IMAGE_EXPORT(void) resize_ui16Tmatrix(ui16Triplet **m, long nrl, long nrh, long ncl, long nch) 301 /* ---------------------------------------------------------------------------------------- */ 302 { 303 long i, ncol=nch-ncl+1; 304 305 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 306 } 307 /* ---------------------------------------------------------------------------------------- */ 308 IMAGE_EXPORT(void) resize_si32Tmatrix(si32Triplet **m, long nrl, long nrh, long ncl, long nch) 309 /* ---------------------------------------------------------------------------------------- */ 310 { 311 long i, ncol=nch-ncl+1; 312 313 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 314 } 315 /* ---------------------------------------------------------------------------------------- */ 316 IMAGE_EXPORT(void) resize_ui32Tmatrix(ui32Triplet **m, long nrl, long nrh, long ncl, long nch) 317 /* ---------------------------------------------------------------------------------------- */ 318 { 319 long i, ncol=nch-ncl+1; 320 321 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 322 } 323 /* -------------------------------------------------------------------------------------- */ 324 IMAGE_EXPORT(void) resize_f32Tmatrix(f32Triplet **m, long nrl, long nrh, long ncl, long nch) 325 /* -------------------------------------------------------------------------------------- */ 326 { 327 long i, ncol=nch-ncl+1; 328 329 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 330 } 38 39 #undef reset_endline_type_matrix 40 #define reset_endline_type_matrix(t) \ 41 void short_name(t,reset_endline_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ 42 { \ 43 int32_t ncol = nch - ncl + 1; \ 44 for (int32_t i = nrl + 1; i <= nrh; i++) { \ 45 m[i] = m[i - 1] + ncol; \ 46 } \ 47 } 48 49 reset_endline_type_matrix(int8_t); 50 reset_endline_type_matrix(uint8_t); 51 reset_endline_type_matrix(int16_t); 52 reset_endline_type_matrix(uint16_t); 53 reset_endline_type_matrix(int32_t); 54 reset_endline_type_matrix(uint32_t); 55 reset_endline_type_matrix(int64_t); 56 reset_endline_type_matrix(uint64_t); 57 58 59 #undef endline_type_matrix 60 #define endline_type_matrix(t) \ 61 void short_name(t,endline_,matrix)(t ** m, int32_t i, int32_t l) \ 62 { \ 63 m[i + 1] = m[i] + l; \ 64 } \ 65 void short_name(t,endline0_,matrix)(t ** m, int32_t i, int32_t l, int32_t ncl) \ 66 { \ 67 m[i + 1] = m[i] + l + 1; \ 68 m[i][ncl] = (t) l; \ 69 } \ 70 void short_name(t,endline1_,matrix)(t ** m, int32_t i, int32_t l, int32_t ncl) \ 71 { \ 72 m[i + 1] = m[i] + l + 1; \ 73 m[i][ncl - 1] = (t) l; \ 74 } 75 76 endline_type_matrix(int8_t); 77 endline_type_matrix(uint8_t); 78 endline_type_matrix(int16_t); 79 endline_type_matrix(uint16_t); 80 endline_type_matrix(int32_t); 81 endline_type_matrix(uint32_t); 82 endline_type_matrix(int64_t); 83 endline_type_matrix(uint64_t); 84 85 86 #undef resize_type_matrix 87 #define resize_type_matrix(t) \ 88 void short_name(t,resize_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ 89 { \ 90 int32_t ncol = nch - ncl + 1; \ 91 for (int32_t i = nrl + 1; i <= nrh; i++) { \ 92 m[i] = m[i - 1] + ncol; \ 93 } \ 94 } 95 96 resize_type_matrix(si16Point); 97 resize_type_matrix(ui16Point); 98 resize_type_matrix(si32Point); 99 resize_type_matrix(ui32Point); 100 resize_type_matrix(f32Point); 101 resize_type_matrix(si16Triplet); 102 resize_type_matrix(ui16Triplet); 103 resize_type_matrix(si32Triplet); 104 resize_type_matrix(ui32Triplet); 105 resize_type_matrix(f32Triplet); 106 107 331 108 /* 332 109 * -------------- … … 334 111 * -------------- 335 112 */ 336 /* ---------------------------------------------------------------- */ 337 IMAGE_EXPORT(void) bmatrix_reverse(byte **m, long nrl, long nrh, long ncl, long nch) 338 /* ---------------------------------------------------------------- */ 339 { 340 long i, mrow=(nrl+nrh+1)/2; 341 byte *t; 342 343 for(i=nrl; i<mrow; i++) { 344 t = m[i]; 345 m[i] = m[nrh-i]; 346 m[nrh-i] = t; 347 } 348 } 349 /* ----------------------------------------------------------------- */ 350 IMAGE_EXPORT(void) smatrix_reverse(sint16 **m, long nrl, long nrh, long ncl, long nch) 351 /* ----------------------------------------------------------------- */ 352 { 353 long i, mrow=(nrl+nrh+1)/2; 354 sint16 *t; 355 356 for(i=nrl; i<mrow; i++) { 357 t = m[i]; 358 m[i] = m[nrh-i]; 359 m[nrh-i] = t; 360 } 361 } 362 /* ------------------------------------------------------------------- */ 363 IMAGE_EXPORT(void) usmatrix_reverse(uint16 **m, long nrl, long nrh, long ncl, long nch) 364 /* ------------------------------------------------------------------- */ 365 { 366 long i, mrow=(nrl+nrh+1)/2; 367 uint16 *t; 368 369 for(i=nrl; i<mrow; i++) { 370 t = m[i]; 371 m[i] = m[nrh-i]; 372 m[nrh-i] = t; 373 } 374 } 375 /* --------------------------------------------------------------------------------------------------------- */ 376 IMAGE_EXPORT(void) desinterlace_bmatrix(byte **S, long nrl, long nrh, long ncl, long nch, byte **D0, byte **D1) 377 /* --------------------------------------------------------------------------------------------------------- */ 378 { 379 int i, i0, i1; 380 int j; 381 382 i0 = i1 = nrl; 383 384 if((nrl&1)==0) { 385 386 // nrl is even 387 for(i=nrl; i<=nrh; i+=2) { 388 //dup_bvector(S[i+0], ncl, nch, D0[i0++]); 389 //dup_bvector(S[i+1], ncl, nch, D1[i1++]); 390 for(j=ncl; j<=nch; j++) D0[i0][j] = S[i][j]; i0++; 391 for(j=ncl; j<=nch; j++) D1[i1][j] = S[i][j]; i1++; 392 } 393 // epilog 394 if((nrh&1)==0) { 395 //dup_bvector(S[nrh], ncl, nch, D0[i0]); 396 for(j=ncl; j<=nch; j++) D0[i0][j] = S[i][j]; i0++; 397 } 398 399 } else { 400 401 // nrl is odd 402 for(i=nrl; i<=nrh; i+=2) { 403 //dup_bvector(S[i+0], ncl, nch, D1[i1++]); 404 //dup_bvector(S[i+1], ncl, nch, D0[i0++]); 405 for(j=ncl; j<=nch; j++) D1[i1][j] = S[i][j]; i1++; 406 for(j=ncl; j<=nch; j++) D0[i0][j] = S[i][j]; i0++; 407 } 408 // epilog 409 if((nrh&1)==1) { 410 //dup_bvector(S[nrh], ncl, nch, D1[i1]); 411 for(j=ncl; j<=nch; j++) D1[i1][j] = S[i][j]; i1++; 412 } 413 } 414 } 415 /* ------------------------------------------------------------------------------------------------------------ */ 416 IMAGE_EXPORT(void) desinterlace_rgb8matrix(rgb8 **S, long nrl, long nrh, long ncl, long nch, rgb8 **D0, rgb8 **D1) 417 /* ------------------------------------------------------------------------------------------------------------ */ 418 { 419 int i, i0, i1; 420 int j; 421 422 i0 = i1 = nrl; 423 424 if((nrl&1)==0) { 425 426 // nrl is even 427 for(i=nrl; i<=nrh; i+=2) { 428 //dup_rgb8vector(S[i+0], ncl, nch, D0[i0++]); 429 //dup_rgb8vector(S[i+1], ncl, nch, D1[i1++]); 430 for(j=ncl; j<=nch; j++) D0[i0][j] = S[i][j]; i0++; 431 for(j=ncl; j<=nch; j++) D1[i1][j] = S[i][j]; i1++; 432 } 433 // epilog 434 if((nrh&1)==0) { 435 //dup_rgb8vector(S[nrh], ncl, nch, D0[i0]); 436 for(j=ncl; j<=nch; j++) D0[i0][j] = S[i][j]; i0++; 437 } 438 439 } else { 440 441 // nrl is odd 442 for(i=nrl; i<=nrh; i+=2) { 443 //dup_rgb8vector(S[i+0], ncl, nch, D1[i1++]); 444 //dup_rgb8vector(S[i+1], ncl, nch, D0[i0++]); 445 for(j=ncl; j<=nch; j++) D1[i1][j] = S[i][j]; i1++; 446 for(j=ncl; j<=nch; j++) D0[i0][j] = S[i][j]; i0++; 447 } 448 // epilog 449 if((nrh&1)==1) { 450 //dup_rgb8vector(S[nrh], ncl, nch, D1[i1]); 451 for(j=ncl; j<=nch; j++) D1[i1][j] = S[i][j]; i1++; 452 } 453 } 454 } 455 /* ------------------------------------------------------------------------------------------------------- */ 456 IMAGE_EXPORT(void) interlace_bmatrix(byte **S0, long nrl, long nrh, long ncl, long nch, byte **S1, byte **D) 457 /* ------------------------------------------------------------------------------------------------------- */ 458 { 459 // S1 & S2 are supposed to have the same height 460 int i, i0, i1; 461 int j; 462 463 i0 = i1 = nrl; 464 465 for(i=nrl; i<=nrh;) { 466 //dup_bvector(S0[i0++], ncl, nch, D[i++]); 467 //dup_bvector(S1[i1++], ncl, nch, D[i++]); 468 for(j=ncl; j<=nch; j++) D[i][j] = S0[i0][j]; i++; i0++; 469 for(j=ncl; j<=nch; j++) D[i][j] = S0[i1][j]; i++; i1++; 470 } 471 } 472 /* ---------------------------------------------------------------------------------------------------------- */ 473 IMAGE_EXPORT(void) interlace_rgb8matrix(rgb8 **S0, long nrl, long nrh, long ncl, long nch, rgb8 **S1, rgb8 **D) 474 /* ---------------------------------------------------------------------------------------------------------- */ 475 { 476 int i, i0, i1; 477 int j; 478 479 i0 = i1 = nrl; 480 481 for(i=nrl; i<=nrh;) { 482 //dup_rgb8vector(S0[i0++], ncl, nch, D[i++]); 483 //dup_rgb8vector(S1[i1++], ncl, nch, D[i++]); 484 for(j=ncl; j<=nch; j++) D[i][j] = S0[i0][j]; i++; i0++; 485 for(j=ncl; j<=nch; j++) D[i][j] = S0[i1][j]; i++; i1++; 486 } 487 } 488 489 /* ---------------------------------------------------------------------------------------------- */ 490 IMAGE_EXPORT(void) copyc_bmatrix(byte **src,long nrl,long nrh,long ncl, long nch, byte **cond, byte c, byte **dst) 491 /* ---------------------------------------------------------------------------------------------- */ 492 { 493 long i, j; 494 byte *Xi, *Yi, *Ci; 495 496 for(i=nrl; i<=nrh; i++) { 497 Xi = src [i]; 498 Yi = dst [i]; 499 Ci = cond[i]; 500 for(j=ncl; j<=nch; j++) { 501 if(Ci[j] == c) Yi[j] = Xi[j]; else Yi[j] = 0; 502 } 503 } 504 } 505 /* ------------------------------------------------------------------------------ */ 506 IMAGE_EXPORT(void) complete_border_ui8matrix(uint8 **m, long nrl,long nrh,long ncl, long nch, long n) 507 /* ------------------------------------------------------------------------------ */ 508 { 509 long i, j; 510 511 uint8 *Xi; 512 513 for(i=nrl; i<=nrh; i++) { 514 Xi = m[i]; 515 for(j=1; j<=n; j++) { 516 Xi[ncl-j] = Xi[ncl]; 517 Xi[nch+j] = Xi[nch]; 518 } 519 } 520 for(i=1; i<=n; i++) 521 dup_ui8vector(m[nrl], ncl-n, nch+n, m[nrl-i]); 522 for(i=1; i<=n; i++) 523 dup_ui8vector(m[nrh], ncl-n, nch+n, m[nrh+i]); 524 } 525 /* ------------------------------------------------------------------------------------- */ 526 IMAGE_EXPORT(void) complete_border1_ui8matrix(uint8 **m, long nrl,long nrh,long ncl, long nch) 527 /* ------------------------------------------------------------------------------------- */ 528 { 529 long i; 530 uint8 *Xi; 531 532 dup_ui8vector(m[nrl+1], ncl, nch, m[nrl]); 533 534 for(i=nrl; i<=nrh; i++) { 535 Xi = m[i]; 536 Xi[nrl] = Xi[nrl+1]; 537 Xi[nrh] = Xi[nrh-1]; 538 } 539 540 dup_ui8vector(m[nrh-1], ncl, nch, m[nrh]); 541 } 542 /* ------------------------------------------------------------------------------------- */ 543 IMAGE_EXPORT(void) complete_border2_ui8matrix(uint8 **m, long nrl,long nrh,long ncl, long nch) 544 /* ------------------------------------------------------------------------------------- */ 545 { 546 long i; 547 uint8 *Xi; 548 549 dup_ui8vector(m[nrl+2], ncl, nch, m[nrl+0]); 550 dup_ui8vector(m[nrl+2], ncl, nch, m[nrl+1]); 551 552 553 for(i=nrl; i<=nrh; i++) { 554 Xi = m[i]; 555 Xi[nrl] = Xi[nrl+1] = Xi[nrl+2]; 556 Xi[nrh] = Xi[nrh-1] = Xi[nrh-2]; 557 } 558 559 dup_ui8vector(m[nrh-2], ncl, nch, m[nrh-1]); 560 dup_ui8vector(m[nrh-2], ncl, nch, m[nrh-0]); 561 } 562 /* ------------------------------------------------------------------------------------------------ */ 563 IMAGE_EXPORT(void) copy1c_ui8matrix(uint8 **X, long nc, uint8 **Y, long nrl, long nrh, long ncl, long nch) 564 /* ------------------------------------------------------------------------------------------------ */ 565 { 566 int i; 567 568 for(i=nrl; i<=nrh; i++) { 569 //copy1c_ui8vector(X[i], nc, Y[i], ncl, nch); 570 } 571 } 572 /* -------------------------------------------------------------------------------------------------- */ 573 IMAGE_EXPORT(void) copy1c_ui16matrix(uint16 **X, long nc, uint16 **Y, long nrl, long nrh, long ncl, long nch) 574 /* -------------------------------------------------------------------------------------------------- */ 575 { 576 int i; 577 578 for(i=nrl; i<=nrh; i++) { 579 //copy1c_ui16vector(X[i], nc, Y[i], ncl, nch); 580 } 581 } 582 /* ---------------------------------------------------------------------------------------------- */ 583 IMAGE_EXPORT(void) copy1c_ui32matrix(uint32 **X, long nc, uint32 **Y, long nrl, long nrh, long ncl, long nch) 584 /* ---------------------------------------------------------------------------------------------- */ 585 { 586 int i; 587 588 for(i=nrl; i<=nrh; i++) { 589 //copy1c_ui32vector(X[i], nc, Y[i], ncl, nch); 590 } 591 } 592 /* ------------------------------------------------------------------------------------------------- */ 593 IMAGE_EXPORT(void) copy1c_f32matrix(float32 **X, long nc, float32 **Y, long nrl, long nrh, long ncl, long nch) 594 /* ------------------------------------------------------------------------------------------------- */ 595 { 596 int i; 597 598 for(i=nrl; i<=nrh; i++) { 599 //copy1c_f32vector(X[i], nc, Y[i], ncl, nch); 600 } 601 } 602 /* ---------------------------------------------------------------------------------------------------- */ 603 IMAGE_EXPORT(void) copy1c_f64matrix(float64 **X, long nc, float64 **Y, long nrl, long nrh, long ncl, long nch) 604 /* ---------------------------------------------------------------------------------------------------- */ 605 { 606 int i; 607 608 for(i=nrl; i<=nrh; i++) { 609 //copy1c_f64vector(X[i], nc, Y[i], ncl, nch); 610 } 611 } 612 /* --------------------------------------------------------------------------------------------------- */ 613 IMAGE_EXPORT(void) copy1c_rgb8matrix(rgb8 **X, long nc, rgb8 **Y, long nrl, long nrh, long ncl, long nch) 614 /* --------------------------------------------------------------------------------------------------- */ 615 { 616 int i; 617 618 for(i=nrl; i<=nrh; i++) { 619 //copy1c_rgb8vector(X[i], nc, Y[i], ncl, nch); 620 } 621 } 622 /* ------------------------------------------------------------------------------------------------------ */ 623 IMAGE_EXPORT(void) copy1c_rgbx8matrix(rgbx8 **X, long nc, rgbx8 **Y, long nrl, long nrh, long ncl, long nch) 624 /* ------------------------------------------------------------------------------------------------------ */ 625 { 626 int i; 627 628 for(i=nrl; i<=nrh; i++) { 629 //copy1c_rgbx8vector(X[i], nc, Y[i], ncl, nch); 630 } 631 } 632 /* ------------------------------------------------------------------------------------------------ */ 633 IMAGE_EXPORT(void) copy1r_ui8matrix(uint8 **X, long nr, uint8 **Y, long nrl, long nrh, long ncl, long nch) 634 /* ------------------------------------------------------------------------------------------------ */ 635 { 636 int i; 637 638 for(i=nrl; i<=nrh; i++) { 639 dup_ui8vector(X[nr], ncl, nch, Y[i]); 640 } 641 } 642 /* -------------------------------------------------------------------------------------------------- */ 643 IMAGE_EXPORT(void) copy1r_ui16matrix(uint16 **X, long nr, uint16 **Y, long nrl, long nrh, long ncl, long nch) 644 /* -------------------------------------------------------------------------------------------------- */ 645 { 646 int i; 647 648 for(i=nrl; i<=nrh; i++) { 649 dup_ui16vector(X[nr], ncl, nch, Y[i]); 650 } 651 } 652 /* ---------------------------------------------------------------------------------------------- */ 653 IMAGE_EXPORT(void) copy1r_ui32matrix(uint32 **X, long nr, uint32 **Y, long nrl, long nrh, long ncl, long nch) 654 /* ---------------------------------------------------------------------------------------------- */ 655 { 656 int i; 657 658 for(i=nrl; i<=nrh; i++) { 659 dup_ui32vector(X[nr], ncl, nch, Y[i]); 660 } 661 } 662 /* ------------------------------------------------------------------------------------------------- */ 663 IMAGE_EXPORT(void) copy1r_f32matrix(float32 **X, long nr, float32 **Y, long nrl, long nrh, long ncl, long nch) 664 /* ------------------------------------------------------------------------------------------------- */ 665 { 666 int i; 667 668 for(i=nrl; i<=nrh; i++) { 669 dup_f32vector(X[nr], ncl, nch, Y[i]); 670 } 671 } 672 /* ---------------------------------------------------------------------------------------------------- */ 673 IMAGE_EXPORT(void) copy1r_f64matrix(float64 **X, long nr, float64 **Y, long nrl, long nrh, long ncl, long nch) 674 /* ---------------------------------------------------------------------------------------------------- */ 675 { 676 int i; 677 678 for(i=nrl; i<=nrh; i++) { 679 dup_f64vector(X[nr], ncl, nch, Y[i]); 680 } 681 } 682 /* --------------------------------------------------------------------------------------------------- */ 683 IMAGE_EXPORT(void) copy1r_rgb8matrix(rgb8 **X, long nr, rgb8 **Y, long nrl, long nrh, long ncl, long nch) 684 /* --------------------------------------------------------------------------------------------------- */ 685 { 686 int i; 687 688 for(i=nrl; i<=nrh; i++) { 689 dup_rgb8vector(X[nr], ncl, nch, Y[i]); 690 } 691 } 692 /* ------------------------------------------------------------------------------------------------------ */ 693 IMAGE_EXPORT(void) copy1r_rgbx8matrix(rgbx8 **X, long nr, rgbx8 **Y, long nrl, long nrh, long ncl, long nch) 694 /* ------------------------------------------------------------------------------------------------------ */ 695 { 696 int i; 697 698 for(i=nrl; i<=nrh; i++) { 699 dup_rgbx8vector(X[nr], ncl, nch, Y[i]); 700 } 701 } 113 114 #undef type_matrix_reverse 115 #define type_matrix_reverse(t) \ 116 void short_name(t,,matrix_reverse)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ 117 { \ 118 int32_t mrow = (nrl + nrh + 1) / 2; \ 119 t * temp; \ 120 for (int32_t i = nrl; i < mrow; i++) { \ 121 temp = m[i]; \ 122 m[i] = m[nrh - i]; \ 123 m[nrh - i] = temp; \ 124 } \ 125 } 126 127 type_matrix_reverse(int8_t); 128 type_matrix_reverse(uint8_t); 129 type_matrix_reverse(int16_t); 130 type_matrix_reverse(uint16_t); 131 type_matrix_reverse(int32_t); 132 type_matrix_reverse(uint32_t); 133 type_matrix_reverse(int64_t); 134 type_matrix_reverse(uint64_t); 135 type_matrix_reverse(float); 136 type_matrix_reverse(double); 137 138 139 #undef desinterlace_type_matrix 140 #define desinterlace_type_matrix(t) \ 141 void short_name(t,desinterlace_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** D0, t ** D1) \ 142 { \ 143 int32_t i0, i1; \ 144 i0 = i1 = nrl; \ 145 if ((nrl & 1) == 0) { \ 146 /* nrl is even */ \ 147 for (int32_t i = nrl; i <= nrh; i += 2) { \ 148 for (int32_t j = ncl; j <= nch; j++) { \ 149 D0[i0][j] = S[i][j]; \ 150 } \ 151 i0++; \ 152 for (int32_t j = ncl; j <= nch; j++) { \ 153 D1[i1][j] = S[i][j]; \ 154 } \ 155 i1++; \ 156 } \ 157 /* epilog */ \ 158 if ((nrh & 1) == 0) { \ 159 for (int32_t j = ncl; j <= nch; j++) { \ 160 D0[i0][j] = S[nrh][j]; \ 161 } \ 162 i0++; \ 163 } \ 164 } \ 165 else { \ 166 /* nrl is odd */ \ 167 for (int32_t i = nrl; i <= nrh; i += 2) { \ 168 for (int32_t j = ncl; j <= nch; j++) { \ 169 D1[i1][j] = S[i][j]; \ 170 } \ 171 i1++; \ 172 for (int32_t j = ncl; j <= nch; j++) { \ 173 D0[i0][j] = S[i][j]; \ 174 } \ 175 i0++; \ 176 } \ 177 /* epilog */ \ 178 if ((nrh & 1) == 1) { \ 179 for (int32_t j = ncl; j <= nch; j++) { \ 180 D1[i1][j] = S[nrh][j]; \ 181 } \ 182 i1++; \ 183 } \ 184 } \ 185 } 186 187 desinterlace_type_matrix(int8_t); 188 desinterlace_type_matrix(uint8_t); 189 desinterlace_type_matrix(int16_t); 190 desinterlace_type_matrix(uint16_t); 191 desinterlace_type_matrix(int32_t); 192 desinterlace_type_matrix(uint32_t); 193 desinterlace_type_matrix(int64_t); 194 desinterlace_type_matrix(uint64_t); 195 desinterlace_type_matrix(float); 196 desinterlace_type_matrix(double); 197 desinterlace_type_matrix(rgb8); 198 desinterlace_type_matrix(rgbx8); 199 200 201 202 #undef interlace_type_matrix 203 #define interlace_type_matrix(t) \ 204 void short_name(t,interlace_,matrix)(t ** S0, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** S1, t ** D) \ 205 { \ 206 /* S1 & S2 are supposed to have the same height */ \ 207 int i0, i1; \ 208 i0 = i1 = nrl; \ 209 for (int32_t i = nrl; i <= nrh;) { \ 210 for (int32_t j = ncl; j <= nch; j++) { \ 211 D[i][j] = S0[i0][j]; \ 212 } \ 213 i++; \ 214 i0++; \ 215 for (int32_t j = ncl; j <= nch; j++) { \ 216 D[i][j] = S0[i1][j]; \ 217 } \ 218 i++; \ 219 i1++; \ 220 } \ 221 } 222 223 interlace_type_matrix(int8_t); 224 interlace_type_matrix(uint8_t); 225 interlace_type_matrix(int16_t); 226 interlace_type_matrix(uint16_t); 227 interlace_type_matrix(int32_t); 228 interlace_type_matrix(uint32_t); 229 interlace_type_matrix(int64_t); 230 interlace_type_matrix(uint64_t); 231 interlace_type_matrix(float); 232 interlace_type_matrix(double); 233 interlace_type_matrix(rgb8); 234 interlace_type_matrix(rgbx8); 235 236 237 #undef copyc_type_matrix 238 #define copyc_type_matrix(t) \ 239 void short_name(t,copyc_,matrix)(t ** src, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** cond, t c, t ** dst) \ 240 { \ 241 t * Xi; \ 242 t * Yi; \ 243 t * Ci; \ 244 for (int32_t i = nrl; i <= nrh; i++) { \ 245 Xi = src [i]; \ 246 Yi = dst [i]; \ 247 Ci = cond[i]; \ 248 for (int32_t j = ncl; j <= nch; j++) { \ 249 if (Ci[j] == c) { \ 250 Yi[j] = Xi[j]; \ 251 } \ 252 else { \ 253 Yi[j] = 0; \ 254 } \ 255 } \ 256 } \ 257 } 258 259 copyc_type_matrix(int8_t); 260 copyc_type_matrix(uint8_t); 261 copyc_type_matrix(int16_t); 262 copyc_type_matrix(uint16_t); 263 copyc_type_matrix(int32_t); 264 copyc_type_matrix(uint32_t); 265 copyc_type_matrix(int64_t); 266 copyc_type_matrix(uint64_t); 267 copyc_type_matrix(float); 268 copyc_type_matrix(double); 269 270 271 #undef complete_border_type_matrix 272 #define complete_border_type_matrix(t) \ 273 void short_name(t,complete_border_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, int32_t n) \ 274 { \ 275 t * Xi; \ 276 for (int32_t i = nrl; i <= nrh; i++) { \ 277 Xi = m[i]; \ 278 for (int32_t j = 1; j <= n; j++) { \ 279 Xi[ncl - j] = Xi[ncl]; \ 280 Xi[nch + j] = Xi[nch]; \ 281 } \ 282 } \ 283 for (int32_t i = 1; i <= n; i++) { \ 284 short_name(t,dup_,vector)(m[nrl], ncl - n, nch + n, m[nrl - i]); \ 285 } \ 286 for (int32_t i = 1; i <= n; i++) { \ 287 short_name(t,dup_,vector)(m[nrh], ncl - n, nch + n, m[nrh + i]); \ 288 } \ 289 } 290 291 complete_border_type_matrix(int8_t); 292 complete_border_type_matrix(uint8_t); 293 complete_border_type_matrix(int16_t); 294 complete_border_type_matrix(uint16_t); 295 complete_border_type_matrix(int32_t); 296 complete_border_type_matrix(uint32_t); 297 complete_border_type_matrix(int64_t); 298 complete_border_type_matrix(uint64_t); 299 complete_border_type_matrix(float); 300 complete_border_type_matrix(double); 301 complete_border_type_matrix(rgb8); 302 complete_border_type_matrix(rgbx8); 303 304 305 #undef complete_border1_type_matrix 306 #define complete_border1_type_matrix(t) \ 307 void short_name(t,complete_border1_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ 308 { \ 309 t * Xi; \ 310 short_name(t,dup_,vector)(m[nrl + 1], ncl, nch, m[nrl]); \ 311 for (int32_t i = nrl; i <= nrh; i++) { \ 312 Xi = m[i]; \ 313 Xi[nrl] = Xi[nrl + 1]; \ 314 Xi[nrh] = Xi[nrh - 1]; \ 315 } \ 316 short_name(t,dup_,vector)(m[nrh - 1], ncl, nch, m[nrh]); \ 317 } 318 319 complete_border1_type_matrix(int8_t); 320 complete_border1_type_matrix(uint8_t); 321 complete_border1_type_matrix(int16_t); 322 complete_border1_type_matrix(uint16_t); 323 complete_border1_type_matrix(int32_t); 324 complete_border1_type_matrix(uint32_t); 325 complete_border1_type_matrix(int64_t); 326 complete_border1_type_matrix(uint64_t); 327 complete_border1_type_matrix(float); 328 complete_border1_type_matrix(double); 329 complete_border1_type_matrix(rgb8); 330 complete_border1_type_matrix(rgbx8); 331 332 333 #undef complete_border2_type_matrix 334 #define complete_border2_type_matrix(t) \ 335 void short_name(t,complete_border2_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ 336 { \ 337 t * Xi; \ 338 short_name(t,dup_,vector)(m[nrl + 2], ncl, nch, m[nrl + 0]); \ 339 short_name(t,dup_,vector)(m[nrl + 2], ncl, nch, m[nrl + 1]); \ 340 for (int32_t i = nrl; i <= nrh; i++) { \ 341 Xi = m[i]; \ 342 Xi[nrl] = Xi[nrl + 1] = Xi[nrl + 2]; \ 343 Xi[nrh] = Xi[nrh - 1] = Xi[nrh - 2]; \ 344 } \ 345 short_name(t,dup_,vector)(m[nrh - 2], ncl, nch, m[nrh - 1]); \ 346 short_name(t,dup_,vector)(m[nrh - 2], ncl, nch, m[nrh - 0]); \ 347 } 348 349 complete_border2_type_matrix(int8_t); 350 complete_border2_type_matrix(uint8_t); 351 complete_border2_type_matrix(int16_t); 352 complete_border2_type_matrix(uint16_t); 353 complete_border2_type_matrix(int32_t); 354 complete_border2_type_matrix(uint32_t); 355 complete_border2_type_matrix(int64_t); 356 complete_border2_type_matrix(uint64_t); 357 complete_border2_type_matrix(float); 358 complete_border2_type_matrix(double); 359 complete_border2_type_matrix(rgb8); 360 complete_border2_type_matrix(rgbx8); 361 362 363 #undef copy1c_type_matrix 364 #define copy1c_type_matrix(t) \ 365 void short_name(t,copy1c_,matrix)(t ** X, int32_t nc, t ** Y, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ 366 { \ 367 for (int32_t i = nrl; i <= nrh; i++) { \ 368 /* copy1c_ui8vector(X[i], nc, Y[i], ncl, nch); */ \ 369 } \ 370 } 371 372 copy1c_type_matrix(int8_t); 373 copy1c_type_matrix(uint8_t); 374 copy1c_type_matrix(int16_t); 375 copy1c_type_matrix(uint16_t); 376 copy1c_type_matrix(int32_t); 377 copy1c_type_matrix(uint32_t); 378 copy1c_type_matrix(int64_t); 379 copy1c_type_matrix(uint64_t); 380 copy1c_type_matrix(float); 381 copy1c_type_matrix(double); 382 copy1c_type_matrix(rgb8); 383 copy1c_type_matrix(rgbx8); 384 385 386 #undef copy1r_type_matrix 387 #define copy1r_type_matrix(t) \ 388 void short_name(t,copy1r_,matrix)(t ** X, int32_t nr, t ** Y, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ 389 { \ 390 for (int32_t i = nrl; i <= nrh; i++) { \ 391 short_name(t,dup_,vector)(X[nr], ncl, nch, Y[i]); \ 392 } \ 393 } 394 395 copy1r_type_matrix(int8_t); 396 copy1r_type_matrix(uint8_t); 397 copy1r_type_matrix(int16_t); 398 copy1r_type_matrix(uint16_t); 399 copy1r_type_matrix(int32_t); 400 copy1r_type_matrix(uint32_t); 401 copy1r_type_matrix(int64_t); 402 copy1r_type_matrix(uint64_t); 403 copy1r_type_matrix(float); 404 copy1r_type_matrix(double); 405 copy1r_type_matrix(rgb8); 406 copy1r_type_matrix(rgbx8); 407 408 409 // Local Variables: 410 // tab-width: 4 411 // c-basic-offset: 4 412 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 413 // indent-tabs-mode: nil 414 // End: 415 416 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 417
Note: See TracChangeset
for help on using the changeset viewer.