Changeset 821 for soft/giet_vm/applications/rosenfeld/nrc2/src/nrarith2x.c
- Timestamp:
- May 6, 2016, 3:06:29 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/rosenfeld/nrc2/src/nrarith2x.c
r772 r821 17 17 #include <malloc.h> 18 18 #include <math.h> // fabs 19 // #include <memory.h> // memcpy20 19 20 #include "nrc_os_config.h" 21 21 #include "mypredef.h" 22 22 #include "nrtype.h" … … 25 25 #include "nrkernel.h" 26 26 27 /* ------------------------------------------------------------------------------------- */ 28 IMAGE_EXPORT(void) addcnz_bmatrix(byte **src,long nrl,long nrh,long ncl, long nch, byte cte, byte **dst) 29 /* ------------------------------------------------------------------------------------- */ 30 { 31 long i,j; 32 byte *Xi, *Yi; 33 34 for(i=nrl; i<=nrh; i++) { 35 Xi = src[i]; 36 Yi = dst[i]; 37 for(j=ncl; j<=nch; j++) { 38 if(Xi[j]) 39 Yi[j] = Xi[j] + cte; 40 else 41 Yi[j] = Xi[j]; 42 } 43 } 27 28 #undef addcnz_type_matrix 29 #define addcnz_type_matrix(t) \ 30 void short_name(t,addcnz_,matrix)(t ** src, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t cte, t ** dst) \ 31 { \ 32 t * Xi; \ 33 t * Yi; \ 34 for (int32_t i = nrl; i <= nrh; i++) { \ 35 Xi = src[i]; \ 36 Yi = dst[i]; \ 37 for (int32_t j = ncl; j <= nch; j++) { \ 38 if (Xi[j] != 0) { \ 39 Yi[j] = Xi[j] + cte; \ 40 } \ 41 else { \ 42 Yi[j] = Xi[j]; \ 43 } \ 44 } \ 45 } \ 44 46 } 45 /* ----------------------------------------------------------------------------------- */ 46 IMAGE_EXPORT(void) addandc_bmatrix(byte **src,long nrl,long nrh,long ncl, long nch, byte cte, byte **dst) 47 /* ----------------------------------------------------------------------------------- */ 48 { 49 long i,j; 50 byte *Xi, *Yi; 51 52 for(i=nrl; i<=nrh; i++) { 53 Xi = src[i]; 54 Yi = dst[i]; 55 for(j=ncl; j<=nch; j++) { 56 if(Xi[j]) 57 Yi[j] = Xi[j] + cte; 58 else 59 Yi[j] = Xi[i]; 60 } 61 } 47 48 addcnz_type_matrix(int8_t); 49 addcnz_type_matrix(uint8_t); 50 addcnz_type_matrix(int16_t); 51 addcnz_type_matrix(uint16_t); 52 addcnz_type_matrix(int32_t); 53 addcnz_type_matrix(uint32_t); 54 addcnz_type_matrix(int64_t); 55 addcnz_type_matrix(uint64_t); 56 addcnz_type_matrix(float); 57 addcnz_type_matrix(double); 58 59 60 #undef addandc_type_matrix 61 #define addandc_type_matrix(t) \ 62 void short_name(t,addandc_,matrix)(t ** src, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t cte, t ** dst) \ 63 { \ 64 t * Xi; \ 65 t * Yi; \ 66 for (int32_t i = nrl; i <= nrh; i++) { \ 67 Xi = src[i]; \ 68 Yi = dst[i]; \ 69 for (int32_t j = ncl; j <= nch; j++) { \ 70 if (Xi[j] != 0) { \ 71 Yi[j] = Xi[j] + cte; \ 72 } \ 73 } \ 74 } \ 62 75 } 63 /* ---------------------------------------------------------------------------------------- */ 64 IMAGE_EXPORT(void) addandc_si16matrix(sint16 **src,long nrl,long nrh,long ncl, long nch, short cte, sint16 **dst) 65 /* ---------------------------------------------------------------------------------------- */ 66 { 67 long i,j; 68 sint16 *Xi, *Yi; 69 70 for(i=nrl; i<=nrh; i++) { 71 Xi = src[i]; 72 Yi = dst[i]; 73 for(j=ncl; j<=nch; j++) { 74 if(Xi[j]) Yi[j] = Xi[j] + cte; 75 } 76 } 76 77 addandc_type_matrix(int8_t); 78 addandc_type_matrix(uint8_t); 79 addandc_type_matrix(int16_t); 80 addandc_type_matrix(uint16_t); 81 addandc_type_matrix(int32_t); 82 addandc_type_matrix(uint32_t); 83 addandc_type_matrix(int64_t); 84 addandc_type_matrix(uint64_t); 85 addandc_type_matrix(float); 86 addandc_type_matrix(double); 87 88 89 #undef sum_type_matrix 90 #define sum_type_matrix(t,rt) \ 91 rt short_name(t,sum_,matrix)(t ** m, int32_t nrl, int32_t nrh,int32_t ncl, int32_t nch) \ 92 { \ 93 rt s = 0; \ 94 t * Xi; \ 95 for (int32_t i = nrl; i <= nrh; i++) { \ 96 Xi = m[i]; \ 97 for (int32_t j = ncl; j <= nch; j++) { \ 98 s += Xi[j]; \ 99 } \ 100 } \ 101 return s; \ 77 102 } 78 /* ------------------------------------------------------------------------------------------- */ 79 IMAGE_EXPORT(void) addandc_ui16matrix(uint16 **src,long nrl,long nrh,long ncl, long nch, short cte, uint16 **dst) 80 /* ------------------------------------------------------------------------------------------ */ 81 { 82 long i,j; 83 uint16 *Xi, *Yi; 84 85 for(i=nrl; i<=nrh; i++) { 86 Xi = src[i]; 87 Yi = dst[i]; 88 for(j=ncl; j<=nch; j++) { 89 if(Xi[j]) Yi[j] = Xi[j] + cte; 90 } 91 } 92 } 93 /* ----------------------------------------------------------- */ 94 IMAGE_EXPORT(int) count_bmatrix(byte **m, long nrl,long nrh,long ncl, long nch) 95 /* ----------------------------------------------------------- */ 96 { 97 long i, j; 98 int s = 0; 99 byte *Xi; 100 101 for(i=nrl; i<=nrh; i++) { 102 Xi = m[i]; 103 for(j=ncl; j<=nch; j++) { 104 s += Xi[j]; 105 } 106 } 107 return s; 108 } 103 104 105 sum_type_matrix(int8_t, int32_t); 106 sum_type_matrix(uint8_t, uint32_t); 107 sum_type_matrix(int16_t, int32_t); 108 sum_type_matrix(uint16_t, uint32_t); 109 sum_type_matrix(int32_t, int64_t); 110 sum_type_matrix(uint32_t, uint64_t); 111 sum_type_matrix(int64_t, int64_t); 112 sum_type_matrix(uint64_t, uint64_t); 113 sum_type_matrix(float, float); 114 sum_type_matrix(double, double); 115 116 117 // Local Variables: 118 // tab-width: 4 119 // c-basic-offset: 4 120 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 121 // indent-tabs-mode: nil 122 // End: 123 124 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 125
Note: See TracChangeset
for help on using the changeset viewer.