Changeset 1193
- Timestamp:
- Jul 7, 2004, 3:05:01 PM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 20 edited
-
psLib.kdevses (modified) (1 diff)
-
src/collections/psList.c (modified) (5 diffs)
-
src/collections/psList.h (modified) (2 diffs)
-
src/image/psImage.c (modified) (6 diffs)
-
src/image/psImage.d (modified) (1 diff)
-
src/mathtypes/psImage.c (modified) (6 diffs)
-
src/types/psList.c (modified) (5 diffs)
-
src/types/psList.h (modified) (2 diffs)
-
test/collections/tst_psList.c (modified) (17 diffs)
-
test/dataManip/builddir/tst_psImageFFT.d (modified) (1 diff)
-
test/dataManip/builddir/tst_psImageIO.d (modified) (1 diff)
-
test/dataManip/builddir/tst_psVectorFFT.d (modified) (1 diff)
-
test/dataManip/tst_psVectorFFT.c (modified) (2 diffs)
-
test/image/tst_psImage.c (modified) (3 diffs)
-
test/image/tst_psImageFFT.c (modified) (2 diffs)
-
test/image/tst_psImageIO.c (modified) (2 diffs)
-
test/psTest.c (modified) (4 diffs)
-
test/psTest.h (modified) (1 diff)
-
test/sysUtils/builddir/tst_psMemory.d (modified) (1 diff)
-
test/sysUtils/tst_psMemory.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/psLib.kdevses
r1133 r1193 3 3 <KDevPrjSession> 4 4 <DocsAndViews NumberOfDocuments="3" > 5 <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/src/collections/ps List.h" >6 <View0 line=" 19" Type="???" >7 <AdditionalSettings Top="1" Width="11 33" Attach="1" Height="832" Left="1" MinMaxMode="0" />5 <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/src/collections/psImage.c" > 6 <View0 line="446" Type="???" > 7 <AdditionalSettings Top="1" Width="1180" Attach="1" Height="652" Left="1" MinMaxMode="0" /> 8 8 </View0> 9 9 </Doc0> 10 10 <Doc1 NumberOfViews="1" URL="file:/home/desonia/psLib/src/collections/psList.c" > 11 <View0 line=" 480" Type="???" >12 <AdditionalSettings Top="1" Width="11 33" Attach="1" Height="832" Left="1" MinMaxMode="0" />11 <View0 line="106" Type="???" > 12 <AdditionalSettings Top="1" Width="1180" Attach="1" Height="652" Left="1" MinMaxMode="0" /> 13 13 </View0> 14 14 </Doc1> 15 15 <Doc2 NumberOfViews="1" URL="file:/home/desonia/psLib/test/collections/tst_psList.c" > 16 <View0 line=" 969" Type="???" >17 <AdditionalSettings Top="1" Width="11 33" Attach="1" Height="832" Left="1" MinMaxMode="0" />16 <View0 line="311" Type="???" > 17 <AdditionalSettings Top="1" Width="1180" Attach="1" Height="652" Left="1" MinMaxMode="0" /> 18 18 </View0> 19 19 </Doc2> -
trunk/psLib/src/collections/psList.c
r1127 r1193 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 6-29 23:19:11$8 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-07-08 01:05:00 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 80 80 } 81 81 82 psList*psListAdd(psList *list, void *data, int where)82 bool psListAdd(psList *list, void *data, int where) 83 83 { 84 84 psListElem* position; … … 87 87 88 88 if (list == NULL) { 89 return NULL;89 return false; 90 90 } 91 91 92 92 if (data == NULL) { 93 return list; 94 } 95 elem = psAlloc(sizeof(psListElem)); 96 97 pthread_mutex_lock(&list->lock) 98 ; 93 return false; 94 } 99 95 100 96 if (where <= PS_LIST_UNKNOWN) { 101 97 /// XXX What is the better way to communicate this failure to the caller? 102 98 psLogMsg(__func__,PS_LOG_WARN, 103 "The given insert location (%i) for psListAdd is invalid. Adding to head instead.",99 "The given insert location (%i) for psListAdd is invalid.", 104 100 where); 105 where = PS_LIST_HEAD; // given I can't tell caller about this, should just add it somewhere??? 106 } 101 return false; 102 } 103 104 elem = psAlloc(sizeof(psListElem)); 105 106 pthread_mutex_lock(&list->lock) 107 ; 107 108 108 109 if (where > 0 && where > list->size) { … … 162 163 ; 163 164 164 return list; 165 } 166 167 /*****************************************************************************/ 168 169 psList *psListAppend(psList *list, void *data) 170 { 171 return psListAdd(list, data, PS_LIST_TAIL); 165 return true; 172 166 } 173 167 … … 452 446 n = arr->n; 453 447 for (int i = 0; i < n; i++) { 454 psListA ppend(list,arr->data.PTR[i]);448 psListAdd(list,arr->data.PTR[i],PS_LIST_TAIL); 455 449 } 456 450 -
trunk/psLib/src/collections/psList.h
r1127 r1193 10 10 * @ingroup LinkedList 11 11 * 12 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-0 6-29 23:19:11$12 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-07-08 01:05:00 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 81 81 * NULL, the return value will also be NULL. 82 82 */ 83 psList*psListAdd(83 bool psListAdd( 84 84 psList* restrict list, ///< list to add to (if NULL, nothing is done) 85 85 void* data, ///< data item to add. If NULL, list is not modified. 86 86 int where ///< index, PS_LIST_HEAD, PS_LIST_TAIL, or numbered location. 87 );88 89 /** Appends an item to a psList.90 *91 * @return psList* The psList with added data item. If list parameter is92 * NULL, the return value will also be NULL.93 */94 psList* psListAppend(95 psList* restrict list, ///< list to append to (if NULL, nothing is done)96 void *data ///< data item to add. If NULL, list is not modified.97 87 ); 98 88 -
trunk/psLib/src/image/psImage.c
r1165 r1193 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.3 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-07-0 1 00:26:37$11 * @version $Revision: 1.32 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-07-08 01:05:00 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 261 261 } 262 262 263 264 263 265 psImage *psImageCopy(psImage* restrict output, const psImage *input, 264 266 psElemType type) … … 266 268 psElemType inDatatype; 267 269 int elementSize; 270 int elements; 268 271 int numRows; 269 272 int numCols; … … 288 291 numRows = input->numRows; 289 292 numCols = input->numCols; 293 elements = numRows*numCols; 290 294 elementSize = PSELEMTYPE_SIZEOF(inDatatype); 291 295 … … 299 303 // cover the trival case of copy of the same datatype. 300 304 if (type == inDatatype) { 301 memcpy(output->data.V[0],input->data.V[0],elementSize* numRows*numCols);305 memcpy(output->data.V[0],input->data.V[0],elementSize*elements); 302 306 return output; 303 307 } 304 308 305 #define PSIMAGE_ELEMENT_ASSIGN_LOOP(OUT,IN,INTYPE,OUTTYPE) \ 306 { \ 307 ps##INTYPE *in; \ 308 ps##OUTTYPE *out; \ 309 for (int row=0;row<numRows;row++) { \ 310 in = IN->data.INTYPE[row]; \ 311 out = OUT->data.OUTTYPE[row]; \ 312 for (int col=0;col<numCols;col++) { \ 313 out[col] = (ps##OUTTYPE) in[col]; \ 314 } \ 309 #define PSIMAGE_ELEMENT_COPY(IN,INTYPE,OUT,OUTTYPE,ELEMENTS) { \ 310 ps##INTYPE *in = IN->data.INTYPE[0]; \ 311 ps##OUTTYPE *out = OUT->data.OUTTYPE[0]; \ 312 for (int e=0;e<ELEMENTS;e++) { \ 313 *(out++) = *(in++); \ 315 314 } \ 316 315 } 317 316 318 #define PSIMAGE_ ELEMENT_ASSIGN(OUT,IN,OUTTYPE) \319 switch ( IN->type.type) { \317 #define PSIMAGE_COPY_CASE(OUT,OUTTYPE) \ 318 switch (inDatatype) { \ 320 319 case PS_TYPE_S8: \ 321 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,S8,OUTTYPE); \320 PSIMAGE_ELEMENT_COPY(input,S8,OUT,OUTTYPE,elements); \ 322 321 break; \ 323 322 case PS_TYPE_S16: \ 324 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,S16,OUTTYPE); \323 PSIMAGE_ELEMENT_COPY(input,S16,OUT,OUTTYPE,elements); \ 325 324 break; \ 326 325 case PS_TYPE_S32: \ 327 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,S32,OUTTYPE); \326 PSIMAGE_ELEMENT_COPY(input,S32,OUT,OUTTYPE,elements); \ 328 327 break; \ 329 328 case PS_TYPE_S64: \ 330 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,S64,OUTTYPE); \329 PSIMAGE_ELEMENT_COPY(input,S64,OUT,OUTTYPE,elements); \ 331 330 break; \ 332 331 case PS_TYPE_U8: \ 333 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,U8,OUTTYPE); \332 PSIMAGE_ELEMENT_COPY(input,U8,OUT,OUTTYPE,elements); \ 334 333 break; \ 335 334 case PS_TYPE_U16: \ 336 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,U16,OUTTYPE); \335 PSIMAGE_ELEMENT_COPY(input,U16,OUT,OUTTYPE,elements); \ 337 336 break; \ 338 337 case PS_TYPE_U32: \ 339 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,U32,OUTTYPE); \338 PSIMAGE_ELEMENT_COPY(input,U32,OUT,OUTTYPE,elements); \ 340 339 break; \ 341 340 case PS_TYPE_U64: \ 342 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,U64,OUTTYPE); \341 PSIMAGE_ELEMENT_COPY(input,U64,OUT,OUTTYPE,elements); \ 343 342 break; \ 344 343 case PS_TYPE_F32: \ 345 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,F32,OUTTYPE); \344 PSIMAGE_ELEMENT_COPY(input,F32,OUT,OUTTYPE,elements); \ 346 345 break; \ 347 346 case PS_TYPE_F64: \ 348 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,F64,OUTTYPE); \347 PSIMAGE_ELEMENT_COPY(input,F64,OUT,OUTTYPE,elements); \ 349 348 break; \ 350 349 case PS_TYPE_C32: \ 351 PSIMAGE_ELEMENT_ASSIGN_LOOP(OUT,IN,C32,OUTTYPE); \ 352 break; \ 353 case PS_TYPE_PTR: \ 354 psError(__func__,"Can't copy image from a matrix of pointers."); \ 355 psFree(output); \ 356 return NULL; \ 350 PSIMAGE_ELEMENT_COPY(input,C32,OUT,OUTTYPE,elements); \ 351 break; \ 352 case PS_TYPE_C64: \ 353 PSIMAGE_ELEMENT_COPY(input,C64,OUT,OUTTYPE,elements); \ 354 break; \ 357 355 default: \ 358 356 break; \ 359 357 } 360 358 361 // XXX - GCC had problems with the length? of the above macro. The original362 // macro code here is commented out and the preprocessor output is pasted below it363 // (effectively to the end of the function)364 // We need to find out what is doing on here and move back to the macro version.365 #if 0366 switch (type)367 {368 case PS_TYPE_S8:369 PSIMAGE_ELEMENT_ASSIGN(output,input,S8);370 break;371 case PS_TYPE_S16:372 PSIMAGE_ELEMENT_ASSIGN(output,input,S16);373 break;374 case PS_TYPE_S32:375 PSIMAGE_ELEMENT_ASSIGN(output,input,S32);376 break;377 case PS_TYPE_S64:378 PSIMAGE_ELEMENT_ASSIGN(output,input,S64);379 break;380 case PS_TYPE_U8:381 PSIMAGE_ELEMENT_ASSIGN(output,input,U8);382 case PS_TYPE_U16:383 PSIMAGE_ELEMENT_ASSIGN(output,input,U16);384 break;385 case PS_TYPE_U32:386 PSIMAGE_ELEMENT_ASSIGN(output,input,U32);387 break;388 case PS_TYPE_U64:389 PSIMAGE_ELEMENT_ASSIGN(output,input,U64);390 break;391 case PS_TYPE_F32:392 PSIMAGE_ELEMENT_ASSIGN(output,input,F32);393 break;394 case PS_TYPE_F64:395 PSIMAGE_ELEMENT_ASSIGN(output,input,F64);396 break;397 case PS_TYPE_C32:398 PSIMAGE_ELEMENT_ASSIGN(output,input,C32);399 break;400 case PS_TYPE_C64:401 PSIMAGE_ELEMENT_ASSIGN(output,input,C64);402 break;403 case PS_TYPE_PTR:404 psError(__func__,"Can't copy image into a matrix of pointers.");405 psFree(output);406 return NULL;407 }408 #endif409 410 #if 1411 359 switch (type) { 412 360 case PS_TYPE_S8: 413 switch (input->type.type) { 414 case PS_TYPE_S8: { 415 psS8 *in; 416 psS8 *out; 417 for (int row = 0; row < numRows; row++) { 418 in = input->data.S8[row]; 419 out = output->data.S8[row]; 420 for (int col = 0; col < numCols; col++) { 421 out[col] = (psS8) in[col]; 422 } 423 } 424 }; 425 break; 426 case PS_TYPE_S16: { 427 psS16 *in; 428 psS8 *out; 429 for (int row = 0; row < numRows; row++) { 430 in = input->data.S16[row]; 431 out = output->data.S8[row]; 432 for (int col = 0; col < numCols; col++) { 433 out[col] = (psS8) in[col]; 434 } 435 } 436 }; 437 break; 438 case PS_TYPE_S32: { 439 psS32 *in; 440 psS8 *out; 441 for (int row = 0; row < numRows; row++) { 442 in = input->data.S32[row]; 443 out = output->data.S8[row]; 444 for (int col = 0; col < numCols; col++) { 445 out[col] = (psS8) in[col]; 446 } 447 } 448 }; 449 break; 450 case PS_TYPE_S64: { 451 psS64 *in; 452 psS8 *out; 453 for (int row = 0; row < numRows; row++) { 454 in = input->data.S64[row]; 455 out = output->data.S8[row]; 456 for (int col = 0; col < numCols; col++) { 457 out[col] = (psS8) in[col]; 458 } 459 } 460 }; 461 break; 462 case PS_TYPE_U8: { 463 psU8 *in; 464 psS8 *out; 465 for (int row = 0; row < numRows; row++) { 466 in = input->data.U8[row]; 467 out = output->data.S8[row]; 468 for (int col = 0; col < numCols; col++) { 469 out[col] = (psS8) in[col]; 470 } 471 } 472 }; 473 break; 474 case PS_TYPE_U16: { 475 psU16 *in; 476 psS8 *out; 477 for (int row = 0; row < numRows; row++) { 478 in = input->data.U16[row]; 479 out = output->data.S8[row]; 480 for (int col = 0; col < numCols; col++) { 481 out[col] = (psS8) in[col]; 482 } 483 } 484 }; 485 break; 486 case PS_TYPE_U32: { 487 psU32 *in; 488 psS8 *out; 489 for (int row = 0; row < numRows; row++) { 490 in = input->data.U32[row]; 491 out = output->data.S8[row]; 492 for (int col = 0; col < numCols; col++) { 493 out[col] = (psS8) in[col]; 494 } 495 } 496 }; 497 break; 498 case PS_TYPE_U64: { 499 psU64 *in; 500 psS8 *out; 501 for (int row = 0; row < numRows; row++) { 502 in = input->data.U64[row]; 503 out = output->data.S8[row]; 504 for (int col = 0; col < numCols; col++) { 505 out[col] = (psS8) in[col]; 506 } 507 } 508 }; 509 break; 510 case PS_TYPE_F32: { 511 psF32 *in; 512 psS8 *out; 513 for (int row = 0; row < numRows; row++) { 514 in = input->data.F32[row]; 515 out = output->data.S8[row]; 516 for (int col = 0; col < numCols; col++) { 517 out[col] = (psS8) in[col]; 518 } 519 } 520 }; 521 break; 522 case PS_TYPE_F64: { 523 psF64 *in; 524 psS8 *out; 525 for (int row = 0; row < numRows; row++) { 526 in = input->data.F64[row]; 527 out = output->data.S8[row]; 528 for (int col = 0; col < numCols; col++) { 529 out[col] = (psS8) in[col]; 530 } 531 } 532 }; 533 break; 534 case PS_TYPE_C32: { 535 psC32 *in; 536 psS8 *out; 537 for (int row = 0; row < numRows; row++) { 538 in = input->data.C32[row]; 539 out = output->data.S8[row]; 540 for (int col = 0; col < numCols; col++) { 541 out[col] = (psS8) in[col]; 542 } 543 } 544 }; 545 break; 546 case PS_TYPE_PTR: 547 psError (__func__, "Can't copy image from a matrix of pointers."); 548 psFree (output); 549 return ((void *) 0); 550 default: 551 break; 552 }; 361 PSIMAGE_COPY_CASE(output,S8); 553 362 break; 554 363 case PS_TYPE_S16: 555 switch (input->type.type) { 556 case PS_TYPE_S8: { 557 psS8 *in; 558 psS16 *out; 559 for (int row = 0; row < numRows; row++) { 560 in = input->data.S8[row]; 561 out = output->data.S16[row]; 562 for (int col = 0; col < numCols; col++) { 563 out[col] = (psS16) in[col]; 564 } 565 } 566 }; 567 break; 568 case PS_TYPE_S16: { 569 psS16 *in; 570 psS16 *out; 571 for (int row = 0; row < numRows; row++) { 572 in = input->data.S16[row]; 573 out = output->data.S16[row]; 574 for (int col = 0; col < numCols; col++) { 575 out[col] = (psS16) in[col]; 576 } 577 } 578 }; 579 break; 580 case PS_TYPE_S32: { 581 psS32 *in; 582 psS16 *out; 583 for (int row = 0; row < numRows; row++) { 584 in = input->data.S32[row]; 585 out = output->data.S16[row]; 586 for (int col = 0; col < numCols; col++) { 587 out[col] = (psS16) in[col]; 588 } 589 } 590 }; 591 break; 592 case PS_TYPE_S64: { 593 psS64 *in; 594 psS16 *out; 595 for (int row = 0; row < numRows; row++) { 596 in = input->data.S64[row]; 597 out = output->data.S16[row]; 598 for (int col = 0; col < numCols; col++) { 599 out[col] = (psS16) in[col]; 600 } 601 } 602 }; 603 break; 604 case PS_TYPE_U8: { 605 psU8 *in; 606 psS16 *out; 607 for (int row = 0; row < numRows; row++) { 608 in = input->data.U8[row]; 609 out = output->data.S16[row]; 610 for (int col = 0; col < numCols; col++) { 611 out[col] = (psS16) in[col]; 612 } 613 } 614 }; 615 break; 616 case PS_TYPE_U16: { 617 psU16 *in; 618 psS16 *out; 619 for (int row = 0; row < numRows; row++) { 620 in = input->data.U16[row]; 621 out = output->data.S16[row]; 622 for (int col = 0; col < numCols; col++) { 623 out[col] = (psS16) in[col]; 624 } 625 } 626 }; 627 break; 628 case PS_TYPE_U32: { 629 psU32 *in; 630 psS16 *out; 631 for (int row = 0; row < numRows; row++) { 632 in = input->data.U32[row]; 633 out = output->data.S16[row]; 634 for (int col = 0; col < numCols; col++) { 635 out[col] = (psS16) in[col]; 636 } 637 } 638 }; 639 break; 640 case PS_TYPE_U64: { 641 psU64 *in; 642 psS16 *out; 643 for (int row = 0; row < numRows; row++) { 644 in = input->data.U64[row]; 645 out = output->data.S16[row]; 646 for (int col = 0; col < numCols; col++) { 647 out[col] = (psS16) in[col]; 648 } 649 } 650 }; 651 break; 652 case PS_TYPE_F32: { 653 psF32 *in; 654 psS16 *out; 655 for (int row = 0; row < numRows; row++) { 656 in = input->data.F32[row]; 657 out = output->data.S16[row]; 658 for (int col = 0; col < numCols; col++) { 659 out[col] = (psS16) in[col]; 660 } 661 } 662 }; 663 break; 664 case PS_TYPE_F64: { 665 psF64 *in; 666 psS16 *out; 667 for (int row = 0; row < numRows; row++) { 668 in = input->data.F64[row]; 669 out = output->data.S16[row]; 670 for (int col = 0; col < numCols; col++) { 671 out[col] = (psS16) in[col]; 672 } 673 } 674 }; 675 break; 676 case PS_TYPE_C32: { 677 psC32 *in; 678 psS16 *out; 679 for (int row = 0; row < numRows; row++) { 680 in = input->data.C32[row]; 681 out = output->data.S16[row]; 682 for (int col = 0; col < numCols; col++) { 683 out[col] = (psS16) in[col]; 684 } 685 } 686 }; 687 break; 688 case PS_TYPE_PTR: 689 psError (__func__, "Can't copy image from a matrix of pointers."); 690 psFree (output); 691 return ((void *) 0); 692 default: 693 break; 694 }; 364 PSIMAGE_COPY_CASE(output,S16); 695 365 break; 696 366 case PS_TYPE_S32: 697 switch (input->type.type) { 698 case PS_TYPE_S8: { 699 psS8 *in; 700 psS32 *out; 701 for (int row = 0; row < numRows; row++) { 702 in = input->data.S8[row]; 703 out = output->data.S32[row]; 704 for (int col = 0; col < numCols; col++) { 705 out[col] = (psS32) in[col]; 706 } 707 } 708 }; 709 break; 710 case PS_TYPE_S16: { 711 psS16 *in; 712 psS32 *out; 713 for (int row = 0; row < numRows; row++) { 714 in = input->data.S16[row]; 715 out = output->data.S32[row]; 716 for (int col = 0; col < numCols; col++) { 717 out[col] = (psS32) in[col]; 718 } 719 } 720 }; 721 break; 722 case PS_TYPE_S32: { 723 psS32 *in; 724 psS32 *out; 725 for (int row = 0; row < numRows; row++) { 726 in = input->data.S32[row]; 727 out = output->data.S32[row]; 728 for (int col = 0; col < numCols; col++) { 729 out[col] = (psS32) in[col]; 730 } 731 } 732 }; 733 break; 734 case PS_TYPE_S64: { 735 psS64 *in; 736 psS32 *out; 737 for (int row = 0; row < numRows; row++) { 738 in = input->data.S64[row]; 739 out = output->data.S32[row]; 740 for (int col = 0; col < numCols; col++) { 741 out[col] = (psS32) in[col]; 742 } 743 } 744 }; 745 break; 746 case PS_TYPE_U8: { 747 psU8 *in; 748 psS32 *out; 749 for (int row = 0; row < numRows; row++) { 750 in = input->data.U8[row]; 751 out = output->data.S32[row]; 752 for (int col = 0; col < numCols; col++) { 753 out[col] = (psS32) in[col]; 754 } 755 } 756 }; 757 break; 758 case PS_TYPE_U16: { 759 psU16 *in; 760 psS32 *out; 761 for (int row = 0; row < numRows; row++) { 762 in = input->data.U16[row]; 763 out = output->data.S32[row]; 764 for (int col = 0; col < numCols; col++) { 765 out[col] = (psS32) in[col]; 766 } 767 } 768 }; 769 break; 770 case PS_TYPE_U32: { 771 psU32 *in; 772 psS32 *out; 773 for (int row = 0; row < numRows; row++) { 774 in = input->data.U32[row]; 775 out = output->data.S32[row]; 776 for (int col = 0; col < numCols; col++) { 777 out[col] = (psS32) in[col]; 778 } 779 } 780 }; 781 break; 782 case PS_TYPE_U64: { 783 psU64 *in; 784 psS32 *out; 785 for (int row = 0; row < numRows; row++) { 786 in = input->data.U64[row]; 787 out = output->data.S32[row]; 788 for (int col = 0; col < numCols; col++) { 789 out[col] = (psS32) in[col]; 790 } 791 } 792 }; 793 break; 794 case PS_TYPE_F32: { 795 psF32 *in; 796 psS32 *out; 797 for (int row = 0; row < numRows; row++) { 798 in = input->data.F32[row]; 799 out = output->data.S32[row]; 800 for (int col = 0; col < numCols; col++) { 801 out[col] = (psS32) in[col]; 802 } 803 } 804 }; 805 break; 806 case PS_TYPE_F64: { 807 psF64 *in; 808 psS32 *out; 809 for (int row = 0; row < numRows; row++) { 810 in = input->data.F64[row]; 811 out = output->data.S32[row]; 812 for (int col = 0; col < numCols; col++) { 813 out[col] = (psS32) in[col]; 814 } 815 } 816 }; 817 break; 818 case PS_TYPE_C32: { 819 psC32 *in; 820 psS32 *out; 821 for (int row = 0; row < numRows; row++) { 822 in = input->data.C32[row]; 823 out = output->data.S32[row]; 824 for (int col = 0; col < numCols; col++) { 825 out[col] = (psS32) in[col]; 826 } 827 } 828 }; 829 break; 830 case PS_TYPE_PTR: 831 psError (__func__, "Can't copy image from a matrix of pointers."); 832 psFree (output); 833 return ((void *) 0); 834 default: 835 break; 836 }; 367 PSIMAGE_COPY_CASE(output,S32); 837 368 break; 838 369 case PS_TYPE_S64: 839 switch (input->type.type) { 840 case PS_TYPE_S8: { 841 psS8 *in; 842 psS64 *out; 843 for (int row = 0; row < numRows; row++) { 844 in = input->data.S8[row]; 845 out = output->data.S64[row]; 846 for (int col = 0; col < numCols; col++) { 847 out[col] = (psS64) in[col]; 848 } 849 } 850 }; 851 break; 852 case PS_TYPE_S16: { 853 psS16 *in; 854 psS64 *out; 855 for (int row = 0; row < numRows; row++) { 856 in = input->data.S16[row]; 857 out = output->data.S64[row]; 858 for (int col = 0; col < numCols; col++) { 859 out[col] = (psS64) in[col]; 860 } 861 } 862 }; 863 break; 864 case PS_TYPE_S32: { 865 psS32 *in; 866 psS64 *out; 867 for (int row = 0; row < numRows; row++) { 868 in = input->data.S32[row]; 869 out = output->data.S64[row]; 870 for (int col = 0; col < numCols; col++) { 871 out[col] = (psS64) in[col]; 872 } 873 } 874 }; 875 break; 876 case PS_TYPE_S64: { 877 psS64 *in; 878 psS64 *out; 879 for (int row = 0; row < numRows; row++) { 880 in = input->data.S64[row]; 881 out = output->data.S64[row]; 882 for (int col = 0; col < numCols; col++) { 883 out[col] = (psS64) in[col]; 884 } 885 } 886 }; 887 break; 888 case PS_TYPE_U8: { 889 psU8 *in; 890 psS64 *out; 891 for (int row = 0; row < numRows; row++) { 892 in = input->data.U8[row]; 893 out = output->data.S64[row]; 894 for (int col = 0; col < numCols; col++) { 895 out[col] = (psS64) in[col]; 896 } 897 } 898 }; 899 break; 900 case PS_TYPE_U16: { 901 psU16 *in; 902 psS64 *out; 903 for (int row = 0; row < numRows; row++) { 904 in = input->data.U16[row]; 905 out = output->data.S64[row]; 906 for (int col = 0; col < numCols; col++) { 907 out[col] = (psS64) in[col]; 908 } 909 } 910 }; 911 break; 912 case PS_TYPE_U32: { 913 psU32 *in; 914 psS64 *out; 915 for (int row = 0; row < numRows; row++) { 916 in = input->data.U32[row]; 917 out = output->data.S64[row]; 918 for (int col = 0; col < numCols; col++) { 919 out[col] = (psS64) in[col]; 920 } 921 } 922 }; 923 break; 924 case PS_TYPE_U64: { 925 psU64 *in; 926 psS64 *out; 927 for (int row = 0; row < numRows; row++) { 928 in = input->data.U64[row]; 929 out = output->data.S64[row]; 930 for (int col = 0; col < numCols; col++) { 931 out[col] = (psS64) in[col]; 932 } 933 } 934 }; 935 break; 936 case PS_TYPE_F32: { 937 psF32 *in; 938 psS64 *out; 939 for (int row = 0; row < numRows; row++) { 940 in = input->data.F32[row]; 941 out = output->data.S64[row]; 942 for (int col = 0; col < numCols; col++) { 943 out[col] = (psS64) in[col]; 944 } 945 } 946 }; 947 break; 948 case PS_TYPE_F64: { 949 psF64 *in; 950 psS64 *out; 951 for (int row = 0; row < numRows; row++) { 952 in = input->data.F64[row]; 953 out = output->data.S64[row]; 954 for (int col = 0; col < numCols; col++) { 955 out[col] = (psS64) in[col]; 956 } 957 } 958 }; 959 break; 960 case PS_TYPE_C32: { 961 psC32 *in; 962 psS64 *out; 963 for (int row = 0; row < numRows; row++) { 964 in = input->data.C32[row]; 965 out = output->data.S64[row]; 966 for (int col = 0; col < numCols; col++) { 967 out[col] = (psS64) in[col]; 968 } 969 } 970 }; 971 break; 972 case PS_TYPE_PTR: 973 psError (__func__, "Can't copy image from a matrix of pointers."); 974 psFree (output); 975 return ((void *) 0); 976 default: 977 break; 978 }; 370 PSIMAGE_COPY_CASE(output,S64); 979 371 break; 980 372 case PS_TYPE_U8: 981 switch (input->type.type) { 982 case PS_TYPE_S8: { 983 psS8 *in; 984 psU8 *out; 985 for (int row = 0; row < numRows; row++) { 986 in = input->data.S8[row]; 987 out = output->data.U8[row]; 988 for (int col = 0; col < numCols; col++) { 989 out[col] = (psU8) in[col]; 990 } 991 } 992 }; 993 break; 994 case PS_TYPE_S16: { 995 psS16 *in; 996 psU8 *out; 997 for (int row = 0; row < numRows; row++) { 998 in = input->data.S16[row]; 999 out = output->data.U8[row]; 1000 for (int col = 0; col < numCols; col++) { 1001 out[col] = (psU8) in[col]; 1002 } 1003 } 1004 }; 1005 break; 1006 case PS_TYPE_S32: { 1007 psS32 *in; 1008 psU8 *out; 1009 for (int row = 0; row < numRows; row++) { 1010 in = input->data.S32[row]; 1011 out = output->data.U8[row]; 1012 for (int col = 0; col < numCols; col++) { 1013 out[col] = (psU8) in[col]; 1014 } 1015 } 1016 }; 1017 break; 1018 case PS_TYPE_S64: { 1019 psS64 *in; 1020 psU8 *out; 1021 for (int row = 0; row < numRows; row++) { 1022 in = input->data.S64[row]; 1023 out = output->data.U8[row]; 1024 for (int col = 0; col < numCols; col++) { 1025 out[col] = (psU8) in[col]; 1026 } 1027 } 1028 }; 1029 break; 1030 case PS_TYPE_U8: { 1031 psU8 *in; 1032 psU8 *out; 1033 for (int row = 0; row < numRows; row++) { 1034 in = input->data.U8[row]; 1035 out = output->data.U8[row]; 1036 for (int col = 0; col < numCols; col++) { 1037 out[col] = (psU8) in[col]; 1038 } 1039 } 1040 }; 1041 break; 1042 case PS_TYPE_U16: { 1043 psU16 *in; 1044 psU8 *out; 1045 for (int row = 0; row < numRows; row++) { 1046 in = input->data.U16[row]; 1047 out = output->data.U8[row]; 1048 for (int col = 0; col < numCols; col++) { 1049 out[col] = (psU8) in[col]; 1050 } 1051 } 1052 }; 1053 break; 1054 case PS_TYPE_U32: { 1055 psU32 *in; 1056 psU8 *out; 1057 for (int row = 0; row < numRows; row++) { 1058 in = input->data.U32[row]; 1059 out = output->data.U8[row]; 1060 for (int col = 0; col < numCols; col++) { 1061 out[col] = (psU8) in[col]; 1062 } 1063 } 1064 }; 1065 break; 1066 case PS_TYPE_U64: { 1067 psU64 *in; 1068 psU8 *out; 1069 for (int row = 0; row < numRows; row++) { 1070 in = input->data.U64[row]; 1071 out = output->data.U8[row]; 1072 for (int col = 0; col < numCols; col++) { 1073 out[col] = (psU8) in[col]; 1074 } 1075 } 1076 }; 1077 break; 1078 case PS_TYPE_F32: { 1079 psF32 *in; 1080 psU8 *out; 1081 for (int row = 0; row < numRows; row++) { 1082 in = input->data.F32[row]; 1083 out = output->data.U8[row]; 1084 for (int col = 0; col < numCols; col++) { 1085 out[col] = (psU8) in[col]; 1086 } 1087 } 1088 }; 1089 break; 1090 case PS_TYPE_F64: { 1091 psF64 *in; 1092 psU8 *out; 1093 for (int row = 0; row < numRows; row++) { 1094 in = input->data.F64[row]; 1095 out = output->data.U8[row]; 1096 for (int col = 0; col < numCols; col++) { 1097 out[col] = (psU8) in[col]; 1098 } 1099 } 1100 }; 1101 break; 1102 case PS_TYPE_C32: { 1103 psC32 *in; 1104 psU8 *out; 1105 for (int row = 0; row < numRows; row++) { 1106 in = input->data.C32[row]; 1107 out = output->data.U8[row]; 1108 for (int col = 0; col < numCols; col++) { 1109 out[col] = (psU8) in[col]; 1110 } 1111 } 1112 }; 1113 break; 1114 case PS_TYPE_PTR: 1115 psError (__func__, "Can't copy image from a matrix of pointers."); 1116 psFree (output); 1117 return ((void *) 0); 1118 default: 1119 break; 1120 }; 373 PSIMAGE_COPY_CASE(output,U8); 1121 374 break; 1122 375 case PS_TYPE_U16: 1123 switch (input->type.type) { 1124 case PS_TYPE_S8: { 1125 psS8 *in; 1126 psU16 *out; 1127 for (int row = 0; row < numRows; row++) { 1128 in = input->data.S8[row]; 1129 out = output->data.U16[row]; 1130 for (int col = 0; col < numCols; col++) { 1131 out[col] = (psU16) in[col]; 1132 } 1133 } 1134 }; 1135 break; 1136 case PS_TYPE_S16: { 1137 psS16 *in; 1138 psU16 *out; 1139 for (int row = 0; row < numRows; row++) { 1140 in = input->data.S16[row]; 1141 out = output->data.U16[row]; 1142 for (int col = 0; col < numCols; col++) { 1143 out[col] = (psU16) in[col]; 1144 } 1145 } 1146 }; 1147 break; 1148 case PS_TYPE_S32: { 1149 psS32 *in; 1150 psU16 *out; 1151 for (int row = 0; row < numRows; row++) { 1152 in = input->data.S32[row]; 1153 out = output->data.U16[row]; 1154 for (int col = 0; col < numCols; col++) { 1155 out[col] = (psU16) in[col]; 1156 } 1157 } 1158 }; 1159 break; 1160 case PS_TYPE_S64: { 1161 psS64 *in; 1162 psU16 *out; 1163 for (int row = 0; row < numRows; row++) { 1164 in = input->data.S64[row]; 1165 out = output->data.U16[row]; 1166 for (int col = 0; col < numCols; col++) { 1167 out[col] = (psU16) in[col]; 1168 } 1169 } 1170 }; 1171 break; 1172 case PS_TYPE_U8: { 1173 psU8 *in; 1174 psU16 *out; 1175 for (int row = 0; row < numRows; row++) { 1176 in = input->data.U8[row]; 1177 out = output->data.U16[row]; 1178 for (int col = 0; col < numCols; col++) { 1179 out[col] = (psU16) in[col]; 1180 } 1181 } 1182 }; 1183 break; 1184 case PS_TYPE_U16: { 1185 psU16 *in; 1186 psU16 *out; 1187 for (int row = 0; row < numRows; row++) { 1188 in = input->data.U16[row]; 1189 out = output->data.U16[row]; 1190 for (int col = 0; col < numCols; col++) { 1191 out[col] = (psU16) in[col]; 1192 } 1193 } 1194 }; 1195 break; 1196 case PS_TYPE_U32: { 1197 psU32 *in; 1198 psU16 *out; 1199 for (int row = 0; row < numRows; row++) { 1200 in = input->data.U32[row]; 1201 out = output->data.U16[row]; 1202 for (int col = 0; col < numCols; col++) { 1203 out[col] = (psU16) in[col]; 1204 } 1205 } 1206 }; 1207 break; 1208 case PS_TYPE_U64: { 1209 psU64 *in; 1210 psU16 *out; 1211 for (int row = 0; row < numRows; row++) { 1212 in = input->data.U64[row]; 1213 out = output->data.U16[row]; 1214 for (int col = 0; col < numCols; col++) { 1215 out[col] = (psU16) in[col]; 1216 } 1217 } 1218 }; 1219 break; 1220 case PS_TYPE_F32: { 1221 psF32 *in; 1222 psU16 *out; 1223 for (int row = 0; row < numRows; row++) { 1224 in = input->data.F32[row]; 1225 out = output->data.U16[row]; 1226 for (int col = 0; col < numCols; col++) { 1227 out[col] = (psU16) in[col]; 1228 } 1229 } 1230 }; 1231 break; 1232 case PS_TYPE_F64: { 1233 psF64 *in; 1234 psU16 *out; 1235 for (int row = 0; row < numRows; row++) { 1236 in = input->data.F64[row]; 1237 out = output->data.U16[row]; 1238 for (int col = 0; col < numCols; col++) { 1239 out[col] = (psU16) in[col]; 1240 } 1241 } 1242 }; 1243 break; 1244 case PS_TYPE_C32: { 1245 psC32 *in; 1246 psU16 *out; 1247 for (int row = 0; row < numRows; row++) { 1248 in = input->data.C32[row]; 1249 out = output->data.U16[row]; 1250 for (int col = 0; col < numCols; col++) { 1251 out[col] = (psU16) in[col]; 1252 } 1253 } 1254 }; 1255 break; 1256 case PS_TYPE_PTR: 1257 psError (__func__, "Can't copy image from a matrix of pointers."); 1258 psFree (output); 1259 return ((void *) 0); 1260 default: 1261 break; 1262 }; 376 PSIMAGE_COPY_CASE(output,U16); 1263 377 break; 1264 378 case PS_TYPE_U32: 1265 switch (input->type.type) { 1266 case PS_TYPE_S8: { 1267 psS8 *in; 1268 psU32 *out; 1269 for (int row = 0; row < numRows; row++) { 1270 in = input->data.S8[row]; 1271 out = output->data.U32[row]; 1272 for (int col = 0; col < numCols; col++) { 1273 out[col] = (psU32) in[col]; 1274 } 1275 } 1276 }; 1277 break; 1278 case PS_TYPE_S16: { 1279 psS16 *in; 1280 psU32 *out; 1281 for (int row = 0; row < numRows; row++) { 1282 in = input->data.S16[row]; 1283 out = output->data.U32[row]; 1284 for (int col = 0; col < numCols; col++) { 1285 out[col] = (psU32) in[col]; 1286 } 1287 } 1288 }; 1289 break; 1290 case PS_TYPE_S32: { 1291 psS32 *in; 1292 psU32 *out; 1293 for (int row = 0; row < numRows; row++) { 1294 in = input->data.S32[row]; 1295 out = output->data.U32[row]; 1296 for (int col = 0; col < numCols; col++) { 1297 out[col] = (psU32) in[col]; 1298 } 1299 } 1300 }; 1301 break; 1302 case PS_TYPE_S64: { 1303 psS64 *in; 1304 psU32 *out; 1305 for (int row = 0; row < numRows; row++) { 1306 in = input->data.S64[row]; 1307 out = output->data.U32[row]; 1308 for (int col = 0; col < numCols; col++) { 1309 out[col] = (psU32) in[col]; 1310 } 1311 } 1312 }; 1313 break; 1314 case PS_TYPE_U8: { 1315 psU8 *in; 1316 psU32 *out; 1317 for (int row = 0; row < numRows; row++) { 1318 in = input->data.U8[row]; 1319 out = output->data.U32[row]; 1320 for (int col = 0; col < numCols; col++) { 1321 out[col] = (psU32) in[col]; 1322 } 1323 } 1324 }; 1325 break; 1326 case PS_TYPE_U16: { 1327 psU16 *in; 1328 psU32 *out; 1329 for (int row = 0; row < numRows; row++) { 1330 in = input->data.U16[row]; 1331 out = output->data.U32[row]; 1332 for (int col = 0; col < numCols; col++) { 1333 out[col] = (psU32) in[col]; 1334 } 1335 } 1336 }; 1337 break; 1338 case PS_TYPE_U32: { 1339 psU32 *in; 1340 psU32 *out; 1341 for (int row = 0; row < numRows; row++) { 1342 in = input->data.U32[row]; 1343 out = output->data.U32[row]; 1344 for (int col = 0; col < numCols; col++) { 1345 out[col] = (psU32) in[col]; 1346 } 1347 } 1348 }; 1349 break; 1350 case PS_TYPE_U64: { 1351 psU64 *in; 1352 psU32 *out; 1353 for (int row = 0; row < numRows; row++) { 1354 in = input->data.U64[row]; 1355 out = output->data.U32[row]; 1356 for (int col = 0; col < numCols; col++) { 1357 out[col] = (psU32) in[col]; 1358 } 1359 } 1360 }; 1361 break; 1362 case PS_TYPE_F32: { 1363 psF32 *in; 1364 psU32 *out; 1365 for (int row = 0; row < numRows; row++) { 1366 in = input->data.F32[row]; 1367 out = output->data.U32[row]; 1368 for (int col = 0; col < numCols; col++) { 1369 out[col] = (psU32) in[col]; 1370 } 1371 } 1372 }; 1373 break; 1374 case PS_TYPE_F64: { 1375 psF64 *in; 1376 psU32 *out; 1377 for (int row = 0; row < numRows; row++) { 1378 in = input->data.F64[row]; 1379 out = output->data.U32[row]; 1380 for (int col = 0; col < numCols; col++) { 1381 out[col] = (psU32) in[col]; 1382 } 1383 } 1384 }; 1385 break; 1386 case PS_TYPE_C32: { 1387 psC32 *in; 1388 psU32 *out; 1389 for (int row = 0; row < numRows; row++) { 1390 in = input->data.C32[row]; 1391 out = output->data.U32[row]; 1392 for (int col = 0; col < numCols; col++) { 1393 out[col] = (psU32) in[col]; 1394 } 1395 } 1396 }; 1397 break; 1398 case PS_TYPE_PTR: 1399 psError (__func__, "Can't copy image from a matrix of pointers."); 1400 psFree (output); 1401 return ((void *) 0); 1402 default: 1403 break; 1404 }; 379 PSIMAGE_COPY_CASE(output,U32); 1405 380 break; 1406 381 case PS_TYPE_U64: 1407 switch (input->type.type) { 1408 case PS_TYPE_S8: { 1409 psS8 *in; 1410 psU64 *out; 1411 for (int row = 0; row < numRows; row++) { 1412 in = input->data.S8[row]; 1413 out = output->data.U64[row]; 1414 for (int col = 0; col < numCols; col++) { 1415 out[col] = (psU64) in[col]; 1416 } 1417 } 1418 }; 1419 break; 1420 case PS_TYPE_S16: { 1421 psS16 *in; 1422 psU64 *out; 1423 for (int row = 0; row < numRows; row++) { 1424 in = input->data.S16[row]; 1425 out = output->data.U64[row]; 1426 for (int col = 0; col < numCols; col++) { 1427 out[col] = (psU64) in[col]; 1428 } 1429 } 1430 }; 1431 break; 1432 case PS_TYPE_S32: { 1433 psS32 *in; 1434 psU64 *out; 1435 for (int row = 0; row < numRows; row++) { 1436 in = input->data.S32[row]; 1437 out = output->data.U64[row]; 1438 for (int col = 0; col < numCols; col++) { 1439 out[col] = (psU64) in[col]; 1440 } 1441 } 1442 }; 1443 break; 1444 case PS_TYPE_S64: { 1445 psS64 *in; 1446 psU64 *out; 1447 for (int row = 0; row < numRows; row++) { 1448 in = input->data.S64[row]; 1449 out = output->data.U64[row]; 1450 for (int col = 0; col < numCols; col++) { 1451 out[col] = (psU64) in[col]; 1452 } 1453 } 1454 }; 1455 break; 1456 case PS_TYPE_U8: { 1457 psU8 *in; 1458 psU64 *out; 1459 for (int row = 0; row < numRows; row++) { 1460 in = input->data.U8[row]; 1461 out = output->data.U64[row]; 1462 for (int col = 0; col < numCols; col++) { 1463 out[col] = (psU64) in[col]; 1464 } 1465 } 1466 }; 1467 break; 1468 case PS_TYPE_U16: { 1469 psU16 *in; 1470 psU64 *out; 1471 for (int row = 0; row < numRows; row++) { 1472 in = input->data.U16[row]; 1473 out = output->data.U64[row]; 1474 for (int col = 0; col < numCols; col++) { 1475 out[col] = (psU64) in[col]; 1476 } 1477 } 1478 }; 1479 break; 1480 case PS_TYPE_U32: { 1481 psU32 *in; 1482 psU64 *out; 1483 for (int row = 0; row < numRows; row++) { 1484 in = input->data.U32[row]; 1485 out = output->data.U64[row]; 1486 for (int col = 0; col < numCols; col++) { 1487 out[col] = (psU64) in[col]; 1488 } 1489 } 1490 }; 1491 break; 1492 case PS_TYPE_U64: { 1493 psU64 *in; 1494 psU64 *out; 1495 for (int row = 0; row < numRows; row++) { 1496 in = input->data.U64[row]; 1497 out = output->data.U64[row]; 1498 for (int col = 0; col < numCols; col++) { 1499 out[col] = (psU64) in[col]; 1500 } 1501 } 1502 }; 1503 break; 1504 case PS_TYPE_F32: { 1505 psF32 *in; 1506 psU64 *out; 1507 for (int row = 0; row < numRows; row++) { 1508 in = input->data.F32[row]; 1509 out = output->data.U64[row]; 1510 for (int col = 0; col < numCols; col++) { 1511 out[col] = (psU64) in[col]; 1512 } 1513 } 1514 }; 1515 break; 1516 case PS_TYPE_F64: { 1517 psF64 *in; 1518 psU64 *out; 1519 for (int row = 0; row < numRows; row++) { 1520 in = input->data.F64[row]; 1521 out = output->data.U64[row]; 1522 for (int col = 0; col < numCols; col++) { 1523 out[col] = (psU64) in[col]; 1524 } 1525 } 1526 }; 1527 break; 1528 case PS_TYPE_C32: { 1529 psC32 *in; 1530 psU64 *out; 1531 for (int row = 0; row < numRows; row++) { 1532 in = input->data.C32[row]; 1533 out = output->data.U64[row]; 1534 for (int col = 0; col < numCols; col++) { 1535 out[col] = (psU64) in[col]; 1536 } 1537 } 1538 }; 1539 break; 1540 case PS_TYPE_PTR: 1541 psError (__func__, "Can't copy image from a matrix of pointers."); 1542 psFree (output); 1543 return ((void *) 0); 1544 default: 1545 break; 1546 }; 382 PSIMAGE_COPY_CASE(output,U64); 1547 383 break; 1548 384 case PS_TYPE_F32: 1549 switch (input->type.type) { 1550 case PS_TYPE_S8: { 1551 psS8 *in; 1552 psF32 *out; 1553 for (int row = 0; row < numRows; row++) { 1554 in = input->data.S8[row]; 1555 out = output->data.F32[row]; 1556 for (int col = 0; col < numCols; col++) { 1557 out[col] = (psF32) in[col]; 1558 } 1559 } 1560 }; 1561 break; 1562 case PS_TYPE_S16: { 1563 psS16 *in; 1564 psF32 *out; 1565 for (int row = 0; row < numRows; row++) { 1566 in = input->data.S16[row]; 1567 out = output->data.F32[row]; 1568 for (int col = 0; col < numCols; col++) { 1569 out[col] = (psF32) in[col]; 1570 } 1571 } 1572 }; 1573 break; 1574 case PS_TYPE_S32: { 1575 psS32 *in; 1576 psF32 *out; 1577 for (int row = 0; row < numRows; row++) { 1578 in = input->data.S32[row]; 1579 out = output->data.F32[row]; 1580 for (int col = 0; col < numCols; col++) { 1581 out[col] = (psF32) in[col]; 1582 } 1583 } 1584 }; 1585 break; 1586 case PS_TYPE_S64: { 1587 psS64 *in; 1588 psF32 *out; 1589 for (int row = 0; row < numRows; row++) { 1590 in = input->data.S64[row]; 1591 out = output->data.F32[row]; 1592 for (int col = 0; col < numCols; col++) { 1593 out[col] = (psF32) in[col]; 1594 } 1595 } 1596 }; 1597 break; 1598 case PS_TYPE_U8: { 1599 psU8 *in; 1600 psF32 *out; 1601 for (int row = 0; row < numRows; row++) { 1602 in = input->data.U8[row]; 1603 out = output->data.F32[row]; 1604 for (int col = 0; col < numCols; col++) { 1605 out[col] = (psF32) in[col]; 1606 } 1607 } 1608 }; 1609 break; 1610 case PS_TYPE_U16: { 1611 psU16 *in; 1612 psF32 *out; 1613 for (int row = 0; row < numRows; row++) { 1614 in = input->data.U16[row]; 1615 out = output->data.F32[row]; 1616 for (int col = 0; col < numCols; col++) { 1617 out[col] = (psF32) in[col]; 1618 } 1619 } 1620 }; 1621 break; 1622 case PS_TYPE_U32: { 1623 psU32 *in; 1624 psF32 *out; 1625 for (int row = 0; row < numRows; row++) { 1626 in = input->data.U32[row]; 1627 out = output->data.F32[row]; 1628 for (int col = 0; col < numCols; col++) { 1629 out[col] = (psF32) in[col]; 1630 } 1631 } 1632 }; 1633 break; 1634 case PS_TYPE_U64: { 1635 psU64 *in; 1636 psF32 *out; 1637 for (int row = 0; row < numRows; row++) { 1638 in = input->data.U64[row]; 1639 out = output->data.F32[row]; 1640 for (int col = 0; col < numCols; col++) { 1641 out[col] = (psF32) in[col]; 1642 } 1643 } 1644 }; 1645 break; 1646 case PS_TYPE_F32: { 1647 psF32 *in; 1648 psF32 *out; 1649 for (int row = 0; row < numRows; row++) { 1650 in = input->data.F32[row]; 1651 out = output->data.F32[row]; 1652 for (int col = 0; col < numCols; col++) { 1653 out[col] = (psF32) in[col]; 1654 } 1655 } 1656 }; 1657 break; 1658 case PS_TYPE_F64: { 1659 psF64 *in; 1660 psF32 *out; 1661 for (int row = 0; row < numRows; row++) { 1662 in = input->data.F64[row]; 1663 out = output->data.F32[row]; 1664 for (int col = 0; col < numCols; col++) { 1665 out[col] = (psF32) in[col]; 1666 } 1667 } 1668 }; 1669 break; 1670 case PS_TYPE_C32: { 1671 psC32 *in; 1672 psF32 *out; 1673 for (int row = 0; row < numRows; row++) { 1674 in = input->data.C32[row]; 1675 out = output->data.F32[row]; 1676 for (int col = 0; col < numCols; col++) { 1677 out[col] = (psF32) in[col]; 1678 } 1679 } 1680 }; 1681 break; 1682 case PS_TYPE_PTR: 1683 psError (__func__, "Can't copy image from a matrix of pointers."); 1684 psFree (output); 1685 return ((void *) 0); 1686 default: 1687 break; 1688 }; 385 PSIMAGE_COPY_CASE(output,F32); 1689 386 break; 1690 387 case PS_TYPE_F64: 1691 switch (input->type.type) { 1692 case PS_TYPE_S8: { 1693 psS8 *in; 1694 psF64 *out; 1695 for (int row = 0; row < numRows; row++) { 1696 in = input->data.S8[row]; 1697 out = output->data.F64[row]; 1698 for (int col = 0; col < numCols; col++) { 1699 out[col] = (psF64) in[col]; 1700 } 1701 } 1702 }; 1703 break; 1704 case PS_TYPE_S16: { 1705 psS16 *in; 1706 psF64 *out; 1707 for (int row = 0; row < numRows; row++) { 1708 in = input->data.S16[row]; 1709 out = output->data.F64[row]; 1710 for (int col = 0; col < numCols; col++) { 1711 out[col] = (psF64) in[col]; 1712 } 1713 } 1714 }; 1715 break; 1716 case PS_TYPE_S32: { 1717 psS32 *in; 1718 psF64 *out; 1719 for (int row = 0; row < numRows; row++) { 1720 in = input->data.S32[row]; 1721 out = output->data.F64[row]; 1722 for (int col = 0; col < numCols; col++) { 1723 out[col] = (psF64) in[col]; 1724 } 1725 } 1726 }; 1727 break; 1728 case PS_TYPE_S64: { 1729 psS64 *in; 1730 psF64 *out; 1731 for (int row = 0; row < numRows; row++) { 1732 in = input->data.S64[row]; 1733 out = output->data.F64[row]; 1734 for (int col = 0; col < numCols; col++) { 1735 out[col] = (psF64) in[col]; 1736 } 1737 } 1738 }; 1739 break; 1740 case PS_TYPE_U8: { 1741 psU8 *in; 1742 psF64 *out; 1743 for (int row = 0; row < numRows; row++) { 1744 in = input->data.U8[row]; 1745 out = output->data.F64[row]; 1746 for (int col = 0; col < numCols; col++) { 1747 out[col] = (psF64) in[col]; 1748 } 1749 } 1750 }; 1751 break; 1752 case PS_TYPE_U16: { 1753 psU16 *in; 1754 psF64 *out; 1755 for (int row = 0; row < numRows; row++) { 1756 in = input->data.U16[row]; 1757 out = output->data.F64[row]; 1758 for (int col = 0; col < numCols; col++) { 1759 out[col] = (psF64) in[col]; 1760 } 1761 } 1762 }; 1763 break; 1764 case PS_TYPE_U32: { 1765 psU32 *in; 1766 psF64 *out; 1767 for (int row = 0; row < numRows; row++) { 1768 in = input->data.U32[row]; 1769 out = output->data.F64[row]; 1770 for (int col = 0; col < numCols; col++) { 1771 out[col] = (psF64) in[col]; 1772 } 1773 } 1774 }; 1775 break; 1776 case PS_TYPE_U64: { 1777 psU64 *in; 1778 psF64 *out; 1779 for (int row = 0; row < numRows; row++) { 1780 in = input->data.U64[row]; 1781 out = output->data.F64[row]; 1782 for (int col = 0; col < numCols; col++) { 1783 out[col] = (psF64) in[col]; 1784 } 1785 } 1786 }; 1787 break; 1788 case PS_TYPE_F32: { 1789 psF32 *in; 1790 psF64 *out; 1791 for (int row = 0; row < numRows; row++) { 1792 in = input->data.F32[row]; 1793 out = output->data.F64[row]; 1794 for (int col = 0; col < numCols; col++) { 1795 out[col] = (psF64) in[col]; 1796 } 1797 } 1798 }; 1799 break; 1800 case PS_TYPE_F64: { 1801 psF64 *in; 1802 psF64 *out; 1803 for (int row = 0; row < numRows; row++) { 1804 in = input->data.F64[row]; 1805 out = output->data.F64[row]; 1806 for (int col = 0; col < numCols; col++) { 1807 out[col] = (psF64) in[col]; 1808 } 1809 } 1810 }; 1811 break; 1812 case PS_TYPE_C32: { 1813 psC32 *in; 1814 psF64 *out; 1815 for (int row = 0; row < numRows; row++) { 1816 in = input->data.C32[row]; 1817 out = output->data.F64[row]; 1818 for (int col = 0; col < numCols; col++) { 1819 out[col] = (psF64) in[col]; 1820 } 1821 } 1822 }; 1823 break; 1824 case PS_TYPE_PTR: 1825 psError (__func__, "Can't copy image from a matrix of pointers."); 1826 psFree (output); 1827 return ((void *) 0); 1828 default: 1829 break; 1830 }; 388 PSIMAGE_COPY_CASE(output,F64); 1831 389 break; 1832 390 case PS_TYPE_C32: 1833 switch (input->type.type) { 1834 case PS_TYPE_S8: { 1835 psS8 *in; 1836 psC32 *out; 1837 for (int row = 0; row < numRows; row++) { 1838 in = input->data.S8[row]; 1839 out = output->data.C32[row]; 1840 for (int col = 0; col < numCols; col++) { 1841 out[col] = (psC32) in[col]; 1842 } 1843 } 1844 }; 1845 break; 1846 case PS_TYPE_S16: { 1847 psS16 *in; 1848 psC32 *out; 1849 for (int row = 0; row < numRows; row++) { 1850 in = input->data.S16[row]; 1851 out = output->data.C32[row]; 1852 for (int col = 0; col < numCols; col++) { 1853 out[col] = (psC32) in[col]; 1854 } 1855 } 1856 }; 1857 break; 1858 case PS_TYPE_S32: { 1859 psS32 *in; 1860 psC32 *out; 1861 for (int row = 0; row < numRows; row++) { 1862 in = input->data.S32[row]; 1863 out = output->data.C32[row]; 1864 for (int col = 0; col < numCols; col++) { 1865 out[col] = (psC32) in[col]; 1866 } 1867 } 1868 }; 1869 break; 1870 case PS_TYPE_S64: { 1871 psS64 *in; 1872 psC32 *out; 1873 for (int row = 0; row < numRows; row++) { 1874 in = input->data.S64[row]; 1875 out = output->data.C32[row]; 1876 for (int col = 0; col < numCols; col++) { 1877 out[col] = (psC32) in[col]; 1878 } 1879 } 1880 }; 1881 break; 1882 case PS_TYPE_U8: { 1883 psU8 *in; 1884 psC32 *out; 1885 for (int row = 0; row < numRows; row++) { 1886 in = input->data.U8[row]; 1887 out = output->data.C32[row]; 1888 for (int col = 0; col < numCols; col++) { 1889 out[col] = (psC32) in[col]; 1890 } 1891 } 1892 }; 1893 break; 1894 case PS_TYPE_U16: { 1895 psU16 *in; 1896 psC32 *out; 1897 for (int row = 0; row < numRows; row++) { 1898 in = input->data.U16[row]; 1899 out = output->data.C32[row]; 1900 for (int col = 0; col < numCols; col++) { 1901 out[col] = (psC32) in[col]; 1902 } 1903 } 1904 }; 1905 break; 1906 case PS_TYPE_U32: { 1907 psU32 *in; 1908 psC32 *out; 1909 for (int row = 0; row < numRows; row++) { 1910 in = input->data.U32[row]; 1911 out = output->data.C32[row]; 1912 for (int col = 0; col < numCols; col++) { 1913 out[col] = (psC32) in[col]; 1914 } 1915 } 1916 }; 1917 break; 1918 case PS_TYPE_U64: { 1919 psU64 *in; 1920 psC32 *out; 1921 for (int row = 0; row < numRows; row++) { 1922 in = input->data.U64[row]; 1923 out = output->data.C32[row]; 1924 for (int col = 0; col < numCols; col++) { 1925 out[col] = (psC32) in[col]; 1926 } 1927 } 1928 }; 1929 break; 1930 case PS_TYPE_F32: { 1931 psF32 *in; 1932 psC32 *out; 1933 for (int row = 0; row < numRows; row++) { 1934 in = input->data.F32[row]; 1935 out = output->data.C32[row]; 1936 for (int col = 0; col < numCols; col++) { 1937 out[col] = (psC32) in[col]; 1938 } 1939 } 1940 }; 1941 break; 1942 case PS_TYPE_F64: { 1943 psF64 *in; 1944 psC32 *out; 1945 for (int row = 0; row < numRows; row++) { 1946 in = input->data.F64[row]; 1947 out = output->data.C32[row]; 1948 for (int col = 0; col < numCols; col++) { 1949 out[col] = (psC32) in[col]; 1950 } 1951 } 1952 }; 1953 break; 1954 case PS_TYPE_C32: { 1955 psC32 *in; 1956 psC32 *out; 1957 for (int row = 0; row < numRows; row++) { 1958 in = input->data.C32[row]; 1959 out = output->data.C32[row]; 1960 for (int col = 0; col < numCols; col++) { 1961 out[col] = (psC32) in[col]; 1962 } 1963 } 1964 }; 1965 break; 1966 case PS_TYPE_PTR: 1967 psError (__func__, "Can't copy image from a matrix of pointers."); 1968 psFree (output); 1969 return ((void *) 0); 1970 default: 1971 break; 1972 }; 391 PSIMAGE_COPY_CASE(output,C32); 1973 392 break; 1974 393 case PS_TYPE_C64: 1975 switch (input->type.type) { 1976 case PS_TYPE_S8: { 1977 psS8 *in; 1978 psC64 *out; 1979 for (int row = 0; row < numRows; row++) { 1980 in = input->data.S8[row]; 1981 out = output->data.C64[row]; 1982 for (int col = 0; col < numCols; col++) { 1983 out[col] = (psC64) in[col]; 1984 } 1985 } 1986 }; 1987 break; 1988 case PS_TYPE_S16: { 1989 psS16 *in; 1990 psC64 *out; 1991 for (int row = 0; row < numRows; row++) { 1992 in = input->data.S16[row]; 1993 out = output->data.C64[row]; 1994 for (int col = 0; col < numCols; col++) { 1995 out[col] = (psC64) in[col]; 1996 } 1997 } 1998 }; 1999 break; 2000 case PS_TYPE_S32: { 2001 psS32 *in; 2002 psC64 *out; 2003 for (int row = 0; row < numRows; row++) { 2004 in = input->data.S32[row]; 2005 out = output->data.C64[row]; 2006 for (int col = 0; col < numCols; col++) { 2007 out[col] = (psC64) in[col]; 2008 } 2009 } 2010 }; 2011 break; 2012 case PS_TYPE_S64: { 2013 psS64 *in; 2014 psC64 *out; 2015 for (int row = 0; row < numRows; row++) { 2016 in = input->data.S64[row]; 2017 out = output->data.C64[row]; 2018 for (int col = 0; col < numCols; col++) { 2019 out[col] = (psC64) in[col]; 2020 } 2021 } 2022 }; 2023 break; 2024 case PS_TYPE_U8: { 2025 psU8 *in; 2026 psC64 *out; 2027 for (int row = 0; row < numRows; row++) { 2028 in = input->data.U8[row]; 2029 out = output->data.C64[row]; 2030 for (int col = 0; col < numCols; col++) { 2031 out[col] = (psC64) in[col]; 2032 } 2033 } 2034 }; 2035 break; 2036 case PS_TYPE_U16: { 2037 psU16 *in; 2038 psC64 *out; 2039 for (int row = 0; row < numRows; row++) { 2040 in = input->data.U16[row]; 2041 out = output->data.C64[row]; 2042 for (int col = 0; col < numCols; col++) { 2043 out[col] = (psC64) in[col]; 2044 } 2045 } 2046 }; 2047 break; 2048 case PS_TYPE_U32: { 2049 psU32 *in; 2050 psC64 *out; 2051 for (int row = 0; row < numRows; row++) { 2052 in = input->data.U32[row]; 2053 out = output->data.C64[row]; 2054 for (int col = 0; col < numCols; col++) { 2055 out[col] = (psC64) in[col]; 2056 } 2057 } 2058 }; 2059 break; 2060 case PS_TYPE_U64: { 2061 psU64 *in; 2062 psC64 *out; 2063 for (int row = 0; row < numRows; row++) { 2064 in = input->data.U64[row]; 2065 out = output->data.C64[row]; 2066 for (int col = 0; col < numCols; col++) { 2067 out[col] = (psC64) in[col]; 2068 } 2069 } 2070 }; 2071 break; 2072 case PS_TYPE_F32: { 2073 psF32 *in; 2074 psC64 *out; 2075 for (int row = 0; row < numRows; row++) { 2076 in = input->data.F32[row]; 2077 out = output->data.C64[row]; 2078 for (int col = 0; col < numCols; col++) { 2079 out[col] = (psC64) in[col]; 2080 } 2081 } 2082 }; 2083 break; 2084 case PS_TYPE_F64: { 2085 psF64 *in; 2086 psC64 *out; 2087 for (int row = 0; row < numRows; row++) { 2088 in = input->data.F64[row]; 2089 out = output->data.C64[row]; 2090 for (int col = 0; col < numCols; col++) { 2091 out[col] = (psC64) in[col]; 2092 } 2093 } 2094 }; 2095 break; 2096 case PS_TYPE_C32: { 2097 psC32 *in; 2098 psC64 *out; 2099 for (int row = 0; row < numRows; row++) { 2100 in = input->data.C32[row]; 2101 out = output->data.C64[row]; 2102 for (int col = 0; col < numCols; col++) { 2103 out[col] = (psC64) in[col]; 2104 } 2105 } 2106 }; 2107 break; 2108 case PS_TYPE_PTR: 2109 psError (__func__, "Can't copy image from a matrix of pointers."); 2110 psFree (output); 2111 return ((void *) 0); 2112 default: 2113 break; 2114 }; 2115 break; 2116 case PS_TYPE_PTR: 2117 psError (__func__, "Can't copy image into a matrix of pointers."); 2118 psFree (output); 2119 return ((void *) 0); 2120 } 2121 394 PSIMAGE_COPY_CASE(output,C64); 395 break; 396 default: 397 break; 398 } 2122 399 return output; 2123 400 } … … 2340 617 } 2341 618 2342 #endif2343 2344 619 return 0; 2345 620 } -
trunk/psLib/src/image/psImage.d
r986 r1193 1 psImage.o psImage.d : psImage.c ../sysUtils/psMemory.h ../sysUtils/ps Error.h \2 psImage.h psType.h1 psImage.o psImage.d : psImage.c ../sysUtils/psMemory.h ../sysUtils/psAbort.h \ 2 ../sysUtils/psError.h psImage.h psType.h -
trunk/psLib/src/mathtypes/psImage.c
r1165 r1193 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.3 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-07-0 1 00:26:37$11 * @version $Revision: 1.32 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-07-08 01:05:00 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 261 261 } 262 262 263 264 263 265 psImage *psImageCopy(psImage* restrict output, const psImage *input, 264 266 psElemType type) … … 266 268 psElemType inDatatype; 267 269 int elementSize; 270 int elements; 268 271 int numRows; 269 272 int numCols; … … 288 291 numRows = input->numRows; 289 292 numCols = input->numCols; 293 elements = numRows*numCols; 290 294 elementSize = PSELEMTYPE_SIZEOF(inDatatype); 291 295 … … 299 303 // cover the trival case of copy of the same datatype. 300 304 if (type == inDatatype) { 301 memcpy(output->data.V[0],input->data.V[0],elementSize* numRows*numCols);305 memcpy(output->data.V[0],input->data.V[0],elementSize*elements); 302 306 return output; 303 307 } 304 308 305 #define PSIMAGE_ELEMENT_ASSIGN_LOOP(OUT,IN,INTYPE,OUTTYPE) \ 306 { \ 307 ps##INTYPE *in; \ 308 ps##OUTTYPE *out; \ 309 for (int row=0;row<numRows;row++) { \ 310 in = IN->data.INTYPE[row]; \ 311 out = OUT->data.OUTTYPE[row]; \ 312 for (int col=0;col<numCols;col++) { \ 313 out[col] = (ps##OUTTYPE) in[col]; \ 314 } \ 309 #define PSIMAGE_ELEMENT_COPY(IN,INTYPE,OUT,OUTTYPE,ELEMENTS) { \ 310 ps##INTYPE *in = IN->data.INTYPE[0]; \ 311 ps##OUTTYPE *out = OUT->data.OUTTYPE[0]; \ 312 for (int e=0;e<ELEMENTS;e++) { \ 313 *(out++) = *(in++); \ 315 314 } \ 316 315 } 317 316 318 #define PSIMAGE_ ELEMENT_ASSIGN(OUT,IN,OUTTYPE) \319 switch ( IN->type.type) { \317 #define PSIMAGE_COPY_CASE(OUT,OUTTYPE) \ 318 switch (inDatatype) { \ 320 319 case PS_TYPE_S8: \ 321 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,S8,OUTTYPE); \320 PSIMAGE_ELEMENT_COPY(input,S8,OUT,OUTTYPE,elements); \ 322 321 break; \ 323 322 case PS_TYPE_S16: \ 324 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,S16,OUTTYPE); \323 PSIMAGE_ELEMENT_COPY(input,S16,OUT,OUTTYPE,elements); \ 325 324 break; \ 326 325 case PS_TYPE_S32: \ 327 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,S32,OUTTYPE); \326 PSIMAGE_ELEMENT_COPY(input,S32,OUT,OUTTYPE,elements); \ 328 327 break; \ 329 328 case PS_TYPE_S64: \ 330 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,S64,OUTTYPE); \329 PSIMAGE_ELEMENT_COPY(input,S64,OUT,OUTTYPE,elements); \ 331 330 break; \ 332 331 case PS_TYPE_U8: \ 333 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,U8,OUTTYPE); \332 PSIMAGE_ELEMENT_COPY(input,U8,OUT,OUTTYPE,elements); \ 334 333 break; \ 335 334 case PS_TYPE_U16: \ 336 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,U16,OUTTYPE); \335 PSIMAGE_ELEMENT_COPY(input,U16,OUT,OUTTYPE,elements); \ 337 336 break; \ 338 337 case PS_TYPE_U32: \ 339 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,U32,OUTTYPE); \338 PSIMAGE_ELEMENT_COPY(input,U32,OUT,OUTTYPE,elements); \ 340 339 break; \ 341 340 case PS_TYPE_U64: \ 342 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,U64,OUTTYPE); \341 PSIMAGE_ELEMENT_COPY(input,U64,OUT,OUTTYPE,elements); \ 343 342 break; \ 344 343 case PS_TYPE_F32: \ 345 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,F32,OUTTYPE); \344 PSIMAGE_ELEMENT_COPY(input,F32,OUT,OUTTYPE,elements); \ 346 345 break; \ 347 346 case PS_TYPE_F64: \ 348 PSIMAGE_ELEMENT_ ASSIGN_LOOP(OUT,IN,F64,OUTTYPE); \347 PSIMAGE_ELEMENT_COPY(input,F64,OUT,OUTTYPE,elements); \ 349 348 break; \ 350 349 case PS_TYPE_C32: \ 351 PSIMAGE_ELEMENT_ASSIGN_LOOP(OUT,IN,C32,OUTTYPE); \ 352 break; \ 353 case PS_TYPE_PTR: \ 354 psError(__func__,"Can't copy image from a matrix of pointers."); \ 355 psFree(output); \ 356 return NULL; \ 350 PSIMAGE_ELEMENT_COPY(input,C32,OUT,OUTTYPE,elements); \ 351 break; \ 352 case PS_TYPE_C64: \ 353 PSIMAGE_ELEMENT_COPY(input,C64,OUT,OUTTYPE,elements); \ 354 break; \ 357 355 default: \ 358 356 break; \ 359 357 } 360 358 361 // XXX - GCC had problems with the length? of the above macro. The original362 // macro code here is commented out and the preprocessor output is pasted below it363 // (effectively to the end of the function)364 // We need to find out what is doing on here and move back to the macro version.365 #if 0366 switch (type)367 {368 case PS_TYPE_S8:369 PSIMAGE_ELEMENT_ASSIGN(output,input,S8);370 break;371 case PS_TYPE_S16:372 PSIMAGE_ELEMENT_ASSIGN(output,input,S16);373 break;374 case PS_TYPE_S32:375 PSIMAGE_ELEMENT_ASSIGN(output,input,S32);376 break;377 case PS_TYPE_S64:378 PSIMAGE_ELEMENT_ASSIGN(output,input,S64);379 break;380 case PS_TYPE_U8:381 PSIMAGE_ELEMENT_ASSIGN(output,input,U8);382 case PS_TYPE_U16:383 PSIMAGE_ELEMENT_ASSIGN(output,input,U16);384 break;385 case PS_TYPE_U32:386 PSIMAGE_ELEMENT_ASSIGN(output,input,U32);387 break;388 case PS_TYPE_U64:389 PSIMAGE_ELEMENT_ASSIGN(output,input,U64);390 break;391 case PS_TYPE_F32:392 PSIMAGE_ELEMENT_ASSIGN(output,input,F32);393 break;394 case PS_TYPE_F64:395 PSIMAGE_ELEMENT_ASSIGN(output,input,F64);396 break;397 case PS_TYPE_C32:398 PSIMAGE_ELEMENT_ASSIGN(output,input,C32);399 break;400 case PS_TYPE_C64:401 PSIMAGE_ELEMENT_ASSIGN(output,input,C64);402 break;403 case PS_TYPE_PTR:404 psError(__func__,"Can't copy image into a matrix of pointers.");405 psFree(output);406 return NULL;407 }408 #endif409 410 #if 1411 359 switch (type) { 412 360 case PS_TYPE_S8: 413 switch (input->type.type) { 414 case PS_TYPE_S8: { 415 psS8 *in; 416 psS8 *out; 417 for (int row = 0; row < numRows; row++) { 418 in = input->data.S8[row]; 419 out = output->data.S8[row]; 420 for (int col = 0; col < numCols; col++) { 421 out[col] = (psS8) in[col]; 422 } 423 } 424 }; 425 break; 426 case PS_TYPE_S16: { 427 psS16 *in; 428 psS8 *out; 429 for (int row = 0; row < numRows; row++) { 430 in = input->data.S16[row]; 431 out = output->data.S8[row]; 432 for (int col = 0; col < numCols; col++) { 433 out[col] = (psS8) in[col]; 434 } 435 } 436 }; 437 break; 438 case PS_TYPE_S32: { 439 psS32 *in; 440 psS8 *out; 441 for (int row = 0; row < numRows; row++) { 442 in = input->data.S32[row]; 443 out = output->data.S8[row]; 444 for (int col = 0; col < numCols; col++) { 445 out[col] = (psS8) in[col]; 446 } 447 } 448 }; 449 break; 450 case PS_TYPE_S64: { 451 psS64 *in; 452 psS8 *out; 453 for (int row = 0; row < numRows; row++) { 454 in = input->data.S64[row]; 455 out = output->data.S8[row]; 456 for (int col = 0; col < numCols; col++) { 457 out[col] = (psS8) in[col]; 458 } 459 } 460 }; 461 break; 462 case PS_TYPE_U8: { 463 psU8 *in; 464 psS8 *out; 465 for (int row = 0; row < numRows; row++) { 466 in = input->data.U8[row]; 467 out = output->data.S8[row]; 468 for (int col = 0; col < numCols; col++) { 469 out[col] = (psS8) in[col]; 470 } 471 } 472 }; 473 break; 474 case PS_TYPE_U16: { 475 psU16 *in; 476 psS8 *out; 477 for (int row = 0; row < numRows; row++) { 478 in = input->data.U16[row]; 479 out = output->data.S8[row]; 480 for (int col = 0; col < numCols; col++) { 481 out[col] = (psS8) in[col]; 482 } 483 } 484 }; 485 break; 486 case PS_TYPE_U32: { 487 psU32 *in; 488 psS8 *out; 489 for (int row = 0; row < numRows; row++) { 490 in = input->data.U32[row]; 491 out = output->data.S8[row]; 492 for (int col = 0; col < numCols; col++) { 493 out[col] = (psS8) in[col]; 494 } 495 } 496 }; 497 break; 498 case PS_TYPE_U64: { 499 psU64 *in; 500 psS8 *out; 501 for (int row = 0; row < numRows; row++) { 502 in = input->data.U64[row]; 503 out = output->data.S8[row]; 504 for (int col = 0; col < numCols; col++) { 505 out[col] = (psS8) in[col]; 506 } 507 } 508 }; 509 break; 510 case PS_TYPE_F32: { 511 psF32 *in; 512 psS8 *out; 513 for (int row = 0; row < numRows; row++) { 514 in = input->data.F32[row]; 515 out = output->data.S8[row]; 516 for (int col = 0; col < numCols; col++) { 517 out[col] = (psS8) in[col]; 518 } 519 } 520 }; 521 break; 522 case PS_TYPE_F64: { 523 psF64 *in; 524 psS8 *out; 525 for (int row = 0; row < numRows; row++) { 526 in = input->data.F64[row]; 527 out = output->data.S8[row]; 528 for (int col = 0; col < numCols; col++) { 529 out[col] = (psS8) in[col]; 530 } 531 } 532 }; 533 break; 534 case PS_TYPE_C32: { 535 psC32 *in; 536 psS8 *out; 537 for (int row = 0; row < numRows; row++) { 538 in = input->data.C32[row]; 539 out = output->data.S8[row]; 540 for (int col = 0; col < numCols; col++) { 541 out[col] = (psS8) in[col]; 542 } 543 } 544 }; 545 break; 546 case PS_TYPE_PTR: 547 psError (__func__, "Can't copy image from a matrix of pointers."); 548 psFree (output); 549 return ((void *) 0); 550 default: 551 break; 552 }; 361 PSIMAGE_COPY_CASE(output,S8); 553 362 break; 554 363 case PS_TYPE_S16: 555 switch (input->type.type) { 556 case PS_TYPE_S8: { 557 psS8 *in; 558 psS16 *out; 559 for (int row = 0; row < numRows; row++) { 560 in = input->data.S8[row]; 561 out = output->data.S16[row]; 562 for (int col = 0; col < numCols; col++) { 563 out[col] = (psS16) in[col]; 564 } 565 } 566 }; 567 break; 568 case PS_TYPE_S16: { 569 psS16 *in; 570 psS16 *out; 571 for (int row = 0; row < numRows; row++) { 572 in = input->data.S16[row]; 573 out = output->data.S16[row]; 574 for (int col = 0; col < numCols; col++) { 575 out[col] = (psS16) in[col]; 576 } 577 } 578 }; 579 break; 580 case PS_TYPE_S32: { 581 psS32 *in; 582 psS16 *out; 583 for (int row = 0; row < numRows; row++) { 584 in = input->data.S32[row]; 585 out = output->data.S16[row]; 586 for (int col = 0; col < numCols; col++) { 587 out[col] = (psS16) in[col]; 588 } 589 } 590 }; 591 break; 592 case PS_TYPE_S64: { 593 psS64 *in; 594 psS16 *out; 595 for (int row = 0; row < numRows; row++) { 596 in = input->data.S64[row]; 597 out = output->data.S16[row]; 598 for (int col = 0; col < numCols; col++) { 599 out[col] = (psS16) in[col]; 600 } 601 } 602 }; 603 break; 604 case PS_TYPE_U8: { 605 psU8 *in; 606 psS16 *out; 607 for (int row = 0; row < numRows; row++) { 608 in = input->data.U8[row]; 609 out = output->data.S16[row]; 610 for (int col = 0; col < numCols; col++) { 611 out[col] = (psS16) in[col]; 612 } 613 } 614 }; 615 break; 616 case PS_TYPE_U16: { 617 psU16 *in; 618 psS16 *out; 619 for (int row = 0; row < numRows; row++) { 620 in = input->data.U16[row]; 621 out = output->data.S16[row]; 622 for (int col = 0; col < numCols; col++) { 623 out[col] = (psS16) in[col]; 624 } 625 } 626 }; 627 break; 628 case PS_TYPE_U32: { 629 psU32 *in; 630 psS16 *out; 631 for (int row = 0; row < numRows; row++) { 632 in = input->data.U32[row]; 633 out = output->data.S16[row]; 634 for (int col = 0; col < numCols; col++) { 635 out[col] = (psS16) in[col]; 636 } 637 } 638 }; 639 break; 640 case PS_TYPE_U64: { 641 psU64 *in; 642 psS16 *out; 643 for (int row = 0; row < numRows; row++) { 644 in = input->data.U64[row]; 645 out = output->data.S16[row]; 646 for (int col = 0; col < numCols; col++) { 647 out[col] = (psS16) in[col]; 648 } 649 } 650 }; 651 break; 652 case PS_TYPE_F32: { 653 psF32 *in; 654 psS16 *out; 655 for (int row = 0; row < numRows; row++) { 656 in = input->data.F32[row]; 657 out = output->data.S16[row]; 658 for (int col = 0; col < numCols; col++) { 659 out[col] = (psS16) in[col]; 660 } 661 } 662 }; 663 break; 664 case PS_TYPE_F64: { 665 psF64 *in; 666 psS16 *out; 667 for (int row = 0; row < numRows; row++) { 668 in = input->data.F64[row]; 669 out = output->data.S16[row]; 670 for (int col = 0; col < numCols; col++) { 671 out[col] = (psS16) in[col]; 672 } 673 } 674 }; 675 break; 676 case PS_TYPE_C32: { 677 psC32 *in; 678 psS16 *out; 679 for (int row = 0; row < numRows; row++) { 680 in = input->data.C32[row]; 681 out = output->data.S16[row]; 682 for (int col = 0; col < numCols; col++) { 683 out[col] = (psS16) in[col]; 684 } 685 } 686 }; 687 break; 688 case PS_TYPE_PTR: 689 psError (__func__, "Can't copy image from a matrix of pointers."); 690 psFree (output); 691 return ((void *) 0); 692 default: 693 break; 694 }; 364 PSIMAGE_COPY_CASE(output,S16); 695 365 break; 696 366 case PS_TYPE_S32: 697 switch (input->type.type) { 698 case PS_TYPE_S8: { 699 psS8 *in; 700 psS32 *out; 701 for (int row = 0; row < numRows; row++) { 702 in = input->data.S8[row]; 703 out = output->data.S32[row]; 704 for (int col = 0; col < numCols; col++) { 705 out[col] = (psS32) in[col]; 706 } 707 } 708 }; 709 break; 710 case PS_TYPE_S16: { 711 psS16 *in; 712 psS32 *out; 713 for (int row = 0; row < numRows; row++) { 714 in = input->data.S16[row]; 715 out = output->data.S32[row]; 716 for (int col = 0; col < numCols; col++) { 717 out[col] = (psS32) in[col]; 718 } 719 } 720 }; 721 break; 722 case PS_TYPE_S32: { 723 psS32 *in; 724 psS32 *out; 725 for (int row = 0; row < numRows; row++) { 726 in = input->data.S32[row]; 727 out = output->data.S32[row]; 728 for (int col = 0; col < numCols; col++) { 729 out[col] = (psS32) in[col]; 730 } 731 } 732 }; 733 break; 734 case PS_TYPE_S64: { 735 psS64 *in; 736 psS32 *out; 737 for (int row = 0; row < numRows; row++) { 738 in = input->data.S64[row]; 739 out = output->data.S32[row]; 740 for (int col = 0; col < numCols; col++) { 741 out[col] = (psS32) in[col]; 742 } 743 } 744 }; 745 break; 746 case PS_TYPE_U8: { 747 psU8 *in; 748 psS32 *out; 749 for (int row = 0; row < numRows; row++) { 750 in = input->data.U8[row]; 751 out = output->data.S32[row]; 752 for (int col = 0; col < numCols; col++) { 753 out[col] = (psS32) in[col]; 754 } 755 } 756 }; 757 break; 758 case PS_TYPE_U16: { 759 psU16 *in; 760 psS32 *out; 761 for (int row = 0; row < numRows; row++) { 762 in = input->data.U16[row]; 763 out = output->data.S32[row]; 764 for (int col = 0; col < numCols; col++) { 765 out[col] = (psS32) in[col]; 766 } 767 } 768 }; 769 break; 770 case PS_TYPE_U32: { 771 psU32 *in; 772 psS32 *out; 773 for (int row = 0; row < numRows; row++) { 774 in = input->data.U32[row]; 775 out = output->data.S32[row]; 776 for (int col = 0; col < numCols; col++) { 777 out[col] = (psS32) in[col]; 778 } 779 } 780 }; 781 break; 782 case PS_TYPE_U64: { 783 psU64 *in; 784 psS32 *out; 785 for (int row = 0; row < numRows; row++) { 786 in = input->data.U64[row]; 787 out = output->data.S32[row]; 788 for (int col = 0; col < numCols; col++) { 789 out[col] = (psS32) in[col]; 790 } 791 } 792 }; 793 break; 794 case PS_TYPE_F32: { 795 psF32 *in; 796 psS32 *out; 797 for (int row = 0; row < numRows; row++) { 798 in = input->data.F32[row]; 799 out = output->data.S32[row]; 800 for (int col = 0; col < numCols; col++) { 801 out[col] = (psS32) in[col]; 802 } 803 } 804 }; 805 break; 806 case PS_TYPE_F64: { 807 psF64 *in; 808 psS32 *out; 809 for (int row = 0; row < numRows; row++) { 810 in = input->data.F64[row]; 811 out = output->data.S32[row]; 812 for (int col = 0; col < numCols; col++) { 813 out[col] = (psS32) in[col]; 814 } 815 } 816 }; 817 break; 818 case PS_TYPE_C32: { 819 psC32 *in; 820 psS32 *out; 821 for (int row = 0; row < numRows; row++) { 822 in = input->data.C32[row]; 823 out = output->data.S32[row]; 824 for (int col = 0; col < numCols; col++) { 825 out[col] = (psS32) in[col]; 826 } 827 } 828 }; 829 break; 830 case PS_TYPE_PTR: 831 psError (__func__, "Can't copy image from a matrix of pointers."); 832 psFree (output); 833 return ((void *) 0); 834 default: 835 break; 836 }; 367 PSIMAGE_COPY_CASE(output,S32); 837 368 break; 838 369 case PS_TYPE_S64: 839 switch (input->type.type) { 840 case PS_TYPE_S8: { 841 psS8 *in; 842 psS64 *out; 843 for (int row = 0; row < numRows; row++) { 844 in = input->data.S8[row]; 845 out = output->data.S64[row]; 846 for (int col = 0; col < numCols; col++) { 847 out[col] = (psS64) in[col]; 848 } 849 } 850 }; 851 break; 852 case PS_TYPE_S16: { 853 psS16 *in; 854 psS64 *out; 855 for (int row = 0; row < numRows; row++) { 856 in = input->data.S16[row]; 857 out = output->data.S64[row]; 858 for (int col = 0; col < numCols; col++) { 859 out[col] = (psS64) in[col]; 860 } 861 } 862 }; 863 break; 864 case PS_TYPE_S32: { 865 psS32 *in; 866 psS64 *out; 867 for (int row = 0; row < numRows; row++) { 868 in = input->data.S32[row]; 869 out = output->data.S64[row]; 870 for (int col = 0; col < numCols; col++) { 871 out[col] = (psS64) in[col]; 872 } 873 } 874 }; 875 break; 876 case PS_TYPE_S64: { 877 psS64 *in; 878 psS64 *out; 879 for (int row = 0; row < numRows; row++) { 880 in = input->data.S64[row]; 881 out = output->data.S64[row]; 882 for (int col = 0; col < numCols; col++) { 883 out[col] = (psS64) in[col]; 884 } 885 } 886 }; 887 break; 888 case PS_TYPE_U8: { 889 psU8 *in; 890 psS64 *out; 891 for (int row = 0; row < numRows; row++) { 892 in = input->data.U8[row]; 893 out = output->data.S64[row]; 894 for (int col = 0; col < numCols; col++) { 895 out[col] = (psS64) in[col]; 896 } 897 } 898 }; 899 break; 900 case PS_TYPE_U16: { 901 psU16 *in; 902 psS64 *out; 903 for (int row = 0; row < numRows; row++) { 904 in = input->data.U16[row]; 905 out = output->data.S64[row]; 906 for (int col = 0; col < numCols; col++) { 907 out[col] = (psS64) in[col]; 908 } 909 } 910 }; 911 break; 912 case PS_TYPE_U32: { 913 psU32 *in; 914 psS64 *out; 915 for (int row = 0; row < numRows; row++) { 916 in = input->data.U32[row]; 917 out = output->data.S64[row]; 918 for (int col = 0; col < numCols; col++) { 919 out[col] = (psS64) in[col]; 920 } 921 } 922 }; 923 break; 924 case PS_TYPE_U64: { 925 psU64 *in; 926 psS64 *out; 927 for (int row = 0; row < numRows; row++) { 928 in = input->data.U64[row]; 929 out = output->data.S64[row]; 930 for (int col = 0; col < numCols; col++) { 931 out[col] = (psS64) in[col]; 932 } 933 } 934 }; 935 break; 936 case PS_TYPE_F32: { 937 psF32 *in; 938 psS64 *out; 939 for (int row = 0; row < numRows; row++) { 940 in = input->data.F32[row]; 941 out = output->data.S64[row]; 942 for (int col = 0; col < numCols; col++) { 943 out[col] = (psS64) in[col]; 944 } 945 } 946 }; 947 break; 948 case PS_TYPE_F64: { 949 psF64 *in; 950 psS64 *out; 951 for (int row = 0; row < numRows; row++) { 952 in = input->data.F64[row]; 953 out = output->data.S64[row]; 954 for (int col = 0; col < numCols; col++) { 955 out[col] = (psS64) in[col]; 956 } 957 } 958 }; 959 break; 960 case PS_TYPE_C32: { 961 psC32 *in; 962 psS64 *out; 963 for (int row = 0; row < numRows; row++) { 964 in = input->data.C32[row]; 965 out = output->data.S64[row]; 966 for (int col = 0; col < numCols; col++) { 967 out[col] = (psS64) in[col]; 968 } 969 } 970 }; 971 break; 972 case PS_TYPE_PTR: 973 psError (__func__, "Can't copy image from a matrix of pointers."); 974 psFree (output); 975 return ((void *) 0); 976 default: 977 break; 978 }; 370 PSIMAGE_COPY_CASE(output,S64); 979 371 break; 980 372 case PS_TYPE_U8: 981 switch (input->type.type) { 982 case PS_TYPE_S8: { 983 psS8 *in; 984 psU8 *out; 985 for (int row = 0; row < numRows; row++) { 986 in = input->data.S8[row]; 987 out = output->data.U8[row]; 988 for (int col = 0; col < numCols; col++) { 989 out[col] = (psU8) in[col]; 990 } 991 } 992 }; 993 break; 994 case PS_TYPE_S16: { 995 psS16 *in; 996 psU8 *out; 997 for (int row = 0; row < numRows; row++) { 998 in = input->data.S16[row]; 999 out = output->data.U8[row]; 1000 for (int col = 0; col < numCols; col++) { 1001 out[col] = (psU8) in[col]; 1002 } 1003 } 1004 }; 1005 break; 1006 case PS_TYPE_S32: { 1007 psS32 *in; 1008 psU8 *out; 1009 for (int row = 0; row < numRows; row++) { 1010 in = input->data.S32[row]; 1011 out = output->data.U8[row]; 1012 for (int col = 0; col < numCols; col++) { 1013 out[col] = (psU8) in[col]; 1014 } 1015 } 1016 }; 1017 break; 1018 case PS_TYPE_S64: { 1019 psS64 *in; 1020 psU8 *out; 1021 for (int row = 0; row < numRows; row++) { 1022 in = input->data.S64[row]; 1023 out = output->data.U8[row]; 1024 for (int col = 0; col < numCols; col++) { 1025 out[col] = (psU8) in[col]; 1026 } 1027 } 1028 }; 1029 break; 1030 case PS_TYPE_U8: { 1031 psU8 *in; 1032 psU8 *out; 1033 for (int row = 0; row < numRows; row++) { 1034 in = input->data.U8[row]; 1035 out = output->data.U8[row]; 1036 for (int col = 0; col < numCols; col++) { 1037 out[col] = (psU8) in[col]; 1038 } 1039 } 1040 }; 1041 break; 1042 case PS_TYPE_U16: { 1043 psU16 *in; 1044 psU8 *out; 1045 for (int row = 0; row < numRows; row++) { 1046 in = input->data.U16[row]; 1047 out = output->data.U8[row]; 1048 for (int col = 0; col < numCols; col++) { 1049 out[col] = (psU8) in[col]; 1050 } 1051 } 1052 }; 1053 break; 1054 case PS_TYPE_U32: { 1055 psU32 *in; 1056 psU8 *out; 1057 for (int row = 0; row < numRows; row++) { 1058 in = input->data.U32[row]; 1059 out = output->data.U8[row]; 1060 for (int col = 0; col < numCols; col++) { 1061 out[col] = (psU8) in[col]; 1062 } 1063 } 1064 }; 1065 break; 1066 case PS_TYPE_U64: { 1067 psU64 *in; 1068 psU8 *out; 1069 for (int row = 0; row < numRows; row++) { 1070 in = input->data.U64[row]; 1071 out = output->data.U8[row]; 1072 for (int col = 0; col < numCols; col++) { 1073 out[col] = (psU8) in[col]; 1074 } 1075 } 1076 }; 1077 break; 1078 case PS_TYPE_F32: { 1079 psF32 *in; 1080 psU8 *out; 1081 for (int row = 0; row < numRows; row++) { 1082 in = input->data.F32[row]; 1083 out = output->data.U8[row]; 1084 for (int col = 0; col < numCols; col++) { 1085 out[col] = (psU8) in[col]; 1086 } 1087 } 1088 }; 1089 break; 1090 case PS_TYPE_F64: { 1091 psF64 *in; 1092 psU8 *out; 1093 for (int row = 0; row < numRows; row++) { 1094 in = input->data.F64[row]; 1095 out = output->data.U8[row]; 1096 for (int col = 0; col < numCols; col++) { 1097 out[col] = (psU8) in[col]; 1098 } 1099 } 1100 }; 1101 break; 1102 case PS_TYPE_C32: { 1103 psC32 *in; 1104 psU8 *out; 1105 for (int row = 0; row < numRows; row++) { 1106 in = input->data.C32[row]; 1107 out = output->data.U8[row]; 1108 for (int col = 0; col < numCols; col++) { 1109 out[col] = (psU8) in[col]; 1110 } 1111 } 1112 }; 1113 break; 1114 case PS_TYPE_PTR: 1115 psError (__func__, "Can't copy image from a matrix of pointers."); 1116 psFree (output); 1117 return ((void *) 0); 1118 default: 1119 break; 1120 }; 373 PSIMAGE_COPY_CASE(output,U8); 1121 374 break; 1122 375 case PS_TYPE_U16: 1123 switch (input->type.type) { 1124 case PS_TYPE_S8: { 1125 psS8 *in; 1126 psU16 *out; 1127 for (int row = 0; row < numRows; row++) { 1128 in = input->data.S8[row]; 1129 out = output->data.U16[row]; 1130 for (int col = 0; col < numCols; col++) { 1131 out[col] = (psU16) in[col]; 1132 } 1133 } 1134 }; 1135 break; 1136 case PS_TYPE_S16: { 1137 psS16 *in; 1138 psU16 *out; 1139 for (int row = 0; row < numRows; row++) { 1140 in = input->data.S16[row]; 1141 out = output->data.U16[row]; 1142 for (int col = 0; col < numCols; col++) { 1143 out[col] = (psU16) in[col]; 1144 } 1145 } 1146 }; 1147 break; 1148 case PS_TYPE_S32: { 1149 psS32 *in; 1150 psU16 *out; 1151 for (int row = 0; row < numRows; row++) { 1152 in = input->data.S32[row]; 1153 out = output->data.U16[row]; 1154 for (int col = 0; col < numCols; col++) { 1155 out[col] = (psU16) in[col]; 1156 } 1157 } 1158 }; 1159 break; 1160 case PS_TYPE_S64: { 1161 psS64 *in; 1162 psU16 *out; 1163 for (int row = 0; row < numRows; row++) { 1164 in = input->data.S64[row]; 1165 out = output->data.U16[row]; 1166 for (int col = 0; col < numCols; col++) { 1167 out[col] = (psU16) in[col]; 1168 } 1169 } 1170 }; 1171 break; 1172 case PS_TYPE_U8: { 1173 psU8 *in; 1174 psU16 *out; 1175 for (int row = 0; row < numRows; row++) { 1176 in = input->data.U8[row]; 1177 out = output->data.U16[row]; 1178 for (int col = 0; col < numCols; col++) { 1179 out[col] = (psU16) in[col]; 1180 } 1181 } 1182 }; 1183 break; 1184 case PS_TYPE_U16: { 1185 psU16 *in; 1186 psU16 *out; 1187 for (int row = 0; row < numRows; row++) { 1188 in = input->data.U16[row]; 1189 out = output->data.U16[row]; 1190 for (int col = 0; col < numCols; col++) { 1191 out[col] = (psU16) in[col]; 1192 } 1193 } 1194 }; 1195 break; 1196 case PS_TYPE_U32: { 1197 psU32 *in; 1198 psU16 *out; 1199 for (int row = 0; row < numRows; row++) { 1200 in = input->data.U32[row]; 1201 out = output->data.U16[row]; 1202 for (int col = 0; col < numCols; col++) { 1203 out[col] = (psU16) in[col]; 1204 } 1205 } 1206 }; 1207 break; 1208 case PS_TYPE_U64: { 1209 psU64 *in; 1210 psU16 *out; 1211 for (int row = 0; row < numRows; row++) { 1212 in = input->data.U64[row]; 1213 out = output->data.U16[row]; 1214 for (int col = 0; col < numCols; col++) { 1215 out[col] = (psU16) in[col]; 1216 } 1217 } 1218 }; 1219 break; 1220 case PS_TYPE_F32: { 1221 psF32 *in; 1222 psU16 *out; 1223 for (int row = 0; row < numRows; row++) { 1224 in = input->data.F32[row]; 1225 out = output->data.U16[row]; 1226 for (int col = 0; col < numCols; col++) { 1227 out[col] = (psU16) in[col]; 1228 } 1229 } 1230 }; 1231 break; 1232 case PS_TYPE_F64: { 1233 psF64 *in; 1234 psU16 *out; 1235 for (int row = 0; row < numRows; row++) { 1236 in = input->data.F64[row]; 1237 out = output->data.U16[row]; 1238 for (int col = 0; col < numCols; col++) { 1239 out[col] = (psU16) in[col]; 1240 } 1241 } 1242 }; 1243 break; 1244 case PS_TYPE_C32: { 1245 psC32 *in; 1246 psU16 *out; 1247 for (int row = 0; row < numRows; row++) { 1248 in = input->data.C32[row]; 1249 out = output->data.U16[row]; 1250 for (int col = 0; col < numCols; col++) { 1251 out[col] = (psU16) in[col]; 1252 } 1253 } 1254 }; 1255 break; 1256 case PS_TYPE_PTR: 1257 psError (__func__, "Can't copy image from a matrix of pointers."); 1258 psFree (output); 1259 return ((void *) 0); 1260 default: 1261 break; 1262 }; 376 PSIMAGE_COPY_CASE(output,U16); 1263 377 break; 1264 378 case PS_TYPE_U32: 1265 switch (input->type.type) { 1266 case PS_TYPE_S8: { 1267 psS8 *in; 1268 psU32 *out; 1269 for (int row = 0; row < numRows; row++) { 1270 in = input->data.S8[row]; 1271 out = output->data.U32[row]; 1272 for (int col = 0; col < numCols; col++) { 1273 out[col] = (psU32) in[col]; 1274 } 1275 } 1276 }; 1277 break; 1278 case PS_TYPE_S16: { 1279 psS16 *in; 1280 psU32 *out; 1281 for (int row = 0; row < numRows; row++) { 1282 in = input->data.S16[row]; 1283 out = output->data.U32[row]; 1284 for (int col = 0; col < numCols; col++) { 1285 out[col] = (psU32) in[col]; 1286 } 1287 } 1288 }; 1289 break; 1290 case PS_TYPE_S32: { 1291 psS32 *in; 1292 psU32 *out; 1293 for (int row = 0; row < numRows; row++) { 1294 in = input->data.S32[row]; 1295 out = output->data.U32[row]; 1296 for (int col = 0; col < numCols; col++) { 1297 out[col] = (psU32) in[col]; 1298 } 1299 } 1300 }; 1301 break; 1302 case PS_TYPE_S64: { 1303 psS64 *in; 1304 psU32 *out; 1305 for (int row = 0; row < numRows; row++) { 1306 in = input->data.S64[row]; 1307 out = output->data.U32[row]; 1308 for (int col = 0; col < numCols; col++) { 1309 out[col] = (psU32) in[col]; 1310 } 1311 } 1312 }; 1313 break; 1314 case PS_TYPE_U8: { 1315 psU8 *in; 1316 psU32 *out; 1317 for (int row = 0; row < numRows; row++) { 1318 in = input->data.U8[row]; 1319 out = output->data.U32[row]; 1320 for (int col = 0; col < numCols; col++) { 1321 out[col] = (psU32) in[col]; 1322 } 1323 } 1324 }; 1325 break; 1326 case PS_TYPE_U16: { 1327 psU16 *in; 1328 psU32 *out; 1329 for (int row = 0; row < numRows; row++) { 1330 in = input->data.U16[row]; 1331 out = output->data.U32[row]; 1332 for (int col = 0; col < numCols; col++) { 1333 out[col] = (psU32) in[col]; 1334 } 1335 } 1336 }; 1337 break; 1338 case PS_TYPE_U32: { 1339 psU32 *in; 1340 psU32 *out; 1341 for (int row = 0; row < numRows; row++) { 1342 in = input->data.U32[row]; 1343 out = output->data.U32[row]; 1344 for (int col = 0; col < numCols; col++) { 1345 out[col] = (psU32) in[col]; 1346 } 1347 } 1348 }; 1349 break; 1350 case PS_TYPE_U64: { 1351 psU64 *in; 1352 psU32 *out; 1353 for (int row = 0; row < numRows; row++) { 1354 in = input->data.U64[row]; 1355 out = output->data.U32[row]; 1356 for (int col = 0; col < numCols; col++) { 1357 out[col] = (psU32) in[col]; 1358 } 1359 } 1360 }; 1361 break; 1362 case PS_TYPE_F32: { 1363 psF32 *in; 1364 psU32 *out; 1365 for (int row = 0; row < numRows; row++) { 1366 in = input->data.F32[row]; 1367 out = output->data.U32[row]; 1368 for (int col = 0; col < numCols; col++) { 1369 out[col] = (psU32) in[col]; 1370 } 1371 } 1372 }; 1373 break; 1374 case PS_TYPE_F64: { 1375 psF64 *in; 1376 psU32 *out; 1377 for (int row = 0; row < numRows; row++) { 1378 in = input->data.F64[row]; 1379 out = output->data.U32[row]; 1380 for (int col = 0; col < numCols; col++) { 1381 out[col] = (psU32) in[col]; 1382 } 1383 } 1384 }; 1385 break; 1386 case PS_TYPE_C32: { 1387 psC32 *in; 1388 psU32 *out; 1389 for (int row = 0; row < numRows; row++) { 1390 in = input->data.C32[row]; 1391 out = output->data.U32[row]; 1392 for (int col = 0; col < numCols; col++) { 1393 out[col] = (psU32) in[col]; 1394 } 1395 } 1396 }; 1397 break; 1398 case PS_TYPE_PTR: 1399 psError (__func__, "Can't copy image from a matrix of pointers."); 1400 psFree (output); 1401 return ((void *) 0); 1402 default: 1403 break; 1404 }; 379 PSIMAGE_COPY_CASE(output,U32); 1405 380 break; 1406 381 case PS_TYPE_U64: 1407 switch (input->type.type) { 1408 case PS_TYPE_S8: { 1409 psS8 *in; 1410 psU64 *out; 1411 for (int row = 0; row < numRows; row++) { 1412 in = input->data.S8[row]; 1413 out = output->data.U64[row]; 1414 for (int col = 0; col < numCols; col++) { 1415 out[col] = (psU64) in[col]; 1416 } 1417 } 1418 }; 1419 break; 1420 case PS_TYPE_S16: { 1421 psS16 *in; 1422 psU64 *out; 1423 for (int row = 0; row < numRows; row++) { 1424 in = input->data.S16[row]; 1425 out = output->data.U64[row]; 1426 for (int col = 0; col < numCols; col++) { 1427 out[col] = (psU64) in[col]; 1428 } 1429 } 1430 }; 1431 break; 1432 case PS_TYPE_S32: { 1433 psS32 *in; 1434 psU64 *out; 1435 for (int row = 0; row < numRows; row++) { 1436 in = input->data.S32[row]; 1437 out = output->data.U64[row]; 1438 for (int col = 0; col < numCols; col++) { 1439 out[col] = (psU64) in[col]; 1440 } 1441 } 1442 }; 1443 break; 1444 case PS_TYPE_S64: { 1445 psS64 *in; 1446 psU64 *out; 1447 for (int row = 0; row < numRows; row++) { 1448 in = input->data.S64[row]; 1449 out = output->data.U64[row]; 1450 for (int col = 0; col < numCols; col++) { 1451 out[col] = (psU64) in[col]; 1452 } 1453 } 1454 }; 1455 break; 1456 case PS_TYPE_U8: { 1457 psU8 *in; 1458 psU64 *out; 1459 for (int row = 0; row < numRows; row++) { 1460 in = input->data.U8[row]; 1461 out = output->data.U64[row]; 1462 for (int col = 0; col < numCols; col++) { 1463 out[col] = (psU64) in[col]; 1464 } 1465 } 1466 }; 1467 break; 1468 case PS_TYPE_U16: { 1469 psU16 *in; 1470 psU64 *out; 1471 for (int row = 0; row < numRows; row++) { 1472 in = input->data.U16[row]; 1473 out = output->data.U64[row]; 1474 for (int col = 0; col < numCols; col++) { 1475 out[col] = (psU64) in[col]; 1476 } 1477 } 1478 }; 1479 break; 1480 case PS_TYPE_U32: { 1481 psU32 *in; 1482 psU64 *out; 1483 for (int row = 0; row < numRows; row++) { 1484 in = input->data.U32[row]; 1485 out = output->data.U64[row]; 1486 for (int col = 0; col < numCols; col++) { 1487 out[col] = (psU64) in[col]; 1488 } 1489 } 1490 }; 1491 break; 1492 case PS_TYPE_U64: { 1493 psU64 *in; 1494 psU64 *out; 1495 for (int row = 0; row < numRows; row++) { 1496 in = input->data.U64[row]; 1497 out = output->data.U64[row]; 1498 for (int col = 0; col < numCols; col++) { 1499 out[col] = (psU64) in[col]; 1500 } 1501 } 1502 }; 1503 break; 1504 case PS_TYPE_F32: { 1505 psF32 *in; 1506 psU64 *out; 1507 for (int row = 0; row < numRows; row++) { 1508 in = input->data.F32[row]; 1509 out = output->data.U64[row]; 1510 for (int col = 0; col < numCols; col++) { 1511 out[col] = (psU64) in[col]; 1512 } 1513 } 1514 }; 1515 break; 1516 case PS_TYPE_F64: { 1517 psF64 *in; 1518 psU64 *out; 1519 for (int row = 0; row < numRows; row++) { 1520 in = input->data.F64[row]; 1521 out = output->data.U64[row]; 1522 for (int col = 0; col < numCols; col++) { 1523 out[col] = (psU64) in[col]; 1524 } 1525 } 1526 }; 1527 break; 1528 case PS_TYPE_C32: { 1529 psC32 *in; 1530 psU64 *out; 1531 for (int row = 0; row < numRows; row++) { 1532 in = input->data.C32[row]; 1533 out = output->data.U64[row]; 1534 for (int col = 0; col < numCols; col++) { 1535 out[col] = (psU64) in[col]; 1536 } 1537 } 1538 }; 1539 break; 1540 case PS_TYPE_PTR: 1541 psError (__func__, "Can't copy image from a matrix of pointers."); 1542 psFree (output); 1543 return ((void *) 0); 1544 default: 1545 break; 1546 }; 382 PSIMAGE_COPY_CASE(output,U64); 1547 383 break; 1548 384 case PS_TYPE_F32: 1549 switch (input->type.type) { 1550 case PS_TYPE_S8: { 1551 psS8 *in; 1552 psF32 *out; 1553 for (int row = 0; row < numRows; row++) { 1554 in = input->data.S8[row]; 1555 out = output->data.F32[row]; 1556 for (int col = 0; col < numCols; col++) { 1557 out[col] = (psF32) in[col]; 1558 } 1559 } 1560 }; 1561 break; 1562 case PS_TYPE_S16: { 1563 psS16 *in; 1564 psF32 *out; 1565 for (int row = 0; row < numRows; row++) { 1566 in = input->data.S16[row]; 1567 out = output->data.F32[row]; 1568 for (int col = 0; col < numCols; col++) { 1569 out[col] = (psF32) in[col]; 1570 } 1571 } 1572 }; 1573 break; 1574 case PS_TYPE_S32: { 1575 psS32 *in; 1576 psF32 *out; 1577 for (int row = 0; row < numRows; row++) { 1578 in = input->data.S32[row]; 1579 out = output->data.F32[row]; 1580 for (int col = 0; col < numCols; col++) { 1581 out[col] = (psF32) in[col]; 1582 } 1583 } 1584 }; 1585 break; 1586 case PS_TYPE_S64: { 1587 psS64 *in; 1588 psF32 *out; 1589 for (int row = 0; row < numRows; row++) { 1590 in = input->data.S64[row]; 1591 out = output->data.F32[row]; 1592 for (int col = 0; col < numCols; col++) { 1593 out[col] = (psF32) in[col]; 1594 } 1595 } 1596 }; 1597 break; 1598 case PS_TYPE_U8: { 1599 psU8 *in; 1600 psF32 *out; 1601 for (int row = 0; row < numRows; row++) { 1602 in = input->data.U8[row]; 1603 out = output->data.F32[row]; 1604 for (int col = 0; col < numCols; col++) { 1605 out[col] = (psF32) in[col]; 1606 } 1607 } 1608 }; 1609 break; 1610 case PS_TYPE_U16: { 1611 psU16 *in; 1612 psF32 *out; 1613 for (int row = 0; row < numRows; row++) { 1614 in = input->data.U16[row]; 1615 out = output->data.F32[row]; 1616 for (int col = 0; col < numCols; col++) { 1617 out[col] = (psF32) in[col]; 1618 } 1619 } 1620 }; 1621 break; 1622 case PS_TYPE_U32: { 1623 psU32 *in; 1624 psF32 *out; 1625 for (int row = 0; row < numRows; row++) { 1626 in = input->data.U32[row]; 1627 out = output->data.F32[row]; 1628 for (int col = 0; col < numCols; col++) { 1629 out[col] = (psF32) in[col]; 1630 } 1631 } 1632 }; 1633 break; 1634 case PS_TYPE_U64: { 1635 psU64 *in; 1636 psF32 *out; 1637 for (int row = 0; row < numRows; row++) { 1638 in = input->data.U64[row]; 1639 out = output->data.F32[row]; 1640 for (int col = 0; col < numCols; col++) { 1641 out[col] = (psF32) in[col]; 1642 } 1643 } 1644 }; 1645 break; 1646 case PS_TYPE_F32: { 1647 psF32 *in; 1648 psF32 *out; 1649 for (int row = 0; row < numRows; row++) { 1650 in = input->data.F32[row]; 1651 out = output->data.F32[row]; 1652 for (int col = 0; col < numCols; col++) { 1653 out[col] = (psF32) in[col]; 1654 } 1655 } 1656 }; 1657 break; 1658 case PS_TYPE_F64: { 1659 psF64 *in; 1660 psF32 *out; 1661 for (int row = 0; row < numRows; row++) { 1662 in = input->data.F64[row]; 1663 out = output->data.F32[row]; 1664 for (int col = 0; col < numCols; col++) { 1665 out[col] = (psF32) in[col]; 1666 } 1667 } 1668 }; 1669 break; 1670 case PS_TYPE_C32: { 1671 psC32 *in; 1672 psF32 *out; 1673 for (int row = 0; row < numRows; row++) { 1674 in = input->data.C32[row]; 1675 out = output->data.F32[row]; 1676 for (int col = 0; col < numCols; col++) { 1677 out[col] = (psF32) in[col]; 1678 } 1679 } 1680 }; 1681 break; 1682 case PS_TYPE_PTR: 1683 psError (__func__, "Can't copy image from a matrix of pointers."); 1684 psFree (output); 1685 return ((void *) 0); 1686 default: 1687 break; 1688 }; 385 PSIMAGE_COPY_CASE(output,F32); 1689 386 break; 1690 387 case PS_TYPE_F64: 1691 switch (input->type.type) { 1692 case PS_TYPE_S8: { 1693 psS8 *in; 1694 psF64 *out; 1695 for (int row = 0; row < numRows; row++) { 1696 in = input->data.S8[row]; 1697 out = output->data.F64[row]; 1698 for (int col = 0; col < numCols; col++) { 1699 out[col] = (psF64) in[col]; 1700 } 1701 } 1702 }; 1703 break; 1704 case PS_TYPE_S16: { 1705 psS16 *in; 1706 psF64 *out; 1707 for (int row = 0; row < numRows; row++) { 1708 in = input->data.S16[row]; 1709 out = output->data.F64[row]; 1710 for (int col = 0; col < numCols; col++) { 1711 out[col] = (psF64) in[col]; 1712 } 1713 } 1714 }; 1715 break; 1716 case PS_TYPE_S32: { 1717 psS32 *in; 1718 psF64 *out; 1719 for (int row = 0; row < numRows; row++) { 1720 in = input->data.S32[row]; 1721 out = output->data.F64[row]; 1722 for (int col = 0; col < numCols; col++) { 1723 out[col] = (psF64) in[col]; 1724 } 1725 } 1726 }; 1727 break; 1728 case PS_TYPE_S64: { 1729 psS64 *in; 1730 psF64 *out; 1731 for (int row = 0; row < numRows; row++) { 1732 in = input->data.S64[row]; 1733 out = output->data.F64[row]; 1734 for (int col = 0; col < numCols; col++) { 1735 out[col] = (psF64) in[col]; 1736 } 1737 } 1738 }; 1739 break; 1740 case PS_TYPE_U8: { 1741 psU8 *in; 1742 psF64 *out; 1743 for (int row = 0; row < numRows; row++) { 1744 in = input->data.U8[row]; 1745 out = output->data.F64[row]; 1746 for (int col = 0; col < numCols; col++) { 1747 out[col] = (psF64) in[col]; 1748 } 1749 } 1750 }; 1751 break; 1752 case PS_TYPE_U16: { 1753 psU16 *in; 1754 psF64 *out; 1755 for (int row = 0; row < numRows; row++) { 1756 in = input->data.U16[row]; 1757 out = output->data.F64[row]; 1758 for (int col = 0; col < numCols; col++) { 1759 out[col] = (psF64) in[col]; 1760 } 1761 } 1762 }; 1763 break; 1764 case PS_TYPE_U32: { 1765 psU32 *in; 1766 psF64 *out; 1767 for (int row = 0; row < numRows; row++) { 1768 in = input->data.U32[row]; 1769 out = output->data.F64[row]; 1770 for (int col = 0; col < numCols; col++) { 1771 out[col] = (psF64) in[col]; 1772 } 1773 } 1774 }; 1775 break; 1776 case PS_TYPE_U64: { 1777 psU64 *in; 1778 psF64 *out; 1779 for (int row = 0; row < numRows; row++) { 1780 in = input->data.U64[row]; 1781 out = output->data.F64[row]; 1782 for (int col = 0; col < numCols; col++) { 1783 out[col] = (psF64) in[col]; 1784 } 1785 } 1786 }; 1787 break; 1788 case PS_TYPE_F32: { 1789 psF32 *in; 1790 psF64 *out; 1791 for (int row = 0; row < numRows; row++) { 1792 in = input->data.F32[row]; 1793 out = output->data.F64[row]; 1794 for (int col = 0; col < numCols; col++) { 1795 out[col] = (psF64) in[col]; 1796 } 1797 } 1798 }; 1799 break; 1800 case PS_TYPE_F64: { 1801 psF64 *in; 1802 psF64 *out; 1803 for (int row = 0; row < numRows; row++) { 1804 in = input->data.F64[row]; 1805 out = output->data.F64[row]; 1806 for (int col = 0; col < numCols; col++) { 1807 out[col] = (psF64) in[col]; 1808 } 1809 } 1810 }; 1811 break; 1812 case PS_TYPE_C32: { 1813 psC32 *in; 1814 psF64 *out; 1815 for (int row = 0; row < numRows; row++) { 1816 in = input->data.C32[row]; 1817 out = output->data.F64[row]; 1818 for (int col = 0; col < numCols; col++) { 1819 out[col] = (psF64) in[col]; 1820 } 1821 } 1822 }; 1823 break; 1824 case PS_TYPE_PTR: 1825 psError (__func__, "Can't copy image from a matrix of pointers."); 1826 psFree (output); 1827 return ((void *) 0); 1828 default: 1829 break; 1830 }; 388 PSIMAGE_COPY_CASE(output,F64); 1831 389 break; 1832 390 case PS_TYPE_C32: 1833 switch (input->type.type) { 1834 case PS_TYPE_S8: { 1835 psS8 *in; 1836 psC32 *out; 1837 for (int row = 0; row < numRows; row++) { 1838 in = input->data.S8[row]; 1839 out = output->data.C32[row]; 1840 for (int col = 0; col < numCols; col++) { 1841 out[col] = (psC32) in[col]; 1842 } 1843 } 1844 }; 1845 break; 1846 case PS_TYPE_S16: { 1847 psS16 *in; 1848 psC32 *out; 1849 for (int row = 0; row < numRows; row++) { 1850 in = input->data.S16[row]; 1851 out = output->data.C32[row]; 1852 for (int col = 0; col < numCols; col++) { 1853 out[col] = (psC32) in[col]; 1854 } 1855 } 1856 }; 1857 break; 1858 case PS_TYPE_S32: { 1859 psS32 *in; 1860 psC32 *out; 1861 for (int row = 0; row < numRows; row++) { 1862 in = input->data.S32[row]; 1863 out = output->data.C32[row]; 1864 for (int col = 0; col < numCols; col++) { 1865 out[col] = (psC32) in[col]; 1866 } 1867 } 1868 }; 1869 break; 1870 case PS_TYPE_S64: { 1871 psS64 *in; 1872 psC32 *out; 1873 for (int row = 0; row < numRows; row++) { 1874 in = input->data.S64[row]; 1875 out = output->data.C32[row]; 1876 for (int col = 0; col < numCols; col++) { 1877 out[col] = (psC32) in[col]; 1878 } 1879 } 1880 }; 1881 break; 1882 case PS_TYPE_U8: { 1883 psU8 *in; 1884 psC32 *out; 1885 for (int row = 0; row < numRows; row++) { 1886 in = input->data.U8[row]; 1887 out = output->data.C32[row]; 1888 for (int col = 0; col < numCols; col++) { 1889 out[col] = (psC32) in[col]; 1890 } 1891 } 1892 }; 1893 break; 1894 case PS_TYPE_U16: { 1895 psU16 *in; 1896 psC32 *out; 1897 for (int row = 0; row < numRows; row++) { 1898 in = input->data.U16[row]; 1899 out = output->data.C32[row]; 1900 for (int col = 0; col < numCols; col++) { 1901 out[col] = (psC32) in[col]; 1902 } 1903 } 1904 }; 1905 break; 1906 case PS_TYPE_U32: { 1907 psU32 *in; 1908 psC32 *out; 1909 for (int row = 0; row < numRows; row++) { 1910 in = input->data.U32[row]; 1911 out = output->data.C32[row]; 1912 for (int col = 0; col < numCols; col++) { 1913 out[col] = (psC32) in[col]; 1914 } 1915 } 1916 }; 1917 break; 1918 case PS_TYPE_U64: { 1919 psU64 *in; 1920 psC32 *out; 1921 for (int row = 0; row < numRows; row++) { 1922 in = input->data.U64[row]; 1923 out = output->data.C32[row]; 1924 for (int col = 0; col < numCols; col++) { 1925 out[col] = (psC32) in[col]; 1926 } 1927 } 1928 }; 1929 break; 1930 case PS_TYPE_F32: { 1931 psF32 *in; 1932 psC32 *out; 1933 for (int row = 0; row < numRows; row++) { 1934 in = input->data.F32[row]; 1935 out = output->data.C32[row]; 1936 for (int col = 0; col < numCols; col++) { 1937 out[col] = (psC32) in[col]; 1938 } 1939 } 1940 }; 1941 break; 1942 case PS_TYPE_F64: { 1943 psF64 *in; 1944 psC32 *out; 1945 for (int row = 0; row < numRows; row++) { 1946 in = input->data.F64[row]; 1947 out = output->data.C32[row]; 1948 for (int col = 0; col < numCols; col++) { 1949 out[col] = (psC32) in[col]; 1950 } 1951 } 1952 }; 1953 break; 1954 case PS_TYPE_C32: { 1955 psC32 *in; 1956 psC32 *out; 1957 for (int row = 0; row < numRows; row++) { 1958 in = input->data.C32[row]; 1959 out = output->data.C32[row]; 1960 for (int col = 0; col < numCols; col++) { 1961 out[col] = (psC32) in[col]; 1962 } 1963 } 1964 }; 1965 break; 1966 case PS_TYPE_PTR: 1967 psError (__func__, "Can't copy image from a matrix of pointers."); 1968 psFree (output); 1969 return ((void *) 0); 1970 default: 1971 break; 1972 }; 391 PSIMAGE_COPY_CASE(output,C32); 1973 392 break; 1974 393 case PS_TYPE_C64: 1975 switch (input->type.type) { 1976 case PS_TYPE_S8: { 1977 psS8 *in; 1978 psC64 *out; 1979 for (int row = 0; row < numRows; row++) { 1980 in = input->data.S8[row]; 1981 out = output->data.C64[row]; 1982 for (int col = 0; col < numCols; col++) { 1983 out[col] = (psC64) in[col]; 1984 } 1985 } 1986 }; 1987 break; 1988 case PS_TYPE_S16: { 1989 psS16 *in; 1990 psC64 *out; 1991 for (int row = 0; row < numRows; row++) { 1992 in = input->data.S16[row]; 1993 out = output->data.C64[row]; 1994 for (int col = 0; col < numCols; col++) { 1995 out[col] = (psC64) in[col]; 1996 } 1997 } 1998 }; 1999 break; 2000 case PS_TYPE_S32: { 2001 psS32 *in; 2002 psC64 *out; 2003 for (int row = 0; row < numRows; row++) { 2004 in = input->data.S32[row]; 2005 out = output->data.C64[row]; 2006 for (int col = 0; col < numCols; col++) { 2007 out[col] = (psC64) in[col]; 2008 } 2009 } 2010 }; 2011 break; 2012 case PS_TYPE_S64: { 2013 psS64 *in; 2014 psC64 *out; 2015 for (int row = 0; row < numRows; row++) { 2016 in = input->data.S64[row]; 2017 out = output->data.C64[row]; 2018 for (int col = 0; col < numCols; col++) { 2019 out[col] = (psC64) in[col]; 2020 } 2021 } 2022 }; 2023 break; 2024 case PS_TYPE_U8: { 2025 psU8 *in; 2026 psC64 *out; 2027 for (int row = 0; row < numRows; row++) { 2028 in = input->data.U8[row]; 2029 out = output->data.C64[row]; 2030 for (int col = 0; col < numCols; col++) { 2031 out[col] = (psC64) in[col]; 2032 } 2033 } 2034 }; 2035 break; 2036 case PS_TYPE_U16: { 2037 psU16 *in; 2038 psC64 *out; 2039 for (int row = 0; row < numRows; row++) { 2040 in = input->data.U16[row]; 2041 out = output->data.C64[row]; 2042 for (int col = 0; col < numCols; col++) { 2043 out[col] = (psC64) in[col]; 2044 } 2045 } 2046 }; 2047 break; 2048 case PS_TYPE_U32: { 2049 psU32 *in; 2050 psC64 *out; 2051 for (int row = 0; row < numRows; row++) { 2052 in = input->data.U32[row]; 2053 out = output->data.C64[row]; 2054 for (int col = 0; col < numCols; col++) { 2055 out[col] = (psC64) in[col]; 2056 } 2057 } 2058 }; 2059 break; 2060 case PS_TYPE_U64: { 2061 psU64 *in; 2062 psC64 *out; 2063 for (int row = 0; row < numRows; row++) { 2064 in = input->data.U64[row]; 2065 out = output->data.C64[row]; 2066 for (int col = 0; col < numCols; col++) { 2067 out[col] = (psC64) in[col]; 2068 } 2069 } 2070 }; 2071 break; 2072 case PS_TYPE_F32: { 2073 psF32 *in; 2074 psC64 *out; 2075 for (int row = 0; row < numRows; row++) { 2076 in = input->data.F32[row]; 2077 out = output->data.C64[row]; 2078 for (int col = 0; col < numCols; col++) { 2079 out[col] = (psC64) in[col]; 2080 } 2081 } 2082 }; 2083 break; 2084 case PS_TYPE_F64: { 2085 psF64 *in; 2086 psC64 *out; 2087 for (int row = 0; row < numRows; row++) { 2088 in = input->data.F64[row]; 2089 out = output->data.C64[row]; 2090 for (int col = 0; col < numCols; col++) { 2091 out[col] = (psC64) in[col]; 2092 } 2093 } 2094 }; 2095 break; 2096 case PS_TYPE_C32: { 2097 psC32 *in; 2098 psC64 *out; 2099 for (int row = 0; row < numRows; row++) { 2100 in = input->data.C32[row]; 2101 out = output->data.C64[row]; 2102 for (int col = 0; col < numCols; col++) { 2103 out[col] = (psC64) in[col]; 2104 } 2105 } 2106 }; 2107 break; 2108 case PS_TYPE_PTR: 2109 psError (__func__, "Can't copy image from a matrix of pointers."); 2110 psFree (output); 2111 return ((void *) 0); 2112 default: 2113 break; 2114 }; 2115 break; 2116 case PS_TYPE_PTR: 2117 psError (__func__, "Can't copy image into a matrix of pointers."); 2118 psFree (output); 2119 return ((void *) 0); 2120 } 2121 394 PSIMAGE_COPY_CASE(output,C64); 395 break; 396 default: 397 break; 398 } 2122 399 return output; 2123 400 } … … 2340 617 } 2341 618 2342 #endif2343 2344 619 return 0; 2345 620 } -
trunk/psLib/src/types/psList.c
r1127 r1193 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 6-29 23:19:11$8 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-07-08 01:05:00 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 80 80 } 81 81 82 psList*psListAdd(psList *list, void *data, int where)82 bool psListAdd(psList *list, void *data, int where) 83 83 { 84 84 psListElem* position; … … 87 87 88 88 if (list == NULL) { 89 return NULL;89 return false; 90 90 } 91 91 92 92 if (data == NULL) { 93 return list; 94 } 95 elem = psAlloc(sizeof(psListElem)); 96 97 pthread_mutex_lock(&list->lock) 98 ; 93 return false; 94 } 99 95 100 96 if (where <= PS_LIST_UNKNOWN) { 101 97 /// XXX What is the better way to communicate this failure to the caller? 102 98 psLogMsg(__func__,PS_LOG_WARN, 103 "The given insert location (%i) for psListAdd is invalid. Adding to head instead.",99 "The given insert location (%i) for psListAdd is invalid.", 104 100 where); 105 where = PS_LIST_HEAD; // given I can't tell caller about this, should just add it somewhere??? 106 } 101 return false; 102 } 103 104 elem = psAlloc(sizeof(psListElem)); 105 106 pthread_mutex_lock(&list->lock) 107 ; 107 108 108 109 if (where > 0 && where > list->size) { … … 162 163 ; 163 164 164 return list; 165 } 166 167 /*****************************************************************************/ 168 169 psList *psListAppend(psList *list, void *data) 170 { 171 return psListAdd(list, data, PS_LIST_TAIL); 165 return true; 172 166 } 173 167 … … 452 446 n = arr->n; 453 447 for (int i = 0; i < n; i++) { 454 psListA ppend(list,arr->data.PTR[i]);448 psListAdd(list,arr->data.PTR[i],PS_LIST_TAIL); 455 449 } 456 450 -
trunk/psLib/src/types/psList.h
r1127 r1193 10 10 * @ingroup LinkedList 11 11 * 12 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-0 6-29 23:19:11$12 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-07-08 01:05:00 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 81 81 * NULL, the return value will also be NULL. 82 82 */ 83 psList*psListAdd(83 bool psListAdd( 84 84 psList* restrict list, ///< list to add to (if NULL, nothing is done) 85 85 void* data, ///< data item to add. If NULL, list is not modified. 86 86 int where ///< index, PS_LIST_HEAD, PS_LIST_TAIL, or numbered location. 87 );88 89 /** Appends an item to a psList.90 *91 * @return psList* The psList with added data item. If list parameter is92 * NULL, the return value will also be NULL.93 */94 psList* psListAppend(95 psList* restrict list, ///< list to append to (if NULL, nothing is done)96 void *data ///< data item to add. If NULL, list is not modified.97 87 ); 98 88 -
trunk/psLib/test/collections/tst_psList.c
r1126 r1193 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 6-29 23:18:00$8 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-07-08 01:05:01 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 28 28 29 29 testDescription tests[] = { 30 {testListAlloc, "487-testListAlloc",0},31 {testListAdd, "488-testListAdd",0},32 {testListGet, "489-testListGet",0},33 {testListRemove, "490-testListRemove",0},34 {testListConvert, "491-testListConvert",0},35 {testListIterator, "494-testListIterator",0},36 {testListFree, "627-testListFree",0},37 {testListSort, "624-testListSort",0},30 {testListAlloc,487,"psListAlloc",0,false}, 31 {testListAdd,488,"psListAdd",0,false}, 32 {testListGet,489,"psListGet",0,false}, 33 {testListRemove,490,"psListRemove",0,false}, 34 {testListConvert,491,"psListConvert",0,false}, 35 {testListIterator,494,"psListIterator",0,false}, 36 {testListFree,627,"psListFree",0,false}, 37 {testListSort,624,"psListSort",0,false}, 38 38 {NULL} 39 39 }; 40 40 41 int main( )41 int main(int argc, char* argv[]) 42 42 { 43 43 psLogSetLevel(PS_LOG_INFO); 44 44 45 if (! runTestSuite(stderr,"psList",tests )) {45 if (! runTestSuite(stderr,"psList",tests,argc,argv) ) { 46 46 psError(__FILE__,"One or more tests failed"); 47 47 return 1; … … 138 138 139 139 // 1. list is NULL (error) 140 list = psListAdd(NULL,data,PS_LIST_HEAD); 141 142 if (list != NULL) { 143 psError(__func__,"psListAdd was given a NULL list, but returned a non-NULL list."); 144 return 1; 145 } 146 147 // 2. data is NULL (error, list should not grow) 140 if (psListAdd(NULL,data,PS_LIST_HEAD)) { 141 psError(__func__,"psListAdd was given a NULL list, but returned a true/success."); 142 return 1; 143 } 144 148 145 list = psListAlloc(data); 149 146 psFree(data); … … 153 150 } 154 151 155 list = psListAdd(list, NULL,PS_LIST_HEAD); 156 157 if (list->size != 1) { 158 psError(__func__,"psListAdd with a NULL data element changed the list size."); 152 // 2. data is NULL (error, list should not grow) 153 if (psListAdd(list, NULL,PS_LIST_HEAD)) { 154 psError(__func__,"psListAdd successfully added a NULL data item?"); 155 return 40; 156 } 157 if ( list->size != 1) { 158 psError(__func__,"psListAdd with a NULL data element changed the list size or returned success."); 159 159 return 3; 160 160 } … … 163 163 data = psAlloc(sizeof(int)); 164 164 *data = 2; 165 list = psListAdd(list,data,PS_LIST_HEAD); 165 if ( ! psListAdd(list,data,PS_LIST_HEAD) ) { 166 psError(__func__,"psListAdd failed to add a data item to head."); 167 return 21; 168 } 169 166 170 if (psMemGetRefCounter(data) != 2) { 167 171 psError(__func__,"psListAdd didn't increment the data reference count."); … … 169 173 } 170 174 psFree(data); 175 171 176 // verify that the size incremented 172 177 if (list->size != 2) { … … 183 188 data = psAlloc(sizeof(int)); 184 189 *data = 3; 185 list = psListAdd(list,data,PS_LIST_TAIL); 190 if ( ! psListAdd(list,data,PS_LIST_TAIL) ) { 191 psError(__func__,"psListAdd failed to add a data item to tail."); 192 return 21; 193 } 194 186 195 if (psMemGetRefCounter(data) != 2) { 187 196 psError(__func__,"psListAdd didn't increment the data reference count."); 188 return 2 0;197 return 22; 189 198 } 190 199 psFree(data); … … 211 220 data = psAlloc(sizeof(int)); 212 221 *data = 4; 213 psLogMsg(__func__,PS_LOG_INFO,"Following should warn with invalid insert location"); 214 list = psListAdd(list,data,-10); 215 if (psMemGetRefCounter(data) != 2) { 216 psError(__func__,"psListAdd didn't increment the data reference count."); 217 return 20; 218 } 219 psFree(data); 220 // verify that the size incremented 221 if (list->size != 4 || *(int*)list->head->data != 4) { 222 psLogMsg(__func__,PS_LOG_INFO,"Following should error with invalid insert location"); 223 224 if ( psListAdd(list,data,-10) ) { 225 psError(__func__,"psListAdd successfully added data to a -10 position?"); 226 return 30; 227 } 228 if (psMemGetRefCounter(data) != 1) { 229 psError(__func__,"psListAdd incremented the data reference count."); 230 return 24; 231 } 232 psFree(data); 233 // verify that the size wasn't incremented 234 if (list->size != 3) { 222 235 printListInt(list); 223 236 psError(__func__,"psListAdd didn't insert to head when where was invalid."); … … 228 241 data = psAlloc(sizeof(int)); 229 242 *data = 5; 230 list = psListAdd(list,data,1); 243 244 if ( ! psListAdd(list,data,1) ) { 245 psError(__func__,"psListAdd failed to add data to 1 position."); 246 return 30; 247 } 248 231 249 if (psMemGetRefCounter(data) != 2) { 232 250 psError(__func__,"psListAdd didn't increment the data reference count."); 233 return 2 0;251 return 25; 234 252 } 235 253 psFree(data); 236 254 // verify that the size incremented 237 if (list->size != 5|| *(int*)list->head->next->data != 5) {255 if (list->size != 4 || *(int*)list->head->next->data != 5) { 238 256 printListInt(list); 239 257 psError(__func__,"psListAdd didn't insert to position #1."); 240 return 9;258 return 10; 241 259 } 242 260 243 261 data = psAlloc(sizeof(int)); 244 262 *data = 6; 245 list = psListAdd(list,data,4); 263 if ( ! psListAdd(list,data,3) ) { 264 psError(__func__,"psListAdd failed to add data to 4 position."); 265 return 31; 266 } 246 267 if (psMemGetRefCounter(data) != 2) { 247 268 psError(__func__,"psListAdd didn't increment the data reference count."); 248 return 2 0;269 return 26; 249 270 } 250 271 psFree(data); 251 272 // verify that the size incremented 252 if (list->size != 6 || *(int *)list->head->next->next->next->next->data != 6) {273 if (list->size != 5 || *(int *)list->head->next->next->next->data != 6) { 253 274 printListInt(list); 254 275 psError(__func__,"psListAdd didn't insert to position #4."); 255 return 9;276 return 50; 256 277 } 257 278 258 279 data = psAlloc(sizeof(int)); 259 280 *data = 7; 260 list = psListAdd(list,data,2); 281 if ( ! psListAdd(list,data,2) ) { 282 psError(__func__,"psListAdd failed to add data to 2 position."); 283 return 32; 284 } 261 285 if (psMemGetRefCounter(data) != 2) { 262 286 psError(__func__,"psListAdd didn't increment the data reference count."); 263 return 2 0;287 return 28; 264 288 } 265 289 psFree(data); 266 290 // verify that the size incremented 267 if (list->size != 7|| *(int *)list->head->next->next->data != 7) {291 if (list->size != 6 || *(int *)list->head->next->next->data != 7) { 268 292 printListInt(list); 269 293 psError(__func__,"psListAdd didn't insert to position #2."); 270 return 9;294 return 11; 271 295 } 272 296 … … 274 298 *data = 7; 275 299 psLogMsg(__func__,PS_LOG_INFO,"Following should be a warning."); 276 list = psListAdd(list,data,9); 300 301 if ( ! psListAdd(list,data,9) ) { 302 psError(__func__,"psListAdd failed to add data to a 9 position?"); 303 return 30; 304 } 305 277 306 if (psMemGetRefCounter(data) != 2) { 278 307 psError(__func__,"psListAdd didn't increment the data reference count."); 279 return 20; 280 } 281 psFree(data); 308 return 29; 309 } 310 311 psFree(data); 312 282 313 // verify that the size incremented 283 if (list->size != 8) {314 if (list->size != 7) { 284 315 printListInt(list); 285 316 psError(__func__,"psListAdd didn't insert to position #9."); 286 return 9;317 return 12; 287 318 } 288 319 … … 347 378 data = psAlloc(sizeof(int)); 348 379 *data = 1; 349 list =psListAdd(list,data,PS_LIST_TAIL);380 psListAdd(list,data,PS_LIST_TAIL); 350 381 psFree(data); 351 382 352 383 data = psAlloc(sizeof(int)); 353 384 *data = 2; 354 list =psListAdd(list,data,PS_LIST_TAIL);385 psListAdd(list,data,PS_LIST_TAIL); 355 386 psFree(data); 356 387 357 388 data = psAlloc(sizeof(int)); 358 389 *data = 3; 359 list =psListAdd(list,data,PS_LIST_TAIL);390 psListAdd(list,data,PS_LIST_TAIL); 360 391 psFree(data); 361 392 … … 452 483 data = psAlloc(sizeof(int)); 453 484 *data = lcv; 454 list =psListAdd(list,data,PS_LIST_TAIL);485 psListAdd(list,data,PS_LIST_TAIL); 455 486 psMemDecrRefCounter(data); 456 487 } … … 671 702 data = psAlloc(sizeof(int)); 672 703 *data = lcv; 673 list =psListAdd(list,data,PS_LIST_TAIL);704 psListAdd(list,data,PS_LIST_TAIL); 674 705 psMemDecrRefCounter(data); 675 706 } … … 809 840 data = psAlloc(sizeof(int)); 810 841 *data = lcv; 811 list =psListAdd(list,data,PS_LIST_TAIL);842 psListAdd(list,data,PS_LIST_TAIL); 812 843 psFree(data); 813 844 } … … 926 957 data[lcv] = psAlloc(sizeof(int)); 927 958 *data[lcv] = lcv; 928 list =psListAdd(list,data[lcv],PS_LIST_TAIL);959 psListAdd(list,data[lcv],PS_LIST_TAIL); 929 960 if (psMemGetRefCounter(data[lcv]) != 2) { 930 961 psError(__func__,"Reference counter for data was not incremented"); … … 980 1011 *data = lcv*2-12; 981 1012 } 982 list =psListAdd(list,data,PS_LIST_TAIL);1013 psListAdd(list,data,PS_LIST_TAIL); 983 1014 psFree(data); 984 1015 … … 1046 1077 *data = lcv*2-12; 1047 1078 } 1048 list =psListAdd(list,data,PS_LIST_TAIL);1079 psListAdd(list,data,PS_LIST_TAIL); 1049 1080 psFree(data); 1050 1081 -
trunk/psLib/test/dataManip/builddir/tst_psImageFFT.d
r1109 r1193 3 3 ../../include/psTrace.h ../../include/psAbort.h ../../include/psError.h \ 4 4 ../../include/psString.h ../../include/psType.h ../../include/psList.h \ 5 ../../include/ps Vector.h ../../include/psHash.h \6 ../../include/ps Scalar.h ../../include/psImage.h \5 ../../include/psCompare.h ../../include/psVector.h \ 6 ../../include/psHash.h ../../include/psScalar.h ../../include/psImage.h \ 7 7 ../../include/psBitSet.h ../../include/psSort.h ../../include/psStats.h \ 8 8 ../../include/psMatrix.h ../../include/psMatrixVectorArithmetic.h \ -
trunk/psLib/test/dataManip/builddir/tst_psImageIO.d
r1109 r1193 3 3 ../../include/psTrace.h ../../include/psAbort.h ../../include/psError.h \ 4 4 ../../include/psString.h ../../include/psType.h ../../include/psList.h \ 5 ../../include/ps Vector.h ../../include/psHash.h \6 ../../include/ps Scalar.h ../../include/psImage.h \5 ../../include/psCompare.h ../../include/psVector.h \ 6 ../../include/psHash.h ../../include/psScalar.h ../../include/psImage.h \ 7 7 ../../include/psBitSet.h ../../include/psSort.h ../../include/psStats.h \ 8 8 ../../include/psMatrix.h ../../include/psMatrixVectorArithmetic.h \ -
trunk/psLib/test/dataManip/builddir/tst_psVectorFFT.d
r1109 r1193 3 3 ../../include/psTrace.h ../../include/psAbort.h ../../include/psError.h \ 4 4 ../../include/psString.h ../../include/psType.h ../../include/psList.h \ 5 ../../include/ps Vector.h ../../include/psHash.h \6 ../../include/ps Scalar.h ../../include/psImage.h \5 ../../include/psCompare.h ../../include/psVector.h \ 6 ../../include/psHash.h ../../include/psScalar.h ../../include/psImage.h \ 7 7 ../../include/psBitSet.h ../../include/psSort.h ../../include/psStats.h \ 8 8 ../../include/psMatrix.h ../../include/psMatrixVectorArithmetic.h \ -
trunk/psLib/test/dataManip/tst_psVectorFFT.c
r1073 r1193 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 6-23 23:00:17$8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-07-08 01:05:01 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 34 34 35 35 testDescription tests[] = { 36 {testVectorFFT, "600-testVectorFFT",0},37 {testVectorRealImaginary, "601-testVectorRealImaginary",0},38 {testVectorComplex, "602-testVectorComplex",0},39 {testVectorConjugate, "603-testVectorConjugate",0},40 {testVectorPowerSpectrum, "604-testVectorPowerSpectrum",0},36 {testVectorFFT,600,"psVectorFFT",0,false}, 37 {testVectorRealImaginary,601,"psVectorRealImaginary",0,false}, 38 {testVectorComplex,602,"psVectorComplex",0,false}, 39 {testVectorConjugate,603,"psVectorConjugate",0,false}, 40 {testVectorPowerSpectrum,604,"psVectorPowerSpectrum",0,false}, 41 41 {NULL} 42 42 }; 43 43 44 int main( )44 int main(int argc, char* argv[]) 45 45 { 46 46 psLogSetLevel(PS_LOG_INFO); 47 47 48 if (! runTestSuite(stderr,"psFFT",tests )) {48 if (! runTestSuite(stderr,"psFFT",tests,argc,argv) ) { 49 49 psAbort(__FILE__,"One or more tests failed"); 50 50 } -
trunk/psLib/test/image/tst_psImage.c
r1073 r1193 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 6-23 23:00:15$8 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-07-08 01:05:01 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 29 29 30 30 testDescription tests[] = { 31 {testImageAlloc,"546/548-testImageAlloc/Free",0}, 32 {testImageSubset,"547/550-testImageSubset",0}, 33 {testImageCopy,"551-testImageCopy",0}, 34 {testImageClip,"571-testImageClip",0}, 35 {testImageClipNAN,"572-testImageClipNAN",0}, 36 {testImageOverlay,"573-testImageOverlay",0}, 31 {testImageAlloc,546,"psImageAlloc",0,false}, 32 {testImageAlloc,548,"psImageFree",0,true}, 33 {testImageSubset,547,"psImageSubset",0,false}, 34 {testImageSubset,550,"psImageSubset",0,true}, 35 {testImageCopy,551,"psImageCopy",0,false}, 36 {testImageClip,571,"psImageClip",0,false}, 37 {testImageClipNAN,572,"psImageClipNAN",0,false}, 38 {testImageOverlay,573,"psImageOverlay",0,false}, 37 39 {NULL} 38 40 }; 39 41 40 int main( )42 int main(int argc, char* argv[]) 41 43 { 42 44 psLogSetLevel(PS_LOG_INFO); 43 testImageOverlay(); 44 if (! runTestSuite(stderr,"psImage",tests )) {45 46 if (! runTestSuite(stderr,"psImage",tests,argc,argv)) { 45 47 psError(__FILE__,"One or more tests failed"); 46 48 return 1; … … 572 574 573 575 #define testImageCopyTypes(IN) \ 576 printf("to psF32\n"); \ 577 testImageCopyType(IN,F32);\ 578 printf("to psF64\n"); \ 579 testImageCopyType(IN,F64); \ 580 printf("to psU8\n"); \ 574 581 testImageCopyType(IN,U8); \ 582 printf("to psU16\n"); \ 575 583 testImageCopyType(IN,U16); \ 584 printf("to psU32\n"); \ 576 585 testImageCopyType(IN,U32); \ 586 printf("to psS8\n"); \ 577 587 testImageCopyType(IN,S8);\ 588 printf("to psS16\n"); \ 578 589 testImageCopyType(IN,S16);\ 579 testImageCopyType(IN,S32);\580 testImageCopyType(IN, F32);\581 testImageCopyType(IN,F64); 582 590 printf("to psS32\n"); \ 591 testImageCopyType(IN,S32); 592 593 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psU8"); 583 594 testImageCopyTypes(U8); 595 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psU16"); 584 596 testImageCopyTypes(U16); 597 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psU32"); 585 598 testImageCopyTypes(U32); 599 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psS8"); 586 600 testImageCopyTypes(S8); 601 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psS16"); 587 602 testImageCopyTypes(S16); 603 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psS32"); 588 604 testImageCopyTypes(S32); 605 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psF32"); 589 606 testImageCopyTypes(F32); 607 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psF64"); 590 608 testImageCopyTypes(F64); 591 609 -
trunk/psLib/test/image/tst_psImageFFT.c
r1073 r1193 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 6-23 23:00:17$8 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-07-08 01:05:01 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 34 34 35 35 testDescription tests[] = { 36 {testImageFFT, "600-testImageFFT",0},37 {testImageRealImaginary, "601-testImageRealImaginary",0},38 {testImageComplex, "602-testImageComplex",0},39 {testImageConjugate, "603-testImageConjugate",0},40 {testImagePowerSpectrum, "604-testImagePowerSpectrum",0},36 {testImageFFT,600,"psImageFFT",0,false}, 37 {testImageRealImaginary,601,"psImageRealImaginary",0,false}, 38 {testImageComplex,602,"psImageComplex",0,false}, 39 {testImageConjugate,603,"psImageConjugate",0,false}, 40 {testImagePowerSpectrum,604,"psImagePowerSpectrum",0,false}, 41 41 {NULL} 42 42 }; 43 43 44 int main( )44 int main(int argc, char* argv[]) 45 45 { 46 46 psLogSetLevel(PS_LOG_INFO); 47 47 48 if (! runTestSuite(stderr,"psFFT",tests )) {48 if (! runTestSuite(stderr,"psFFT",tests,argc,argv) ) { 49 49 psAbort(__FILE__,"One or more tests failed"); 50 50 } -
trunk/psLib/test/image/tst_psImageIO.c
r1073 r1193 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 6-23 23:00:17$8 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-07-08 01:05:01 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 36 36 testDescription tests[] = { 37 {testImageRead, "567-testImageRead",0},38 {testImageWrite, "569-testImageWrite",0},37 {testImageRead,567,"psImageReadSection",0,false}, 38 {testImageWrite,569,"psImageWriteSection",0,false}, 39 39 {NULL} 40 40 }; 41 41 42 int main( )42 int main(int argc, char* argv[]) 43 43 { 44 44 psLogSetLevel(PS_LOG_INFO); 45 45 46 testImageRead(); 47 48 if (! runTestSuite(stderr,"psImage",tests)) { 46 if (! runTestSuite(stderr,"psImage",tests,argc,argv)) { 49 47 psAbort(__FILE__,"One or more tests failed"); 50 48 } -
trunk/psLib/test/psTest.c
r1034 r1193 15 15 #include <unistd.h> 16 16 #include <sys/wait.h> 17 #include <stdbool.h> 18 #include <string.h> 17 19 18 20 #include "psTest.h" … … 25 27 #define HEADER_BOTTOM "\\**********************************************************************************/\n\n" 26 28 27 bool p_runTestSuite(FILE *fp, const char* testPointFile, const char* packageName, testDescription tests[]) 29 bool p_runTestSuite(FILE *fp, const char* testPointFile, const char* packageName, 30 testDescription tests[], int argc, char * const argv[]) 28 31 { 29 32 bool success = true; 30 31 for (int index=0; tests[index].fcn != NULL; index++) { 32 success = p_runTest(fp,testPointFile,packageName,tests[index].testPointName, 33 tests[index].fcn,tests[index].expectedReturn) && success; 33 bool runAll = true; 34 bool useFork = true; 35 bool found; 36 int c; 37 int n; 38 extern char *optarg; 39 40 if (argc > 0) { 41 while ( (c=getopt(argc,argv,"lhn:dt:")) != -1) { 42 switch (c) { 43 case 'h': 44 printf("Usage: %s [-l] [-d] [-h] [-n=Testpoint#] [-t=TestpointName]\n" 45 " where:\n" 46 " -l : lists the testpoints contained in this test driver executable\n" 47 " -d : turns on debugger-friendly mode (no forking, aborts/signals are not handled)\n" 48 " -h : prints this help\n" 49 " -n : specifies a particular testpoint by number to run\n" 50 " -t : specifies a particular testpoint by name to run\n" 51 " (if no -l, -n or -t options are given, all testpoints are run)\n", 52 argv[0]); 53 runAll = false; 54 break; 55 case 'd': 56 useFork = false; 57 break; 58 case 'l': 59 printf("Test Driver: %s\n",testPointFile); 60 printf("Package Name: %s\n",packageName); 61 printf("Testpoints:\n"); 62 runAll = false; 63 for (int index=0; tests[index].fcn != NULL; index++) { 64 printf(" %6d - %s \n",tests[index].testPointNumber, 65 tests[index].testPointName); 66 } 67 printf("\n"); 68 break; 69 case 't': 70 runAll = false; 71 for (int index=0; tests[index].fcn != NULL; index++) { 72 if (strcmp(optarg,tests[index].testPointName) == 0) { 73 success = p_runTest(fp, 74 testPointFile, 75 packageName, 76 tests[index].testPointName, 77 tests[index].fcn, 78 tests[index].expectedReturn, 79 useFork) && success; 80 } 81 } 82 break; 83 case 'n': 84 runAll = false; 85 if (sscanf(optarg,"%i",&n) != 1) { 86 psError(__func__,"Failed to parse the testpoint number (%s).", 87 optarg); 88 break; 89 } 90 found = false; 91 for (int index=0; tests[index].fcn != NULL; index++) { 92 if (n==tests[index].testPointNumber) { 93 found = true; 94 success = p_runTest(fp, 95 testPointFile, 96 packageName, 97 tests[index].testPointName, 98 tests[index].fcn, 99 tests[index].expectedReturn, 100 useFork) && success; 101 } 102 } 103 if (! found) { 104 psError(__func__,"The specified testpoint number (%d) doesn't exist in this test driver.", 105 n); 106 break; 107 } 108 break; 109 case '?': 110 psError(__func__,"Option %s is not recognized and is ignored.",optarg); 111 break; 112 } 113 } 114 } 115 116 if (runAll) { 117 for (int index=0; tests[index].fcn != NULL; index++) { 118 if (! tests[index].isDuplicateEntry) { 119 success = p_runTest(fp, 120 testPointFile, 121 packageName, 122 tests[index].testPointName, 123 tests[index].fcn, 124 tests[index].expectedReturn, 125 useFork) && success; 126 } 127 } 34 128 } 35 129 return success; … … 37 131 38 132 bool p_runTest(FILE *fp, const char* testPointFile, const char* packageName, const char* testPointName, 39 testFcn fcn, int expectedReturn )133 testFcn fcn, int expectedReturn, bool useFork) 40 134 { 41 135 int childReturn = 0; … … 44 138 p_printPositiveTestHeader(fp,testPointFile,packageName,testPointName); 45 139 46 child = fork(); 47 if (child == 0) { // I am the child process, run the test 140 if (useFork) { 141 child = fork(); 142 if (child == 0) { // I am the child process, run the test 143 int currentId = psMemGetId(); 144 int retVal = fcn(); 145 if (retVal == 0) { // only bother checking memory if test executed to end. 146 if (psMemCheckLeaks(currentId,NULL,stderr) != 0) { 147 psError(__func__,"Memory Leaks Detected"); 148 retVal = 64; 149 } 150 psMemCheckCorruption(1); 151 } 152 exit(retVal); 153 } else if (child < 0) { 154 fprintf(fp,"Couldn't fork a process to run a negative test (%s|%s)", 155 packageName, testPointName); 156 abort(); 157 } 158 159 waitpid(child,&childReturn,0); 160 if (WIFSIGNALED(childReturn)) { 161 childReturn = -WTERMSIG(childReturn); 162 } else { 163 childReturn = WEXITSTATUS(childReturn); 164 } 165 } else { 48 166 int currentId = psMemGetId(); 49 int retVal= fcn();50 if ( retVal== 0) { // only bother checking memory if test executed to end.167 childReturn = fcn(); 168 if (childReturn == 0) { // only bother checking memory if test executed to end. 51 169 if (psMemCheckLeaks(currentId,NULL,stderr) != 0) { 52 170 psError(__func__,"Memory Leaks Detected"); 53 retVal= 64;171 childReturn = 64; 54 172 } 55 173 psMemCheckCorruption(1); 56 174 } 57 exit(retVal); 58 } else if (child < 0) { 59 fprintf(fp,"Couldn't fork a process to run a negative test (%s|%s)", 60 packageName, testPointName); 61 abort(); 62 } 63 64 waitpid(child,&childReturn,0); 65 if (WIFSIGNALED(childReturn)) { 66 childReturn = -WTERMSIG(childReturn); 67 } else { 68 childReturn = WEXITSTATUS(childReturn); 69 } 175 } 176 70 177 71 178 if (childReturn != expectedReturn) { -
trunk/psLib/test/psTest.h
r637 r1193 20 20 { 21 21 testFcn fcn; 22 int testPointNumber; 22 23 const char* testPointName; 23 24 int expectedReturn; 25 bool isDuplicateEntry; 24 26 } 25 27 testDescription; 26 28 27 #define runTest(filePtr, packageName, testPointName, fcn, expectedReturn ) \28 p_runTest(filePtr, __FILE__, packageName, testPointName, fcn, expectedReturn )29 #define runTest(filePtr, packageName, testPointName, fcn, expectedReturn, useFork) \ 30 p_runTest(filePtr, __FILE__, packageName, testPointName, fcn, expectedReturn, useFork) 29 31 30 #define runTestSuite(filePtr, packageName, tests ) \31 p_runTestSuite(filePtr, __FILE__, packageName, tests )32 #define runTestSuite(filePtr, packageName, tests, argc, argv) \ 33 p_runTestSuite(filePtr, __FILE__, packageName, tests, argc, argv) 32 34 33 35 34 36 /////////////////////////// PRIVATE FUNCTIONS ////////////////////////////// 35 37 36 bool p_runTest(FILE *fp, const char* testPointFile, const char* packageName, const char* testPointName, 37 testFcn fcn, int expectedReturn); 38 bool p_runTest( 39 FILE *fp, 40 const char* testPointFile, 41 const char* packageName, 42 const char* testPointName, 43 testFcn fcn, 44 int expectedReturn, 45 bool useFork 46 ); 38 47 39 bool p_runTestSuite(FILE *fp, const char* testPointFile, const char* packageName, testDescription tests[]); 48 bool p_runTestSuite( 49 FILE *fp, 50 const char* testPointFile, 51 const char* packageName, 52 testDescription tests[], 53 int argc, 54 char * const argv[] 55 ); 40 56 41 void p_printPositiveTestHeader(FILE *fp, const char* testPointFile, const char* packageName, 42 const char* testPointName); 57 void p_printPositiveTestHeader( 58 FILE *fp, 59 const char* testPointFile, 60 const char* packageName, 61 const char* testPointName 62 ); 43 63 44 void p_printNegativeTestHeader(FILE *fp, const char* testPointFile, const char* packageName, 45 const char* testPointName,const char* expectedError, int exitValue); 64 void p_printNegativeTestHeader( 65 FILE *fp, 66 const char* testPointFile, 67 const char* packageName, 68 const char* testPointName, 69 const char* expectedError, 70 int exitValue 71 ); 46 72 47 void p_printFooter(FILE *fp, const char* testPointFile, const char* packageName, const char* testPointName, 48 bool success); 73 void p_printFooter( 74 FILE *fp, 75 const char* testPointFile, 76 const char* packageName, 77 const char* testPointName, 78 bool success 79 ); 49 80 50 81 #endif -
trunk/psLib/test/sysUtils/builddir/tst_psMemory.d
r1109 r1193 3 3 ../../include/psTrace.h ../../include/psAbort.h ../../include/psError.h \ 4 4 ../../include/psString.h ../../include/psType.h ../../include/psList.h \ 5 ../../include/ps Vector.h ../../include/psHash.h \6 ../../include/ps Scalar.h ../../include/psImage.h \5 ../../include/psCompare.h ../../include/psVector.h \ 6 ../../include/psHash.h ../../include/psScalar.h ../../include/psImage.h \ 7 7 ../../include/psBitSet.h ../../include/psSort.h ../../include/psStats.h \ 8 8 ../../include/psMatrix.h ../../include/psMatrixVectorArithmetic.h \ -
trunk/psLib/test/sysUtils/tst_psMemory.c
r1097 r1193 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-0 6-25 21:51:46$8 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-07-08 01:05:01 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 45 45 46 46 testDescription tests[] = { 47 {TPCheckBufferPositive,"449-TPCheckBufferPositive",0}, 48 {TPOutOfMemory,"450-TPOutOfMemory",-6}, 49 {TPReallocOutOfMemory,"562-TPReallocOutOfMemory",-6}, 50 {TPrealloc,"451-TPrealloc",0}, 51 {TPallocCallback,"452/453-TPallocCallback",0}, 52 {TPcheckLeaks,"454-TPcheckLeaks",0}, 53 {TPmemCorruption,"455-TPmemCorruption",0}, 54 {TPFreeReferencedMemory,"456-TPFreeReferencedMemory",0}, 47 {TPCheckBufferPositive,449,"checkBufferPositive",0,false}, 48 {TPOutOfMemory,450,"outOfMemory",-6,false}, 49 {TPReallocOutOfMemory,562,"reallocOutOfMemory",-6,false}, 50 {TPrealloc,451,"psRealloc",0,false}, 51 {TPallocCallback,452,"allocCallback",0,false}, 52 {TPallocCallback,453,"allocCallback2",0,true}, 53 {TPcheckLeaks,454,"checkLeaks",0,false}, 54 {TPmemCorruption,455,"psMemCorruption",0,false}, 55 {TPFreeReferencedMemory,456,"freeReferencedMemory",0,false}, 55 56 {NULL} 56 57 }; 57 58 58 int main( )59 int main(int argc, char* argv[]) 59 60 { 60 61 psLogSetLevel(PS_LOG_INFO); 61 62 62 if (! runTestSuite(stderr,"psMemory",tests )) {63 if (! runTestSuite(stderr,"psMemory",tests,argc,argv) ) { 63 64 psError(__FILE__,"One or more tests failed"); 64 65 return 1;
Note:
See TracChangeset
for help on using the changeset viewer.
