Changeset 822 for soft/giet_vm/applications/rosenfeld
- Timestamp:
- Jun 1, 2016, 10:25:43 AM (8 years ago)
- Location:
- soft/giet_vm/applications/rosenfeld
- Files:
-
- 5 added
- 4 deleted
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/rosenfeld/Makefile
r821 r822 3 3 SRC_PATH = src-par 4 4 OBJ_PATH = obj 5 EXE_PATH = bin6 5 INC_PATH = include 7 6 … … 61 60 62 61 63 all: $(APP_NAME) 62 all: nrclib $(APP_NAME) 63 64 nrclib: 65 make -C nrc2 64 66 65 67 $(APP_NAME): $(OBJ_FILE) 66 68 $(LD) -o $@ $^ $(LDFLAGS) 69 70 #obj/bmpNR.o: src-par/bmpNR.c $(INC_FILE) nrc2/libnrc2x.a ../../build/libs/libuser.a nrc2/include/nrc_os_config.h 71 # $(CC) -c $(CFLAGS) -o $@ $< 67 72 68 73 $(OBJ_PATH)/%.o: $(SRC_PATH)/%.c $(INC_FILE) nrc2/libnrc2x.a ../../build/libs/libuser.a nrc2/include/nrc_os_config.h -
soft/giet_vm/applications/rosenfeld/include/clock.h
r821 r822 31 31 32 32 33 static void local_sort_asc(uint 32_t tab[], int size) {34 int tmp;35 int i, j;33 static void local_sort_asc(uint64_t tab[], int32_t size) { 34 int32_t tmp; 35 int32_t i, j; 36 36 for (i = 0; i < size; i++) { 37 uint 32_t min = tab[i];38 int jmin = i;37 uint64_t min = tab[i]; 38 int32_t jmin = i; 39 39 for (j = i + 1; j < size; j++) { 40 40 if (tab[j] < min) { … … 51 51 52 52 53 #define CLOCK_DEC uint 32_t app_start; \54 uint 32_t app_end; \55 uint 32_t app_create; \56 uint 32_t app_join; \57 uint 32_t * thread_start; \58 uint 32_t * thread_end; \59 uint 32_t * thread_compute_start; \60 uint 32_t * thread_compute_end; \53 #define CLOCK_DEC uint64_t app_start; \ 54 uint64_t app_end; \ 55 uint64_t app_create; \ 56 uint64_t app_join; \ 57 uint64_t * thread_start; \ 58 uint64_t * thread_end; \ 59 uint64_t * thread_compute_start; \ 60 uint64_t * thread_compute_end; \ 61 61 int32_t step_number; \ 62 62 int32_t clock_thread_num; \ 63 uint 32_t ** thread_start_step; \64 uint 32_t ** thread_end_step; \65 uint 32_t global_thread_start; \66 uint 32_t global_thread_end; \67 uint 32_t global_thread_compute_start; \68 uint 32_t global_thread_compute_end; \69 uint 32_t * global_thread_start_step; \70 uint 32_t * global_thread_end_step; \63 uint64_t ** thread_start_step; \ 64 uint64_t ** thread_end_step; \ 65 uint64_t global_thread_start; \ 66 uint64_t global_thread_end; \ 67 uint64_t global_thread_compute_start; \ 68 uint64_t global_thread_compute_end; \ 69 uint64_t * global_thread_start_step; \ 70 uint64_t * global_thread_end_step; 71 71 72 72 #if TARGET_OS == GIETVM … … 76 76 struct timeval full_time; \ 77 77 gettimeofday(&full_time, NULL); \ 78 x = (u nsigned long) ((full_time.tv_usec + full_time.tv_sec * 1000000) / 1000); \78 x = (uint64_t) ((full_time.tv_usec + full_time.tv_sec * 1000000)); \ 79 79 }) 80 80 #endif … … 84 84 clock_thread_num = (x); \ 85 85 step_number = (y); \ 86 global_thread_start = 0xFFFFFFFF LLU;\86 global_thread_start = 0xFFFFFFFFFFFFFFFFLLU; \ 87 87 global_thread_end = 0; \ 88 global_thread_compute_start = 0xFFFFFFFF LLU;\88 global_thread_compute_start = 0xFFFFFFFFFFFFFFFFLLU; \ 89 89 global_thread_compute_end = 0; \ 90 90 if ((x) > 0) { \ 91 thread_start = (uint 32_t *) malloc(sizeof(uint32_t) * (x)); \92 thread_end = (uint 32_t *) malloc(sizeof(uint32_t) * (x)); \93 thread_compute_start = (uint 32_t *) malloc(sizeof(uint32_t) * (x)); \94 thread_compute_end = (uint 32_t *) malloc(sizeof(uint32_t) * (x)); \91 thread_start = (uint64_t *) malloc(sizeof(uint64_t) * (x)); \ 92 thread_end = (uint64_t *) malloc(sizeof(uint64_t) * (x)); \ 93 thread_compute_start = (uint64_t *) malloc(sizeof(uint64_t) * (x)); \ 94 thread_compute_end = (uint64_t *) malloc(sizeof(uint64_t) * (x)); \ 95 95 if ((y) > 0) { \ 96 global_thread_start_step = (uint 32_t *) malloc(sizeof(uint32_t) * (y)); \97 global_thread_end_step = (uint 32_t *) malloc(sizeof(uint32_t) * (y)); \98 thread_start_step = (uint 32_t **) malloc(sizeof(uint32_t *) * (y)); \99 thread_end_step = (uint 32_t **) malloc(sizeof(uint32_t *) * (y)); \100 for (int j = 0; j < (y); j++) {\101 global_thread_start_step[j] = 0xFFFFFFFF LU;\96 global_thread_start_step = (uint64_t *) malloc(sizeof(uint64_t) * (y)); \ 97 global_thread_end_step = (uint64_t *) malloc(sizeof(uint64_t) * (y)); \ 98 thread_start_step = (uint64_t **) malloc(sizeof(uint64_t *) * (y)); \ 99 thread_end_step = (uint64_t **) malloc(sizeof(uint64_t *) * (y)); \ 100 for (int32_t j = 0; j < (y); j++) { \ 101 global_thread_start_step[j] = 0xFFFFFFFFFFFFFFFFLU; \ 102 102 global_thread_end_step[j] = 0; \ 103 thread_start_step[j] = (uint 32_t *) malloc(sizeof(uint32_t) * (x)); \104 thread_end_step[j] = (uint 32_t *) malloc(sizeof(uint32_t) * (x)); \103 thread_start_step[j] = (uint64_t *) malloc(sizeof(uint64_t) * (x)); \ 104 thread_end_step[j] = (uint64_t *) malloc(sizeof(uint64_t) * (x)); \ 105 105 } \ 106 106 } \ … … 121 121 122 122 123 // x = number of threads124 123 #define CLOCK_FINALIZE ({ \ 125 for (int i = 0; i < clock_thread_num; i++) {\124 for (int32_t i = 0; i < clock_thread_num; i++) { \ 126 125 if (thread_start[i] < global_thread_start) { \ 127 126 global_thread_start = thread_start[i]; \ … … 136 135 global_thread_compute_end = thread_compute_end[i]; \ 137 136 } \ 138 for (int j = 0; j < step_number; j++) {\137 for (int32_t j = 0; j < step_number; j++) { \ 139 138 if (thread_start_step[j][i] < global_thread_start_step[j]) { \ 140 139 global_thread_start_step[j] = thread_start_step[j][i]; \ … … 147 146 }) 148 147 149 #define PRINT_CLOCK ({ \150 printf("Timestamps:\n");\151 printf("[APP_START] : %d\n", app_start); \152 printf("[APP_CREATE] : %d\n", app_create); \153 printf("[THREAD_START] : %d\n", global_thread_start); \154 printf("[THREAD_COMPUTE_START] : %d\n", global_thread_compute_start); \155 for (int j = 0; j < step_number; j++) {\156 printf("[THREAD_START_STEP_%d] : %d\n", j, global_thread_start_step[j]); \157 printf("[THREAD_END_STEP_%d] : %d\n", j, global_thread_end_step[j]); \158 } \159 printf("[THREAD_COMPUTE_END] : %d\n", global_thread_compute_end); \160 printf("[THREAD_END] : %d\n", global_thread_end); \161 printf("[APP_JOIN] : %d\n", app_join); \162 printf("[APP_END] : %d\n", app_end); \163 printf("Durations (in cycles):\n");\164 printf("[TOTAL] : %d\n", app_end - app_start); \165 printf("[THREAD] : %d\n", app_join - app_create); \166 printf("[PARALLEL] : %d\n", global_thread_end - global_thread_start); \167 printf("[PARALLEL_COMPUTE] : %d\n", global_thread_compute_end - global_thread_compute_start); \168 for (int j = 0; j < step_number; j++) {\169 printf("[THREAD_STEP_%d] : %d\n", j, global_thread_end_step[j] - global_thread_start_step[j]); \170 } \171 printf("\n");\172 printf("*** All threads times output in a gnuplot data-style ***\n");\173 local_sort_asc(thread_start, clock_thread_num); \174 local_sort_asc(thread_compute_start, clock_thread_num); \175 local_sort_asc(thread_compute_end, clock_thread_num); \176 local_sort_asc(thread_end, clock_thread_num); \177 for (int j = 0; j < step_number; j++) {\178 local_sort_asc(thread_start_step[j], clock_thread_num); \179 local_sort_asc(thread_end_step[j], clock_thread_num); \180 } \181 printf("# cycle thread_id\n");\182 for (int i = 0; i < clock_thread_num; i++) {\183 printf("%d\t%d\n", thread_start[i], i); \184 printf("%d\t%d\n", thread_compute_start[i], i); \185 for (int j = 0; j < step_number; j++) {\186 printf("%d\t%d\n", thread_start_step[j][i], i); \187 printf("%d\t%d\n", thread_end_step[j][i], i); \188 } \189 printf("%d\t%d\n", thread_compute_end[i], i); \190 printf("%d\t%d\n", thread_end[i], i); \191 } \148 #define PRINT_CLOCK ({ \ 149 MCA_VERBOSE1(printf("Timestamps:\n")); \ 150 MCA_VERBOSE1(printf("[APP_START] : %llu\n", app_start)); \ 151 MCA_VERBOSE1(printf("[APP_CREATE] : %llu\n", app_create)); \ 152 MCA_VERBOSE1(printf("[THREAD_START] : %llu\n", global_thread_start)); \ 153 MCA_VERBOSE1(printf("[THREAD_COMPUTE_START] : %llu\n", global_thread_compute_start)); \ 154 for (int32_t j = 0; j < step_number; j++) { \ 155 MCA_VERBOSE1(printf("[THREAD_START_STEP_%d] : %llu\n", j, global_thread_start_step[j])); \ 156 MCA_VERBOSE1(printf("[THREAD_END_STEP_%d] : %llu\n", j, global_thread_end_step[j])); \ 157 } \ 158 MCA_VERBOSE1(printf("[THREAD_COMPUTE_END] : %llu\n", global_thread_compute_end)); \ 159 MCA_VERBOSE1(printf("[THREAD_END] : %llu\n", global_thread_end)); \ 160 MCA_VERBOSE1(printf("[APP_JOIN] : %llu\n", app_join)); \ 161 MCA_VERBOSE1(printf("[APP_END] : %llu\n", app_end)); \ 162 MCA_VERBOSE1(printf("Durations (in cycles):\n")); \ 163 MCA_VERBOSE1(printf("[TOTAL] : %llu\n", app_end - app_start)); \ 164 MCA_VERBOSE1(printf("[THREAD] : %llu\n", app_join - app_create)); \ 165 MCA_VERBOSE1(printf("[PARALLEL] : %llu\n", global_thread_end - global_thread_start)); \ 166 MCA_VERBOSE1(printf("[PARALLEL_COMPUTE] : %llu\n", global_thread_compute_end - global_thread_compute_start)); \ 167 for (int32_t j = 0; j < step_number; j++) { \ 168 MCA_VERBOSE1(printf("[THREAD_STEP_%d] : %llu\n", j, global_thread_end_step[j] - global_thread_start_step[j])); \ 169 } \ 170 MCA_VERBOSE1(printf("\n")); \ 171 MCA_VERBOSE1(printf("*** All threads times output in a gnuplot data-style ***\n")); \ 172 local_sort_asc(thread_start, clock_thread_num); \ 173 local_sort_asc(thread_compute_start, clock_thread_num); \ 174 local_sort_asc(thread_compute_end, clock_thread_num); \ 175 local_sort_asc(thread_end, clock_thread_num); \ 176 for (int32_t j = 0; j < step_number; j++) { \ 177 local_sort_asc(thread_start_step[j], clock_thread_num); \ 178 local_sort_asc(thread_end_step[j], clock_thread_num); \ 179 } \ 180 MCA_VERBOSE1(printf("# cycle thread_id\n")); \ 181 for (int32_t i = 0; i < clock_thread_num; i++) { \ 182 MCA_VERBOSE1(printf("%llu\t%d\n", thread_start[i], i)); \ 183 MCA_VERBOSE1(printf("%llu\t%d\n", thread_compute_start[i], i)); \ 184 for (int32_t j = 0; j < step_number; j++) { \ 185 MCA_VERBOSE1(printf("%llu\t%d\n", thread_start_step[j][i], i)); \ 186 MCA_VERBOSE1(printf("%llu\t%d\n", thread_end_step[j][i], i)); \ 187 } \ 188 MCA_VERBOSE1(printf("%llu\t%d\n", thread_compute_end[i], i)); \ 189 MCA_VERBOSE1(printf("%llu\t%d\n", thread_end[i], i)); \ 190 } \ 192 191 }) 193 192 … … 197 196 198 197 199 #define CLOCK_FREE ({ 200 if (clock_thread_num > 0) { 201 free(thread_start); 202 free(thread_end); 203 free(thread_compute_start); 204 free(thread_compute_end); 205 if (step_number > 0) { 206 free(global_thread_start_step); 207 free(global_thread_end_step); 208 for (int j = 0; j < step_number; j++) {\209 free(thread_start_step[j]); 210 free(thread_end_step[j]); 211 } 212 free(thread_start_step); 213 free(thread_end_step); 214 } 215 } 198 #define CLOCK_FREE ({ \ 199 if (clock_thread_num > 0) { \ 200 free(thread_start); \ 201 free(thread_end); \ 202 free(thread_compute_start); \ 203 free(thread_compute_end); \ 204 if (step_number > 0) { \ 205 free(global_thread_start_step); \ 206 free(global_thread_end_step); \ 207 for (int32_t j = 0; j < step_number; j++) { \ 208 free(thread_start_step[j]); \ 209 free(thread_end_step[j]); \ 210 } \ 211 free(thread_start_step); \ 212 free(thread_end_step); \ 213 } \ 214 } \ 216 215 }) 217 216 -
soft/giet_vm/applications/rosenfeld/include/config.h
r821 r822 1 2 #ifndef __CONFIG_H_ 3 #define __CONFIG_H_ 1 4 2 5 #define SLOW 0 … … 4 7 #define FAST 1 5 8 #define PYR_BARRIERS 0 6 #define PARMERGE 1 9 #define PARMERGE 0 10 #define ARSP 0 7 11 8 12 #if FAST && SLOW … … 14 18 #endif 15 19 16 #if PARMERGE && (!FEATURES || !FAST) 17 #error "PARMERGE is only supported for the FAST version with FEATURES enabled" 20 21 #if FAST 22 #if !FEATURES && !PARMERGE && !ARSP 23 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Rosenfeld_Dist(e, f, T, D, alpha) 24 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Rosenfeld_Dist(e, f, g, T, D, alpha) 25 #elif !FEATURES && !PARMERGE && ARSP 26 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Arsp_Rosenfeld_Dist(e, f, T, D, alpha) 27 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Arsp_Rosenfeld_Dist(e, f, g, T, D, alpha) 28 #error "Configuration Not implemented" 29 #elif !FEATURES && PARMERGE && !ARSP 30 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Parallel_Rosenfeld_Dist(e, f, T, D, alpha, F) 31 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Parallel_Rosenfeld_Dist(e, f, g, T, D, alpha, F) 32 #error "Configuration Not implemented" 33 #elif !FEATURES && PARMERGE && ARSP 34 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Parallel_Arsp_Rosenfeld_Dist(e, f, T, D, alpha, F) 35 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Parallel_Arsp_Rosenfeld_Dist(e, f, g, T, D, alpha, F) 36 #elif FEATURES && !PARMERGE && !ARSP 37 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Features_Rosenfeld_Dist(e, f, T, D, alpha, F) 38 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Features_Rosenfeld_Dist(e, f, g, T, D, alpha, F) 39 #elif FEATURES && !PARMERGE && ARSP 40 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Features_Arsp_Rosenfeld_Dist(e, f, T, D, alpha, F) 41 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Features_Arsp_Rosenfeld_Dist(e, f, g, T, D, alpha, F) 42 #error "Configuration Not implemented" 43 #elif FEATURES && PARMERGE && !ARSP 44 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Parallel_Features_Rosenfeld_Dist(e, f, T, D, alpha, F) 45 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Parallel_Features_Rosenfeld_Dist(e, f, g, T, D, alpha, F) 46 #elif FEATURES && PARMERGE && ARSP 47 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Parallel_Features_Arsp_Rosenfeld_Dist(e, f, T, D, alpha, F) 48 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Parallel_Features_Arsp_Rosenfeld_Dist(e, f, g, T, D, alpha, F) 49 #error "Configuration Not implemented" 50 #endif 18 51 #endif 19 52 53 #if SLOW 54 #if FEATURES 55 #define SetRoot_Rosenfeld(D, r, eps, alpha, F) SetRoot_Features_Rosenfeld_Dist(D, r, eps, alpha, F) 56 #else 57 #define SetRoot_Rosenfeld(D, r, eps, alpha, F) SetRoot_Rosenfeld_Dist(D, r, eps, alpha) 58 #endif 59 #if PARMERGE 60 #error "Configuration SLOW and PARMERGE Not implemented" 61 #endif 62 #if ARSP 63 #error "Configuration SLOW and ARSP Not implemented" 64 #endif 65 #endif 66 67 // Verbose level 68 // 0 : No trace at all 69 // 1 : Traces compatible with execution times measurements, 70 // in particular, there must not be any traces in the 71 // "compute" sections 72 // 2 : Standard level 73 // 3 : Maximum (debug) level 74 #define MCA_VERBOSE_LEVEL 2 75 76 #endif // __CONFIG_H__ 77 78 -
soft/giet_vm/applications/rosenfeld/include/ecc_features.h
r821 r822 25 25 // ------------------------------------------------------------------------ 26 26 27 // @QM 28 // Je m'autorise à mettre des champs de la structure 29 // conditionnellement vis-à -vis de flags, car : 30 // 1. Il ne s'agit pas d'une bibliothÚque 31 // 2. Tous les fichiers .c dépendent de tous les .h, et donc 32 // en particulier du fichier config.h qui définit les flags 33 // Il est donc impossible de mélanger deux fichiers binaires 34 // qui ont des définitions différentes de cette structure 27 35 typedef struct { 28 29 uint16 xmin; 30 uint16 xmax; 31 uint16 ymin; 32 uint16 ymax; 33 34 uint32 S; 35 36 uint32 Sx; 37 uint32 Sy; 36 #if FEATURES 37 uint16 xmin; 38 uint16 xmax; 39 uint16 ymin; 40 uint16 ymax; 41 42 uint32 S; 43 44 uint32 Sx; 45 uint32 Sy; 46 #endif 38 47 #if PARMERGE 39 48 pthread_spinlock_t lock; 40 49 #endif 41 42 50 } RegionStats; 43 51 … … 210 218 int RegionStatsVector_Match (RegionStats *S1, int i0, int i1, RegionStats *S2, int j0, int j1); 211 219 212 #ifdef __cplusplus213 }214 #endif215 220 216 221 #endif /* __FEATURES_H__ */ -
soft/giet_vm/applications/rosenfeld/include/mca.h
r821 r822 26 26 27 27 28 // QM : using mutex lock instead of mutexlock,29 // because apparently mutexlocks cause a bug in valgrind28 // QM : using mutex lock instead of spinlock, 29 // because apparently spinlocks cause a bug in valgrind 30 30 // (solved but the installed version is not recent enough) 31 31 // cf. https://bugs.kde.org/show_bug.cgi?id=336435 32 32 pthread_mutex_t print_lock; 33 33 34 #define MCA_VERBOSE0(X) ({ \ 34 35 36 37 #if MCA_VERBOSE_LEVEL >= 1 38 #define MCA_VERBOSE1(X) ({ \ 35 39 pthread_mutex_lock(&print_lock); \ 36 40 X; \ 37 41 pthread_mutex_unlock(&print_lock); \ 38 42 }) 39 #define MCA_VERBOSE1(X) ({ \ 43 #else 44 #define MCA_VERBOSE1(X) 45 #endif 46 47 #if MCA_VERBOSE_LEVEL >= 2 48 #define MCA_VERBOSE2(X) ({ \ 40 49 pthread_mutex_lock(&print_lock); \ 41 50 X; \ 42 51 pthread_mutex_unlock(&print_lock); \ 43 52 }) 44 #define MCA_DISPLAY0(X) ({ \ 53 #else 54 #define MCA_VERBOSE2(X) 55 #endif 56 57 #if MCA_VERBOSE_LEVEL >= 3 58 #define MCA_VERBOSE3(X) ({ \ 45 59 pthread_mutex_lock(&print_lock); \ 46 60 X; \ 47 61 pthread_mutex_unlock(&print_lock); \ 48 62 }) 49 #define MCA_DISPLAY1(X) ({ \ 50 pthread_mutex_lock(&print_lock); \ 51 X; \ 52 pthread_mutex_unlock(&print_lock); \ 53 }) 54 55 56 #define MCA_VERBOSE2(X) 57 /* 58 #define MCA_VERBOSE2(X) ({ \ 59 pthread_mutex_lock(&print_lock); \ 60 X; \ 61 pthread_mutex_unlock(&print_lock); \ 62 }) 63 */ 64 65 #define MCA_DISPLAY2(X) 66 63 #else 64 #define MCA_VERBOSE3(X) 65 #endif 67 66 68 67 -
soft/giet_vm/applications/rosenfeld/nrc2/Makefile
r821 r822 7 7 8 8 # -- File list ---------- 9 FILE = nralloc1.c, nralloc2.c, nralloc2x.c, nrarith0.c, nrarith1.c, nrarith2.c, nrarith2x.c, nrbool1.c, nrbool2.c, nrhisto.c, nrio0.c, nrio1.c, nrio2.c, nrlinalg.c, nrlut.c, nrmem1.c, nrmem1x.c, nrmem2.c, nrmem2x.c, nrset1.c, nrset2.c, nrset2x.c, nrsort1.c, nrsort2.c, nrwrap1.c, nrwrap2.c 9 FILE = nralloc1.c, nralloc2.c, nralloc2x.c, nrarith0.c, nrarith1.c, nrarith2.c, nrarith2x.c, nrbool1.c, nrbool2.c, nrio0.c, nrio1.c, nrio1x.c, nrio2.c, nrlinalg.c, nrlut.c, nrmem1.c, nrmem1x.c, nrmem2.c, nrmem2x.c, nrset1.c, nrset2.c, nrset2x.c, nrsort1.c, nrsort2.c, nrwrap1.c, nrwrap2.c 10 FILE := $(FILE), nrio1f.c, nrio1xf.c, nrio2f.c # comment if giet 10 11 11 12 … … 16 17 OBJ_PATH = obj 17 18 INC_PATH = include 19 PRODUCT = libnrc2x.a 20 21 all: checktarget $(PRODUCT) 18 22 19 23 ifeq ($(TARGET),giet-vm) … … 36 40 CFLAGSCPU := -mips32 -EL -G0 -mhard-float 37 41 42 checktarget: 43 @if [ -f $(PRODUCT) ] && objdump -f $(PRODUCT) | grep "little" > /dev/null ; then \ 44 echo -ne "" ; \ 45 else \ 46 rm -f $(OBJS) $(PRODUCT) ;\ 47 fi 38 48 endif 39 49 … … 50 60 C_CONFIG_FLAGS = -DCLI 51 61 C_INC_FLAGS = -I$(INC_PATH) 62 63 checktarget: 64 @if [ -f $(PRODUCT) ] && objdump -f $(PRODUCT) | grep "86" > /dev/null ; then \ 65 echo -ne "" ; \ 66 else \ 67 rm -f $(OBJS) $(PRODUCT) ;\ 68 fi 52 69 53 70 endif … … 66 83 67 84 68 PRODUCT = libnrc2x.a69 85 70 86 OBJS = $(addprefix $(OBJ_PATH)/, $(addsuffix .o, $(basename $(FILE)))) 71 87 72 all: $(PRODUCT)73 88 74 $(OBJ_PATH)/%.o: $(SRC_PATH)/%.c 89 $(OBJ_PATH)/%.o: $(SRC_PATH)/%.c $(INC_PATH)/*.h 75 90 $(CC) -c $(CFLAGS) -o $@ $< 76 91 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrbool1.h
r772 r822 11 11 #define _NR_BOOL1_H_ 12 12 13 #ifdef __cplusplus14 #ifdef PRAGMA_VERBOSE15 #pragma message ("C++")16 #endif17 extern "C" {18 #endif19 13 20 #ifdef PRAGMA_VERBOSE 21 //#pragma message("- include nrbool1.h") 22 #endif 23 24 /* ========================= */ 25 /* === Logical operation === */ 26 /* ========================= */ 14 /* ========================== */ 15 /* === Logical operations === */ 16 /* ========================== */ 27 17 28 18 /* ----------- */ … … 30 20 /* ----------- */ 31 21 /* Y = ! Y */ 32 IMAGE_EXPORT(void) not_bvector (byte *X, long ncl, long nch, byte *Y); 33 IMAGE_EXPORT(void) not_si8vector (sint8 *X, long ncl, long nch, sint8 *Y); 34 IMAGE_EXPORT(void) not_ui8vector (uint8 *X, long ncl, long nch, uint8 *Y); 35 IMAGE_EXPORT(void) not_si16vector (sint16 *X, long ncl, long nch, sint16 *Y); 36 IMAGE_EXPORT(void) not_ui16vector (uint16 *X, long ncl, long nch, uint16 *Y); 37 IMAGE_EXPORT(void) not_si32vector (sint32 *X, long ncl, long nch, sint32 *Y); 38 IMAGE_EXPORT(void) not_ui32vector (uint32 *X, long ncl, long nch, uint32 *Y); 39 IMAGE_EXPORT(void) not_si64vector (sint64 *X, long ncl, long nch, sint64 *Y); 40 IMAGE_EXPORT(void) not_ui64vector (uint64 *X, long ncl, long nch, uint64 *Y); 41 IMAGE_EXPORT(void) not_rgb8vector (rgb8 *X, long ncl, long nch, rgb8 *Y); 42 IMAGE_EXPORT(void) not_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 *Y); 22 23 #define not_type_vector(t) \ 24 void short_name(t,not_,vector)(t * X, int32_t ncl, int32_t nch, t * Y) 25 26 not_type_vector(int8_t); 27 not_type_vector(uint8_t); 28 not_type_vector(int16_t); 29 not_type_vector(uint16_t); 30 not_type_vector(int32_t); 31 not_type_vector(uint32_t); 32 not_type_vector(int64_t); 33 not_type_vector(uint64_t); 34 not_type_vector(rgb8); 35 not_type_vector(rgbx8); 36 43 37 44 38 /* ---------- */ … … 47 41 /* Z = X | Y */ 48 42 49 IMAGE_EXPORT(void) or_bvector (byte *X, long ncl, long nch, byte *Y, byte *Z); 50 IMAGE_EXPORT(void) or_si8vector (sint8 *X, long ncl, long nch, sint8 *Y, sint8 *Z); 51 IMAGE_EXPORT(void) or_ui8vector (uint8 *X, long ncl, long nch, uint8 *Y, uint8 *Z); 52 IMAGE_EXPORT(void) or_si16vector (sint16 *X, long ncl, long nch, sint16 *Y, sint16 *Z); 53 IMAGE_EXPORT(void) or_ui16vector (uint16 *X, long ncl, long nch, uint16 *Y, uint16 *Z); 54 IMAGE_EXPORT(void) or_si32vector (sint32 *X, long ncl, long nch, sint32 *Y, sint32 *Z); 55 IMAGE_EXPORT(void) or_ui32vector (uint32 *X, long ncl, long nch, uint32 *Y, uint32 *Z); 56 IMAGE_EXPORT(void) or_si64vector (sint64 *X, long ncl, long nch, sint64 *Y, sint64 *Z); 57 IMAGE_EXPORT(void) or_ui64vector (uint64 *X, long ncl, long nch, uint64 *Y, uint64 *Z); 58 IMAGE_EXPORT(void) or_rgb8vector (rgb8 *X, long ncl, long nch, rgb8 *Y, rgb8 *Z); 59 IMAGE_EXPORT(void) or_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 *Y, rgbx8 *Z); 43 #define or_type_vector(t) \ 44 void short_name(t,or_,vector)(t * X, int32_t ncl, int32_t nch, t * Y, t * Z); \ 45 void short_name(t,orc_,vector)(t * X, int32_t ncl, int32_t nch, t y, t * Z) 60 46 61 IMAGE_EXPORT(void) orc_bvector (byte *X, long ncl, long nch, byte y, byte *Z);62 IMAGE_EXPORT(void) orc_si8vector (sint8 *X, long ncl, long nch, sint8 y, sint8 *Z);63 IMAGE_EXPORT(void) orc_ui8vector (uint8 *X, long ncl, long nch, uint8 y, uint8 *Z);64 IMAGE_EXPORT(void) orc_si16vector (sint16 *X, long ncl, long nch, sint16 y, sint16 *Z);65 IMAGE_EXPORT(void) orc_ui16vector (uint16 *X, long ncl, long nch, uint16 y, uint16 *Z);66 IMAGE_EXPORT(void) orc_si32vector (sint32 *X, long ncl, long nch, sint32 y, sint32 *Z);67 IMAGE_EXPORT(void) orc_ui32vector (uint32 *X, long ncl, long nch, uint32 y, uint32 *Z);68 IMAGE_EXPORT(void) orc_si64vector (sint64 *X, long ncl, long nch, sint64 y, sint64 *Z);69 IMAGE_EXPORT(void) orc_ui64vector (uint64 *X, long ncl, long nch, uint64 y, uint64 *Z);70 IMAGE_EXPORT(void) orc_rgb8vector (rgb8 *X, long ncl, long nch, rgb8 y, rgb8 *Z);71 IMAGE_EXPORT(void) orc_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 y, rgbx8 *Z); 47 or_type_vector(int8_t); 48 or_type_vector(uint8_t); 49 or_type_vector(int16_t); 50 or_type_vector(uint16_t); 51 or_type_vector(int32_t); 52 or_type_vector(uint32_t); 53 or_type_vector(int64_t); 54 or_type_vector(uint64_t); 55 or_type_vector(rgb8); 56 or_type_vector(rgbx8); 57 72 58 73 59 /* ----------- */ … … 76 62 /* Z = X ^ Y */ 77 63 78 IMAGE_EXPORT(void) xor_bvector (byte *X, long ncl, long nch, byte *Y, byte *Z); 79 IMAGE_EXPORT(void) xor_si8vector (sint8 *X, long ncl, long nch, sint8 *Y, sint8 *Z); 80 IMAGE_EXPORT(void) xor_ui8vector (uint8 *X, long ncl, long nch, uint8 *Y, uint8 *Z); 81 IMAGE_EXPORT(void) xor_si16vector (sint16 *X, long ncl, long nch, sint16 *Y, sint16 *Z); 82 IMAGE_EXPORT(void) xor_ui16vector (uint16 *X, long ncl, long nch, uint16 *Y, uint16 *Z); 83 IMAGE_EXPORT(void) xor_si32vector (sint32 *X, long ncl, long nch, sint32 *Y, sint32 *Z); 84 IMAGE_EXPORT(void) xor_ui32vector (uint32 *X, long ncl, long nch, uint32 *Y, uint32 *Z); 85 IMAGE_EXPORT(void) xor_si64vector (sint64 *X, long ncl, long nch, sint64 *Y, sint64 *Z); 86 IMAGE_EXPORT(void) xor_ui64vector (uint64 *X, long ncl, long nch, uint64 *Y, uint64 *Z); 87 IMAGE_EXPORT(void) xor_rgb8vector (rgb8 *X, long ncl, long nch, rgb8 *Y, rgb8 *Z); 88 IMAGE_EXPORT(void) xor_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 *Y, rgbx8 *Z); 64 #define xor_type_vector(t) \ 65 void short_name(t,xor_,vector)(t * X, int32_t ncl, int32_t nch, t * Y, t * Z); \ 66 void short_name(t,xorc_,vector)(t * X, int32_t ncl, int32_t nch, t y, t * Z) 89 67 90 IMAGE_EXPORT(void) xorc_bvector (byte *X, long ncl, long nch, byte y, byte *Z);91 IMAGE_EXPORT(void) xorc_si8vector (sint8 *X, long ncl, long nch, sint8 y, sint8 *Z);92 IMAGE_EXPORT(void) xorc_ui8vector (uint8 *X, long ncl, long nch, uint8 y, uint8 *Z);93 IMAGE_EXPORT(void) xorc_si16vector (sint16 *X, long ncl, long nch, sint16 y, sint16 *Z);94 IMAGE_EXPORT(void) xorc_ui16vector (uint16 *X, long ncl, long nch, uint16 y, uint16 *Z);95 IMAGE_EXPORT(void) xorc_si32vector (sint32 *X, long ncl, long nch, sint32 y, sint32 *Z);96 IMAGE_EXPORT(void) xorc_ui32vector (uint32 *X, long ncl, long nch, uint32 y, uint32 *Z);97 IMAGE_EXPORT(void) xorc_si64vector (sint64 *X, long ncl, long nch, sint64 y, sint64 *Z);98 IMAGE_EXPORT(void) xorc_ui64vector (uint64 *X, long ncl, long nch, uint64 y, uint64 *Z);99 IMAGE_EXPORT(void) xorc_rgb8vector (rgb8 *X, long ncl, long nch, rgb8 y, rgb8 *Z);100 IMAGE_EXPORT(void) xorc_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 y, rgbx8 *Z); 68 xor_type_vector(int8_t); 69 xor_type_vector(uint8_t); 70 xor_type_vector(int16_t); 71 xor_type_vector(uint16_t); 72 xor_type_vector(int32_t); 73 xor_type_vector(uint32_t); 74 xor_type_vector(int64_t); 75 xor_type_vector(uint64_t); 76 xor_type_vector(rgb8); 77 xor_type_vector(rgbx8); 78 101 79 102 80 /* ----------- */ … … 105 83 /* Z = X & Y */ 106 84 107 IMAGE_EXPORT(void) and_bvector (byte *X, long ncl, long nch, byte *Y, byte *Z); 108 IMAGE_EXPORT(void) and_si8vector (sint8 *X, long ncl, long nch, sint8 *Y, sint8 *Z); 109 IMAGE_EXPORT(void) and_ui8vector (uint8 *X, long ncl, long nch, uint8 *Y, uint8 *Z); 110 IMAGE_EXPORT(void) and_si16vector (sint16 *X, long ncl, long nch, sint16 *Y, sint16 *Z); 111 IMAGE_EXPORT(void) and_ui16vector (uint16 *X, long ncl, long nch, uint16 *Y, uint16 *Z); 112 IMAGE_EXPORT(void) and_si32vector (sint32 *X, long ncl, long nch, sint32 *Y, sint32 *Z); 113 IMAGE_EXPORT(void) and_ui32vector (uint32 *X, long ncl, long nch, uint32 *Y, uint32 *Z); 114 IMAGE_EXPORT(void) and_si64vector (sint64 *X, long ncl, long nch, sint64 *Y, sint64 *Z); 115 IMAGE_EXPORT(void) and_ui64vector (uint64 *X, long ncl, long nch, uint64 *Y, uint64 *Z); 116 IMAGE_EXPORT(void) and_rgb8vector (rgb8 *X, long ncl, long nch, rgb8 *Y, rgb8 *Z); 117 IMAGE_EXPORT(void) and_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 *Y, rgbx8 *Z); 85 #define and_type_vector(t) \ 86 void short_name(t,and_,vector)(t * X, int32_t ncl, int32_t nch, t * Y, t * Z); \ 87 void short_name(t,andc_,vector)(t * X, int32_t ncl, int32_t nch, t y, t * Z) 118 88 119 IMAGE_EXPORT(void) andc_bvector (byte *X, long ncl, long nch, byte y, byte *Z); 120 IMAGE_EXPORT(void) andc_si8vector (sint8 *X, long ncl, long nch, sint8 y, sint8 *Z); 121 IMAGE_EXPORT(void) andc_ui8vector (uint8 *X, long ncl, long nch, uint8 y, uint8 *Z); 122 IMAGE_EXPORT(void) andc_si16vector (sint16 *X, long ncl, long nch, sint16 y, sint16 *Z); 123 IMAGE_EXPORT(void) andc_ui16vector (uint16 *X, long ncl, long nch, uint16 y, uint16 *Z); 124 IMAGE_EXPORT(void) andc_si32vector (sint32 *X, long ncl, long nch, sint32 y, sint32 *Z); 125 IMAGE_EXPORT(void) andc_ui32vector (uint32 *X, long ncl, long nch, uint32 y, uint32 *Z); 126 IMAGE_EXPORT(void) andc_si64vector (sint64 *X, long ncl, long nch, sint64 y, sint64 *Z); 127 IMAGE_EXPORT(void) andc_ui64vector (uint64 *X, long ncl, long nch, uint64 y, uint64 *Z); 128 IMAGE_EXPORT(void) andc_rgb8vector (rgb8 *X, long ncl, long nch, rgb8 y, rgb8 *Z); 129 IMAGE_EXPORT(void) andc_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 y, rgbx8 *Z); 89 and_type_vector(int8_t); 90 and_type_vector(uint8_t); 91 and_type_vector(int16_t); 92 and_type_vector(uint16_t); 93 and_type_vector(int32_t); 94 and_type_vector(uint32_t); 95 and_type_vector(int64_t); 96 and_type_vector(uint64_t); 97 and_type_vector(rgb8); 98 and_type_vector(rgbx8); 130 99 131 100 132 #ifdef __cplusplus 133 } 134 #endif 101 #endif // _NR_BOOL1_H_ 135 102 136 #endif // _NR_BOOL1_H_ 103 // Local Variables: 104 // tab-width: 4 105 // c-basic-offset: 4 106 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 107 // indent-tabs-mode: nil 108 // End: 109 110 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 111 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrbool2.h
r772 r822 11 11 #define _NR_BOOL2_H_ 12 12 13 #ifdef __cplusplus 14 #ifdef PRAGMA_VERBOSE 15 #pragma message ("C++") 16 #endif 17 extern "C" { 18 #endif 13 #include "nrc_os_config.h" 19 14 20 #ifdef PRAGMA_VERBOSE21 //#pragma message("- include nrbool2.h")22 #endif23 15 24 IMAGE_EXPORT(int) cmpeq_bmatrix(byte **X, long nrl,long nrh,long ncl, long nch, byte **Y); 25 IMAGE_EXPORT(int) cmpeq_si8matrix(sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 **Y); 26 IMAGE_EXPORT(int) cmpeq_ui8matrix(uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 **Y); 27 IMAGE_EXPORT(int) cmpeq_si16matrix(sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y); 28 IMAGE_EXPORT(int) cmpeq_ui16matrix(uint16 **X, long nrl, long nrh, long ncl, long nch, uint16 **Y); 29 IMAGE_EXPORT(int) cmpeq_si32matrix(sint32 **X, long nrl, long nrh, long ncl, long nch, sint32 **Y); 30 IMAGE_EXPORT(int) cmpeq_ui32matrix(uint32 **X, long nrl, long nrh, long ncl, long nch, uint32 **Y); 16 #define cmpeq_type_matrix(t) \ 17 int32_t short_name(t,cmpeq_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y) 18 19 cmpeq_type_matrix(int8_t); 20 cmpeq_type_matrix(uint8_t); 21 cmpeq_type_matrix(int16_t); 22 cmpeq_type_matrix(uint16_t); 23 cmpeq_type_matrix(int32_t); 24 cmpeq_type_matrix(uint32_t); 25 cmpeq_type_matrix(int64_t); 26 cmpeq_type_matrix(uint64_t); 31 27 32 28 … … 37 33 */ 38 34 39 IMAGE_EXPORT(void) not_bmatrix (byte **X, long nrl,long nrh,long ncl, long nch, byte **Y); 40 IMAGE_EXPORT(void) not_si8matrix (sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 **Y); 41 IMAGE_EXPORT(void) not_ui8matrix (uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 **Y); 42 IMAGE_EXPORT(void) not_si16matrix (sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y); 43 IMAGE_EXPORT(void) not_ui16matrix (uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 **Y); 44 IMAGE_EXPORT(void) not_si32matrix (sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 **Y); 45 IMAGE_EXPORT(void) not_ui32matrix (uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 **Y); 46 IMAGE_EXPORT(void) not_si64matrix (sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 **Y); 47 IMAGE_EXPORT(void) not_ui64matrix (uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 **Y); 48 IMAGE_EXPORT(void) not_rgb8matrix (rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y); 49 IMAGE_EXPORT(void) not_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y); 35 #define not_type_matrix(t) \ 36 void short_name(t,not_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y) 37 38 not_type_matrix(int8_t); 39 not_type_matrix(uint8_t); 40 not_type_matrix(int16_t); 41 not_type_matrix(uint16_t); 42 not_type_matrix(int32_t); 43 not_type_matrix(uint32_t); 44 not_type_matrix(int64_t); 45 not_type_matrix(uint64_t); 46 not_type_matrix(rgb8); 47 not_type_matrix(rgbx8); 48 50 49 51 50 /* … … 55 54 */ 56 55 57 IMAGE_EXPORT(void) or_bmatrix (byte **X, long nrl,long nrh,long ncl, long nch, byte **Y, byte **Z); 58 IMAGE_EXPORT(void) or_si8matrix (sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 **Y, sint8 **Z); 59 IMAGE_EXPORT(void) or_ui8matrix (uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 **Y, uint8 **Z); 60 IMAGE_EXPORT(void) or_si16matrix (sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y, sint16 **Z); 61 IMAGE_EXPORT(void) or_ui16matrix (uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 **Y, uint16 **Z); 62 IMAGE_EXPORT(void) or_si32matrix (sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 **Y, sint32 **Z); 63 IMAGE_EXPORT(void) or_ui32matrix (uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 **Y, uint32 **Z); 64 IMAGE_EXPORT(void) or_si64matrix (sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 **Y, sint64 **Z); 65 IMAGE_EXPORT(void) or_ui64matrix (uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 **Y, uint64 **Z); 66 IMAGE_EXPORT(void) or_rgb8matrix (rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y, rgb8 **Z); 67 IMAGE_EXPORT(void) or_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y, rgbx8 **Z); 56 #define or_type_matrix(t) \ 57 void short_name(t,or_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z); \ 58 void short_name(t,orc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) 68 59 69 IMAGE_EXPORT(void) orc_bmatrix (byte **X, long nrl,long nrh,long ncl, long nch, byte y, byte **Z);70 IMAGE_EXPORT(void) orc_si8matrix (sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 y, sint8 **Z);71 IMAGE_EXPORT(void) orc_ui8matrix (uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 y, uint8 **Z);72 IMAGE_EXPORT(void) orc_si16matrix (sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 y, sint16 **Z);73 IMAGE_EXPORT(void) orc_ui16matrix (uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 y, uint16 **Z);74 IMAGE_EXPORT(void) orc_si32matrix (sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 y, sint32 **Z);75 IMAGE_EXPORT(void) orc_ui32matrix (uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 y, uint32 **Z);76 IMAGE_EXPORT(void) orc_si64matrix (sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 y, sint64 **Z);77 IMAGE_EXPORT(void) orc_ui64matrix (uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 y, uint64 **Z);78 IMAGE_EXPORT(void) orc_rgb8matrix (rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 y, rgb8 **Z);79 IMAGE_EXPORT(void) orc_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 y, rgbx8 **Z); 60 or_type_matrix(int8_t); 61 or_type_matrix(uint8_t); 62 or_type_matrix(int16_t); 63 or_type_matrix(uint16_t); 64 or_type_matrix(int32_t); 65 or_type_matrix(uint32_t); 66 or_type_matrix(int64_t); 67 or_type_matrix(uint64_t); 68 or_type_matrix(rgb8); 69 or_type_matrix(rgbx8); 70 80 71 81 72 /* … … 85 76 */ 86 77 87 IMAGE_EXPORT(void) xor_bmatrix (byte **X, long nrl,long nrh,long ncl, long nch, byte **Y, byte **Z); 88 IMAGE_EXPORT(void) xor_si8matrix (sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 **Y, sint8 **Z); 89 IMAGE_EXPORT(void) xor_ui8matrix (uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 **Y, uint8 **Z); 90 IMAGE_EXPORT(void) xor_si16matrix (sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y, sint16 **Z); 91 IMAGE_EXPORT(void) xor_ui16matrix (uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 **Y, uint16 **Z); 92 IMAGE_EXPORT(void) xor_si32matrix (sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 **Y, sint32 **Z); 93 IMAGE_EXPORT(void) xor_ui32matrix (uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 **Y, uint32 **Z); 94 IMAGE_EXPORT(void) xor_si64matrix (sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 **Y, sint64 **Z); 95 IMAGE_EXPORT(void) xor_ui64matrix (uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 **Y, uint64 **Z); 96 IMAGE_EXPORT(void) xor_rgb8matrix (rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y, rgb8 **Z); 97 IMAGE_EXPORT(void) xor_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y, rgbx8 **Z); 78 #define xor_type_matrix(t) \ 79 void short_name(t,xor_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z); \ 80 void short_name(t,xorc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) 98 81 99 IMAGE_EXPORT(void) xorc_bmatrix (byte **X, long nrl,long nrh,long ncl, long nch, byte y, byte **Z);100 IMAGE_EXPORT(void) xorc_si8matrix (sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 y, sint8 **Z);101 IMAGE_EXPORT(void) xorc_ui8matrix (uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 y, uint8 **Z);102 IMAGE_EXPORT(void) xorc_si16matrix (sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 y, sint16 **Z);103 IMAGE_EXPORT(void) xorc_ui16matrix (uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 y, uint16 **Z);104 IMAGE_EXPORT(void) xorc_si32matrix (sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 y, sint32 **Z);105 IMAGE_EXPORT(void) xorc_ui32matrix (uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 y, uint32 **Z);106 IMAGE_EXPORT(void) xorc_si64matrix (sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 y, sint64 **Z);107 IMAGE_EXPORT(void) xorc_ui64matrix (uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 y, uint64 **Z);108 IMAGE_EXPORT(void) xorc_rgb8matrix (rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 y, rgb8 **Z);109 IMAGE_EXPORT(void) xorc_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 y, rgbx8 **Z); 82 xor_type_matrix(int8_t); 83 xor_type_matrix(uint8_t); 84 xor_type_matrix(int16_t); 85 xor_type_matrix(uint16_t); 86 xor_type_matrix(int32_t); 87 xor_type_matrix(uint32_t); 88 xor_type_matrix(int64_t); 89 xor_type_matrix(uint64_t); 90 xor_type_matrix(rgb8); 91 xor_type_matrix(rgbx8); 92 110 93 111 94 /* 112 * ---------- -95 * ---------- 113 96 * --- And --- 114 * ---------- -97 * ---------- 115 98 */ 116 99 117 IMAGE_EXPORT(void) and_bmatrix (byte **X, long nrl,long nrh,long ncl, long nch, byte **Y, byte **Z); 118 IMAGE_EXPORT(void) and_si8matrix (sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 **Y, sint8 **Z); 119 IMAGE_EXPORT(void) and_ui8matrix (uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 **Y, uint8 **Z); 120 IMAGE_EXPORT(void) and_si16matrix (sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y, sint16 **Z); 121 IMAGE_EXPORT(void) and_ui16matrix (uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 **Y, uint16 **Z); 122 IMAGE_EXPORT(void) and_si32matrix (sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 **Y, sint32 **Z); 123 IMAGE_EXPORT(void) and_ui32matrix (uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 **Y, uint32 **Z); 124 IMAGE_EXPORT(void) and_si64matrix (sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 **Y, sint64 **Z); 125 IMAGE_EXPORT(void) and_ui64matrix (uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 **Y, uint64 **Z); 126 IMAGE_EXPORT(void) and_rgb8matrix (rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y, rgb8 **Z); 127 IMAGE_EXPORT(void) and_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y, rgbx8 **Z); 100 #define and_type_matrix(t) \ 101 void short_name(t,and_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z); \ 102 void short_name(t,andc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) 128 103 129 IMAGE_EXPORT(void) andc_bmatrix (byte **X, long nrl,long nrh,long ncl, long nch, byte y, byte **Z); 130 IMAGE_EXPORT(void) andc_si8matrix (sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 y, sint8 **Z); 131 IMAGE_EXPORT(void) andc_ui8matrix (uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 y, uint8 **Z); 132 IMAGE_EXPORT(void) andc_si16matrix (sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 y, sint16 **Z); 133 IMAGE_EXPORT(void) andc_ui16matrix (uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 y, uint16 **Z); 134 IMAGE_EXPORT(void) andc_si32matrix (sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 y, sint32 **Z); 135 IMAGE_EXPORT(void) andc_ui32matrix (uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 y, uint32 **Z); 136 IMAGE_EXPORT(void) andc_si64matrix (sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 y, sint64 **Z); 137 IMAGE_EXPORT(void) andc_ui64matrix (uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 y, uint64 **Z); 138 IMAGE_EXPORT(void) andc_rgb8matrix (rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 y, rgb8 **Z); 139 IMAGE_EXPORT(void) andc_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 y, rgbx8 **Z); 104 and_type_matrix(int8_t); 105 and_type_matrix(uint8_t); 106 and_type_matrix(int16_t); 107 and_type_matrix(uint16_t); 108 and_type_matrix(int32_t); 109 and_type_matrix(uint32_t); 110 and_type_matrix(int64_t); 111 and_type_matrix(uint64_t); 112 and_type_matrix(rgb8); 113 and_type_matrix(rgbx8); 140 114 141 #ifdef __cplusplus142 }143 #endif144 115 145 116 #endif // _NR_BOOL2_H_ 117 118 // Local Variables: 119 // tab-width: 4 120 // c-basic-offset: 4 121 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 122 // indent-tabs-mode: nil 123 // End: 124 125 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 126 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrio.h
r772 r822 11 11 #define __NRIO_H__ 12 12 13 #ifdef __cplusplus14 #pragma message ("C++")15 extern "C" {16 #endif17 18 #ifdef VERBOSE_PRAGMA19 //#pragma message ("- *** include nrio.h ***")20 #endif21 22 13 #include "nrio0.h" 23 14 #include "nrio1.h" … … 25 16 #include "nrio3.h" 26 17 27 #ifdef __cplusplus28 }29 #endif30 31 18 #endif // __NRIO_H__ -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrio0.h
r777 r822 11 11 #define _NR_IO0_H_ 12 12 13 #ifdef __cplusplus 14 #pragma message ("C++") 15 extern "C" { 16 #endif 17 18 #ifdef VERBOSE_PRAGMA 19 //#pragma message ("- *** include nrio0.h ***") 20 #endif 13 void generate_filename_k_ndigit (char * filename, int k, int ndigit, char * complete_filename, int maxlen); 14 void generate_filename_k_ndigit_extension(char * filename, int k, int ndigit, char * extension, char * complete_filename, int maxlen); 21 15 22 IMAGE_EXPORT(void) generate_filename_k_ndigit (char *filename, int k, int ndigit, char *complete_filename, int maxlen); 23 IMAGE_EXPORT(void) generate_filename_k_ndigit_extension(char *filename, int k, int ndigit, char *extension, char *complete_filename, int maxlen); 16 void generate_path_filename (char * path, char * filename, char * complete_filename, int maxlen); 17 void generate_path_filename_extension (char * path, char * filename, char * extension, char * complete_filename, int maxlen); 18 void generate_path_filename_suffix_extension (char * path, char * filename, char * suffix, char * extension, char * complete_filename, int maxlen); 19 void generate_path_filename_k_ndigit_extension (char * path, char * filename, int k, int ndigit, char * extension, char * complete_filename, int maxlen); 20 void generate_path_filename_k_ndigit_l_extension(char * path, char * filename, int k, int ndigit, int l, char * extension, char * complete_filename, int maxlen); 24 21 25 IMAGE_EXPORT(void) generate_path_filename (char *path, char *filename, char *complete_filename, int maxlen); 26 IMAGE_EXPORT(void) generate_path_filename_extension (char *path, char *filename, char *extension, char *complete_filename, int maxlen); 27 IMAGE_EXPORT(void) generate_path_filename_suffix_extension (char *path, char *filename, char *suffix, char *extension, char *complete_filename, int maxlen); 28 IMAGE_EXPORT(void) generate_path_filename_k_ndigit_extension (char *path, char *filename, int k, int ndigit, char *extension, char *complete_filename, int maxlen); 29 IMAGE_EXPORT(void) generate_path_filename_k_ndigit_l_extension(char *path, char *filename, int k, int ndigit, int l, char *extension, char *complete_filename, int maxlen); 22 void select_display_positive_parameters(int iformat, char ** format, char ** str); 30 23 31 void select_display_positive_parameters(int iformat, char **format, char **str);32 33 #ifdef __cplusplus34 }35 #endif36 24 37 25 #endif // _NR_IO0_H_ -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrio1.h
r772 r822 11 11 #define _NR_IO1_H_ 12 12 13 #ifdef __cplusplus14 #pragma message ("C++")15 extern "C" {16 #endif17 18 #ifdef VERBOSE_PRAGMA19 //#pragma message ("- *** include nrio1.h ***")20 #endif21 22 13 /* 23 * ---------------------- 24 * --- display_vector ---25 * ---------------------- 14 * ----------------------------------------------------------------------------------- 15 * --- display_vector + display_vector_number + display_vector_T + vector_number_T --- 16 * ----------------------------------------------------------------------------------- 26 17 */ 27 18 28 IMAGE_EXPORT(void) display_bvector (byte *v, long nl,long nh, char *format, char *name); 29 IMAGE_EXPORT(void) display_si8vector (sint8 *v, long nl,long nh, char *format, char *name); 30 IMAGE_EXPORT(void) display_ui8vector (uint8 *v, long nl,long nh, char *format, char *name); 31 IMAGE_EXPORT(void) display_si16vector (sint16 *v, long nl,long nh, char *format, char *name); 32 IMAGE_EXPORT(void) display_ui16vector (uint16 *v, long nl,long nh, char *format, char *name); 33 IMAGE_EXPORT(void) display_si32vector (sint32 *v, long nl,long nh, char *format, char *name); 34 IMAGE_EXPORT(void) display_ui32vector (uint32 *v, long nl,long nh, char *format, char *name); 35 IMAGE_EXPORT(void) display_si64vector (sint64 *v, long nl,long nh, char *format, char *name); 36 IMAGE_EXPORT(void) display_ui64vector (uint64 *v, long nl,long nh, char *format, char *name); 19 #define display_type_vector(t) \ 20 void short_name(t,display_,vector)(t * v, int32_t nl, int32_t nh, char * format, char * name); \ 21 void short_name(t,display_,vector_number)(t * v, int32_t nl, int32_t nh, char * format, char * name); \ 22 void short_name(t,display_,vector_T)(t * v, int32_t i0, int32_t i1, char * format, char * name); \ 23 void short_name(t,display_,vector_number_T)(t * v, int32_t i0, int32_t i1, char * format, char * name) 37 24 38 IMAGE_EXPORT(void) display_f32vector (float32 *v, long nl,long nh, char *format, char *name); 39 IMAGE_EXPORT(void) display_f64vector (float64 *v, long nl,long nh, char *format, char *name); 25 display_type_vector(int8_t); 26 display_type_vector(uint8_t); 27 display_type_vector(int16_t); 28 display_type_vector(uint16_t); 29 display_type_vector(int32_t); 30 display_type_vector(uint32_t); 31 display_type_vector(int64_t); 32 display_type_vector(uint64_t); 33 display_type_vector(float); 34 display_type_vector(double); 35 display_type_vector(rgb8); 36 display_type_vector(rgbx8); 40 37 41 IMAGE_EXPORT(void) display_rgb8vector (rgb8 *v, long nl,long nh, char *format, char *name);42 IMAGE_EXPORT(void) display_rgbx8vector(rgbx8 *v, long nl,long nh, char *format, char *name);43 44 /*45 * -----------------------------46 * --- display_vector_number ---47 * -----------------------------48 */49 50 IMAGE_EXPORT(void) display_bvector_number (byte *v, long nl,long nh, char *format, char *name);51 IMAGE_EXPORT(void) display_si8vector_number (sint8 *v, long nl,long nh, char *format, char *name);52 IMAGE_EXPORT(void) display_ui8vector_number (uint8 *v, long nl,long nh, char *format, char *name);53 IMAGE_EXPORT(void) display_si16vector_number (sint16 *v, long nl,long nh, char *format, char *name);54 IMAGE_EXPORT(void) display_ui16vector_number (uint16 *v, long nl,long nh, char *format, char *name);55 IMAGE_EXPORT(void) display_si32vector_number (sint32 *v, long nl,long nh, char *format, char *name);56 IMAGE_EXPORT(void) display_ui32vector_number (uint32 *v, long nl,long nh, char *format, char *name);57 IMAGE_EXPORT(void) display_si64vector_number (sint64 *v, long nl,long nh, char *format, char *name);58 IMAGE_EXPORT(void) display_ui64vector_number (uint64 *v, long nl,long nh, char *format, char *name);59 60 IMAGE_EXPORT(void) display_f32vector_number (float32 *v, long nl,long nh, char *format, char *name);61 IMAGE_EXPORT(void) display_f64vector_number (float64 *v, long nl,long nh, char *format, char *name);62 63 IMAGE_EXPORT(void) display_rgb8vector_number (rgb8 *v, long nl,long nh, char *format, char *name);64 IMAGE_EXPORT(void) display_rgbx8vector_number(rgbx8 *v, long nl,long nh, char *format, char *name);65 66 /*67 * ------------------------68 * --- display_vector_T ---69 * ------------------------70 */71 72 IMAGE_EXPORT(void) display_si8vector_T (sint8 *v,int i0, int i1, char *format, char *name);73 IMAGE_EXPORT(void) display_ui8vector_T (uint8 *v,int i0, int i1, char *format, char *name);74 IMAGE_EXPORT(void) display_si16vector_T (sint16 *v,int i0, int i1, char *format, char *name);75 IMAGE_EXPORT(void) display_ui16vector_T (uint16 *v,int i0, int i1, char *format, char *name);76 IMAGE_EXPORT(void) display_si32vector_T (sint32 *v,int i0, int i1, char *format, char *name);77 IMAGE_EXPORT(void) display_ui32vector_T (uint32 *v,int i0, int i1, char *format, char *name);78 IMAGE_EXPORT(void) display_si64vector_T (sint64 *v,int i0, int i1, char *format, char *name);79 IMAGE_EXPORT(void) display_ui64vector_T (uint64 *v,int i0, int i1, char *format, char *name);80 81 IMAGE_EXPORT(void) display_f32vector_T (float32 *v,int i0, int i1, char *format, char *name);82 IMAGE_EXPORT(void) display_f64vector_T (float64 *v,int i0, int i1, char *format, char *name);83 84 IMAGE_EXPORT(void) display_rgb8vector_T (rgb8 *v, int i0, int i1, char *format, char *name);85 IMAGE_EXPORT(void) display_rgbx8vector_T(rgbx8 *v, int i0, int i1, char *format, char *name);86 87 /*88 * -------------------------------89 * --- display_vector_number_T ---90 * -------------------------------91 */92 93 IMAGE_EXPORT(void) display_si8vector_number_T (sint8 *v,int i0, int i1, char *format, char *name);94 IMAGE_EXPORT(void) display_ui8vector_number_T (uint8 *v,int i0, int i1, char *format, char *name);95 IMAGE_EXPORT(void) display_si16vector_number_T(sint16 *v,int i0, int i1, char *format, char *name);96 IMAGE_EXPORT(void) display_ui16vector_number_T(uint16 *v,int i0, int i1, char *format, char *name);97 IMAGE_EXPORT(void) display_si32vector_number_T(sint32 *v,int i0, int i1, char *format, char *name);98 IMAGE_EXPORT(void) display_ui32vector_number_T(uint32 *v,int i0, int i1, char *format, char *name);99 IMAGE_EXPORT(void) display_si64vector_number_T(sint64 *v,int i0, int i1, char *format, char *name);100 IMAGE_EXPORT(void) display_ui64vector_number_T(uint64 *v,int i0, int i1, char *format, char *name);101 102 IMAGE_EXPORT(void) display_f32vector_number_T (float32 *v,int i0, int i1, char *format, char *name);103 IMAGE_EXPORT(void) display_f64vector_number_T (float64 *v,int i0, int i1, char *format, char *name);104 105 IMAGE_EXPORT(void) display_rgb8vector_number_T (rgb8 *v,int i0, int i1, char *format, char *name);106 IMAGE_EXPORT(void) display_rgbx8vector_number_T(rgbx8 *v,int i0, int i1, char *format, char *name);107 38 108 39 /* … … 111 42 * ------------------------------- 112 43 */ 113 114 void display_ui8vector_positive (uint8 *v, int j0, int j1, int iformat, char *name); 115 void display_ui16vector_positive(uint16 *v, int j0, int j1, int iformat, char *name); 116 void display_ui32vector_positive(uint32 *v, int j0, int j1, int iformat, char *name); 117 44 45 #undef display_type_vector_positive 46 #define display_type_vector_positive(t) \ 47 void short_name(t,display_,vector_positive)(t * v, int32_t j0, int32_t j1, int32_t iformat, char * name) 48 49 display_type_vector_positive(int8_t); 50 display_type_vector_positive(uint8_t); 51 display_type_vector_positive(int16_t); 52 display_type_vector_positive(uint16_t); 53 display_type_vector_positive(int32_t); 54 display_type_vector_positive(uint32_t); 55 display_type_vector_positive(int64_t); 56 display_type_vector_positive(uint64_t); 57 display_type_vector_positive(float); 58 display_type_vector_positive(double); 59 60 118 61 /* 119 62 * -------------------- 120 63 * --- write_vector --- 64 * --- write_vector_T --- 65 * --- write_vector_number --- 66 * --- write_vector_T_number --- 67 * --- fread_vector --- 68 * --- fwrite_vector --- 121 69 * -------------------- 122 70 */ 123 71 124 IMAGE_EXPORT(void) write_si8vector (sint8 *v,long nl,long nh, char *format, char *filename); 125 IMAGE_EXPORT(void) write_ui8vector (uint8 *v,long nl,long nh, char *format, char *filename); 126 IMAGE_EXPORT(void) write_si16vector (sint16 *v,long nl,long nh, char *format, char *filename); 127 IMAGE_EXPORT(void) write_ui16vector (uint16 *v,long nl,long nh, char *format, char *filename); 128 IMAGE_EXPORT(void) write_si32vector (sint32 *v,long nl,long nh, char *format, char *filename); 129 IMAGE_EXPORT(void) write_ui32vector (uint32 *v,long nl,long nh, char *format, char *filename); 130 IMAGE_EXPORT(void) write_si64vector (sint64 *v,long nl,long nh, char *format, char *filename); 131 IMAGE_EXPORT(void) write_ui64vector (uint64 *v,long nl,long nh, char *format, char *filename); 72 #define write_type_vector(t) \ 73 void short_name(t,write_,vector)(t * v, int32_t nl, int32_t nh, char * format, char * filename); \ 74 void short_name(t,write_,vector_T)(t * v, int32_t nl, int32_t nh, char * format, char * filename); \ 75 void short_name(t,write_,vector_number)(t * v, int32_t nl, int32_t nh, char * format, char * filename); \ 76 void short_name(t,write_,vector_T_number)(t * v, int32_t nl, int32_t nh, char * format, char * filename); \ 77 void short_name(t,fread_,vector)(char * filename, t * v, int32_t nl, int32_t nh); \ 78 void short_name(t,fwrite_,vector)(t * v, int32_t nl, int32_t nh, char * filename) \ 132 79 133 IMAGE_EXPORT(void) write_f32vector (float32 *v,long nl,long nh, char *format, char *filename); 134 IMAGE_EXPORT(void) write_f64vector (float64 *v,long nl,long nh, char *format, char *filename); 80 write_type_vector(int8_t); 81 write_type_vector(uint8_t); 82 write_type_vector(int16_t); 83 write_type_vector(uint16_t); 84 write_type_vector(int32_t); 85 write_type_vector(uint32_t); 86 write_type_vector(int64_t); 87 write_type_vector(uint64_t); 88 write_type_vector(float); 89 write_type_vector(double); 90 write_type_vector(rgb8); 91 write_type_vector(rgbx8); 135 92 136 IMAGE_EXPORT(void) write_rgb8vector (rgb8 *v,long nl,long nh, char *format, char *filename);137 IMAGE_EXPORT(void) write_rgbx8vector(rgbx8 *v,long nl,long nh, char *format, char *filename);138 139 /*140 * ----------------------141 * --- write_vector_T ---142 * ----------------------143 */144 145 IMAGE_EXPORT(void) write_si8vector_T (sint8 *v,long nl,long nh, char *format, char *filename);146 IMAGE_EXPORT(void) write_ui8vector_T (uint8 *v,long nl,long nh, char *format, char *filename);147 IMAGE_EXPORT(void) write_si16vector_T (sint16 *v,long nl,long nh, char *format, char *filename);148 IMAGE_EXPORT(void) write_ui16vector_T (uint16 *v,long nl,long nh, char *format, char *filename);149 IMAGE_EXPORT(void) write_si32vector_T (sint32 *v,long nl,long nh, char *format, char *filename);150 IMAGE_EXPORT(void) write_ui32vector_T (uint32 *v,long nl,long nh, char *format, char *filename);151 IMAGE_EXPORT(void) write_si64vector_T (sint64 *v,long nl,long nh, char *format, char *filename);152 IMAGE_EXPORT(void) write_ui64vector_T (uint64 *v,long nl,long nh, char *format, char *filename);153 154 IMAGE_EXPORT(void) write_f32vector_T (float32 *v,long nl,long nh, char *format, char *filename);155 IMAGE_EXPORT(void) write_f64vector_T (float64 *v,long nl,long nh, char *format, char *filename);156 157 IMAGE_EXPORT(void) write_rgb8vector_T (rgb8 *v,long nl,long nh, char *format, char *filename);158 IMAGE_EXPORT(void) write_rgbx8vector_T(rgbx8 *v,long nl,long nh, char *format, char *filename);159 160 /*161 * ---------------------------162 * --- write_vector_number ---163 * ---------------------------164 */165 166 IMAGE_EXPORT(void) write_si8vector_number (sint8 *v,long nl,long nh, char *format, char *filename);167 IMAGE_EXPORT(void) write_ui8vector_number (uint8 *v,long nl,long nh, char *format, char *filename);168 IMAGE_EXPORT(void) write_si16vector_number (sint16 *v,long nl,long nh, char *format, char *filename);169 IMAGE_EXPORT(void) write_ui16vector_number (uint16 *v,long nl,long nh, char *format, char *filename);170 IMAGE_EXPORT(void) write_si32vector_number (sint32 *v,long nl,long nh, char *format, char *filename);171 IMAGE_EXPORT(void) write_ui32vector_number (uint32 *v,long nl,long nh, char *format, char *filename);172 IMAGE_EXPORT(void) write_si64vector_number (sint64 *v,long nl,long nh, char *format, char *filename);173 IMAGE_EXPORT(void) write_ui64vector_number (uint64 *v,long nl,long nh, char *format, char *filename);174 175 IMAGE_EXPORT(void) write_f32vector_number (float32 *v,long nl,long nh, char *format, char *filename);176 IMAGE_EXPORT(void) write_f64vector_number (float64 *v,long nl,long nh, char *format, char *filename);177 178 IMAGE_EXPORT(void) write_rgb8vector_number (rgb8 *v,long nl,long nh, char *format, char *filename);179 IMAGE_EXPORT(void) write_rgbx8vector_number(rgbx8 *v,long nl,long nh, char *format, char *filename);180 181 /*182 * -----------------------------183 * --- write_vector_T_number ---184 * -----------------------------185 */186 187 IMAGE_EXPORT(void) write_si8vector_T_number (sint8 *v,long nl,long nh, char *format, char *filename);188 IMAGE_EXPORT(void) write_ui8vector_T_number (uint8 *v,long nl,long nh, char *format, char *filename);189 IMAGE_EXPORT(void) write_si16vector_T_number (sint16 *v,long nl,long nh, char *format, char *filename);190 IMAGE_EXPORT(void) write_ui16vector_T_number (uint16 *v,long nl,long nh, char *format, char *filename);191 IMAGE_EXPORT(void) write_si32vector_T_number (sint32 *v,long nl,long nh, char *format, char *filename);192 IMAGE_EXPORT(void) write_ui32vector_T_number (uint32 *v,long nl,long nh, char *format, char *filename);193 IMAGE_EXPORT(void) write_si64vector_T_number (sint64 *v,long nl,long nh, char *format, char *filename);194 IMAGE_EXPORT(void) write_ui64vector_T_number (uint64 *v,long nl,long nh, char *format, char *filename);195 196 IMAGE_EXPORT(void) write_f32vector_T_number (float32 *v,long nl,long nh, char *format, char *filename);197 IMAGE_EXPORT(void) write_f64vector_T_number (float64 *v,long nl,long nh, char *format, char *filename);198 199 IMAGE_EXPORT(void) write_rgb8vector_T_number (rgb8 *v,long nl,long nh, char *format, char *filename);200 IMAGE_EXPORT(void) write_rgbx8vector_T_number(rgbx8 *v,long nl,long nh, char *format, char *filename);201 202 /*203 * --------------------204 * --- fread_vector ---205 * --------------------206 */207 IMAGE_EXPORT(void) fread_si8vector (char *filename, sint8 *v,long nl,long nh);208 IMAGE_EXPORT(void) fread_ui8vector (char *filename, uint8 *v,long nl,long nh);209 IMAGE_EXPORT(void) fread_si16vector (char *filename, sint16 *v,long nl,long nh);210 IMAGE_EXPORT(void) fread_ui16vector (char *filename, uint16 *v,long nl,long nh);211 IMAGE_EXPORT(void) fread_si32vector (char *filename, sint32 *v,long nl,long nh);212 IMAGE_EXPORT(void) fread_ui32vector (char *filename, uint32 *v,long nl,long nh);213 IMAGE_EXPORT(void) fread_si64vector (char *filename, sint64 *v,long nl,long nh);214 IMAGE_EXPORT(void) fread_ui64vector (char *filename, uint64 *v,long nl,long nh);215 216 IMAGE_EXPORT(void) fread_f32vector (char *filename, float32 *v,long nl,long nh);217 IMAGE_EXPORT(void) fread_f64vector (char *filename, float64 *v,long nl,long nh);218 219 IMAGE_EXPORT(void) fread_rgb8vector (char *filename, rgb8 *v,long nl,long nh);220 IMAGE_EXPORT(void) fread_rgbx8vector(char *filename, rgbx8 *v,long nl,long nh);221 222 /*223 * ---------------------224 * --- fwrite_vector ---225 * ---------------------226 */227 IMAGE_EXPORT(void) fwrite_si8vector (sint8 *v,long nl,long nh,char *filename);228 IMAGE_EXPORT(void) fwrite_ui8vector (uint8 *v,long nl,long nh,char *filename);229 IMAGE_EXPORT(void) fwrite_si16vector (sint16 *v,long nl,long nh,char *filename);230 IMAGE_EXPORT(void) fwrite_ui16vector (uint16 *v,long nl,long nh,char *filename);231 IMAGE_EXPORT(void) fwrite_si32vector (sint32 *v,long nl,long nh,char *filename);232 IMAGE_EXPORT(void) fwrite_ui32vector (uint32 *v,long nl,long nh,char *filename);233 IMAGE_EXPORT(void) fwrite_si64vector (sint64 *v,long nl,long nh,char *filename);234 IMAGE_EXPORT(void) fwrite_ui64vector (uint64 *v,long nl,long nh,char *filename);235 236 IMAGE_EXPORT(void) fwrite_f32vector (float32 *v,long nl,long nh,char *filename);237 IMAGE_EXPORT(void) fwrite_f64vector (float64 *v,long nl,long nh,char *filename);238 239 IMAGE_EXPORT(void) fwrite_rgb8vector (rgb8 *v,long nl,long nh,char *filename);240 IMAGE_EXPORT(void) fwrite_rgbx8vector(rgbx8 *v,long nl,long nh,char *filename);241 242 #ifdef __cplusplus243 }244 #endif245 93 246 94 #endif // _NR_IO1_H_ 95 96 // Local Variables: 97 // tab-width: 4 98 // c-basic-offset: 4 99 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 100 // indent-tabs-mode: nil 101 // End: 102 103 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 104 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrio1x.h
r772 r822 11 11 #define _NR_IO1X_H_ 12 12 13 #ifdef __cplusplus 14 #pragma message ("C++") 15 extern "C" { 16 #endif 17 18 IMAGE_EXPORT(void) display_bvector_circular (byte *v,long nl,long nh, long c0, long c1, char *format, char *name); 19 IMAGE_EXPORT(void) display_si16vector_circular (sint16 *v,long nl,long nh, long c0, long c1, char *format, char *name); 20 IMAGE_EXPORT(void) display_ui16vector_circular (uint16 *v,long nl,long nh, long c0, long c1, char *format, char *name); 21 IMAGE_EXPORT(void) display_f32vector_circular (float32 *v,long nl,long nh, long c0, long c1, char *format, char *name); 22 IMAGE_EXPORT(void) display_f64vector_circular (float64 *v,long nl,long nh, long c0, long c1, char *format, char *name); 13 #define display_type_vector_circular(t) \ 14 void short_name(t,display_,vector_circular)(t * v, int32_t nl, int32_t nh, int32_t c0, int32_t c1, char * format, char * name); \ 15 void short_name(t,display_,vector_circular_number)(t * v, int32_t nl, int32_t nh, int32_t c0, int32_t c1, char * format, char * name); \ 16 void short_name(t,display_,vector_cycle)(t * v, int32_t nl, int32_t nh, char * format, char * name); \ 17 void short_name(t,write_,vector_circular)(t * v, int32_t nl, int32_t nh, int32_t c0, int32_t c1, char * format, char * filename) 23 18 24 IMAGE_EXPORT(void) display_bvector_circular_number (byte *v,long nl,long nh, long c0, long c1, char *format, char *name); 25 IMAGE_EXPORT(void) display_si16vector_circular_number(sint16 *v,long nl,long nh, long c0, long c1, char *format, char *name); 26 IMAGE_EXPORT(void) display_ui16vector_circular_number(uint16 *v,long nl,long nh, long c0, long c1, char *format, char *name); 27 IMAGE_EXPORT(void) display_f32vector_circular_number (float32 *v,long nl,long nh, long c0, long c1, char *format, char *name); 28 IMAGE_EXPORT(void) display_f64vector_circular_number (float64 *v,long nl,long nh, long c0, long c1, char *format, char *name); 19 display_type_vector_circular(int8_t); 20 display_type_vector_circular(uint8_t); 21 display_type_vector_circular(int16_t); 22 display_type_vector_circular(uint16_t); 23 display_type_vector_circular(int32_t); 24 display_type_vector_circular(uint32_t); 25 display_type_vector_circular(int64_t); 26 display_type_vector_circular(uint64_t); 27 display_type_vector_circular(float); 28 display_type_vector_circular(double); 29 29 30 IMAGE_EXPORT(void) display_bvector_cycle (byte *v,long nl,long nh, char *format, char *name);31 IMAGE_EXPORT(void) display_si16vector_cycle(sint16 *v,long nl,long nh, char *format, char *name);32 IMAGE_EXPORT(void) display_ui16vector_cycle(uint16 *v,long nl,long nh, char *format, char *name);33 34 IMAGE_EXPORT(void) write_bvector_circular(byte *v,long nl,long nh, long c0, long c1, char *format, char *filename);35 36 37 #ifdef __cplusplus38 }39 #endif40 30 41 31 #endif // _NR_IO1X_H_ 32 33 // Local Variables: 34 // tab-width: 4 35 // c-basic-offset: 4 36 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 37 // indent-tabs-mode: nil 38 // End: 39 40 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 41 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrio2.h
r798 r822 11 11 #define _NR_IO2_H_ 12 12 13 #ifdef __cplusplus14 #pragma message ("C++")15 extern "C" {16 #endif17 18 #ifdef VERBOSE_PRAGMA19 //#pragma message ("- *** include nrio2.h ***")20 #endif21 22 13 23 14 /* 24 15 * ---------------------- 25 16 * --- display_matrix --- 17 * --- display_matrix_T --- 18 * --- display_matrix_number --- 19 * --- display_matrix_positive --- 26 20 * ---------------------- 27 21 */ 28 22 29 IMAGE_EXPORT(void) display_si8matrix (sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name); 30 IMAGE_EXPORT(void) display_ui8matrix (uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name); 31 IMAGE_EXPORT(void) display_si16matrix (sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name); 32 IMAGE_EXPORT(void) display_ui16matrix (uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name); 33 IMAGE_EXPORT(void) display_si32matrix (sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name); 34 IMAGE_EXPORT(void) display_ui32matrix (uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name); 35 IMAGE_EXPORT(void) display_si64matrix (sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name); 36 IMAGE_EXPORT(void) display_ui64matrix (uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name); 23 #define display_type_matrix(t) \ 24 void short_name(t,display_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name); \ 25 void short_name(t,display_,matrix_T)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name); \ 26 void short_name(t,display_,matrix_number)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name); \ 27 void short_name(t,display_,matrix_positive)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t iformat, char * name) 37 28 38 IMAGE_EXPORT(void) display_f32matrix (float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);39 IMAGE_EXPORT(void) display_f64matrix (float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);40 29 41 IMAGE_EXPORT(void) display_rgb8matrix (rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name); 42 IMAGE_EXPORT(void) display_rgbx8matrix(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name); 30 display_type_matrix(int8_t); 31 display_type_matrix(uint8_t); 32 display_type_matrix(int16_t); 33 display_type_matrix(uint16_t); 34 display_type_matrix(int32_t); 35 display_type_matrix(uint32_t); 36 display_type_matrix(int64_t); 37 display_type_matrix(uint64_t); 38 display_type_matrix(float); 39 display_type_matrix(double); 40 display_type_matrix(rgb8); 41 display_type_matrix(rgbx8); 43 42 44 /*45 * ------------------------46 * --- display_matrix_T ---47 * ------------------------48 */49 50 IMAGE_EXPORT(void) display_si8matrix_T (sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);51 IMAGE_EXPORT(void) display_ui8matrix_T (uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);52 IMAGE_EXPORT(void) display_si16matrix_T(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);53 IMAGE_EXPORT(void) display_ui16matrix_T(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);54 IMAGE_EXPORT(void) display_si32matrix_T(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);55 IMAGE_EXPORT(void) display_ui32matrix_T(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);56 IMAGE_EXPORT(void) display_si64matrix_T(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);57 IMAGE_EXPORT(void) display_ui64matrix_T(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);58 59 IMAGE_EXPORT(void) display_f32matrix_T (float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);60 IMAGE_EXPORT(void) display_f64matrix_T (float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);61 62 IMAGE_EXPORT(void) display_rgb8matrix_T (rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);63 IMAGE_EXPORT(void) display_rgbx8matrix_T(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);64 65 /*66 * -----------------------------67 * --- display_matrix_number ---68 * -----------------------------69 */70 71 IMAGE_EXPORT(void) display_si8matrix_number (sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);72 IMAGE_EXPORT(void) display_ui8matrix_number (uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);73 IMAGE_EXPORT(void) display_si16matrix_number(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);74 IMAGE_EXPORT(void) display_ui16matrix_number(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);75 IMAGE_EXPORT(void) display_i32matrix_number (sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);76 IMAGE_EXPORT(void) display_ui32matrix_number(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);77 IMAGE_EXPORT(void) display_si64matrix_number(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);78 IMAGE_EXPORT(void) display_ui64matrix_number(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);79 80 IMAGE_EXPORT(void) display_f32matrix_number (float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);81 IMAGE_EXPORT(void) display_f64matrix_number (float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);82 83 IMAGE_EXPORT(void) display_rgb8matrix_number (rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);84 IMAGE_EXPORT(void) display_rgbx8matrix_number(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);85 43 86 44 /* 87 45 * -------------------- 88 46 * --- write_matrix --- 89 * --------------------90 */91 92 IMAGE_EXPORT(void) write_si8matrix (sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);93 IMAGE_EXPORT(void) write_ui8matrix (uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);94 IMAGE_EXPORT(void) write_si16matrix (sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);95 IMAGE_EXPORT(void) write_ui16matrix (uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);96 IMAGE_EXPORT(void) write_si32matrix (sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);97 IMAGE_EXPORT(void) write_ui32matrix (uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);98 IMAGE_EXPORT(void) write_si64matrix (sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);99 IMAGE_EXPORT(void) write_ui64matrix (uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);100 101 IMAGE_EXPORT(void) write_f32matrix (float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);102 IMAGE_EXPORT(void) write_f64matrix (float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);103 104 IMAGE_EXPORT(void) write_rgb8matrix (rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);105 IMAGE_EXPORT(void) write_rgbx8matrix(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);106 107 /*108 * ----------------------109 47 * --- write_matrix_T --- 110 * ----------------------111 */112 113 IMAGE_EXPORT(void) write_si8matrix_T (sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);114 IMAGE_EXPORT(void) write_ui8matrix_T (uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);115 IMAGE_EXPORT(void) write_si16matrix_T (sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);116 IMAGE_EXPORT(void) write_ui16matrix_T (uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);117 IMAGE_EXPORT(void) write_si32matrix_T (sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);118 IMAGE_EXPORT(void) write_ui32matrix_T (uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);119 IMAGE_EXPORT(void) write_si64matrix_T (sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);120 IMAGE_EXPORT(void) write_ui64matrix_T (uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);121 122 IMAGE_EXPORT(void) write_f32matrix_T (float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);123 IMAGE_EXPORT(void) write_f64matrix_T (float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);124 125 IMAGE_EXPORT(void) write_rgb8matrix_T (rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);126 IMAGE_EXPORT(void) write_rgbx8matrix_T(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);127 128 /*129 * ---------------------------130 48 * --- write_matrix_number --- 131 * ---------------------------132 */133 134 IMAGE_EXPORT(void) write_si8matrix_number (sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);135 IMAGE_EXPORT(void) write_ui8matrix_number (uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);136 IMAGE_EXPORT(void) write_si16matrix_number (sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);137 IMAGE_EXPORT(void) write_ui16matrix_number (uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);138 IMAGE_EXPORT(void) write_si32matrix_number (sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);139 IMAGE_EXPORT(void) write_ui32matrix_number (uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);140 IMAGE_EXPORT(void) write_si64matrix_number (sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);141 IMAGE_EXPORT(void) write_ui64matrix_number (uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);142 143 IMAGE_EXPORT(void) write_f32matrix_number (float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);144 IMAGE_EXPORT(void) write_f64matrix_number (float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);145 146 IMAGE_EXPORT(void) write_rgb8matrix_number (rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);147 IMAGE_EXPORT(void) write_rgbx8matrix_number(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);148 149 /*150 * -----------------------------151 49 * --- write_matrix_T_number --- 152 * -----------------------------153 */154 155 IMAGE_EXPORT(void) write_si8matrix_T_number (sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);156 IMAGE_EXPORT(void) write_ui8matrix_T_number (uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);157 IMAGE_EXPORT(void) write_si16matrix_T_number (sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);158 IMAGE_EXPORT(void) write_ui16matrix_T_number (uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);159 IMAGE_EXPORT(void) write_si32matrix_T_number (sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);160 IMAGE_EXPORT(void) write_ui32matrix_T_number (uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);161 IMAGE_EXPORT(void) write_si64matrix_T_number (sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);162 IMAGE_EXPORT(void) write_ui64matrix_T_number (uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);163 164 IMAGE_EXPORT(void) write_f32matrix_T_number (float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);165 IMAGE_EXPORT(void) write_f64matrix_T_number (float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);166 167 IMAGE_EXPORT(void) write_rgb8matrix_T_number (rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);168 IMAGE_EXPORT(void) write_rgbx8matrix_T_number(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);169 170 /*171 * ---------------------172 50 * --- fwrite_matrix --- 173 * ---------------------174 */175 176 IMAGE_EXPORT(void) fwrite_si8matrix (sint8 **m,long nrl,long nrh,long ncl, long nch, char *filename);177 IMAGE_EXPORT(void) fwrite_ui8matrix (uint8 **m,long nrl,long nrh,long ncl, long nch, char *filename);178 IMAGE_EXPORT(void) fwrite_si16matrix (sint16 **m,long nrl,long nrh,long ncl, long nch, char *filename);179 IMAGE_EXPORT(void) fwrite_ui16matrix (uint16 **m,long nrl,long nrh,long ncl, long nch, char *filename);180 IMAGE_EXPORT(void) fwrite_si32matrix (sint32 **m,long nrl,long nrh,long ncl, long nch, char *filename);181 IMAGE_EXPORT(void) fwrite_ui32matrix (uint32 **m,long nrl,long nrh,long ncl, long nch, char *filename);182 IMAGE_EXPORT(void) fwrite_si64matrix (sint64 **m,long nrl,long nrh,long ncl, long nch, char *filename);183 IMAGE_EXPORT(void) fwrite_ui64matrix (uint64 **m,long nrl,long nrh,long ncl, long nch, char *filename);184 185 IMAGE_EXPORT(void) fwrite_f32matrix (float32 **m,long nrl,long nrh,long ncl, long nch, char *filename);186 IMAGE_EXPORT(void) fwrite_f64matrix (float64 **m,long nrl,long nrh,long ncl, long nch, char *filename);187 188 IMAGE_EXPORT(void) fwrite_rgb8matrix(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *filename);189 IMAGE_EXPORT(void) fwrite_rgbx8matrix(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *filename);190 191 /*192 * --------------------193 51 * --- fread_matrix --- 194 52 * -------------------- 195 53 */ 196 54 197 IMAGE_EXPORT(void) fread_si8matrix (char *filename, sint8 **m,long nrl,long nrh,long ncl, long nch); 198 IMAGE_EXPORT(void) fread_ui8matrix (char *filename, uint8 **m,long nrl,long nrh,long ncl, long nch); 199 IMAGE_EXPORT(void) fread_si16matrix (char *filename, sint16 **m,long nrl,long nrh,long ncl, long nch); 200 IMAGE_EXPORT(void) fread_ui16matrix (char *filename, uint16 **m,long nrl,long nrh,long ncl, long nch); 201 IMAGE_EXPORT(void) fread_si32matrix (char *filename, sint32 **m,long nrl,long nrh,long ncl, long nch); 202 IMAGE_EXPORT(void) fread_ui32matrix (char *filename, uint32 **m,long nrl,long nrh,long ncl, long nch); 203 IMAGE_EXPORT(void) fread_si64matrix (char *filename, sint64 **m,long nrl,long nrh,long ncl, long nch); 204 IMAGE_EXPORT(void) fread_ui64matrix (char *filename, uint64 **m,long nrl,long nrh,long ncl, long nch); 205 IMAGE_EXPORT(void) fread_f32matrix (char *filename, float32 **m,long nrl,long nrh,long ncl, long nch); 206 IMAGE_EXPORT(void) fread_f64matrix (char *filename, float64 **m,long nrl,long nrh,long ncl, long nch); 55 #define write_type_matrix(t) \ 56 void short_name(t,write_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename); \ 57 void short_name(t,write_,matrix_T)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename); \ 58 void short_name(t,write_,matrix_number)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename); \ 59 void short_name(t,write_,matrix_T_number)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename); \ 60 void short_name(t,fwrite_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * filename); \ 61 void short_name(t,fread_,matrix)(char * filename, t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ 207 62 208 IMAGE_EXPORT(void) fread_rgb8matrix (char *filename, rgb8 **m,long nrl,long nrh,long ncl, long nch); 209 IMAGE_EXPORT(void) fread_rgbx8matrix(char *filename, rgbx8 **m,long nrl,long nrh,long ncl, long nch); 63 write_type_matrix(int8_t); 64 write_type_matrix(uint8_t); 65 write_type_matrix(int16_t); 66 write_type_matrix(uint16_t); 67 write_type_matrix(int32_t); 68 write_type_matrix(uint32_t); 69 write_type_matrix(int64_t); 70 write_type_matrix(uint64_t); 71 write_type_matrix(float); 72 write_type_matrix(double); 73 write_type_matrix(rgb8); 74 write_type_matrix(rgbx8); 210 75 211 /*212 * -------------------------------213 * --- display_matrix_positive ---214 * -------------------------------215 */216 217 void display_si8matrix_positive (sint8 * *m, int i0, int i1, int j0, int j1, int iformat, char *name);218 void display_ui8matrix_positive (uint8 * *m, int i0, int i1, int j0, int j1, int iformat, char *name);219 void display_si16matrix_positive(sint16 **m, int i0, int i1, int j0, int j1, int iformat, char *name);220 void display_ui16matrix_positive(uint16 **m, int i0, int i1, int j0, int j1, int iformat, char *name);221 void display_si32matrix_positive(sint32 **m, int i0, int i1, int j0, int j1, int iformat, char *name);222 void display_ui32matrix_positive(uint32 **m, int i0, int i1, int j0, int j1, int iformat, char *name);223 void display_si64matrix_positive(sint64 **m, int i0, int i1, int j0, int j1, int iformat, char *name);224 void display_ui64matrix_positive(uint64 **m, int i0, int i1, int j0, int j1, int iformat, char *name);225 76 226 77 // ------------------------------- … … 228 79 // ------------------------------- 229 80 230 void write_ui8matrix_positive (uint8 **m,int i0, int i1, int j0, int j1, int iformat, char *filename); 231 void write_ui16matrix_positive(uint16 **m,int i0, int i1, int j0, int j1, int iformat, char *filename); 232 void write_ui32matrix_positive(uint32 **m,int i0, int i1, int j0, int j1, int iformat, char *filename); 81 #define write_type_matrix_positive(t) \ 82 void short_name(t,write_,matrix_positive)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t iformat, char * filename) 83 84 write_type_matrix_positive(uint8_t); 85 write_type_matrix_positive(uint16_t); 86 write_type_matrix_positive(uint32_t); 233 87 234 88 /* ------------------------ */ … … 236 90 /* ------------------------ */ 237 91 238 IMAGE_EXPORT(uint8 **) LoadPGM_ui8matrix(char *filename, int *nrl, int *nrh, int *ncl, int *nch);239 IMAGE_EXPORT(uint8 **) LoadPGM_bmatrix (char *filename, int *nrl, int *nrh, int *ncl, int *nch);240 IMAGE_EXPORT(void) LoadPGM_bmatrix2 (char *filename, int *nrl, int *nrh, int *ncl, int *nch, uint8 **m);241 IMAGE_EXPORT(void) MLoadPGM_bmatrix (char *filename, int nrl, int nrh, int ncl, int nch, uint8 **m);92 uint8_t ** LoadPGM_ui8matrix (char * filename, int32_t * nrl, int32_t * nrh, int32_t * ncl, int32_t * nch); 93 void LoadPGM_ui8matrix2 (char * filename, int32_t * nrl, int32_t * nrh, int32_t * ncl, int32_t * nch, uint8_t ** m); 94 rgb8 ** LoadPPM_rgb8matrix (char * filename, int32_t * nrl, int32_t * nrh, int32_t * ncl, int32_t * nch); 95 void LoadPPM_rgb8matrix2(char * filename, int32_t * nrl, int32_t * nrh, int32_t * ncl, int32_t * nch, rgb8 ** m); 242 96 243 IMAGE_EXPORT(void) SavePGM_bmatrix (uint8 **m, int nrl, int nrh, int ncl, int nch, char *filename); 244 IMAGE_EXPORT(void) SavePGM_ui8matrix(uint8 **m, int nrl, int nrh, int ncl, int nch, char *filename); 245 246 IMAGE_EXPORT(rgb8 **) LoadPPM_rgb8matrix (char *filename, int *nrl, int *nrh, int *ncl, int *nch); 247 IMAGE_EXPORT(void) LoadPPM_rgb8matrix2(char *filename, int *nrl, int *nrh, int *ncl, int *nch, rgb8 **m); 248 249 IMAGE_EXPORT(void) SavePPM_rgb8matrix(rgb8 **m, int nrl, int nrh, int ncl, int nch, char *filename); 97 void MLoadPGM_ui8matrix(char * filename, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint8 ** m); 98 void SavePGM_ui8matrix (uint8_t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * filename); 99 void SavePPM_rgb8matrix (rgb8 ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * filename); 250 100 251 101 252 102 253 #ifdef __cplusplus254 }255 #endif256 257 103 #endif // _NR_IO2_H_ 258 104 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrtype.h
r821 r822 17 17 18 18 #include <stdint.h> 19 20 // ---------------------------------- //21 // -- don not write under the line -- //22 // ---------------------------------- //23 19 24 20 -
soft/giet_vm/applications/rosenfeld/nrc2/src/nralloc1.c
r821 r822 157 157 #undef remote_type_vector 158 158 #define remote_type_vector(t) \ 159 t * short_name(t,remote_,vector)(int32_t nl, int32_t nh, int32_t x, int32_t y) \159 t * short_name(t,remote_,vector)(int32_t nl, int32_t nh, int32_t x, int32_t y) \ 160 160 { \ 161 161 t * v; \ -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrbool1.c
r772 r822 17 17 #include <math.h> // fabs 18 18 19 #include "nrc_os_config.h" 19 20 #include "mypredef.h" 20 21 #include "nrtype.h" … … 31 32 */ 32 33 33 /* -------------------------------------------------------------- */ 34 IMAGE_EXPORT(void) not_bvector(byte *X, long ncl, long nch, byte *Y) 35 /* -------------------------------------------------------------- */ 36 { 37 long j; 38 39 for(j=ncl; j<=nch; j++) { 40 Y[j] = ~X[j]; 41 } 42 } 43 /* ------------------------------------------------------------------ */ 44 IMAGE_EXPORT(void) not_si8vector(sint8 *X, long ncl, long nch, sint8 *Y) 45 /* ------------------------------------------------------------------ */ 46 { 47 long j; 48 49 for(j=ncl; j<=nch; j++) { 50 Y[j] = ~X[j]; 51 } 52 } 53 /* ------------------------------------------------------------------ */ 54 IMAGE_EXPORT(void) not_ui8vector(uint8 *X, long ncl, long nch, uint8 *Y) 55 /* ------------------------------------------------------------------ */ 56 { 57 long j; 58 59 for(j=ncl; j<=nch; j++) { 60 Y[j] = ~X[j]; 61 } 62 } 63 /* --------------------------------------------------------------------- */ 64 IMAGE_EXPORT(void) not_si16vector(sint16 *X, long ncl, long nch, sint16 *Y) 65 /* --------------------------------------------------------------------- */ 66 { 67 long j; 68 69 for(j=ncl; j<=nch; j++) { 70 Y[j] = ~X[j]; 71 } 72 } 73 /* --------------------------------------------------------------------- */ 74 IMAGE_EXPORT(void) not_ui16vector(uint16 *X, long ncl, long nch, uint16 *Y) 75 /* --------------------------------------------------------------------- */ 76 { 77 long j; 78 79 for(j=ncl; j<=nch; j++) { 80 Y[j] = ~X[j]; 81 } 82 } 83 /* --------------------------------------------------------------------- */ 84 IMAGE_EXPORT(void) not_si32vector(sint32 *X, long ncl, long nch, sint32 *Y) 85 /* --------------------------------------------------------------------- */ 86 { 87 long j; 88 89 for(j=ncl; j<=nch; j++) { 90 Y[j] = ~X[j]; 91 } 92 } 93 /* --------------------------------------------------------------------- */ 94 IMAGE_EXPORT(void) not_ui32vector(uint32 *X, long ncl, long nch, uint32 *Y) 95 /* --------------------------------------------------------------------- */ 96 { 97 long j; 98 99 for(j=ncl; j<=nch; j++) { 100 Y[j] = ~X[j]; 101 } 102 } 103 /* --------------------------------------------------------------------- */ 104 IMAGE_EXPORT(void) not_si64vector(sint64 *X, long ncl, long nch, sint64 *Y) 105 /* --------------------------------------------------------------------- */ 106 { 107 long j; 108 109 for(j=ncl; j<=nch; j++) { 110 Y[j] = ~X[j]; 111 } 112 } 113 /* --------------------------------------------------------------------- */ 114 IMAGE_EXPORT(void) not_ui64vector(uint64 *X, long ncl, long nch, uint64 *Y) 115 /* --------------------------------------------------------------------- */ 116 { 117 long j; 118 119 for(j=ncl; j<=nch; j++) { 120 Y[j] = ~X[j]; 121 } 122 } 34 #undef not_type_vector 35 #define not_type_vector(t) \ 36 void short_name(t,not_,vector)(t * X, int32_t ncl, int32_t nch, t * Y) \ 37 { \ 38 for (int32_t j = ncl; j <= nch; j++) { \ 39 Y[j] = ~X[j]; \ 40 } \ 41 } 42 43 not_type_vector(int8_t); 44 not_type_vector(uint8_t); 45 not_type_vector(int16_t); 46 not_type_vector(uint16_t); 47 not_type_vector(int32_t); 48 not_type_vector(uint32_t); 49 not_type_vector(int64_t); 50 not_type_vector(uint64_t); 51 52 123 53 /* ----------------------------------------------------------------- */ 124 IMAGE_EXPORT(void) not_rgb8vector(rgb8 *X, long ncl, long nch, rgb8 *Y)54 void not_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y) 125 55 /* ----------------------------------------------------------------- */ 126 56 { 127 long j; 128 rgb8 x, y; 129 130 for(j=ncl; j<=nch; j++) { 131 x = X[j]; 132 RGB8_NOT(x,y); 133 Y[j] = y; 134 } 135 } 57 for (int32_t j = ncl; j <= nch; j++) { 58 RGB8_NOT(X[j], Y[j]); 59 } 60 } 61 136 62 /* -------------------------------------------------------------------- */ 137 IMAGE_EXPORT(void) not_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 *Y)63 void not_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y) 138 64 /* -------------------------------------------------------------------- */ 139 65 { 140 long j; 141 rgbx8 x, y; 142 143 for(j=ncl; j<=nch; j++) { 144 x = X[j]; 145 RGBX8_NOT(x,y); 146 Y[j] = y; 147 } 148 } 66 for (int32_t j = ncl; j <= nch; j++) { 67 RGBX8_NOT(X[j], Y[j]); 68 } 69 } 70 149 71 /* 150 72 * ----------- … … 153 75 */ 154 76 155 /* ---------------------------------------------------------------------- */ 156 IMAGE_EXPORT(void) or_bvector(byte *X, long ncl, long nch, byte *Y, byte *Z) 157 /* ---------------------------------------------------------------------- */ 158 { 159 long j; 160 161 for(j=ncl; j<=nch; j++) { 162 Z[j] = X[j] | Y[j]; 163 } 164 } 165 /* --------------------------------------------------------------------------- */ 166 IMAGE_EXPORT(void) or_si8vector(sint8 *X, long ncl, long nch, sint8 *Y, sint8 *Z) 167 /* --------------------------------------------------------------------------- */ 168 { 169 long j; 170 171 for(j=ncl; j<=nch; j++) { 172 Z[j] = X[j] | Y[j]; 173 } 174 } 175 /* --------------------------------------------------------------------------- */ 176 IMAGE_EXPORT(void) or_ui8vector(uint8 *X, long ncl, long nch, uint8 *Y, uint8 *Z) 177 /* --------------------------------------------------------------------------- */ 178 { 179 long j; 180 181 for(j=ncl; j<=nch; j++) { 182 Z[j] = X[j] | Y[j]; 183 } 184 } 185 /* ------------------------------------------------------------------------------- */ 186 IMAGE_EXPORT(void) or_si16vector(sint16 *X, long ncl, long nch, sint16 *Y, sint16 *Z) 187 /* ------------------------------------------------------------------------------- */ 188 { 189 long j; 190 191 for(j=ncl; j<=nch; j++) { 192 Z[j] = X[j] | Y[j]; 193 } 194 } 195 /* ------------------------------------------------------------------------------- */ 196 IMAGE_EXPORT(void) or_ui16vector(uint16 *X, long ncl, long nch, uint16 *Y, uint16 *Z) 197 /* ------------------------------------------------------------------------------- */ 198 { 199 long j; 200 201 for(j=ncl; j<=nch; j++) { 202 Z[j] = X[j] | Y[j]; 203 } 204 } 205 /* ------------------------------------------------------------------------------- */ 206 IMAGE_EXPORT(void) or_si32vector(sint32 *X, long ncl, long nch, sint32 *Y, sint32 *Z) 207 /* ------------------------------------------------------------------------------- */ 208 { 209 long j; 210 211 for(j=ncl; j<=nch; j++) { 212 Z[j] = X[j] | Y[j]; 213 } 214 } 215 /* ------------------------------------------------------------------------------- */ 216 IMAGE_EXPORT(void) or_ui32vector(uint32 *X, long ncl, long nch, uint32 *Y, uint32 *Z) 217 /* ------------------------------------------------------------------------------- */ 218 { 219 long j; 220 221 for(j=ncl; j<=nch; j++) { 222 Z[j] = X[j] | Y[j]; 223 } 224 } 225 /* ------------------------------------------------------------------------------- */ 226 IMAGE_EXPORT(void) or_si64vector(sint64 *X, long ncl, long nch, sint64 *Y, sint64 *Z) 227 /* ------------------------------------------------------------------------------- */ 228 { 229 long j; 230 231 for(j=ncl; j<=nch; j++) { 232 Z[j] = X[j] | Y[j]; 233 } 234 } 235 /* ------------------------------------------------------------------------------- */ 236 IMAGE_EXPORT(void) or_ui64vector(uint64 *X, long ncl, long nch, uint64 *Y, uint64 *Z) 237 /* ------------------------------------------------------------------------------- */ 238 { 239 long j; 240 241 for(j=ncl; j<=nch; j++) { 242 Z[j] = X[j] | Y[j]; 243 } 244 } 77 #undef or_type_vector 78 #define or_type_vector(t) \ 79 void short_name(t,or_,vector)(t * X, int32_t ncl, int32_t nch, t * Y, t * Z) \ 80 { \ 81 for (int32_t j = ncl; j <= nch; j++) { \ 82 Z[j] = X[j] | Y[j]; \ 83 } \ 84 } 85 86 or_type_vector(int8_t); 87 or_type_vector(uint8_t); 88 or_type_vector(int16_t); 89 or_type_vector(uint16_t); 90 or_type_vector(int32_t); 91 or_type_vector(uint32_t); 92 or_type_vector(int64_t); 93 or_type_vector(uint64_t); 94 95 245 96 /* ------------------------------------------------------------------------- */ 246 IMAGE_EXPORT(void) or_rgb8vector(rgb8 *X, long ncl, long nch, rgb8 *Y, rgb8 *Z)97 void or_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y, rgb8 * Z) 247 98 /* ------------------------------------------------------------------------- */ 248 99 { 249 long j; 250 rgb8 x, y, z; 251 252 for(j=ncl; j<=nch; j++) { 253 x = X[j]; 254 y = Y[j]; 255 RGB8_OR(x,y,z); 256 Z[j] = z; 100 for (int32_t j = ncl; j <= nch; j++) { 101 RGB8_OR(X[j], Y[j], Z[j]); 257 102 } 258 103 } 259 104 /* ----------------------------------------------------------------------------- */ 260 IMAGE_EXPORT(void) or_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 *Y, rgbx8 *Z)105 void or_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y, rgbx8 * Z) 261 106 /* ----------------------------------------------------------------------------- */ 262 107 { 263 long j; 264 rgbx8 x, y, z; 265 266 for(j=ncl; j<=nch; j++) { 267 x = X[j]; 268 y = Y[j]; 269 RGBX8_OR(x,y,z); 270 Z[j] = z; 271 } 272 } 273 /* ---------------------------------------------------------------------- */ 274 IMAGE_EXPORT(void) orc_bvector(byte *X, long ncl, long nch, byte y, byte *Z) 275 /* ---------------------------------------------------------------------- */ 276 { 277 long j; 278 279 for(j=ncl; j<=nch; j++) { 280 Z[j] = X[j] | y; 281 } 282 } 283 /* --------------------------------------------------------------------------- */ 284 IMAGE_EXPORT(void) orc_si8vector(sint8 *X, long ncl, long nch, sint8 y, sint8 *Z) 285 /* --------------------------------------------------------------------------- */ 286 { 287 long j; 288 289 for(j=ncl; j<=nch; j++) { 290 Z[j] = X[j] | y; 291 } 292 } 293 /* --------------------------------------------------------------------------- */ 294 IMAGE_EXPORT(void) orc_ui8vector(uint8 *X, long ncl, long nch, uint8 y, uint8 *Z) 295 /* --------------------------------------------------------------------------- */ 296 { 297 long j; 298 299 for(j=ncl; j<=nch; j++) { 300 Z[j] = X[j] | y; 301 } 302 } 303 /* ------------------------------------------------------------------------------- */ 304 IMAGE_EXPORT(void) orc_si16vector(sint16 *X, long ncl, long nch, sint16 y, sint16 *Z) 305 /* ------------------------------------------------------------------------------- */ 306 { 307 long j; 308 309 for(j=ncl; j<=nch; j++) { 310 Z[j] = X[j] | y; 311 } 312 } 313 /* ------------------------------------------------------------------------------- */ 314 IMAGE_EXPORT(void) orc_ui16vector(uint16 *X, long ncl, long nch, uint16 y, uint16 *Z) 315 /* ------------------------------------------------------------------------------- */ 316 { 317 long j; 318 319 for(j=ncl; j<=nch; j++) { 320 Z[j] = X[j] | y; 321 } 322 } 323 /* ------------------------------------------------------------------------------- */ 324 IMAGE_EXPORT(void) orc_si32vector(sint32 *X, long ncl, long nch, sint32 y, sint32 *Z) 325 /* ------------------------------------------------------------------------------- */ 326 { 327 long j; 328 329 for(j=ncl; j<=nch; j++) { 330 Z[j] = X[j] | y; 331 } 332 } 333 /* ------------------------------------------------------------------------------- */ 334 IMAGE_EXPORT(void) orc_ui32vector(uint32 *X, long ncl, long nch, uint32 y, uint32 *Z) 335 /* ------------------------------------------------------------------------------- */ 336 { 337 long j; 338 339 for(j=ncl; j<=nch; j++) { 340 Z[j] = X[j] | y; 341 } 342 } 343 /* ------------------------------------------------------------------------------- */ 344 IMAGE_EXPORT(void) orc_si64vector(sint64 *X, long ncl, long nch, sint64 y, sint64 *Z) 345 /* ------------------------------------------------------------------------------- */ 346 { 347 long j; 348 349 for(j=ncl; j<=nch; j++) { 350 Z[j] = X[j] | y; 351 } 352 } 353 /* ------------------------------------------------------------------------------- */ 354 IMAGE_EXPORT(void) orc_ui64vector(uint64 *X, long ncl, long nch, uint64 y, uint64 *Z) 355 /* ------------------------------------------------------------------------------- */ 356 { 357 long j; 358 359 for(j=ncl; j<=nch; j++) { 360 Z[j] = X[j] | y; 361 } 362 } 108 for (int32_t j = ncl; j <= nch; j++) { 109 RGBX8_OR(X[j], Y[j], Z[j]); 110 } 111 } 112 113 114 #undef orc_type_vector 115 #define orc_type_vector(t) \ 116 void short_name(t,orc_,vector)(t * X, int32_t ncl, int32_t nch, t y, t * Z) \ 117 { \ 118 for (int32_t j = ncl; j <= nch; j++) { \ 119 Z[j] = X[j] | y; \ 120 } \ 121 } 122 123 orc_type_vector(int8_t); 124 orc_type_vector(uint8_t); 125 orc_type_vector(int16_t); 126 orc_type_vector(uint16_t); 127 orc_type_vector(int32_t); 128 orc_type_vector(uint32_t); 129 orc_type_vector(int64_t); 130 orc_type_vector(uint64_t); 131 132 363 133 /* ------------------------------------------------------------------------- */ 364 IMAGE_EXPORT(void) orc_rgb8vector(rgb8 *X, long ncl, long nch, rgb8 y, rgb8 *Z)134 void orc_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 y, rgb8 * Z) 365 135 /* ------------------------------------------------------------------------- */ 366 136 { 367 long j; 368 rgb8 x, z; 369 370 for(j=ncl; j<=nch; j++) { 371 x = X[j]; 372 RGB8_OR(x,y,z); 373 Z[j] = z; 374 } 375 } 137 for (int32_t j = ncl; j <= nch; j++) { 138 RGB8_OR(X[j], y, Z[j]); 139 } 140 } 141 376 142 /* ----------------------------------------------------------------------------- */ 377 IMAGE_EXPORT(void) orc_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 y, rgbx8 *Z)143 void orc_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 * Z) 378 144 /* ----------------------------------------------------------------------------- */ 379 145 { 380 long j; 381 rgbx8 x, z; 382 383 for(j=ncl; j<=nch; j++) { 384 x = X[j]; 385 RGBX8_OR(x,y,z); 386 Z[j] = z; 387 } 388 } 146 for (int32_t j = ncl; j <= nch; j++) { 147 RGBX8_OR(X[j], y, Z[j]); 148 } 149 } 150 151 389 152 /* 390 153 * ----------- … … 392 155 * ----------- 393 156 */ 394 /* ----------------------------------------------------------------------- */ 395 IMAGE_EXPORT(void) xor_bvector(byte *X, long ncl, long nch, byte *Y, byte *Z) 396 /* ----------------------------------------------------------------------- */ 397 { 398 long j; 399 400 for(j=ncl; j<=nch; j++) { 401 Z[j] = X[j] ^ Y[j]; 402 } 403 } 404 /* ---------------------------------------------------------------------------- */ 405 IMAGE_EXPORT(void) xor_si8vector(sint8 *X, long ncl, long nch, sint8 *Y, sint8 *Z) 406 /* ---------------------------------------------------------------------------- */ 407 { 408 long j; 409 410 for(j=ncl; j<=nch; j++) { 411 Z[j] = X[j] ^ Y[j]; 412 } 413 } 414 /* ---------------------------------------------------------------------------- */ 415 IMAGE_EXPORT(void) xor_ui8vector(uint8 *X, long ncl, long nch, uint8 *Y, uint8 *Z) 416 /* ---------------------------------------------------------------------------- */ 417 { 418 long j; 419 420 for(j=ncl; j<=nch; j++) { 421 Z[j] = X[j] ^ Y[j]; 422 } 423 } 424 /* -------------------------------------------------------------------------------- */ 425 IMAGE_EXPORT(void) xor_si16vector(sint16 *X, long ncl, long nch, sint16 *Y, sint16 *Z) 426 /* -------------------------------------------------------------------------------- */ 427 { 428 long j; 429 430 for(j=ncl; j<=nch; j++) { 431 Z[j] = X[j] ^ Y[j]; 432 } 433 } 434 /* -------------------------------------------------------------------------------- */ 435 IMAGE_EXPORT(void) xor_ui16vector(uint16 *X, long ncl, long nch, uint16 *Y, uint16 *Z) 436 /* -------------------------------------------------------------------------------- */ 437 { 438 long j; 439 440 for(j=ncl; j<=nch; j++) { 441 Z[j] = X[j] ^ Y[j]; 442 } 443 } 444 /* -------------------------------------------------------------------------------- */ 445 IMAGE_EXPORT(void) xor_si32vector(sint32 *X, long ncl, long nch, sint32 *Y, sint32 *Z) 446 /* -------------------------------------------------------------------------------- */ 447 { 448 long j; 449 450 for(j=ncl; j<=nch; j++) { 451 Z[j] = X[j] ^ Y[j]; 452 } 453 } 454 /* -------------------------------------------------------------------------------- */ 455 IMAGE_EXPORT(void) xor_ui32vector(uint32 *X, long ncl, long nch, uint32 *Y, uint32 *Z) 456 /* -------------------------------------------------------------------------------- */ 457 { 458 long j; 459 460 for(j=ncl; j<=nch; j++) { 461 Z[j] = X[j] ^ Y[j]; 462 } 463 } 464 /* -------------------------------------------------------------------------------- */ 465 IMAGE_EXPORT(void) xor_si64vector(sint64 *X, long ncl, long nch, sint64 *Y, sint64 *Z) 466 /* -------------------------------------------------------------------------------- */ 467 { 468 long j; 469 470 for(j=ncl; j<=nch; j++) { 471 Z[j] = X[j] ^ Y[j]; 472 } 473 } 474 /* -------------------------------------------------------------------------------- */ 475 IMAGE_EXPORT(void) xor_ui64vector(uint64 *X, long ncl, long nch, uint64 *Y, uint64 *Z) 476 /* -------------------------------------------------------------------------------- */ 477 { 478 long j; 479 480 for(j=ncl; j<=nch; j++) { 481 Z[j] = X[j] ^ Y[j]; 482 } 483 } 484 /* -------------------------------------------------------------------------- */ 485 IMAGE_EXPORT(void) xor_rgb8vector(rgb8 *X, long ncl, long nch, rgb8 *Y, rgb8 *Z) 486 /* -------------------------------------------------------------------------- */ 487 { 488 long j; 489 rgb8 x, y, z; 490 491 for(j=ncl; j<=nch; j++) { 492 x = X[j]; 493 y = Y[j]; 494 RGB8_XOR(x,y,z); 495 Z[j] = z; 496 } 497 } 498 /* ------------------------------------------------------------------------------ */ 499 IMAGE_EXPORT(void) xor_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 *Y, rgbx8 *Z) 500 /* ------------------------------------------------------------------------------ */ 501 { 502 long j; 503 rgbx8 x, y, z; 504 505 for(j=ncl; j<=nch; j++) { 506 x = X[j]; 507 y = Y[j]; 508 RGBX8_XOR(x,y,z); 509 Z[j] = z; 510 } 511 } 512 /* ----------------------------------------------------------------------- */ 513 IMAGE_EXPORT(void) xorc_bvector(byte *X, long ncl, long nch, byte y, byte *Z) 514 /* ----------------------------------------------------------------------- */ 515 { 516 long j; 517 518 for(j=ncl; j<=nch; j++) { 519 Z[j] = X[j] ^ y; 520 } 521 } 522 /* ---------------------------------------------------------------------------- */ 523 IMAGE_EXPORT(void) xorc_si8vector(sint8 *X, long ncl, long nch, sint8 y, sint8 *Z) 524 /* ---------------------------------------------------------------------------- */ 525 { 526 long j; 527 528 for(j=ncl; j<=nch; j++) { 529 Z[j] = X[j] ^ y; 530 } 531 } 532 /* ---------------------------------------------------------------------------- */ 533 IMAGE_EXPORT(void) xorc_ui8vector(uint8 *X, long ncl, long nch, uint8 y, uint8 *Z) 534 /* ---------------------------------------------------------------------------- */ 535 { 536 long j; 537 538 for(j=ncl; j<=nch; j++) { 539 Z[j] = X[j] ^ y; 540 } 541 } 542 /* -------------------------------------------------------------------------------- */ 543 IMAGE_EXPORT(void) xorc_si16vector(sint16 *X, long ncl, long nch, sint16 y, sint16 *Z) 544 /* -------------------------------------------------------------------------------- */ 545 { 546 long j; 547 548 for(j=ncl; j<=nch; j++) { 549 Z[j] = X[j] ^ y; 550 } 551 } 552 /* -------------------------------------------------------------------------------- */ 553 IMAGE_EXPORT(void) xorc_ui16vector(uint16 *X, long ncl, long nch, uint16 y, uint16 *Z) 554 /* -------------------------------------------------------------------------------- */ 555 { 556 long j; 557 558 for(j=ncl; j<=nch; j++) { 559 Z[j] = X[j] ^ y; 560 } 561 } 562 /* -------------------------------------------------------------------------------- */ 563 IMAGE_EXPORT(void) xorc_si32vector(sint32 *X, long ncl, long nch, sint32 y, sint32 *Z) 564 /* -------------------------------------------------------------------------------- */ 565 { 566 long j; 567 568 for(j=ncl; j<=nch; j++) { 569 Z[j] = X[j] ^ y; 570 } 571 } 572 /* -------------------------------------------------------------------------------- */ 573 IMAGE_EXPORT(void) xorc_ui32vector(uint32 *X, long ncl, long nch, uint32 y, uint32 *Z) 574 /* -------------------------------------------------------------------------------- */ 575 { 576 long j; 577 578 for(j=ncl; j<=nch; j++) { 579 Z[j] = X[j] ^ y; 580 } 581 } 582 /* -------------------------------------------------------------------------------- */ 583 IMAGE_EXPORT(void) xorc_si64vector(sint64 *X, long ncl, long nch, sint64 y, sint64 *Z) 584 /* -------------------------------------------------------------------------------- */ 585 { 586 long j; 587 588 for(j=ncl; j<=nch; j++) { 589 Z[j] = X[j] ^ y; 590 } 591 } 592 /* -------------------------------------------------------------------------------- */ 593 IMAGE_EXPORT(void) xorc_ui64vector(uint64 *X, long ncl, long nch, uint64 y, uint64 *Z) 594 /* -------------------------------------------------------------------------------- */ 595 { 596 long j; 597 598 for(j=ncl; j<=nch; j++) { 599 Z[j] = X[j] ^ y; 600 } 601 } 602 /* -------------------------------------------------------------------------- */ 603 IMAGE_EXPORT(void) xorc_rgb8vector(rgb8 *X, long ncl, long nch, rgb8 y, rgb8 *Z) 604 /* -------------------------------------------------------------------------- */ 605 { 606 long j; 607 rgb8 x, z; 608 609 for(j=ncl; j<=nch; j++) { 610 x = X[j]; 611 RGB8_XOR(x,y,z); 612 Z[j] = z; 613 } 614 } 615 /* ------------------------------------------------------------------------------ */ 616 IMAGE_EXPORT(void) xorc_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 y, rgbx8 *Z) 617 /* ------------------------------------------------------------------------------ */ 618 { 619 long j; 620 rgbx8 x, z; 621 622 for(j=ncl; j<=nch; j++) { 623 x = X[j]; 624 RGBX8_XOR(x,y,z); 625 Z[j] = z; 626 } 627 } 157 158 #undef xor_type_vector 159 #define xor_type_vector(t) \ 160 void short_name(t,xor_,vector)(t * X, int32_t ncl, int32_t nch, t * Y, t * Z) \ 161 { \ 162 for (int32_t j = ncl; j <= nch; j++) { \ 163 Z[j] = X[j] ^ Y[j]; \ 164 } \ 165 } 166 167 xor_type_vector(int8_t); 168 xor_type_vector(uint8_t); 169 xor_type_vector(int16_t); 170 xor_type_vector(uint16_t); 171 xor_type_vector(int32_t); 172 xor_type_vector(uint32_t); 173 xor_type_vector(int64_t); 174 xor_type_vector(uint64_t); 175 176 177 /* -------------------------------------------------------------------------- */ 178 void xor_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y, rgb8 * Z) 179 /* -------------------------------------------------------------------------- */ 180 { 181 for (int32_t j = ncl; j <= nch; j++) { 182 RGB8_XOR(X[j], Y[j], Z[j]); 183 } 184 } 185 186 /* ------------------------------------------------------------------------------ */ 187 void xor_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y, rgbx8 * Z) 188 /* ------------------------------------------------------------------------------ */ 189 { 190 for (int32_t j = ncl; j <= nch; j++) { 191 RGBX8_XOR(X[j], Y[j], Z[j]); 192 } 193 } 194 195 196 #undef xorc_type_vector 197 #define xorc_type_vector(t) \ 198 void short_name(t,xorc_,vector)(t * X, int32_t ncl, int32_t nch, t y, t * Z) \ 199 { \ 200 for (int32_t j = ncl; j <= nch; j++) { \ 201 Z[j] = X[j] ^ y; \ 202 } \ 203 } 204 205 xorc_type_vector(int8_t); 206 xorc_type_vector(uint8_t); 207 xorc_type_vector(int16_t); 208 xorc_type_vector(uint16_t); 209 xorc_type_vector(int32_t); 210 xorc_type_vector(uint32_t); 211 xorc_type_vector(int64_t); 212 xorc_type_vector(uint64_t); 213 214 215 /* -------------------------------------------------------------------------- */ 216 void xorc_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 y, rgb8 * Z) 217 /* -------------------------------------------------------------------------- */ 218 { 219 for (int32_t j = ncl; j <= nch; j++) { 220 RGB8_XOR(X[j], y, Z[j]); 221 } 222 } 223 224 /* ------------------------------------------------------------------------------ */ 225 void xorc_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 * Z) 226 /* ------------------------------------------------------------------------------ */ 227 { 228 for (int32_t j = ncl; j <= nch; j++) { 229 RGBX8_XOR(X[j], y, Z[j]); 230 } 231 } 232 233 628 234 /* 629 235 * ----------- … … 631 237 * ----------- 632 238 */ 633 /* ----------------------------------------------------------------------- */ 634 IMAGE_EXPORT(void) and_bvector(byte *X, long ncl, long nch, byte *Y, byte *Z) 635 /* ----------------------------------------------------------------------- */ 636 { 637 long j; 638 639 for(j=ncl; j<=nch; j++) { 640 Z[j] = X[j] & Y[j]; 641 } 642 } 643 /* ---------------------------------------------------------------------------- */ 644 IMAGE_EXPORT(void) and_si8vector(sint8 *X, long ncl, long nch, sint8 *Y, sint8 *Z) 645 /* ---------------------------------------------------------------------------- */ 646 { 647 long j; 648 649 for(j=ncl; j<=nch; j++) { 650 Z[j] = X[j] & Y[j]; 651 } 652 } 653 /* ---------------------------------------------------------------------------- */ 654 IMAGE_EXPORT(void) and_ui8vector(uint8 *X, long ncl, long nch, uint8 *Y, uint8 *Z) 655 /* ---------------------------------------------------------------------------- */ 656 { 657 long j; 658 659 for(j=ncl; j<=nch; j++) { 660 Z[j] = X[j] & Y[j]; 661 } 662 } 663 /* -------------------------------------------------------------------------------- */ 664 IMAGE_EXPORT(void) and_si16vector(sint16 *X, long ncl, long nch, sint16 *Y, sint16 *Z) 665 /* -------------------------------------------------------------------------------- */ 666 { 667 long j; 668 669 for(j=ncl; j<=nch; j++) { 670 Z[j] = X[j] & Y[j]; 671 } 672 } 673 /* -------------------------------------------------------------------------------- */ 674 IMAGE_EXPORT(void) and_ui16vector(uint16 *X, long ncl, long nch, uint16 *Y, uint16 *Z) 675 /* -------------------------------------------------------------------------------- */ 676 { 677 long j; 678 679 for(j=ncl; j<=nch; j++) { 680 Z[j] = X[j] & Y[j]; 681 } 682 } 683 /* -------------------------------------------------------------------------------- */ 684 IMAGE_EXPORT(void) and_si32vector(sint32 *X, long ncl, long nch, sint32 *Y, sint32 *Z) 685 /* -------------------------------------------------------------------------------- */ 686 { 687 long j; 688 689 for(j=ncl; j<=nch; j++) { 690 Z[j] = X[j] & Y[j]; 691 } 692 } 693 /* -------------------------------------------------------------------------------- */ 694 IMAGE_EXPORT(void) and_ui32vector(uint32 *X, long ncl, long nch, uint32 *Y, uint32 *Z) 695 /* -------------------------------------------------------------------------------- */ 696 { 697 long j; 698 699 for(j=ncl; j<=nch; j++) { 700 Z[j] = X[j] & Y[j]; 701 } 702 } 703 /* -------------------------------------------------------------------------------- */ 704 IMAGE_EXPORT(void) and_si64vector(sint64 *X, long ncl, long nch, sint64 *Y, sint64 *Z) 705 /* -------------------------------------------------------------------------------- */ 706 { 707 long j; 708 709 for(j=ncl; j<=nch; j++) { 710 Z[j] = X[j] & Y[j]; 711 } 712 } 713 /* -------------------------------------------------------------------------------- */ 714 IMAGE_EXPORT(void) and_ui64vector(uint64 *X, long ncl, long nch, uint64 *Y, uint64 *Z) 715 /* -------------------------------------------------------------------------------- */ 716 { 717 long j; 718 719 for(j=ncl; j<=nch; j++) { 720 Z[j] = X[j] & Y[j]; 721 } 722 } 723 /* -------------------------------------------------------------------------- */ 724 IMAGE_EXPORT(void) and_rgb8vector(rgb8 *X, long ncl, long nch, rgb8 *Y, rgb8 *Z) 725 /* -------------------------------------------------------------------------- */ 726 { 727 long j; 728 rgb8 x, y, z; 729 730 for(j=ncl; j<=nch; j++) { 731 x = X[j]; 732 y = Y[j]; 733 RGB8_AND(x,y,z); 734 Z[j] = z; 735 } 736 } 737 /* ------------------------------------------------------------------------------ */ 738 IMAGE_EXPORT(void) and_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 *Y, rgbx8 *Z) 739 /* ------------------------------------------------------------------------------ */ 740 { 741 long j; 742 rgbx8 x, y, z; 743 744 for(j=ncl; j<=nch; j++) { 745 x = X[j]; 746 y = Y[j]; 747 RGBX8_AND(x,y,z); 748 Z[j] = z; 749 } 750 } 751 /* ----------------------------------------------------------------------- */ 752 IMAGE_EXPORT(void) andc_bvector(byte *X, long ncl, long nch, byte y, byte *Z) 753 /* ----------------------------------------------------------------------- */ 754 { 755 long j; 756 757 for(j=ncl; j<=nch; j++) { 758 Z[j] = X[j] & y; 759 } 760 } 761 /* ---------------------------------------------------------------------------- */ 762 IMAGE_EXPORT(void) andc_si8vector(sint8 *X, long ncl, long nch, sint8 y, sint8 *Z) 763 /* ---------------------------------------------------------------------------- */ 764 { 765 long j; 766 767 for(j=ncl; j<=nch; j++) { 768 Z[j] = X[j] & y; 769 } 770 } 771 /* ---------------------------------------------------------------------------- */ 772 IMAGE_EXPORT(void) andc_ui8vector(uint8 *X, long ncl, long nch, uint8 y, uint8 *Z) 773 /* ---------------------------------------------------------------------------- */ 774 { 775 long j; 776 777 for(j=ncl; j<=nch; j++) { 778 Z[j] = X[j] & y; 779 } 780 } 781 /* -------------------------------------------------------------------------------- */ 782 IMAGE_EXPORT(void) andc_si16vector(sint16 *X, long ncl, long nch, sint16 y, sint16 *Z) 783 /* -------------------------------------------------------------------------------- */ 784 { 785 long j; 786 787 for(j=ncl; j<=nch; j++) { 788 Z[j] = X[j] & y; 789 } 790 } 791 /* -------------------------------------------------------------------------------- */ 792 IMAGE_EXPORT(void) andc_ui16vector(uint16 *X, long ncl, long nch, uint16 y, uint16 *Z) 793 /* -------------------------------------------------------------------------------- */ 794 { 795 long j; 796 797 for(j=ncl; j<=nch; j++) { 798 Z[j] = X[j] & y; 799 } 800 } 801 /* -------------------------------------------------------------------------------- */ 802 IMAGE_EXPORT(void) andc_si32vector(sint32 *X, long ncl, long nch, sint32 y, sint32 *Z) 803 /* -------------------------------------------------------------------------------- */ 804 { 805 long j; 806 807 for(j=ncl; j<=nch; j++) { 808 Z[j] = X[j] & y; 809 } 810 } 811 /* -------------------------------------------------------------------------------- */ 812 IMAGE_EXPORT(void) andc_ui32vector(uint32 *X, long ncl, long nch, uint32 y, uint32 *Z) 813 /* -------------------------------------------------------------------------------- */ 814 { 815 long j; 816 817 for(j=ncl; j<=nch; j++) { 818 Z[j] = X[j] & y; 819 } 820 } 821 /* -------------------------------------------------------------------------------- */ 822 IMAGE_EXPORT(void) andc_si64vector(sint64 *X, long ncl, long nch, sint64 y, sint64 *Z) 823 /* -------------------------------------------------------------------------------- */ 824 { 825 long j; 826 827 for(j=ncl; j<=nch; j++) { 828 Z[j] = X[j] & y; 829 } 830 } 831 /* -------------------------------------------------------------------------------- */ 832 IMAGE_EXPORT(void) andc_ui64vector(uint64 *X, long ncl, long nch, uint64 y, uint64 *Z) 833 /* -------------------------------------------------------------------------------- */ 834 { 835 long j; 836 837 for(j=ncl; j<=nch; j++) { 838 Z[j] = X[j] & y; 839 } 840 } 841 /* -------------------------------------------------------------------------- */ 842 IMAGE_EXPORT(void) andc_rgb8vector(rgb8 *X, long ncl, long nch, rgb8 y, rgb8 *Z) 843 /* -------------------------------------------------------------------------- */ 844 { 845 long j; 846 rgb8 x, z; 847 848 for(j=ncl; j<=nch; j++) { 849 x = X[j]; 850 RGB8_AND(x,y,z); 851 Z[j] = z; 852 } 853 } 854 /* ------------------------------------------------------------------------------ */ 855 IMAGE_EXPORT(void) andc_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 y, rgbx8 *Z) 856 /* ------------------------------------------------------------------------------ */ 857 { 858 long j; 859 rgbx8 x, z; 860 861 for(j=ncl; j<=nch; j++) { 862 x = X[j]; 863 RGBX8_AND(x,y,z); 864 Z[j] = z; 865 } 866 } 239 240 241 #undef and_type_vector 242 #define and_type_vector(t) \ 243 void short_name(t,and_,vector)(t * X, int32_t ncl, int32_t nch, t * Y, t * Z) \ 244 { \ 245 for (int32_t j = ncl; j <= nch; j++) { \ 246 Z[j] = X[j] & Y[j]; \ 247 } \ 248 } 249 250 and_type_vector(int8_t); 251 and_type_vector(uint8_t); 252 and_type_vector(int16_t); 253 and_type_vector(uint16_t); 254 and_type_vector(int32_t); 255 and_type_vector(uint32_t); 256 and_type_vector(int64_t); 257 and_type_vector(uint64_t); 258 259 260 /* -------------------------------------------------------------------------- */ 261 void and_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y, rgb8 * Z) 262 /* -------------------------------------------------------------------------- */ 263 { 264 for (int32_t j = ncl; j <= nch; j++) { 265 RGB8_AND(X[j], Y[j], Z[j]); 266 } 267 } 268 269 /* ------------------------------------------------------------------------------ */ 270 void and_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y, rgbx8 * Z) 271 /* ------------------------------------------------------------------------------ */ 272 { 273 for (int32_t j = ncl; j <= nch; j++) { 274 RGBX8_AND(X[j], Y[j], Z[j]); 275 } 276 } 277 278 279 #undef andc_type_vector 280 #define andc_type_vector(t) \ 281 void short_name(t,andc_,vector)(t * X, int32_t ncl, int32_t nch, t y, t * Z) \ 282 { \ 283 for (int32_t j = ncl; j <= nch; j++) { \ 284 Z[j] = X[j] ^ y; \ 285 } \ 286 } 287 288 andc_type_vector(int8_t); 289 andc_type_vector(uint8_t); 290 andc_type_vector(int16_t); 291 andc_type_vector(uint16_t); 292 andc_type_vector(int32_t); 293 andc_type_vector(uint32_t); 294 andc_type_vector(int64_t); 295 andc_type_vector(uint64_t); 296 297 298 /* -------------------------------------------------------------------------- */ 299 void andc_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 y, rgb8 * Z) 300 /* -------------------------------------------------------------------------- */ 301 { 302 for (int32_t j = ncl; j <= nch; j++) { 303 RGB8_AND(X[j], y, Z[j]); 304 } 305 } 306 307 /* ------------------------------------------------------------------------------ */ 308 void andc_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 * Z) 309 /* ------------------------------------------------------------------------------ */ 310 { 311 for (int32_t j = ncl; j <= nch; j++) { 312 RGBX8_AND(X[j], y, Z[j]); 313 } 314 } 315 316 317 // Local Variables: 318 // tab-width: 4 319 // c-basic-offset: 4 320 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 321 // indent-tabs-mode: nil 322 // End: 323 324 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 325 -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrbool2.c
r772 r822 16 16 #include <stddef.h> 17 17 #include <stdlib.h> 18 #include <math.h> // fabs 18 #include <math.h> 19 #include <stdbool.h> 19 20 21 #include "nrc_os_config.h" 20 22 #include "mypredef.h" 21 23 #include "nrtype.h" … … 27 29 #include "nrbool2.h" 28 30 29 /* ----------------------------------------------------------------------------------- */ 30 IMAGE_EXPORT(int) cmpeq_bmatrix(byte **X, long nrl,long nrh,long ncl, long nch, byte **Y) 31 /* ----------------------------------------------------------------------------------- */ 32 { 33 int i, j; 34 35 for(i=nrl; i<=nrh; i++) { 36 for(j=ncl; j<=nch; j++) { 37 if(X[i][j] != Y[i][j]) return 1; 38 } 39 } 40 return 0; 31 32 #undef cmpeq_type_matrix 33 #define cmpeq_type_matrix(t) \ 34 int32_t short_name(t,cmpeq_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y) \ 35 { \ 36 for (int32_t i = nrl; i <= nrh; i++) { \ 37 for (int32_t j = ncl; j <= nch; j++) { \ 38 if (X[i][j] != Y[i][j]) { \ 39 return 1; \ 40 } \ 41 } \ 42 } \ 43 return 0; \ 41 44 } 42 /* --------------------------------------------------------------------------------------- */ 43 IMAGE_EXPORT(int) cmpeq_si8matrix(sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 **Y) 44 /* --------------------------------------------------------------------------------------- */ 45 { 46 int i, j; 47 48 for(i=nrl; i<=nrh; i++) { 49 for(j=ncl; j<=nch; j++) { 50 if(X[i][j] != Y[i][j]) return 1; 51 } 52 } 53 return 0; 54 } 55 /* ----------------------------------------------------------------------------------------- */ 56 IMAGE_EXPORT(int) cmpeq_ui8matrix(uint8 **X, long nrl, long nrh, long ncl, long nch, uint8 **Y) 57 /* ----------------------------------------------------------------------------------------- */ 58 { 59 int i, j; 60 61 for(i=nrl; i<=nrh; i++) { 62 for(j=ncl; j<=nch; j++) { 63 if(X[i][j] != Y[i][j]) return 1; 64 } 65 } 66 return 0; 67 } 68 /* -------------------------------------------------------------------------------------------- */ 69 IMAGE_EXPORT(int) cmpeq_si16matrix(sint16 **X, long nrl ,long nrh, long ncl, long nch, sint16 **Y) 70 /* -------------------------------------------------------------------------------------------- */ 71 { 72 int i, j; 73 74 for(i=nrl; i<=nrh; i++) { 75 for(j=ncl; j<=nch; j++) { 76 if(X[i][j] != Y[i][j]) return 1; 77 } 78 } 79 return 0; 80 } 81 /* -------------------------------------------------------------------------------------------- */ 82 IMAGE_EXPORT(int) cmpeq_ui16matrix(uint16 **X, long nrl, long nrh, long ncl, long nch, uint16 **Y) 83 /* -------------------------------------------------------------------------------------------- */ 84 { 85 int i, j; 86 87 for(i=nrl; i<=nrh; i++) { 88 for(j=ncl; j<=nch; j++) { 89 if(X[i][j] != Y[i][j]) return 1; 90 } 91 } 92 return 0; 93 } 94 /* -------------------------------------------------------------------------------------------- */ 95 IMAGE_EXPORT(int) cmpeq_si32matrix(sint32 **X, long nrl, long nrh, long ncl, long nch, sint32 **Y) 96 /* -------------------------------------------------------------------------------------------- */ 97 { 98 int i, j; 99 100 for(i=nrl; i<=nrh; i++) { 101 for(j=ncl; j<=nch; j++) { 102 if(X[i][j] != Y[i][j]) return 1; 103 } 104 } 105 return 0; 106 } 107 /* -------------------------------------------------------------------------------------------- */ 108 IMAGE_EXPORT(int) cmpeq_ui32matrix(uint32 **X, long nrl, long nrh, long ncl, long nch, uint32 **Y) 109 /* -------------------------------------------------------------------------------------------- */ 110 { 111 int i, j; 112 113 for(i=nrl; i<=nrh; i++) { 114 for(j=ncl; j<=nch; j++) { 115 if(X[i][j] != Y[i][j]) return 1; 116 } 117 } 118 return 0; 119 } 45 46 cmpeq_type_matrix(int8_t); 47 cmpeq_type_matrix(uint8_t); 48 cmpeq_type_matrix(int16_t); 49 cmpeq_type_matrix(uint16_t); 50 cmpeq_type_matrix(int32_t); 51 cmpeq_type_matrix(uint32_t); 52 cmpeq_type_matrix(int64_t); 53 cmpeq_type_matrix(uint64_t); 54 55 120 56 121 57 /* … … 125 61 */ 126 62 127 /* ---------------------------------------------------------------------------------- */ 128 IMAGE_EXPORT(void) not_bmatrix(byte **X, long nrl,long nrh,long ncl, long nch, byte **Y) 129 /* ---------------------------------------------------------------------------------- */ 130 { 131 long i; 132 133 for(i=nrl; i<=nrh; i++) { 134 not_bvector(X[i], ncl, nch, Y[i]); 135 } 63 #undef not_type_matrix 64 #define not_type_matrix(t) \ 65 void short_name(t,not_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y) \ 66 { \ 67 for (int32_t i = nrl; i <= nrh; i++) { \ 68 short_name(t,not_,vector)(X[i], ncl, nch, Y[i]); \ 69 } \ 136 70 } 137 /* -------------------------------------------------------------------------------------- */ 138 IMAGE_EXPORT(void) not_si8matrix(sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 **Y) 139 /* -------------------------------------------------------------------------------------- */ 140 { 141 long i; 142 143 for(i=nrl; i<=nrh; i++) { 144 not_si8vector(X[i], ncl, nch, Y[i]); 145 } 146 } 147 /* -------------------------------------------------------------------------------------- */ 148 IMAGE_EXPORT(void) not_ui8matrix(uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 **Y) 149 /* -------------------------------------------------------------------------------------- */ 150 { 151 long i; 152 153 for(i=nrl; i<=nrh; i++) { 154 not_ui8vector(X[i], ncl, nch, Y[i]); 155 } 156 } 157 /* ----------------------------------------------------------------------------------------- */ 158 IMAGE_EXPORT(void) not_si16matrix(sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y) 159 /* ----------------------------------------------------------------------------------------- */ 160 { 161 long i; 162 163 for(i=nrl; i<=nrh; i++) { 164 not_si16vector(X[i], ncl, nch, Y[i]); 165 } 166 } 167 /* ----------------------------------------------------------------------------------------- */ 168 IMAGE_EXPORT(void) not_ui16matrix(uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 **Y) 169 /* ----------------------------------------------------------------------------------------- */ 170 { 171 long i; 172 173 for(i=nrl; i<=nrh; i++) { 174 not_ui16vector(X[i], ncl, nch, Y[i]); 175 } 176 } 177 /* ---------------------------------------------------------------------------------------- */ 178 IMAGE_EXPORT(void) not_si32matrix(int32 **X, long nrl,long nrh,long ncl, long nch, sint32 **Y) 179 /* ---------------------------------------------------------------------------------------- */ 180 { 181 long i; 182 183 for(i=nrl; i<=nrh; i++) { 184 not_si32vector(X[i], ncl, nch, Y[i]); 185 } 186 } 187 /* ----------------------------------------------------------------------------------------- */ 188 IMAGE_EXPORT(void) not_ui32matrix(uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 **Y) 189 /* ----------------------------------------------------------------------------------------- */ 190 { 191 long i; 192 193 for(i=nrl; i<=nrh; i++) { 194 not_ui32vector(X[i], ncl, nch, Y[i]); 195 } 196 } 197 /* --------------------------------------------------------------------------------------- */ 198 IMAGE_EXPORT(void) not_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y) 199 /* --------------------------------------------------------------------------------------- */ 200 { 201 long i; 202 203 for(i=nrl; i<=nrh; i++) { 204 not_rgb8vector(X[i], ncl, nch, Y[i]); 205 } 206 } 207 /* ------------------------------------------------------------------------------------------ */ 208 IMAGE_EXPORT(void) not_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y) 209 /* ------------------------------------------------------------------------------------------ */ 210 { 211 long i; 212 213 for(i=nrl; i<=nrh; i++) { 214 not_rgbx8vector(X[i], ncl, nch, Y[i]); 215 } 216 } 71 72 not_type_matrix(int8_t); 73 not_type_matrix(uint8_t); 74 not_type_matrix(int16_t); 75 not_type_matrix(uint16_t); 76 not_type_matrix(int32_t); 77 not_type_matrix(uint32_t); 78 not_type_matrix(int64_t); 79 not_type_matrix(uint64_t); 80 not_type_matrix(rgb8); 81 not_type_matrix(rgbx8); 82 83 217 84 218 85 /* … … 222 89 */ 223 90 224 /* ------------------------------------------------------------------------------------------- */ 225 IMAGE_EXPORT(void) or_bmatrix(byte **X, long nrl,long nrh,long ncl, long nch, byte **Y, byte **Z) 226 /* ------------------------------------------------------------------------------------------- */ 227 { 228 long i; 229 230 for(i=nrl; i<=nrh; i++) { 231 or_bvector(X[i], ncl, nch, Y[i], Z[i]); 232 } 91 #undef or_type_matrix 92 #define or_type_matrix(t) \ 93 void short_name(t,or_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z) \ 94 { \ 95 for (int32_t i = nrl; i <= nrh; i++) { \ 96 short_name(t,or_,vector)(X[i], ncl, nch, Y[i], Z[i]); \ 97 } \ 98 } \ 99 void short_name(t,orc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) \ 100 { \ 101 for (int32_t i = nrl; i <= nrh; i++) { \ 102 short_name(t,orc_,vector)(X[i], ncl, nch, y, Z[i]); \ 103 } \ 233 104 } 234 /* ------------------------------------------------------------------------------------------------ */235 IMAGE_EXPORT(void) or_si8matrix(sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 **Y, sint8 **Z)236 /* ------------------------------------------------------------------------------------------------ */237 {238 long i;239 240 for(i=nrl; i<=nrh; i++) {241 or_si8vector(X[i], ncl, nch, Y[i], Z[i]);242 }243 }244 /* ------------------------------------------------------------------------------------------------ */245 IMAGE_EXPORT(void) or_ui8matrix(uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 **Y, uint8 **Z)246 /* ------------------------------------------------------------------------------------------------ */247 {248 long i;249 250 for(i=nrl; i<=nrh; i++) {251 or_ui8vector(X[i], ncl, nch, Y[i], Z[i]);252 }253 }254 /* ---------------------------------------------------------------------------------------------------- */255 IMAGE_EXPORT(void) or_si16matrix(sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y, sint16 **Z)256 /* ---------------------------------------------------------------------------------------------------- */257 {258 long i;259 260 for(i=nrl; i<=nrh; i++) {261 or_si16vector(X[i], ncl, nch, Y[i], Z[i]);262 }263 }264 /* ---------------------------------------------------------------------------------------------------- */265 IMAGE_EXPORT(void) or_ui16matrix(uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 **Y, uint16 **Z)266 /* ---------------------------------------------------------------------------------------------------- */267 {268 long i;269 270 for(i=nrl; i<=nrh; i++) {271 or_ui16vector(X[i], ncl, nch, Y[i], Z[i]);272 }273 }274 /* ---------------------------------------------------------------------------------------------------- */275 IMAGE_EXPORT(void) or_si32matrix(sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 **Y, sint32 **Z)276 /* ---------------------------------------------------------------------------------------------------- */277 {278 long i;279 280 for(i=nrl; i<=nrh; i++) {281 or_si32vector(X[i], ncl, nch, Y[i], Z[i]);282 }283 }284 /* ---------------------------------------------------------------------------------------------------- */285 IMAGE_EXPORT(void) or_ui32matrix(uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 **Y, uint32 **Z)286 /* ---------------------------------------------------------------------------------------------------- */287 {288 long i;289 290 for(i=nrl; i<=nrh; i++) {291 or_ui32vector(X[i], ncl, nch, Y[i], Z[i]);292 }293 }294 /* ---------------------------------------------------------------------------------------------------- */295 IMAGE_EXPORT(void) or_si64matrix(sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 **Y, sint64 **Z)296 /* ---------------------------------------------------------------------------------------------------- */297 {298 long i;299 300 for(i=nrl; i<=nrh; i++) {301 or_si64vector(X[i], ncl, nch, Y[i], Z[i]);302 }303 }304 /* ---------------------------------------------------------------------------------------------------- */305 IMAGE_EXPORT(void) or_ui64matrix(uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 **Y, uint64 **Z)306 /* ---------------------------------------------------------------------------------------------------- */307 {308 long i;309 310 for(i=nrl; i<=nrh; i++) {311 or_ui64vector(X[i], ncl, nch, Y[i], Z[i]);312 }313 }314 /* ---------------------------------------------------------------------------------------------- */315 IMAGE_EXPORT(void) or_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y, rgb8 **Z)316 /* ---------------------------------------------------------------------------------------------- */317 {318 long i;319 320 for(i=nrl; i<=nrh; i++) {321 or_rgb8vector(X[i], ncl, nch, Y[i], Z[i]);322 }323 }324 /* -------------------------------------------------------------------------------------------------- */325 IMAGE_EXPORT(void) or_rgb8xmatrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y, rgbx8 **Z)326 /* -------------------------------------------------------------------------------------------------- */327 {328 long i;329 330 for(i=nrl; i<=nrh; i++) {331 or_rgbx8vector(X[i], ncl, nch, Y[i], Z[i]);332 }333 }334 /* ------------------------------------------------------------------------------------------ */335 IMAGE_EXPORT(void) orc_bmatrix(byte **X, long nrl,long nrh,long ncl, long nch, byte y, byte **Z)336 /* ------------------------------------------------------------------------------------------ */337 {338 long i;339 340 for(i=nrl; i<=nrh; i++) {341 orc_bvector(X[i], ncl, nch, y, Z[i]);342 }343 }344 /* ----------------------------------------------------------------------------------------------- */345 IMAGE_EXPORT(void) orc_si8matrix(sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 y, sint8 **Z)346 /* ----------------------------------------------------------------------------------------------- */347 {348 long i;349 350 for(i=nrl; i<=nrh; i++) {351 orc_si8vector(X[i], ncl, nch, y, Z[i]);352 }353 }354 /* ----------------------------------------------------------------------------------------------- */355 IMAGE_EXPORT(void) orc_ui8matrix(uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 y, uint8 **Z)356 /* ----------------------------------------------------------------------------------------------- */357 {358 long i;359 360 for(i=nrl; i<=nrh; i++) {361 orc_ui8vector(X[i], ncl, nch, y, Z[i]);362 }363 }364 /* -------------------------------------------------------------------------------------------------- */365 IMAGE_EXPORT(void) orc_i16matrix(sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 y, sint16 **Z)366 /* -------------------------------------------------------------------------------------------------- */367 {368 long i;369 370 for(i=nrl; i<=nrh; i++) {371 orc_si16vector(X[i], ncl, nch, y, Z[i]);372 }373 }374 /* --------------------------------------------------------------------------------------------------- */375 IMAGE_EXPORT(void) orc_ui16matrix(uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 y, uint16 **Z)376 /* --------------------------------------------------------------------------------------------------- */377 {378 long i;379 380 for(i=nrl; i<=nrh; i++) {381 orc_ui16vector(X[i], ncl, nch, y, Z[i]);382 }383 }384 /* --------------------------------------------------------------------------------------------------- */385 IMAGE_EXPORT(void) orc_si32matrix(sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 y, sint32 **Z)386 /* --------------------------------------------------------------------------------------------------- */387 {388 long i;389 390 for(i=nrl; i<=nrh; i++) {391 orc_si32vector(X[i], ncl, nch, y, Z[i]);392 }393 }394 /* --------------------------------------------------------------------------------------------------- */395 IMAGE_EXPORT(void) orc_ui32matrix(uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 y, uint32 **Z)396 /* --------------------------------------------------------------------------------------------------- */397 {398 long i;399 400 for(i=nrl; i<=nrh; i++) {401 orc_ui32vector(X[i], ncl, nch, y, Z[i]);402 }403 }404 /* --------------------------------------------------------------------------------------------------- */405 IMAGE_EXPORT(void) orc_si64matrix(sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 y, sint64 **Z)406 /* --------------------------------------------------------------------------------------------------- */407 {408 long i;409 410 for(i=nrl; i<=nrh; i++) {411 orc_si64vector(X[i], ncl, nch, y, Z[i]);412 }413 }414 /* --------------------------------------------------------------------------------------------------- */415 IMAGE_EXPORT(void) orc_ui64matrix(uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 y, uint64 **Z)416 105 417 /* --------------------------------------------------------------------------------------------------- */ 418 { 419 long i; 420 421 for(i=nrl; i<=nrh; i++) { 422 orc_ui64vector(X[i], ncl, nch, y, Z[i]); 423 } 424 } 425 /* --------------------------------------------------------------------------------------------- */ 426 IMAGE_EXPORT(void) orc_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 y, rgb8 **Z) 427 /* --------------------------------------------------------------------------------------------- */ 428 { 429 long i; 430 431 for(i=nrl; i<=nrh; i++) { 432 orc_rgb8vector(X[i], ncl, nch, y, Z[i]); 433 } 434 } 435 /* ------------------------------------------------------------------------------------------------- */ 436 IMAGE_EXPORT(void) orc_rgb8xmatrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 y, rgbx8 **Z) 437 /* ------------------------------------------------------------------------------------------------- */ 438 { 439 long i; 440 441 for(i=nrl; i<=nrh; i++) { 442 orc_rgbx8vector(X[i], ncl, nch, y, Z[i]); 443 } 444 } 106 or_type_matrix(int8_t); 107 or_type_matrix(uint8_t); 108 or_type_matrix(int16_t); 109 or_type_matrix(uint16_t); 110 or_type_matrix(int32_t); 111 or_type_matrix(uint32_t); 112 or_type_matrix(int64_t); 113 or_type_matrix(uint64_t); 114 or_type_matrix(rgb8); 115 or_type_matrix(rgbx8); 116 445 117 446 118 /* … … 450 122 */ 451 123 452 /* -------------------------------------------------------------------------------------------- */ 453 IMAGE_EXPORT(void) xor_bmatrix(byte **X, long nrl,long nrh,long ncl, long nch, byte **Y, byte **Z) 454 /* -------------------------------------------------------------------------------------------- */ 455 { 456 long i; 457 458 for(i=nrl; i<=nrh; i++) { 459 xor_bvector(X[i], ncl, nch, Y[i], Z[i]); 460 } 124 #undef xor_type_matrix 125 #define xor_type_matrix(t) \ 126 void short_name(t,xor_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z) \ 127 { \ 128 for (int32_t i = nrl; i <= nrh; i++) { \ 129 short_name(t,xor_,vector)(X[i], ncl, nch, Y[i], Z[i]); \ 130 } \ 131 } \ 132 void short_name(t,xorc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) \ 133 { \ 134 for (int32_t i = nrl; i <= nrh; i++) { \ 135 short_name(t,xorc_,vector)(X[i], ncl, nch, y, Z[i]); \ 136 } \ 461 137 } 462 /* ------------------------------------------------------------------------------------------------- */ 463 IMAGE_EXPORT(void) xor_si8matrix(sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 **Y, sint8 **Z) 464 /* ------------------------------------------------------------------------------------------------- */ 465 { 466 long i; 467 468 for(i=nrl; i<=nrh; i++) { 469 xor_si8vector(X[i], ncl, nch, Y[i], Z[i]); 470 } 471 } 472 /* ------------------------------------------------------------------------------------------------- */ 473 IMAGE_EXPORT(void) xor_ui8matrix(uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 **Y, uint8 **Z) 474 /* ------------------------------------------------------------------------------------------------- */ 475 { 476 long i; 477 478 for(i=nrl; i<=nrh; i++) { 479 xor_ui8vector(X[i], ncl, nch, Y[i], Z[i]); 480 } 481 } 482 /* ----------------------------------------------------------------------------------------------------- */ 483 IMAGE_EXPORT(void) xor_si16matrix(sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y, sint16 **Z) 484 /* ----------------------------------------------------------------------------------------------------- */ 485 { 486 long i; 487 488 for(i=nrl; i<=nrh; i++) { 489 xor_si16vector(X[i], ncl, nch, Y[i], Z[i]); 490 } 491 } 492 /* ----------------------------------------------------------------------------------------------------- */ 493 IMAGE_EXPORT(void) xor_ui16matrix(uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 **Y, uint16 **Z) 494 /* ----------------------------------------------------------------------------------------------------- */ 495 { 496 long i; 497 498 for(i=nrl; i<=nrh; i++) { 499 xor_ui16vector(X[i], ncl, nch, Y[i], Z[i]); 500 } 501 } 502 /* ----------------------------------------------------------------------------------------------------- */ 503 IMAGE_EXPORT(void) xor_si32matrix(sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 **Y, sint32 **Z) 504 /* ----------------------------------------------------------------------------------------------------- */ 505 { 506 long i; 507 508 for(i=nrl; i<=nrh; i++) { 509 xor_si32vector(X[i], ncl, nch, Y[i], Z[i]); 510 } 511 } 512 /* ----------------------------------------------------------------------------------------------------- */ 513 IMAGE_EXPORT(void) xor_ui32matrix(uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 **Y, uint32 **Z) 514 /* ----------------------------------------------------------------------------------------------------- */ 515 { 516 long i; 517 518 for(i=nrl; i<=nrh; i++) { 519 xor_ui32vector(X[i], ncl, nch, Y[i], Z[i]); 520 } 521 } 522 /* ----------------------------------------------------------------------------------------------------- */ 523 IMAGE_EXPORT(void) xor_si64matrix(sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 **Y, sint64 **Z) 524 /* ----------------------------------------------------------------------------------------------------- */ 525 { 526 long i; 527 528 for(i=nrl; i<=nrh; i++) { 529 xor_si64vector(X[i], ncl, nch, Y[i], Z[i]); 530 } 531 } 532 /* ----------------------------------------------------------------------------------------------------- */ 533 IMAGE_EXPORT(void) xor_ui64matrix(uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 **Y, uint64 **Z) 534 /* ----------------------------------------------------------------------------------------------------- */ 535 { 536 long i; 537 538 for(i=nrl; i<=nrh; i++) { 539 xor_ui64vector(X[i], ncl, nch, Y[i], Z[i]); 540 } 541 } 542 /* ----------------------------------------------------------------------------------------------- */ 543 IMAGE_EXPORT(void) xor_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y, rgb8 **Z) 544 /* ----------------------------------------------------------------------------------------------- */ 545 { 546 long i; 547 548 for(i=nrl; i<=nrh; i++) { 549 xor_rgb8vector(X[i], ncl, nch, Y[i], Z[i]); 550 } 551 } 552 /* --------------------------------------------------------------------------------------------------- */ 553 IMAGE_EXPORT(void) xor_rgb8xmatrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y, rgbx8 **Z) 554 /* --------------------------------------------------------------------------------------------------- */ 555 { 556 long i; 557 558 for(i=nrl; i<=nrh; i++) { 559 xor_rgbx8vector(X[i], ncl, nch, Y[i], Z[i]); 560 } 561 } 562 /* ------------------------------------------------------------------------------------------- */ 563 IMAGE_EXPORT(void) xorc_bmatrix(byte **X, long nrl,long nrh,long ncl, long nch, byte y, byte **Z) 564 /* ------------------------------------------------------------------------------------------- */ 565 { 566 long i; 567 568 for(i=nrl; i<=nrh; i++) { 569 xorc_bvector(X[i], ncl, nch, y, Z[i]); 570 } 571 } 572 /* ------------------------------------------------------------------------------------------------ */ 573 IMAGE_EXPORT(void) xorc_si8matrix(sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 y, sint8 **Z) 574 /* ------------------------------------------------------------------------------------------------ */ 575 { 576 long i; 577 578 for(i=nrl; i<=nrh; i++) { 579 xorc_si8vector(X[i], ncl, nch, y, Z[i]); 580 } 581 } 582 /* ------------------------------------------------------------------------------------------------ */ 583 IMAGE_EXPORT(void) xorc_ui8matrix(uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 y, uint8 **Z) 584 /* ------------------------------------------------------------------------------------------------ */ 585 { 586 long i; 587 588 for(i=nrl; i<=nrh; i++) { 589 xorc_ui8vector(X[i], ncl, nch, y, Z[i]); 590 } 591 } 592 /* --------------------------------------------------------------------------------------------------- */ 593 IMAGE_EXPORT(void) xorc_i16matrix(sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 y, sint16 **Z) 594 /* --------------------------------------------------------------------------------------------------- */ 595 { 596 long i; 597 598 for(i=nrl; i<=nrh; i++) { 599 xorc_si16vector(X[i], ncl, nch, y, Z[i]); 600 } 601 } 602 /* ---------------------------------------------------------------------------------------------------- */ 603 IMAGE_EXPORT(void) xorc_ui16matrix(uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 y, uint16 **Z) 604 /* ---------------------------------------------------------------------------------------------------- */ 605 { 606 long i; 607 608 for(i=nrl; i<=nrh; i++) { 609 xorc_ui16vector(X[i], ncl, nch, y, Z[i]); 610 } 611 } 612 /* ---------------------------------------------------------------------------------------------------- */ 613 IMAGE_EXPORT(void) xorc_si32matrix(sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 y, sint32 **Z) 614 /* ---------------------------------------------------------------------------------------------------- */ 615 { 616 long i; 617 618 for(i=nrl; i<=nrh; i++) { 619 xorc_si32vector(X[i], ncl, nch, y, Z[i]); 620 } 621 } 622 /* ---------------------------------------------------------------------------------------------------- */ 623 IMAGE_EXPORT(void) xorc_ui32matrix(uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 y, uint32 **Z) 624 /* ---------------------------------------------------------------------------------------------------- */ 625 { 626 long i; 627 628 for(i=nrl; i<=nrh; i++) { 629 xorc_ui32vector(X[i], ncl, nch, y, Z[i]); 630 } 631 } 632 /* ---------------------------------------------------------------------------------------------------- */ 633 IMAGE_EXPORT(void) xorc_si64matrix(sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 y, sint64 **Z) 634 /* ---------------------------------------------------------------------------------------------------- */ 635 { 636 long i; 637 638 for(i=nrl; i<=nrh; i++) { 639 xorc_si64vector(X[i], ncl, nch, y, Z[i]); 640 } 641 } 642 /* ---------------------------------------------------------------------------------------------------- */ 643 IMAGE_EXPORT(void) xorc_ui64matrix(uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 y, uint64 **Z) 644 /* ---------------------------------------------------------------------------------------------------- */ 645 { 646 long i; 647 648 for(i=nrl; i<=nrh; i++) { 649 xorc_ui64vector(X[i], ncl, nch, y, Z[i]); 650 } 651 } 652 /* ---------------------------------------------------------------------------------------------- */ 653 IMAGE_EXPORT(void) xorc_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 y, rgb8 **Z) 654 /* ---------------------------------------------------------------------------------------------- */ 655 { 656 long i; 657 658 for(i=nrl; i<=nrh; i++) { 659 xorc_rgb8vector(X[i], ncl, nch, y, Z[i]); 660 } 661 } 662 /* -------------------------------------------------------------------------------------------------- */ 663 IMAGE_EXPORT(void) xorc_rgb8xmatrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 y, rgbx8 **Z) 664 /* -------------------------------------------------------------------------------------------------- */ 665 { 666 long i; 667 668 for(i=nrl; i<=nrh; i++) { 669 xorc_rgbx8vector(X[i], ncl, nch, y, Z[i]); 670 } 671 } 138 139 xor_type_matrix(int8_t); 140 xor_type_matrix(uint8_t); 141 xor_type_matrix(int16_t); 142 xor_type_matrix(uint16_t); 143 xor_type_matrix(int32_t); 144 xor_type_matrix(uint32_t); 145 xor_type_matrix(int64_t); 146 xor_type_matrix(uint64_t); 147 xor_type_matrix(rgb8); 148 xor_type_matrix(rgbx8); 672 149 673 150 … … 678 155 */ 679 156 680 /* -------------------------------------------------------------------------------------------- */ 681 IMAGE_EXPORT(void) and_bmatrix(byte **X, long nrl,long nrh,long ncl, long nch, byte **Y, byte **Z) 682 /* -------------------------------------------------------------------------------------------- */ 683 { 684 long i; 685 686 for(i=nrl; i<=nrh; i++) { 687 and_bvector(X[i], ncl, nch, Y[i], Z[i]); 688 } 157 #undef and_type_matrix 158 #define and_type_matrix(t) \ 159 void short_name(t,and_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z) \ 160 { \ 161 for (int32_t i = nrl; i <= nrh; i++) { \ 162 short_name(t,and_,vector)(X[i], ncl, nch, Y[i], Z[i]); \ 163 } \ 164 } \ 165 void short_name(t,andc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) \ 166 { \ 167 for (int32_t i = nrl; i <= nrh; i++) { \ 168 short_name(t,andc_,vector)(X[i], ncl, nch, y, Z[i]); \ 169 } \ 689 170 } 690 /* ------------------------------------------------------------------------------------------------- */ 691 IMAGE_EXPORT(void) and_si8matrix(sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 **Y, sint8 **Z) 692 /* ------------------------------------------------------------------------------------------------- */ 693 { 694 long i; 695 696 for(i=nrl; i<=nrh; i++) { 697 and_si8vector(X[i], ncl, nch, Y[i], Z[i]); 698 } 699 } 700 /* ------------------------------------------------------------------------------------------------- */ 701 IMAGE_EXPORT(void) and_ui8matrix(uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 **Y, uint8 **Z) 702 /* ------------------------------------------------------------------------------------------------- */ 703 { 704 long i; 705 706 for(i=nrl; i<=nrh; i++) { 707 and_ui8vector(X[i], ncl, nch, Y[i], Z[i]); 708 } 709 } 710 /* ----------------------------------------------------------------------------------------------------- */ 711 IMAGE_EXPORT(void) and_si16matrix(sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y, sint16 **Z) 712 /* ----------------------------------------------------------------------------------------------------- */ 713 { 714 long i; 715 716 for(i=nrl; i<=nrh; i++) { 717 and_si16vector(X[i], ncl, nch, Y[i], Z[i]); 718 } 719 } 720 /* ----------------------------------------------------------------------------------------------------- */ 721 IMAGE_EXPORT(void) and_ui16matrix(uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 **Y, uint16 **Z) 722 /* ----------------------------------------------------------------------------------------------------- */ 723 { 724 long i; 725 726 for(i=nrl; i<=nrh; i++) { 727 and_ui16vector(X[i], ncl, nch, Y[i], Z[i]); 728 } 729 } 730 /* ----------------------------------------------------------------------------------------------------- */ 731 IMAGE_EXPORT(void) and_si32matrix(sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 **Y, sint32 **Z) 732 /* ----------------------------------------------------------------------------------------------------- */ 733 { 734 long i; 735 736 for(i=nrl; i<=nrh; i++) { 737 and_si32vector(X[i], ncl, nch, Y[i], Z[i]); 738 } 739 } 740 /* ----------------------------------------------------------------------------------------------------- */ 741 IMAGE_EXPORT(void) and_ui32matrix(uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 **Y, uint32 **Z) 742 /* ----------------------------------------------------------------------------------------------------- */ 743 { 744 long i; 745 746 for(i=nrl; i<=nrh; i++) { 747 and_ui32vector(X[i], ncl, nch, Y[i], Z[i]); 748 } 749 } 750 /* ----------------------------------------------------------------------------------------------------- */ 751 IMAGE_EXPORT(void) and_si64matrix(sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 **Y, sint64 **Z) 752 /* ----------------------------------------------------------------------------------------------------- */ 753 { 754 long i; 755 756 for(i=nrl; i<=nrh; i++) { 757 and_si64vector(X[i], ncl, nch, Y[i], Z[i]); 758 } 759 } 760 /* ----------------------------------------------------------------------------------------------------- */ 761 IMAGE_EXPORT(void) and_ui64matrix(uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 **Y, uint64 **Z) 762 /* ----------------------------------------------------------------------------------------------------- */ 763 { 764 long i; 765 766 for(i=nrl; i<=nrh; i++) { 767 and_ui64vector(X[i], ncl, nch, Y[i], Z[i]); 768 } 769 } 770 /* ----------------------------------------------------------------------------------------------- */ 771 IMAGE_EXPORT(void) and_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y, rgb8 **Z) 772 /* ----------------------------------------------------------------------------------------------- */ 773 { 774 long i; 775 776 for(i=nrl; i<=nrh; i++) { 777 and_rgb8vector(X[i], ncl, nch, Y[i], Z[i]); 778 } 779 } 780 /* --------------------------------------------------------------------------------------------------- */ 781 IMAGE_EXPORT(void) and_rgb8xmatrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y, rgbx8 **Z) 782 /* --------------------------------------------------------------------------------------------------- */ 783 { 784 long i; 785 786 for(i=nrl; i<=nrh; i++) { 787 and_rgbx8vector(X[i], ncl, nch, Y[i], Z[i]); 788 } 789 } 790 /* ------------------------------------------------------------------------------------------- */ 791 IMAGE_EXPORT(void) andc_bmatrix(byte **X, long nrl,long nrh,long ncl, long nch, byte y, byte **Z) 792 /* ------------------------------------------------------------------------------------------- */ 793 { 794 long i; 795 796 for(i=nrl; i<=nrh; i++) { 797 andc_bvector(X[i], ncl, nch, y, Z[i]); 798 } 799 } 800 /* ------------------------------------------------------------------------------------------------ */ 801 IMAGE_EXPORT(void) andc_si8matrix(sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 y, sint8 **Z) 802 /* ------------------------------------------------------------------------------------------------ */ 803 { 804 long i; 805 806 for(i=nrl; i<=nrh; i++) { 807 andc_si8vector(X[i], ncl, nch, y, Z[i]); 808 } 809 } 810 /* ------------------------------------------------------------------------------------------------ */ 811 IMAGE_EXPORT(void) andc_ui8matrix(uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 y, uint8 **Z) 812 /* ------------------------------------------------------------------------------------------------ */ 813 { 814 long i; 815 816 for(i=nrl; i<=nrh; i++) { 817 andc_ui8vector(X[i], ncl, nch, y, Z[i]); 818 } 819 } 820 /* --------------------------------------------------------------------------------------------------- */ 821 IMAGE_EXPORT(void) andc_i16matrix(sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 y, sint16 **Z) 822 /* --------------------------------------------------------------------------------------------------- */ 823 { 824 long i; 825 826 for(i=nrl; i<=nrh; i++) { 827 andc_si16vector(X[i], ncl, nch, y, Z[i]); 828 } 829 } 830 /* ---------------------------------------------------------------------------------------------------- */ 831 IMAGE_EXPORT(void) andc_ui16matrix(uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 y, uint16 **Z) 832 /* ---------------------------------------------------------------------------------------------------- */ 833 { 834 long i; 835 836 for(i=nrl; i<=nrh; i++) { 837 andc_ui16vector(X[i], ncl, nch, y, Z[i]); 838 } 839 } 840 /* ---------------------------------------------------------------------------------------------------- */ 841 IMAGE_EXPORT(void) andc_si32matrix(sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 y, sint32 **Z) 842 /* ---------------------------------------------------------------------------------------------------- */ 843 { 844 long i; 845 846 for(i=nrl; i<=nrh; i++) { 847 andc_si32vector(X[i], ncl, nch, y, Z[i]); 848 } 849 } 850 /* ---------------------------------------------------------------------------------------------------- */ 851 IMAGE_EXPORT(void) andc_ui32matrix(uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 y, uint32 **Z) 852 /* ---------------------------------------------------------------------------------------------------- */ 853 { 854 long i; 855 856 for(i=nrl; i<=nrh; i++) { 857 andc_ui32vector(X[i], ncl, nch, y, Z[i]); 858 } 859 } 860 /* ---------------------------------------------------------------------------------------------------- */ 861 IMAGE_EXPORT(void) andc_si64matrix(sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 y, sint64 **Z) 862 /* ---------------------------------------------------------------------------------------------------- */ 863 { 864 long i; 865 866 for(i=nrl; i<=nrh; i++) { 867 andc_si64vector(X[i], ncl, nch, y, Z[i]); 868 } 869 } 870 /* ---------------------------------------------------------------------------------------------------- */ 871 IMAGE_EXPORT(void) andc_ui64matrix(uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 y, uint64 **Z) 872 /* ---------------------------------------------------------------------------------------------------- */ 873 { 874 long i; 875 876 for(i=nrl; i<=nrh; i++) { 877 andc_ui64vector(X[i], ncl, nch, y, Z[i]); 878 } 879 } 880 /* ---------------------------------------------------------------------------------------------- */ 881 IMAGE_EXPORT(void) andc_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 y, rgb8 **Z) 882 /* ---------------------------------------------------------------------------------------------- */ 883 { 884 long i; 885 886 for(i=nrl; i<=nrh; i++) { 887 andc_rgb8vector(X[i], ncl, nch, y, Z[i]); 888 } 889 } 890 /* -------------------------------------------------------------------------------------------------- */ 891 IMAGE_EXPORT(void) andc_rgb8xmatrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 y, rgbx8 **Z) 892 /* -------------------------------------------------------------------------------------------------- */ 893 { 894 long i; 895 896 for(i=nrl; i<=nrh; i++) { 897 andc_rgbx8vector(X[i], ncl, nch, y, Z[i]); 898 } 899 } 171 172 and_type_matrix(int8_t); 173 and_type_matrix(uint8_t); 174 and_type_matrix(int16_t); 175 and_type_matrix(uint16_t); 176 and_type_matrix(int32_t); 177 and_type_matrix(uint32_t); 178 and_type_matrix(int64_t); 179 and_type_matrix(uint64_t); 180 and_type_matrix(rgb8); 181 and_type_matrix(rgbx8); 182 183 184 // Local Variables: 185 // tab-width: 4 186 // c-basic-offset: 4 187 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 188 // indent-tabs-mode: nil 189 // End: 190 191 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 192 -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrio0.c
r777 r822 26 26 27 27 /* --------------------------------------------------------------------------------------------------- */ 28 IMAGE_EXPORT(void) generate_filename_k_ndigit(char *filename, int k, int ndigit, char *complete_filename, int maxlen)28 void generate_filename_k_ndigit(char * filename, int k, int ndigit, char * complete_filename, int maxlen) 29 29 /* --------------------------------------------------------------------------------------------------- */ 30 30 { 31 char *format = "%s%d.txt";31 char * format = "%s%d.txt"; 32 32 33 switch(ndigit) {34 case 0 : format = "%s%d.txt"; break;35 case 1 : format = "%s%01d.txt"; break;36 case 2 : format = "%s%02d.txt"; break;37 case 3 : format = "%s%03d.txt"; break;38 case 4 : format = "%s%04d.txt"; break;39 case 5 : format = "%s%05d.txt"; break;40 case 6 : format = "%s%06d.txt"; break;41 case 7 : format = "%s%07d.txt"; break;42 case 8 : format = "%s%08d.txt"; break;43 case 9 : format = "%s%09d.txt"; break;44 }45 snprintf(complete_filename, maxlen, format, filename, k);33 switch (ndigit) { 34 case 0 : format = "%s%d.txt"; break; 35 case 1 : format = "%s%01d.txt"; break; 36 case 2 : format = "%s%02d.txt"; break; 37 case 3 : format = "%s%03d.txt"; break; 38 case 4 : format = "%s%04d.txt"; break; 39 case 5 : format = "%s%05d.txt"; break; 40 case 6 : format = "%s%06d.txt"; break; 41 case 7 : format = "%s%07d.txt"; break; 42 case 8 : format = "%s%08d.txt"; break; 43 case 9 : format = "%s%09d.txt"; break; 44 } 45 snprintf(complete_filename, maxlen, format, filename, k); 46 46 } 47 47 /* ------------------------------------------------------------------------------------------------------------------------------------------ */ 48 IMAGE_EXPORT(void) generate_filename_k_ndigit_extension(char *filename, int k, int ndigit, char *extension, char *complete_filename, int maxlen)48 void generate_filename_k_ndigit_extension(char * filename, int k, int ndigit, char * extension, char * complete_filename, int maxlen) 49 49 /* ------------------------------------------------------------------------------------------------------------------------------------------ */ 50 50 { 51 char *format = "%s%d.%s";51 char * format = "%s%d.%s"; 52 52 53 switch(ndigit) {54 case 0 : format = "%s%d.%s"; break;55 case 1 : format = "%s%01d.%s"; break;56 case 2 : format = "%s%02d.%s"; break;57 case 3 : format = "%s%03d.%s"; break;58 case 4 : format = "%s%04d.%s"; break;59 case 5 : format = "%s%05d.%s"; break;60 case 6 : format = "%s%06d.%s"; break;61 case 7 : format = "%s%07d.%s"; break;62 case 8 : format = "%s%08d.%s"; break;63 case 9 : format = "%s%09d.%s"; break;64 }65 snprintf(complete_filename, maxlen, format, filename, k, extension);53 switch (ndigit) { 54 case 0 : format = "%s%d.%s"; break; 55 case 1 : format = "%s%01d.%s"; break; 56 case 2 : format = "%s%02d.%s"; break; 57 case 3 : format = "%s%03d.%s"; break; 58 case 4 : format = "%s%04d.%s"; break; 59 case 5 : format = "%s%05d.%s"; break; 60 case 6 : format = "%s%06d.%s"; break; 61 case 7 : format = "%s%07d.%s"; break; 62 case 8 : format = "%s%08d.%s"; break; 63 case 9 : format = "%s%09d.%s"; break; 64 } 65 snprintf(complete_filename, maxlen, format, filename, k, extension); 66 66 } 67 68 67 69 /* ---------------------------------------------------------------------------------------------------- */ 68 IMAGE_EXPORT(void) generate_path_filename(char *path, char *filename, char *complete_filename, int maxlen)70 void generate_path_filename(char * path, char * filename, char * complete_filename, int maxlen) 69 71 /* ---------------------------------------------------------------------------------------------------- */ 70 72 { 71 snprintf(complete_filename, maxlen, "%s%s", path, filename);73 snprintf(complete_filename, maxlen, "%s%s", path, filename); 72 74 } 75 76 73 77 /* ------------------------------------------------------------------------------------------------------------------------------- */ 74 IMAGE_EXPORT(void) generate_path_filename_extension(char *path, char *filename, char *extension, char *complete_filename, int maxlen)78 void generate_path_filename_extension(char * path, char * filename, char * extension, char * complete_filename, int maxlen) 75 79 /* ------------------------------------------------------------------------------------------------------------------------------- */ 76 80 { 77 snprintf(complete_filename, maxlen, "%s%s.%s", path, filename, extension);81 snprintf(complete_filename, maxlen, "%s%s.%s", path, filename, extension); 78 82 } 83 84 79 85 /* ---------------------------------------------------------------------------------------------------------------------------------------------------- */ 80 IMAGE_EXPORT(void) generate_path_filename_suffix_extension(char *path, char *filename, char *suffix, char *extension, char *complete_filename, int maxlen)86 void generate_path_filename_suffix_extension(char * path, char * filename, char * suffix, char * extension, char * complete_filename, int maxlen) 81 87 /* ---------------------------------------------------------------------------------------------------------------------------------------------------- */ 82 88 { 83 89 snprintf(complete_filename, maxlen, "%s%s%s.%s", path, filename, suffix, extension); 84 90 } 91 92 85 93 /* ----------------------------------------------------------------------------------------------------------------------------------------------------------- */ 86 IMAGE_EXPORT(void) generate_path_filename_k_ndigit_extension(char *path, char *filename, int k, int ndigit, char *extension, char *complete_filename, int maxlen)94 void generate_path_filename_k_ndigit_extension(char * path, char * filename, int k, int ndigit, char * extension, char * complete_filename, int maxlen) 87 95 /* ----------------------------------------------------------------------------------------------------------------------------------------------------------- */ 88 96 { 89 char *format = "%s%s%d.%s";97 char * format = "%s%s%d.%s"; 90 98 91 switch(ndigit) {92 case 0 : format = "%s%s%d.%s"; break;93 case 1 : format = "%s%s%01d.%s"; break;94 case 2 : format = "%s%s%02d.%s"; break;95 case 3 : format = "%s%s%03d.%s"; break;96 case 4 : format = "%s%s%04d.%s"; break;97 case 5 : format = "%s%s%05d.%s"; break;98 case 6 : format = "%s%s%06d.%s"; break;99 case 7 : format = "%s%s%07d.%s"; break;100 case 8 : format = "%s%s%08d.%s"; break;101 case 9 : format = "%s%s%09d.%s"; break;102 }103 snprintf(complete_filename, maxlen, format, path, filename, k, extension);99 switch(ndigit) { 100 case 0 : format = "%s%s%d.%s"; break; 101 case 1 : format = "%s%s%01d.%s"; break; 102 case 2 : format = "%s%s%02d.%s"; break; 103 case 3 : format = "%s%s%03d.%s"; break; 104 case 4 : format = "%s%s%04d.%s"; break; 105 case 5 : format = "%s%s%05d.%s"; break; 106 case 6 : format = "%s%s%06d.%s"; break; 107 case 7 : format = "%s%s%07d.%s"; break; 108 case 8 : format = "%s%s%08d.%s"; break; 109 case 9 : format = "%s%s%09d.%s"; break; 110 } 111 snprintf(complete_filename, maxlen, format, path, filename, k, extension); 104 112 } 113 114 105 115 /* -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */ 106 IMAGE_EXPORT(void) generate_path_filename_k_ndigit_l_extension(char *path, char *filename, int k, int ndigit, int l, char *extension, char *complete_filename, int maxlen)116 void generate_path_filename_k_ndigit_l_extension(char * path, char * filename, int k, int ndigit, int l, char * extension, char * complete_filename, int maxlen) 107 117 /* -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */ 108 118 { 109 char *format = "%s%s%d_%d.%s";119 char * format = "%s%s%d_%d.%s"; 110 120 111 switch(ndigit) {112 case 0 : format = "%s%s%d_%d.%s";break;113 case 1 : format = "%s%s%01d_%01d.%s"; break;114 case 2 : format = "%s%s%02d_%02d.%s"; break;115 case 3 : format = "%s%s%03d_%03d.%s"; break;116 case 4 : format = "%s%s%04d_%04d.%s"; break;117 case 5 : format = "%s%s%05d_%05d.%s"; break;118 case 6 : format = "%s%s%06d_%06d.%s"; break;119 case 7 : format = "%s%s%07d_%07d.%s"; break;120 case 8 : format = "%s%s%08d_%08d.%s"; break;121 case 9 : format = "%s%s%09d_%09d.%s"; break;122 }123 snprintf(complete_filename, maxlen, format, path, filename, k, l, extension);121 switch (ndigit) { 122 case 0 : format = "%s%s%d_%d.%s"; break; 123 case 1 : format = "%s%s%01d_%01d.%s"; break; 124 case 2 : format = "%s%s%02d_%02d.%s"; break; 125 case 3 : format = "%s%s%03d_%03d.%s"; break; 126 case 4 : format = "%s%s%04d_%04d.%s"; break; 127 case 5 : format = "%s%s%05d_%05d.%s"; break; 128 case 6 : format = "%s%s%06d_%06d.%s"; break; 129 case 7 : format = "%s%s%07d_%07d.%s"; break; 130 case 8 : format = "%s%s%08d_%08d.%s"; break; 131 case 9 : format = "%s%s%09d_%09d.%s"; break; 132 } 133 snprintf(complete_filename, maxlen, format, path, filename, k, l, extension); 124 134 } 125 // ---------------------------------------------------------------------------- 126 void select_display_positive_parameters(int iformat, char **format, char **str) 127 // ---------------------------------------------------------------------------- 135 136 137 // ------------------------------------------------------------------------------ 138 void select_display_positive_parameters(int iformat, char ** format, char ** str) 139 // ------------------------------------------------------------------------------ 128 140 { 129 char * format1 = "%1d", *str1 = " ";130 char * format2 = "%2d", *str2 = " ";131 char * format3 = "%3d", *str3 = " ";132 char * format4 = "%4d", *str4 = " ";133 char * format5 = "%5d", *str5 = " ";134 char * format6 = "%6d", *str6 = " ";135 char * format7 = "%7d", *str7 = " ";136 char * format8 = "%8d", *str8 = " ";137 char * format9 = "%9d", *str9 = " ";138 139 switch (iformat) {141 char * format1 = "%1d", * str1 = " "; 142 char * format2 = "%2d", * str2 = " "; 143 char * format3 = "%3d", * str3 = " "; 144 char * format4 = "%4d", * str4 = " "; 145 char * format5 = "%5d", * str5 = " "; 146 char * format6 = "%6d", * str6 = " "; 147 char * format7 = "%7d", * str7 = " "; 148 char * format8 = "%8d", * str8 = " "; 149 char * format9 = "%9d", * str9 = " "; 150 151 switch (iformat) { 140 152 case 1: *format = format1; *str = str1; break; 141 153 case 2: *format = format2; *str = str2; break; … … 150 162 } 151 163 } 164 165 // Local Variables: 166 // tab-width: 4 167 // c-basic-offset: 4 168 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 169 // indent-tabs-mode: nil 170 // End: 171 172 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 173 -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrio1.c
r805 r822 33 33 */ 34 34 35 /* ------------------------------------------------------------------------------- */ 36 IMAGE_EXPORT(void) display_bvector(byte *v,long nl,long nh, char *format, char *name) 37 /* ------------------------------------------------------------------------------- */ 38 { 39 long i; 40 41 if(name != NULL) printf("%s", name); 42 43 for(i=nl; i<=nh; i++) { 44 printf(format, v[i]); 45 } 46 printf("\n"); 47 } 48 /* ---------------------------------------------------------------------------------- */ 49 IMAGE_EXPORT(void) display_si8vector(sint8 *v,long nl,long nh, char *format, char *name) 50 /* ---------------------------------------------------------------------------------- */ 51 { 52 long i; 53 54 if(name != NULL) printf("%s", name); 55 56 for(i=nl; i<=nh; i++) { 57 printf(format, v[i]); 58 } 59 printf("\n"); 60 } 61 /* ---------------------------------------------------------------------------------- */ 62 IMAGE_EXPORT(void) display_ui8vector(uint8 *v,long nl,long nh, char *format, char *name) 63 /* ---------------------------------------------------------------------------------- */ 64 { 65 long i; 66 67 if(name != NULL) printf("%s", name); 68 69 for(i=nl; i<=nh; i++) { 70 printf(format, v[i]); 71 } 72 printf("\n"); 73 } 74 /* ------------------------------------------------------------------------------------ */ 75 IMAGE_EXPORT(void) display_si16vector(sint16 *v,long nl,long nh, char *format, char *name) 76 /* ------------------------------------------------------------------------------------ */ 77 { 78 long i; 79 80 if(name != NULL) printf("%s", name); 81 82 for(i=nl; i<=nh; i++) { 83 printf(format, v[i]); 84 } 85 printf("\n"); 86 } 87 /* ------------------------------------------------------------------------------------- */ 88 IMAGE_EXPORT(void) display_ui16vector(uint16 *v,long nl,long nh, char *format, char *name) 89 /* ------------------------------------------------------------------------------------- */ 90 { 91 long i; 92 93 if(name != NULL) printf("%s", name); 94 95 for(i=nl; i<=nh; i++) { 96 printf(format, v[i]); 97 } 98 printf("\n"); 99 } 100 /* ------------------------------------------------------------------------------------ */ 101 IMAGE_EXPORT(void) display_si32vector(sint32 *v,long nl,long nh, char *format, char *name) 102 /* ------------------------------------------------------------------------------------ */ 103 { 104 long i; 105 106 if(name != NULL) printf("%s", name); 107 108 for(i=nl; i<=nh; i++) { 109 printf(format, v[i]); 110 } 111 printf("\n"); 112 } 113 /* ------------------------------------------------------------------------------------ */ 114 IMAGE_EXPORT(void) display_ui32vector(uint32 *v,long nl,long nh, char *format, char *name) 115 /* ------------------------------------------------------------------------------------ */ 116 { 117 long i; 118 119 if(name != NULL) printf("%s", name); 120 121 for(i=nl; i<=nh; i++) { 122 printf(format, v[i]); 123 } 124 printf("\n"); 125 } 126 /* ------------------------------------------------------------------------------------ */ 127 IMAGE_EXPORT(void) display_si64vector(sint64 *v,long nl,long nh, char *format, char *name) 128 /* ------------------------------------------------------------------------------------ */ 129 { 130 long i; 131 132 if(name != NULL) printf("%s", name); 133 134 for(i=nl; i<=nh; i++) { 135 printf(format, v[i]); 136 } 137 printf("\n"); 138 } 139 /* ------------------------------------------------------------------------------------ */ 140 IMAGE_EXPORT(void) display_ui64vector(uint64 *v,long nl,long nh, char *format, char *name) 141 /* ------------------------------------------------------------------------------------ */ 142 { 143 long i; 144 145 if(name != NULL) printf("%s", name); 146 147 for(i=nl; i<=nh; i++) { 148 printf(format, v[i]); 149 } 150 printf("\n"); 151 } 152 /* ------------------------------------------------------------------------------------ */ 153 IMAGE_EXPORT(void) display_f32vector(float32 *v,long nl,long nh, char *format, char *name) 154 /* ------------------------------------------------------------------------------------ */ 155 { 156 long i; 157 158 if(name != NULL) printf("%s", name); 159 160 for(i=nl; i<=nh; i++) { 161 printf(format, v[i]); 162 } 163 printf("\n"); 164 } 165 /* ------------------------------------------------------------------------------------ */ 166 IMAGE_EXPORT(void) display_f64vector(float64 *v,long nl,long nh, char *format, char *name) 167 /* ------------------------------------------------------------------------------------ */ 168 { 169 long i; 170 171 if(name != NULL) printf("%s", name); 172 173 for(i=nl; i<=nh; i++) { 174 printf(format, v[i]); 175 } 176 printf("\n"); 177 } 178 /* ---------------------------------------------------------------------------------- */ 179 IMAGE_EXPORT(void) display_rgb8vector(rgb8 *v,long nl,long nh, char *format, char *name) 180 /* ---------------------------------------------------------------------------------- */ 181 { 182 long i; 183 184 if(name != NULL) printf("%s", name); 185 186 for(i=nl; i<=nh; i++) { 187 printf(format, v[i]); 188 } 189 printf("\n"); 190 } 191 /* ------------------------------------------------------------------------------------ */ 192 IMAGE_EXPORT(void) display_rgbx8vector(rgbx8 *v,long nl,long nh, char *format, char *name) 193 /* ------------------------------------------------------------------------------------ */ 194 { 195 long i; 196 197 if(name != NULL) printf("%s", name); 198 199 for(i=nl; i<=nh; i++) { 200 printf(format, v[i]); 201 } 202 printf("\n"); 203 } 35 #undef display_type_vector 36 #define display_type_vector(t) \ 37 void short_name(t,display_,vector)(t * v, int32_t nl, int32_t nh, char * format, char * name) \ 38 { \ 39 if (name != NULL) { \ 40 printf("%s", name); \ 41 } \ 42 for (int32_t i = nl; i <= nh; i++) { \ 43 printf(format, v[i]); \ 44 } \ 45 printf("\n"); \ 46 } 47 48 display_type_vector(int8_t); 49 display_type_vector(uint8_t); 50 display_type_vector(int16_t); 51 display_type_vector(uint16_t); 52 display_type_vector(int32_t); 53 display_type_vector(uint32_t); 54 display_type_vector(int64_t); 55 display_type_vector(uint64_t); 56 display_type_vector(float); 57 display_type_vector(double); 58 display_type_vector(rgb8); 59 display_type_vector(rgbx8); 60 204 61 205 62 /* … … 209 66 */ 210 67 211 /* -------------------------------------------------------------------------------------- */ 212 IMAGE_EXPORT(void) display_bvector_number(byte *v,long nl,long nh, char *format, char *name) 213 /* -------------------------------------------------------------------------------------- */ 214 { 215 long i; 216 217 if(name != NULL) printf("%s\n", name); 218 219 for(i=nl; i<=nh; i++) { 220 printf(format, i); 221 } 222 printf("\n"); 223 224 for(i=nl; i<=nh; i++) { 225 printf(format, v[i]); 226 } 227 printf("\n"); 228 } 229 /* ----------------------------------------------------------------------------------------- */ 230 IMAGE_EXPORT(void) display_si8vector_number(sint8 *v,long nl,long nh, char *format, char *name) 231 /* ----------------------------------------------------------------------------------------- */ 232 { 233 long i; 234 235 if(name != NULL) printf(name); 236 for(i=nl; i<=nh; i++) { 237 printf(format, i); 238 } 239 printf("\n"); 240 241 for(i=nl; i<=nh; i++) { 242 printf(format, v[i]); 243 } 244 printf("\n"); 245 } 246 /* ----------------------------------------------------------------------------------------- */ 247 IMAGE_EXPORT(void) display_ui8vector_number(uint8 *v,long nl,long nh, char *format, char *name) 248 /* ----------------------------------------------------------------------------------------- */ 249 { 250 long i; 251 252 if(name != NULL) printf(name); 253 for(i=nl; i<=nh; i++) { 254 printf(format, i); 255 } 256 printf("\n"); 257 258 for(i=nl; i<=nh; i++) { 259 printf(format, v[i]); 260 } 261 printf("\n"); 262 } 263 /* ------------------------------------------------------------------------------------------- */ 264 IMAGE_EXPORT(void) display_si16vector_number(sint16 *v,long nl,long nh, char *format, char *name) 265 /* ------------------------------------------------------------------------------------------- */ 266 { 267 long i; 268 269 if(name != NULL) printf(name); 270 for(i=nl; i<=nh; i++) { 271 printf(format, i); 272 } 273 printf("\n"); 274 275 for(i=nl; i<=nh; i++) { 276 printf(format, v[i]); 277 } 278 printf("\n"); 279 } 280 /* ------------------------------------------------------------------------------------------- */ 281 IMAGE_EXPORT(void) display_ui16vector_number(uint16 *v,long nl,long nh, char *format, char *name) 282 /* ------------------------------------------------------------------------------------------- */ 283 { 284 long i; 285 286 if(name != NULL) printf(name); 287 for(i=nl; i<=nh; i++) { 288 printf(format, i); 289 } 290 printf("\n"); 291 292 for(i=nl; i<=nh; i++) { 293 printf(format, v[i]); 294 } 295 printf("\n"); 296 } 297 /* ------------------------------------------------------------------------------------------- */ 298 IMAGE_EXPORT(void) display_si32vector_number(sint32 *v,long nl,long nh, char *format, char *name) 299 /* ------------------------------------------------------------------------------------------- */ 300 { 301 long i; 302 303 if(name != NULL) printf("%s\n", name); 304 305 for(i=nl; i<=nh; i++) { 306 printf(format, i); 307 } 308 printf("\n"); 309 310 for(i=nl; i<=nh; i++) { 311 printf(format, v[i]); 312 } 313 printf("\n"); 314 } 315 /* ------------------------------------------------------------------------------------------- */ 316 IMAGE_EXPORT(void) display_ui32vector_number(uint32 *v,long nl,long nh, char *format, char *name) 317 /* ------------------------------------------------------------------------------------------- */ 318 { 319 long i; 320 321 if(name != NULL) printf("%s\n", name); 322 323 for(i=nl; i<=nh; i++) { 324 printf(format, i); 325 printf(" "); 326 } 327 printf("\n"); 328 329 for(i=nl; i<=nh; i++) { 330 printf(format, v[i]); 331 printf(" "); 332 } 333 printf("\n"); 334 } 335 /* ------------------------------------------------------------------------------------------- */ 336 IMAGE_EXPORT(void) display_si64vector_number(sint64 *v,long nl,long nh, char *format, char *name) 337 /* ------------------------------------------------------------------------------------------- */ 338 { 339 long i; 340 341 if(name != NULL) printf("%s\n", name); 342 343 for(i=nl; i<=nh; i++) { 344 printf(format, i); 345 } 346 printf("\n"); 347 348 for(i=nl; i<=nh; i++) { 349 printf(format, v[i]); 350 } 351 printf("\n"); 352 } 353 /* ------------------------------------------------------------------------------------------- */ 354 IMAGE_EXPORT(void) display_ui64vector_number(uint64 *v,long nl,long nh, char *format, char *name) 355 /* ------------------------------------------------------------------------------------------- */ 356 { 357 long i; 358 359 if(name != NULL) printf("%s\n", name); 360 361 for(i=nl; i<=nh; i++) { 362 printf(format, i); 363 } 364 printf("\n"); 365 366 for(i=nl; i<=nh; i++) { 367 printf(format, v[i]); 368 } 369 printf("\n"); 370 } 371 /* ------------------------------------------------------------------------------------------- */ 372 IMAGE_EXPORT(void) display_f32vector_number(float32 *v,long nl,long nh, char *format, char *name) 373 /* ------------------------------------------------------------------------------------------- */ 374 { 375 long i; 376 377 if(name != NULL) printf("%s\n", name); 378 379 for(i=nl; i<=nh; i++) { 380 printf(format, i); 381 } 382 printf("\n"); 383 384 for(i=nl; i<=nh; i++) { 385 printf(format, v[i]); 386 } 387 printf("\n"); 388 } 389 /* ------------------------------------------------------------------------------------------- */ 390 IMAGE_EXPORT(void) display_f64vector_number(float64 *v,long nl,long nh, char *format, char *name) 391 /* ------------------------------------------------------------------------------------------- */ 392 { 393 long i; 394 395 if(name != NULL) printf("%s\n", name); 396 397 for(i=nl; i<=nh; i++) { 398 printf(format, i); 399 } 400 printf("\n"); 401 402 for(i=nl; i<=nh; i++) { 403 printf(format, v[i]); 404 } 405 printf("\n"); 406 } 407 /* ----------------------------------------------------------------------------------------- */ 408 IMAGE_EXPORT(void) display_rgb8vector_number(rgb8 *v,long nl,long nh, char *format, char *name) 409 /* ----------------------------------------------------------------------------------------- */ 410 { 411 long i; 412 413 if(name != NULL) printf("%s\n", name); 414 415 for(i=nl; i<=nh; i++) { 416 printf(format, i); 417 } 418 printf("\n"); 419 420 for(i=nl; i<=nh; i++) { 421 printf(format, v[i]); 422 } 423 printf("\n"); 424 } 425 /* ------------------------------------------------------------------------------------------- */ 426 IMAGE_EXPORT(void) display_rgbx8vector_number(rgbx8 *v,long nl,long nh, char *format, char *name) 427 /* ------------------------------------------------------------------------------------------- */ 428 { 429 long i; 430 431 if(name != NULL) printf("%s\n", name); 432 433 for(i=nl; i<=nh; i++) { 434 printf(format, i); 435 } 436 printf("\n"); 437 438 for(i=nl; i<=nh; i++) { 439 printf(format, v[i]); 440 } 441 printf("\n"); 442 } 68 #undef display_type_vector_number 69 #define display_type_vector_number(t) \ 70 void short_name(t,display_,vector_number)(t * v, int32_t nl, int32_t nh, char * format, char * name) \ 71 { \ 72 if (name != NULL) { \ 73 printf("%s\n", name); \ 74 } \ 75 for (int32_t i = nl; i <= nh; i++) { \ 76 printf(format, i); \ 77 } \ 78 printf("\n"); \ 79 for (int32_t i = nl; i <= nh; i++) { \ 80 printf(format, v[i]); \ 81 } \ 82 printf("\n"); \ 83 } 84 85 86 display_type_vector_number(int8_t); 87 display_type_vector_number(uint8_t); 88 display_type_vector_number(int16_t); 89 display_type_vector_number(uint16_t); 90 display_type_vector_number(int32_t); 91 display_type_vector_number(uint32_t); 92 display_type_vector_number(int64_t); 93 display_type_vector_number(uint64_t); 94 display_type_vector_number(float); 95 display_type_vector_number(double); 96 display_type_vector_number(rgb8); 97 display_type_vector_number(rgbx8); 98 99 443 100 /* 444 101 * ------------------------ … … 447 104 */ 448 105 449 /* ----------------------------------------------------------------------------------- */ 450 IMAGE_EXPORT(void) display_si8vector_T(sint8 *v,int i0, int i1, char *format, char *name) 451 /* ----------------------------------------------------------------------------------- */ 452 { 453 int i; 454 455 if(name != NULL) printf(name); 456 457 for(i=i0; i<=i1; i++) { 458 printf(format, v[i]); 459 printf("\n"); 460 } 461 } 462 /* ----------------------------------------------------------------------------------- */ 463 IMAGE_EXPORT(void) display_ui8vector_T(uint8 *v,int i0, int i1, char *format, char *name) 464 /* ----------------------------------------------------------------------------------- */ 465 { 466 int i; 467 468 if(name != NULL) printf(name); 469 470 for(i=i0; i<=i1; i++) { 471 printf(format, v[i]); 472 printf("\n"); 473 } 474 } 475 /* ------------------------------------------------------------------------------------- */ 476 IMAGE_EXPORT(void) display_si16vector_T(sint16 *v,int i0, int i1, char *format, char *name) 477 /* ------------------------------------------------------------------------------------- */ 478 { 479 int i; 480 481 if(name != NULL) printf(name); 482 483 for(i=i0; i<=i1; i++) { 484 printf(format, v[i]); 485 printf("\n"); 486 } 487 } 488 /* ------------------------------------------------------------------------------------- */ 489 IMAGE_EXPORT(void) display_ui16vector_T(uint16 *v,int i0, int i1, char *format, char *name) 490 /* ------------------------------------------------------------------------------------- */ 491 { 492 int i; 493 494 if(name != NULL) printf(name); 495 496 for(i=i0; i<=i1; i++) { 497 printf(format, v[i]); 498 printf("\n"); 499 } 500 } 501 /* ------------------------------------------------------------------------------------- */ 502 IMAGE_EXPORT(void) display_si32vector_T(sint32 *v,int i0, int i1, char *format, char *name) 503 /* ------------------------------------------------------------------------------------- */ 504 { 505 int i; 506 507 if(name != NULL) printf(name); 508 509 for(i=i0; i<=i1; i++) { 510 printf(format, v[i]); 511 printf("\n"); 512 } 513 } 514 /* ------------------------------------------------------------------------------------- */ 515 IMAGE_EXPORT(void) display_ui32vector_T(uint32 *v,int i0, int i1, char *format, char *name) 516 /* ------------------------------------------------------------------------------------- */ 517 { 518 int i; 519 520 if(name != NULL) printf(name); 521 522 for(i=i0; i<=i1; i++) { 523 printf(format, v[i]); 524 printf("\n"); 525 } 526 } 527 /* ------------------------------------------------------------------------------------- */ 528 IMAGE_EXPORT(void) display_si64vector_T(sint64 *v,int i0, int i1, char *format, char *name) 529 /* ------------------------------------------------------------------------------------- */ 530 { 531 int i; 532 533 if(name != NULL) printf(name); 534 535 for(i=i0; i<=i1; i++) { 536 printf(format, v[i]); 537 printf("\n"); 538 } 539 } 540 /* ------------------------------------------------------------------------------------- */ 541 IMAGE_EXPORT(void) display_ui64vector_T(uint64 *v,int i0, int i1, char *format, char *name) 542 /* ------------------------------------------------------------------------------------- */ 543 { 544 int i; 545 546 if(name != NULL) printf(name); 547 548 for(i=i0; i<=i1; i++) { 549 printf(format, v[i]); 550 printf("\n"); 551 } 552 } 553 /* ------------------------------------------------------------------------------------- */ 554 IMAGE_EXPORT(void) display_f32vector_T(float32 *v,int i0, int i1, char *format, char *name) 555 /* ------------------------------------------------------------------------------------- */ 556 { 557 int i; 558 559 if(name != NULL) printf(name); 560 561 for(i=i0; i<=i1; i++) { 562 printf(format, v[i]); 563 printf("\n"); 564 } 565 } 566 /* ------------------------------------------------------------------------------------- */ 567 IMAGE_EXPORT(void) display_f64vector_T(float64 *v,int i0, int i1, char *format, char *name) 568 /* ------------------------------------------------------------------------------------- */ 569 { 570 int i; 571 572 if(name != NULL) printf(name); 573 574 for(i=i0; i<=i1; i++) { 575 printf(format, v[i]); 576 printf("\n"); 577 } 578 } 579 /* ----------------------------------------------------------------------------------- */ 580 IMAGE_EXPORT(void) display_rgb8vector_T(rgb8 *v,int i0, int i1, char *format, char *name) 581 /* ----------------------------------------------------------------------------------- */ 582 { 583 int i; 584 585 if(name != NULL) printf(name); 586 587 for(i=i0; i<=i1; i++) { 588 printf(format, v[i]); 589 printf("\n"); 590 } 591 } 592 /* ------------------------------------------------------------------------------------- */ 593 IMAGE_EXPORT(void) display_rgbx8vector_T(rgbx8 *v,int i0, int i1, char *format, char *name) 594 /* ------------------------------------------------------------------------------------- */ 595 { 596 int i; 597 598 if(name != NULL) printf(name); 599 600 for(i=i0; i<=i1; i++) { 601 printf(format, v[i]); 602 printf("\n"); 603 } 604 } 106 107 #undef display_type_vector_T 108 #define display_type_vector_T(t) \ 109 void short_name(t,display_,vector_T)(t * v, int32_t i0, int32_t i1, char * format, char * name) \ 110 { \ 111 if (name != NULL) { \ 112 printf("%s", name); \ 113 } \ 114 for (int32_t i = i0; i <= i1; i++) { \ 115 printf(format, v[i]); \ 116 printf("\n"); \ 117 } \ 118 printf("\n"); \ 119 } 120 121 display_type_vector_T(int8_t); 122 display_type_vector_T(uint8_t); 123 display_type_vector_T(int16_t); 124 display_type_vector_T(uint16_t); 125 display_type_vector_T(int32_t); 126 display_type_vector_T(uint32_t); 127 display_type_vector_T(int64_t); 128 display_type_vector_T(uint64_t); 129 display_type_vector_T(float); 130 display_type_vector_T(double); 131 display_type_vector_T(rgb8); 132 display_type_vector_T(rgbx8); 133 605 134 606 135 /* … … 610 139 */ 611 140 612 /* ------------------------------------------------------------------------------------------ */ 613 IMAGE_EXPORT(void) display_si8vector_number_T(sint8 *v,int i0, int i1, char *format, char *name) 614 /* ------------------------------------------------------------------------------------------ */ 615 { 616 int i; 617 618 if(name != NULL) printf(name); 619 620 for(i=i0; i<=i1; i++) { 621 printf("%8d ", i); 622 printf(format, v[i]); 623 printf("\n"); 624 } 625 } 626 /* ------------------------------------------------------------------------------------------ */ 627 IMAGE_EXPORT(void) display_ui8vector_number_T(uint8 *v,int i0, int i1, char *format, char *name) 628 /* ------------------------------------------------------------------------------------------ */ 629 { 630 int i; 631 632 if(name != NULL) printf(name); 633 634 for(i=i0; i<=i1; i++) { 635 printf("%8d ", i); 636 printf(format, v[i]); 637 printf("\n"); 638 } 639 } 640 /* -------------------------------------------------------------------------------------------- */ 641 IMAGE_EXPORT(void) display_si16vector_number_T(sint16 *v,int i0, int i1, char *format, char *name) 642 /* -------------------------------------------------------------------------------------------- */ 643 { 644 int i; 645 646 if(name != NULL) printf(name); 647 648 for(i=i0; i<=i1; i++) { 649 printf("%8d ", i); 650 printf(format, v[i]); 651 printf("\n"); 652 } 653 } 654 /* -------------------------------------------------------------------------------------------- */ 655 IMAGE_EXPORT(void) display_ui16vector_number_T(uint16 *v,int i0, int i1, char *format, char *name) 656 /* -------------------------------------------------------------------------------------------- */ 657 { 658 int i; 659 660 if(name != NULL) printf(name); 661 662 for(i=i0; i<=i1; i++) { 663 printf("%8d ", i); 664 printf(format, v[i]); 665 printf("\n"); 666 } 667 } 668 /* -------------------------------------------------------------------------------------------- */ 669 IMAGE_EXPORT(void) display_si32vector_number_T(sint32 *v,int i0, int i1, char *format, char *name) 670 /* -------------------------------------------------------------------------------------------- */ 671 { 672 int i; 673 674 if(name != NULL) printf(name); 675 676 for(i=i0; i<=i1; i++) { 677 printf("%8d ", i); 678 printf(format, v[i]); 679 printf("\n"); 680 } 681 } 682 /* -------------------------------------------------------------------------------------------- */ 683 IMAGE_EXPORT(void) display_ui32vector_number_T(uint32 *v,int i0, int i1, char *format, char *name) 684 /* -------------------------------------------------------------------------------------------- */ 685 { 686 int i; 687 688 if(name != NULL) printf(name); 689 690 for(i=i0; i<=i1; i++) { 691 printf("%8d ", i); 692 printf(format, v[i]); 693 printf("\n"); 694 } 695 } 696 /* -------------------------------------------------------------------------------------------- */ 697 IMAGE_EXPORT(void) display_si64vector_number_T(sint64 *v,int i0, int i1, char *format, char *name) 698 /* -------------------------------------------------------------------------------------------- */ 699 { 700 int i; 701 702 if(name != NULL) printf(name); 703 704 for(i=i0; i<=i1; i++) { 705 printf("%8d ", i); 706 printf(format, v[i]); 707 printf("\n"); 708 } 709 } 710 /* -------------------------------------------------------------------------------------------- */ 711 IMAGE_EXPORT(void) display_ui64vector_number_T(uint64 *v,int i0, int i1, char *format, char *name) 712 /* -------------------------------------------------------------------------------------------- */ 713 { 714 int i; 715 716 if(name != NULL) printf(name); 717 718 for(i=i0; i<=i1; i++) { 719 printf("%8d ", i); 720 printf(format, v[i]); 721 printf("\n"); 722 } 723 } 724 /* -------------------------------------------------------------------------------------------- */ 725 IMAGE_EXPORT(void) display_f32vector_number_T(float32 *v,int i0, int i1, char *format, char *name) 726 /* -------------------------------------------------------------------------------------------- */ 727 { 728 int i; 729 730 if(name != NULL) printf(name); 731 732 for(i=i0; i<=i1; i++) { 733 printf("%8d ", i); 734 printf(format, v[i]); 735 printf("\n"); 736 } 737 } 738 /* -------------------------------------------------------------------------------------------- */ 739 IMAGE_EXPORT(void) display_f64vector_number_T(float64 *v,int i0, int i1, char *format, char *name) 740 /* -------------------------------------------------------------------------------------------- */ 741 { 742 int i; 743 744 if(name != NULL) printf(name); 745 746 for(i=i0; i<=i1; i++) { 747 printf("%8d ", i); 748 printf(format, v[i]); 749 printf("\n"); 750 } 751 } 752 /* ------------------------------------------------------------------------------------------ */ 753 IMAGE_EXPORT(void) display_rgb8vector_number_T(rgb8 *v,int i0, int i1, char *format, char *name) 754 /* ------------------------------------------------------------------------------------------ */ 755 { 756 int i; 757 758 if(name != NULL) printf(name); 759 760 for(i=i0; i<=i1; i++) { 761 printf("%8d ", i); 762 printf(format, v[i]); 763 printf("\n"); 764 } 765 } 766 /* -------------------------------------------------------------------------------------------- */ 767 IMAGE_EXPORT(void) display_rgbx8vector_number_T(rgbx8 *v,int i0, int i1, char *format, char *name) 768 /* -------------------------------------------------------------------------------------------- */ 769 { 770 int i; 771 772 if(name != NULL) printf(name); 773 774 for(i=i0; i<=i1; i++) { 775 printf("%8d ", i); 776 printf(format, v[i]); 777 printf("\n"); 778 } 779 } 141 142 #undef display_type_vector_number_T 143 #define display_type_vector_number_T(t) \ 144 void short_name(t,display_,vector_number_T)(t * v, int32_t i0, int32_t i1, char * format, char * name) \ 145 { \ 146 if (name != NULL) { \ 147 printf("%s", name); \ 148 } \ 149 for (int32_t i = i0; i <= i1; i++) { \ 150 printf("%8d ", i); \ 151 printf(format, v[i]); \ 152 printf("\n"); \ 153 } \ 154 printf("\n"); \ 155 } 156 157 display_type_vector_number_T(int8_t); 158 display_type_vector_number_T(uint8_t); 159 display_type_vector_number_T(int16_t); 160 display_type_vector_number_T(uint16_t); 161 display_type_vector_number_T(int32_t); 162 display_type_vector_number_T(uint32_t); 163 display_type_vector_number_T(int64_t); 164 display_type_vector_number_T(uint64_t); 165 display_type_vector_number_T(float); 166 display_type_vector_number_T(double); 167 display_type_vector_number_T(rgb8); 168 display_type_vector_number_T(rgbx8); 169 780 170 781 171 /* … … 785 175 */ 786 176 787 // ------------------------------------------------------------------------------- 788 void display_ui8vector_positive(uint8 *v, int j0, int j1, int iformat, char *name) 789 // ------------------------------------------------------------------------------- 790 { 791 int j; 792 char *format, *str; 793 794 select_display_positive_parameters(iformat, &format, &str); 795 796 if(name != NULL) printf(name); 797 798 for(j=j0; j<=j1; j++) { 799 if(v[j]) { 800 printf(format, v[j]); 801 } else { 802 printf("%s", str); 803 } 804 } 805 printf("\n"); 806 } 807 808 // --------------------------------------------------------------------------------- 809 void display_ui16vector_positive(uint16 *v, int j0, int j1, int iformat, char *name) 810 // --------------------------------------------------------------------------------- 811 { 812 int j; 813 char *format, *str; 814 815 select_display_positive_parameters(iformat, &format, &str); 816 817 if(name != NULL) printf(name); 818 819 for(j=j0; j<=j1; j++) { 820 if(v[j]) { 821 printf(format, v[j]); 822 } else { 823 printf("%s", str); 824 } 825 } 826 printf("\n"); 827 } 828 // --------------------------------------------------------------------------------- 829 void display_ui32vector_positive(uint32 *v, int j0, int j1, int iformat, char *name) 830 // --------------------------------------------------------------------------------- 831 { 832 int j; 833 char *format, *str; 834 835 select_display_positive_parameters(iformat, &format, &str); 836 837 if(name != NULL) printf(name); 838 839 for(j=j0; j<=j1; j++) { 840 if(v[j]) { 841 printf(format, v[j]); 842 } else { 843 printf("%s", str); 844 } 845 } 846 printf("\n"); 847 } 177 #undef display_type_vector_positive 178 #define display_type_vector_positive(t) \ 179 void short_name(t,display_,vector_positive)(t * v, int32_t j0, int32_t j1, int32_t iformat, char * name) \ 180 { \ 181 char * format; \ 182 char * str; \ 183 select_display_positive_parameters(iformat, &format, &str); \ 184 if (name != NULL) { \ 185 printf(name); \ 186 } \ 187 for (int32_t j = j0; j <= j1; j++) { \ 188 if (v[j] != 0) { \ 189 printf(format, v[j]); \ 190 } \ 191 else { \ 192 printf("%s", str); \ 193 } \ 194 } \ 195 printf("\n"); \ 196 } 197 198 199 display_type_vector_positive(int8_t); 200 display_type_vector_positive(uint8_t); 201 display_type_vector_positive(int16_t); 202 display_type_vector_positive(uint16_t); 203 display_type_vector_positive(int32_t); 204 display_type_vector_positive(uint32_t); 205 display_type_vector_positive(int64_t); 206 display_type_vector_positive(uint64_t); 207 display_type_vector_positive(float); 208 display_type_vector_positive(double); 209 210 // Local Variables: 211 // tab-width: 4 212 // c-basic-offset: 4 213 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 214 // indent-tabs-mode: nil 215 // End: 216 217 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 218 -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrio1f.c
r772 r822 16 16 #include <stdlib.h> 17 17 18 #include "nrc_os_config.h" 18 19 #include "mypredef.h" 19 20 #include "nrtype.h" … … 31 32 * -------------------- 32 33 */ 33 /* ------------------------------------------------------------------------------------ */ 34 IMAGE_EXPORT(void) write_si8vector(sint8 *v,long nl,long nh, char *format, char *filename) 35 /* ------------------------------------------------------------------------------------ */ 36 { 37 long k; 38 FILE *f; 39 40 f = fopen(filename, "wt"); 41 if(f == NULL) { nrerror("Can't open file in write_si8vector"); } 42 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 43 fclose(f); 44 } 45 /* ------------------------------------------------------------------------------------ */ 46 IMAGE_EXPORT(void) write_ui8vector(uint8 *v,long nl,long nh, char *format, char *filename) 47 /* ------------------------------------------------------------------------------------ */ 48 { 49 long k; 50 FILE *f; 51 52 f = fopen(filename, "wt"); 53 if(f == NULL) { nrerror("Can't open file in write_ui8vector"); } 54 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 55 fclose(f); 34 35 #undef write_type_vector 36 #define write_type_vector(t) \ 37 void short_name(t,write_,vector)(t * v, int32_t nl, int32_t nh, char * format, char * filename) \ 38 { \ 39 FILE * f = fopen(filename, "wt"); \ 40 if (f == NULL) { \ 41 nrerror("Can't open file %s in %s\n", filename, __func__); \ 42 } \ 43 for (int32_t k = nl; k <= nh; k++) { \ 44 fprintf(f, format, v[k]); \ 45 } \ 46 fprintf(f, "\n"); \ 47 fclose(f); \ 48 } 49 50 write_type_vector(int8_t); 51 write_type_vector(uint8_t); 52 write_type_vector(int16_t); 53 write_type_vector(uint16_t); 54 write_type_vector(int32_t); 55 write_type_vector(uint32_t); 56 write_type_vector(int64_t); 57 write_type_vector(uint64_t); 58 write_type_vector(float); 59 write_type_vector(double); 60 61 62 /* ---------------------------------------------------------------------------------- */ 63 void write_rgb8vector(rgb8 * v,int32_t nl, int32_t nh, char * format, char * filename) 64 /* ---------------------------------------------------------------------------------- */ 65 { 66 FILE * f = fopen(filename, "wt"); 67 if (f == NULL) { 68 nrerror("Can't open file %s in %s\n", filename, __func__); \ 69 } 70 for (int32_t k = nl; k <= nh; k++) { 71 fprintf(f, format, v[k].r, v[k].g, v[k].b); 72 } 73 fprintf(f, "\n"); 74 fclose(f); 56 75 } 57 76 58 77 /* -------------------------------------------------------------------------------------- */ 59 IMAGE_EXPORT(void) write_si16vector(sint16 *v,long nl,long nh, char *format, char *filename)78 void write_rgbx8vector(rgbx8 * v, int32_t nl, int32_t nh, char * format, char * filename) 60 79 /* -------------------------------------------------------------------------------------- */ 61 80 { 62 long k; 63 FILE *f; 64 65 f = fopen(filename, "wt"); 66 if(f == NULL) { nrerror("Can't open file in write_si16vector"); } 67 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 68 fclose(f); 69 } 70 /* -------------------------------------------------------------------------------------- */ 71 IMAGE_EXPORT(void) write_ui16vector(uint16 *v,long nl,long nh, char *format, char *filename) 72 /* -------------------------------------------------------------------------------------- */ 73 { 74 long k; 75 FILE *f; 76 77 f = fopen(filename, "wt"); 78 if(f == NULL) { nrerror("Can't open file in write_ui16vector"); } 79 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 80 fclose(f); 81 } 82 /* -------------------------------------------------------------------------------------- */ 83 IMAGE_EXPORT(void) write_si32vector(sint32 *v,long nl,long nh, char *format, char *filename) 84 /* -------------------------------------------------------------------------------------- */ 85 { 86 long k; 87 FILE *f; 88 89 f = fopen(filename, "wt"); 90 if(f == NULL) { nrerror("Can't open file in write_si32vector"); } 91 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 92 fclose(f); 93 } 94 /* -------------------------------------------------------------------------------------- */ 95 IMAGE_EXPORT(void) write_ui32vector(uint32 *v,long nl,long nh, char *format, char *filename) 96 /* -------------------------------------------------------------------------------------- */ 97 { 98 long k; 99 FILE *f; 100 101 f = fopen(filename, "wt"); 102 if(f == NULL) { nrerror("Can't open file in write_ui32vector"); } 103 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 104 fclose(f); 105 } 106 /* -------------------------------------------------------------------------------------- */ 107 IMAGE_EXPORT(void) write_si64vector(sint64 *v,long nl,long nh, char *format, char *filename) 108 /* -------------------------------------------------------------------------------------- */ 109 { 110 long k; 111 FILE *f; 112 113 f = fopen(filename, "wt"); 114 if(f == NULL) { nrerror("Can't open file in write_si64vector"); } 115 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 116 fclose(f); 117 } 118 /* ------------------------------------------------------------------------------------- */ 119 IMAGE_EXPORT(void) write_i64vector(uint64 *v,long nl,long nh, char *format, char *filename) 120 /* ------------------------------------------------------------------------------------- */ 121 { 122 long k; 123 FILE *f; 124 125 f = fopen(filename, "wt"); 126 if(f == NULL) { nrerror("Can't open file in write_ui64vector"); } 127 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 128 fclose(f); 129 } 130 /* -------------------------------------------------------------------------------------- */ 131 IMAGE_EXPORT(void) write_f32vector(float32 *v,long nl,long nh, char *format, char *filename) 132 /* -------------------------------------------------------------------------------------- */ 133 { 134 long k; 135 FILE *f; 136 137 f = fopen(filename, "wt"); 138 if(f == NULL) { nrerror("Can't open file in write_f32vector"); } 139 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 140 fclose(f); 141 } 142 /* -------------------------------------------------------------------------------------- */ 143 IMAGE_EXPORT(void) write_f64vector(float64 *v,long nl,long nh, char *format, char *filename) 144 /* -------------------------------------------------------------------------------------- */ 145 { 146 long k; 147 FILE *f; 148 149 f = fopen(filename, "wt"); 150 if(f == NULL) { nrerror("Can't open file in write_f64vector"); } 151 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 152 fclose(f); 153 } 154 /* ---------------------------------------------------------------------------------- */ 155 IMAGE_EXPORT(void) write_rgb8vector(rgb8 *v,long nl,long nh, char *format, char *filename) 156 /* ---------------------------------------------------------------------------------- */ 157 { 158 long k; 159 FILE *f; 160 161 f = fopen(filename, "wt"); 162 if(f == NULL) { nrerror("Can't open file in write_rgb8vector"); } 163 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k].r, v[k].g, v[k].b); } fputc('\n', f); 164 fclose(f); 165 } 166 /* -------------------------------------------------------------------------------------- */ 167 IMAGE_EXPORT(void) write_rgbx8vector(rgbx8 *v,long nl,long nh, char *format, char *filename) 168 /* -------------------------------------------------------------------------------------- */ 169 { 170 long k; 171 FILE *f; 172 173 f = fopen(filename, "wt"); 174 if(f == NULL) { nrerror("Can't open file in write_rgbx8vector"); } 175 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k].r, v[k].g, v[k].b); } fputc('\n', f); 176 fclose(f); 177 } 81 FILE * f = fopen(filename, "wt"); 82 if (f == NULL) { 83 nrerror("Can't open file %s in %s\n", filename, __func__); \ 84 } 85 for (int32_t k = nl; k <= nh; k++) { 86 fprintf(f, format, v[k].r, v[k].g, v[k].b); 87 } 88 fprintf(f, "\n"); 89 fclose(f); 90 } 91 92 178 93 /* 179 94 * ---------------------- … … 181 96 * ---------------------- 182 97 */ 98 99 #undef write_type_vector_T 100 #define write_type_vector_T(t) \ 101 void short_name(t,write_,vector_T)(t * v, int32_t nl, int32_t nh, char * format, char * filename) \ 102 { \ 103 FILE * f = fopen(filename, "wt"); \ 104 if (f == NULL) { \ 105 nrerror("Can't open file %s in %s\n", filename, __func__); \ 106 } \ 107 for (int32_t k = nl; k <= nh; k++) { \ 108 fprintf(f, format, v[k]); \ 109 fprintf(f, "\n"); \ 110 } \ 111 fclose(f); \ 112 } 113 114 write_type_vector_T(int8_t); 115 write_type_vector_T(uint8_t); 116 write_type_vector_T(int16_t); 117 write_type_vector_T(uint16_t); 118 write_type_vector_T(int32_t); 119 write_type_vector_T(uint32_t); 120 write_type_vector_T(int64_t); 121 write_type_vector_T(uint64_t); 122 write_type_vector_T(float); 123 write_type_vector_T(double); 124 125 126 /* ---------------------------------------------------------------------------------- */ 127 void write_rgb8vector_T(rgb8 * v,int32_t nl, int32_t nh, char * format, char * filename) 128 /* ---------------------------------------------------------------------------------- */ 129 { 130 FILE * f = fopen(filename, "wt"); 131 if (f == NULL) { 132 nrerror("Can't open file %s in %s\n", filename, __func__); \ 133 } 134 for (int32_t k = nl; k <= nh; k++) { 135 fprintf(f, format, v[k].r, v[k].g, v[k].b); 136 fprintf(f, "\n"); 137 } 138 fclose(f); 139 } 140 183 141 /* -------------------------------------------------------------------------------------- */ 184 IMAGE_EXPORT(void) write_si8vector_T(sint8 *v,long nl,long nh, char *format, char *filename)142 void write_rgbx8vector_T(rgbx8 * v, int32_t nl, int32_t nh, char * format, char * filename) 185 143 /* -------------------------------------------------------------------------------------- */ 186 144 { 187 long k; 188 FILE *f; 189 190 f = fopen(filename, "wt"); 191 if(f == NULL) { nrerror("Can't open file in write_si8vector"); } 192 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); fputc('\n', f); } 193 fclose(f); 194 } 195 /* -------------------------------------------------------------------------------------- */ 196 IMAGE_EXPORT(void) write_ui8vector_T(uint8 *v,long nl,long nh, char *format, char *filename) 197 /* -------------------------------------------------------------------------------------- */ 198 { 199 long k; 200 FILE *f; 201 202 f = fopen(filename, "wt"); 203 if(f == NULL) { nrerror("Can't open file in write_ui8vector"); } 204 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); fputc('\n', f); } 205 fclose(f); 206 } 207 /* ---------------------------------------------------------------------------------------- */ 208 IMAGE_EXPORT(void) write_si16vector_T(sint16 *v,long nl,long nh, char *format, char *filename) 209 /* ---------------------------------------------------------------------------------------- */ 210 { 211 long k; 212 FILE *f; 213 214 f = fopen(filename, "wt"); 215 if(f == NULL) { nrerror("Can't open file in write_si16vector"); } 216 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); fputc('\n', f); } 217 fclose(f); 218 } 219 /* -------------------------------------------------------------------------------------- */ 220 IMAGE_EXPORT(void) write_ui16vector_T(uint16 *v,long nl,long nh, char *format, char *filename) 221 /* -------------------------------------------------------------------------------------- */ 222 { 223 long k; 224 FILE *f; 225 226 f = fopen(filename, "wt"); 227 if(f == NULL) { nrerror("Can't open file in write_ui16vector"); } 228 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); fputc('\n', f); } 229 fclose(f); 230 } 231 /* ---------------------------------------------------------------------------------------- */ 232 IMAGE_EXPORT(void) write_si32vector_T(sint32 *v,long nl,long nh, char *format, char *filename) 233 /* ---------------------------------------------------------------------------------------- */ 234 { 235 long k; 236 FILE *f; 237 238 f = fopen(filename, "wt"); 239 if(f == NULL) { nrerror("Can't open file in write_si32vector"); } 240 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); fputc('\n', f); } 241 fclose(f); 242 } 243 /* ---------------------------------------------------------------------------------------- */ 244 IMAGE_EXPORT(void) write_ui32vector_T(uint32 *v,long nl,long nh, char *format, char *filename) 245 /* ---------------------------------------------------------------------------------------- */ 246 { 247 long k; 248 FILE *f; 249 250 f = fopen(filename, "wt"); 251 if(f == NULL) { nrerror("Can't open file in write_ui32vector"); } 252 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); fputc('\n', f); } 253 fclose(f); 254 } 255 /* ---------------------------------------------------------------------------------------- */ 256 IMAGE_EXPORT(void) write_si64vector_T(sint64 *v,long nl,long nh, char *format, char *filename) 257 /* ---------------------------------------------------------------------------------------- */ 258 { 259 long k; 260 FILE *f; 261 262 f = fopen(filename, "wt"); 263 if(f == NULL) { nrerror("Can't open file in write_si64vector"); } 264 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); fputc('\n', f); } 265 fclose(f); 266 } 267 /* ---------------------------------------------------------------------------------------- */ 268 IMAGE_EXPORT(void) write_ui64vector_T(uint64 *v,long nl,long nh, char *format, char *filename) 269 /* ---------------------------------------------------------------------------------------- */ 270 { 271 long k; 272 FILE *f; 273 274 f = fopen(filename, "wt"); 275 if(f == NULL) { nrerror("Can't open file in write_ui64vector"); } 276 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); fputc('\n', f); } 277 fclose(f); 278 } 279 /* -------------------------------------------------------------------------------------- */ 280 IMAGE_EXPORT(void) write_rgb8vector_T(rgb8 *v,long nl,long nh, char *format, char *filename) 281 /* -------------------------------------------------------------------------------------- */ 282 { 283 long k; 284 FILE *f; 285 286 f = fopen(filename, "wt"); 287 if(f == NULL) { nrerror("Can't open file in write_rgb8vector_T"); } 288 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k].r, v[k].g, v[k].b); fputc('\n', f); } 289 fclose(f); 290 } 291 /* ---------------------------------------------------------------------------------------- */ 292 IMAGE_EXPORT(void) write_rgbx8vector_T(rgbx8 *v,long nl,long nh, char *format, char *filename) 293 /* ---------------------------------------------------------------------------------------- */ 294 { 295 long k; 296 FILE *f; 297 298 f = fopen(filename, "wt"); 299 if(f == NULL) { nrerror("Can't open file in write_rgbx8vector_T"); } 300 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k].r, v[k].g, v[k].b); fputc('\n', f); } 301 fclose(f); 302 } 145 FILE * f = fopen(filename, "wt"); 146 if (f == NULL) { 147 nrerror("Can't open file %s in %s\n", filename, __func__); \ 148 } 149 for (int32_t k = nl; k <= nh; k++) { 150 fprintf(f, format, v[k].r, v[k].g, v[k].b); 151 fprintf(f, "\n"); 152 } 153 fclose(f); 154 } 155 303 156 304 157 /* … … 307 160 * --------------------------- 308 161 */ 162 163 // @QM : fprintf(f, format, k, k, k); ? 164 #undef write_type_vector_number 165 #define write_type_vector_number(t) \ 166 void short_name(t,write_,vector_number)(t * v, int32_t nl, int32_t nh, char * format, char * filename) \ 167 { \ 168 FILE * f = fopen(filename, "wt"); \ 169 if (f == NULL) { \ 170 nrerror("Can't open file %s in %s\n", filename, __func__); \ 171 } \ 172 for (int32_t k = nl; k <= nh; k++) { \ 173 fprintf(f, format, k); \ 174 } \ 175 fprintf(f, "\n"); \ 176 for (int32_t k = nl; k <= nh; k++) { \ 177 fprintf(f, format, v[k]); \ 178 } \ 179 fprintf(f, "\n"); \ 180 fclose(f); \ 181 } 182 183 write_type_vector_number(int8_t); 184 write_type_vector_number(uint8_t); 185 write_type_vector_number(int16_t); 186 write_type_vector_number(uint16_t); 187 write_type_vector_number(int32_t); 188 write_type_vector_number(uint32_t); 189 write_type_vector_number(int64_t); 190 write_type_vector_number(uint64_t); 191 write_type_vector_number(float); 192 write_type_vector_number(double); 193 194 195 /* ------------------------------------------------------------------------------------------- */ 196 void write_rgb8vector_number(rgb8 * v, int32_t nl, int32_t nh, char * format, char * filename) 197 /* ------------------------------------------------------------------------------------------- */ 198 { 199 FILE * f = fopen(filename, "wt"); 200 if (f == NULL) { 201 nrerror("Can't open file %s in %s\n", filename, __func__); 202 } 203 for (int32_t k = nl; k <= nh; k++) { 204 fprintf(f, "%3d", k); 205 } 206 fprintf(f, "\n"); 207 for (int32_t k = nl; k <= nh; k++) { 208 fprintf(f, format, v[k].r, v[k].g, v[k].b); 209 } 210 fprintf(f, "\n"); 211 fclose(f); 212 } 213 214 309 215 /* --------------------------------------------------------------------------------------------- */ 310 IMAGE_EXPORT(void) write_si8vector_number(sint8 *v,long nl,long nh, char *format, char *filename)216 void write_rgbx8vector_number(rgbx8 * v, int32_t nl, int32_t nh, char * format, char * filename) 311 217 /* --------------------------------------------------------------------------------------------- */ 312 218 { 313 int k; 314 FILE *f; 315 316 f = fopen(filename, "wt"); 317 if(f == NULL) { nrerror("Can't open file in write_si8vector_number"); } 318 for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f); 319 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 320 fclose(f); 321 } 322 /* ------------------------------------------------------------------------------------------- */ 323 IMAGE_EXPORT(void) write_ui8vector_number(uint8 *v,long nl,long nh, char *format, char *filename) 324 /* ------------------------------------------------------------------------------------------- */ 325 { 326 int k; 327 FILE *f; 328 329 f = fopen(filename, "wt"); 330 if(f == NULL) { nrerror("Can't open file in write_ui8vector_number"); } 331 for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f); 332 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 333 fclose(f); 334 } 335 /* --------------------------------------------------------------------------------------------- */ 336 IMAGE_EXPORT(void) write_si16vector_number(sint16 *v,long nl,long nh, char *format, char *filename) 337 /* --------------------------------------------------------------------------------------------- */ 338 { 339 int k; 340 FILE *f; 341 342 f = fopen(filename, "wt"); 343 if(f == NULL) { nrerror("Can't open file in write_si16vector_number"); } 344 for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f); 345 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 346 fclose(f); 347 } 348 /* ------------------------------------------------------------------------------------------- */ 349 IMAGE_EXPORT(void) write_ui16vector_number(uint16 *v,long nl,long nh, char *format, char *filename) 350 /* ------------------------------------------------------------------------------------------- */ 351 { 352 int k; 353 FILE *f; 354 355 f = fopen(filename, "wt"); 356 if(f == NULL) { nrerror("Can't open file in write_ui16vector_number"); } 357 for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f); 358 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 359 fclose(f); 360 } 361 /* --------------------------------------------------------------------------------------------- */ 362 IMAGE_EXPORT(void) write_si32vector_number(sint32 *v,long nl,long nh, char *format, char *filename) 363 /* --------------------------------------------------------------------------------------------- */ 364 { 365 int k; 366 FILE *f; 367 368 f = fopen(filename, "wt"); 369 if(f == NULL) { nrerror("Can't open file in write_si32vector_number"); } 370 for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f); 371 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 372 fclose(f); 373 } 374 /* ------------------------------------------------------------------------------------------- */ 375 IMAGE_EXPORT(void) write_ui32vector_number(uint32 *v,long nl,long nh, char *format, char *filename) 376 /* ------------------------------------------------------------------------------------------- */ 377 { 378 int k; 379 FILE *f; 380 381 f = fopen(filename, "wt"); 382 if(f == NULL) { nrerror("Can't open file in write_ui32vector_number"); } 383 for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f); 384 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 385 fclose(f); 386 } 387 /* --------------------------------------------------------------------------------------------- */ 388 IMAGE_EXPORT(void) write_si64vector_number(sint64 *v,long nl,long nh, char *format, char *filename) 389 /* --------------------------------------------------------------------------------------------- */ 390 { 391 int k; 392 FILE *f; 393 394 f = fopen(filename, "wt"); 395 if(f == NULL) { nrerror("Can't open file in write_si64vector_number"); } 396 for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f); 397 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 398 fclose(f); 399 } 400 /* ------------------------------------------------------------------------------------------- */ 401 IMAGE_EXPORT(void) write_ui64vector_number(uint64 *v,long nl,long nh, char *format, char *filename) 402 /* ------------------------------------------------------------------------------------------- */ 403 { 404 int k; 405 FILE *f; 406 407 f = fopen(filename, "wt"); 408 if(f == NULL) { nrerror("Can't open file in write_ui64vector_number"); } 409 for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f); 410 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 411 fclose(f); 412 } 413 /* --------------------------------------------------------------------------------------------- */ 414 IMAGE_EXPORT(void) write_f32vector_number(float32 *v,long nl,long nh, char *format, char *filename) 415 /* --------------------------------------------------------------------------------------------- */ 416 { 417 int k; 418 FILE *f; 419 420 f = fopen(filename, "wt"); 421 if(f == NULL) { nrerror("Can't open file in write_f32vector_number"); } 422 for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f); 423 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 424 fclose(f); 425 } 426 /* --------------------------------------------------------------------------------------------- */ 427 IMAGE_EXPORT(void) write_f64vector_number(float64 *v,long nl,long nh, char *format, char *filename) 428 /* --------------------------------------------------------------------------------------------- */ 429 { 430 int k; 431 FILE *f; 432 433 f = fopen(filename, "wt"); 434 if(f == NULL) { nrerror("Can't open file in write_f32vector_number"); } 435 for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f); 436 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f); 437 fclose(f); 438 } 439 /* ------------------------------------------------------------------------------------------- */ 440 IMAGE_EXPORT(void) write_rgb8vector_number(rgb8 *v,long nl,long nh, char *format, char *filename) 441 /* ------------------------------------------------------------------------------------------- */ 442 { 443 int k; 444 FILE *f; 445 446 f = fopen(filename, "wt"); 447 if(f == NULL) { nrerror("Can't open file in write_rgb8vector_number"); } 448 for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f); 449 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k].r, v[k].g, v[k].b); } fputc('\n', f); 450 fclose(f); 451 } 452 /* --------------------------------------------------------------------------------------------- */ 453 IMAGE_EXPORT(void) write_rgbx8vector_number(rgbx8 *v,long nl,long nh, char *format, char *filename) 454 /* --------------------------------------------------------------------------------------------- */ 455 { 456 int k; 457 FILE *f; 458 459 f = fopen(filename, "wt"); 460 if(f == NULL) { nrerror("Can't open file in write_rgbx8vector_number"); } 461 for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f); 462 for(k=nl; k<=nh; k++) { fprintf(f, format, v[k].r, v[k].g, v[k].b); } fputc('\n', f); 463 fclose(f); 464 } 219 FILE * f = fopen(filename, "wt"); 220 if (f == NULL) { 221 nrerror("Can't open file %s in %s\n", filename, __func__); 222 } 223 for (int32_t k = nl; k <= nh; k++) { 224 fprintf(f, "%3d", k); 225 } 226 fprintf(f, "\n"); 227 for (int32_t k = nl; k <= nh; k++) { 228 fprintf(f, format, v[k].r, v[k].g, v[k].b); 229 } 230 fprintf(f, "\n"); 231 fclose(f); 232 } 233 234 465 235 /* 466 236 * ----------------------------- … … 469 239 */ 470 240 241 #undef write_type_vector_T_number 242 #define write_type_vector_T_number(t) \ 243 void short_name(t,write_,vector_T_number)(t * v, int32_t nl, int32_t nh, char * format, char * filename) \ 244 { \ 245 FILE * f = fopen(filename, "wt"); \ 246 if (f == NULL) { \ 247 nrerror("Can't open file %s in %s\n", filename, __func__); \ 248 } \ 249 for (int32_t k = nl; k <= nh; k++) { \ 250 fprintf(f, "%3d", k); \ 251 fprintf(f, format, v[k]); \ 252 fprintf(f, "\n"); \ 253 } \ 254 fclose(f); \ 255 } 256 257 write_type_vector_T_number(int8_t); 258 write_type_vector_T_number(uint8_t); 259 write_type_vector_T_number(int16_t); 260 write_type_vector_T_number(uint16_t); 261 write_type_vector_T_number(int32_t); 262 write_type_vector_T_number(uint32_t); 263 write_type_vector_T_number(int64_t); 264 write_type_vector_T_number(uint64_t); 265 write_type_vector_T_number(float); 266 write_type_vector_T_number(double); 267 268 269 /* ------------------------------------------------------------------------------------------- */ 270 void write_rgb8vector_T_number(rgb8 * v, int32_t nl, int32_t nh, char * format, char * filename) 271 /* ------------------------------------------------------------------------------------------- */ 272 { 273 FILE * f = fopen(filename, "wt"); 274 if (f == NULL) { 275 nrerror("Can't open file %s in %s\n", filename, __func__); 276 } 277 for (int32_t k = nl; k <= nh; k++) { 278 fprintf(f, "%3d", k); 279 fprintf(f, format, v[k].r, v[k].g, v[k].b); 280 fprintf(f, "\n"); 281 } 282 fclose(f); 283 } 284 285 471 286 /* --------------------------------------------------------------------------------------------- */ 472 IMAGE_EXPORT(void) write_si8vector_T_number(sint8 *v,long nl,long nh, char *format, char *filename)287 void write_rgbx8vector_T_number(rgbx8 * v, int32_t nl, int32_t nh, char * format, char * filename) 473 288 /* --------------------------------------------------------------------------------------------- */ 474 289 { 475 int k; 476 FILE *f; 477 478 f = fopen(filename, "wt"); 479 if(f == NULL) { nrerror("Can't open file in write_si8vector"); } 480 for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); } 481 fclose(f); 482 } 483 /* --------------------------------------------------------------------------------------------- */ 484 IMAGE_EXPORT(void) write_ui8vector_T_number(uint8 *v,long nl,long nh, char *format, char *filename) 485 /* --------------------------------------------------------------------------------------------- */ 486 { 487 int k; 488 FILE *f; 489 490 f = fopen(filename, "wt"); 491 if(f == NULL) { nrerror("Can't open file in write_ui8vector"); } 492 for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); } 493 fclose(f); 494 } 495 /* ----------------------------------------------------------------------------------------------- */ 496 IMAGE_EXPORT(void) write_si16vector_T_number(sint16 *v,long nl,long nh, char *format, char *filename) 497 /* ----------------------------------------------------------------------------------------------- */ 498 { 499 int k; 500 FILE *f; 501 502 f = fopen(filename, "wt"); 503 if(f == NULL) { nrerror("Can't open file in write_si16vector"); } 504 for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); } 505 fclose(f); 506 } 507 /* ----------------------------------------------------------------------------------------------- */ 508 IMAGE_EXPORT(void) write_ui16vector_T_number(uint16 *v,long nl,long nh, char *format, char *filename) 509 /* ----------------------------------------------------------------------------------------------- */ 510 { 511 int k; 512 FILE *f; 513 514 f = fopen(filename, "wt"); 515 if(f == NULL) { nrerror("Can't open file in write_ui16vector"); } 516 for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); } 517 fclose(f); 518 } 519 /* ----------------------------------------------------------------------------------------------- */ 520 IMAGE_EXPORT(void) write_si32vector_T_number(sint32 *v,long nl,long nh, char *format, char *filename) 521 /* ----------------------------------------------------------------------------------------------- */ 522 { 523 int k; 524 FILE *f; 525 526 f = fopen(filename, "wt"); 527 if(f == NULL) { nrerror("Can't open file in write_si32vector"); } 528 for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); } 529 fclose(f); 530 } 531 /* ------------------------------------------------------------------------------------------- */ 532 IMAGE_EXPORT(void) write_ui32vector_T_number(uint32 *v,long nl,long nh, char *format, char *filename) 533 /* ------------------------------------------------------------------------------------------- */ 534 { 535 int k; 536 FILE *f; 537 538 f = fopen(filename, "wt"); 539 if(f == NULL) { nrerror("Can't open file in write_ui32vector_T_number"); } 540 for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); } 541 fclose(f); 542 } 543 /* ----------------------------------------------------------------------------------------------- */ 544 IMAGE_EXPORT(void) write_si64vector_T_number(sint64 *v,long nl,long nh, char *format, char *filename) 545 /* ----------------------------------------------------------------------------------------------- */ 546 { 547 int k; 548 FILE *f; 549 550 f = fopen(filename, "wt"); 551 if(f == NULL) { nrerror("Can't open file in write_i64vector"); } 552 for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); } 553 fclose(f); 554 } 555 /* ----------------------------------------------------------------------------------------------- */ 556 IMAGE_EXPORT(void) write_ui64vector_T_number(uint64 *v,long nl,long nh, char *format, char *filename) 557 /* ----------------------------------------------------------------------------------------------- */ 558 { 559 int k; 560 FILE *f; 561 562 f = fopen(filename, "wt"); 563 if(f == NULL) { nrerror("Can't open file in write_i64vector"); } 564 for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); } 565 fclose(f); 566 } 567 /* ----------------------------------------------------------------------------------------------- */ 568 IMAGE_EXPORT(void) write_f32vector_T_number(float32 *v,long nl,long nh, char *format, char *filename) 569 /* ----------------------------------------------------------------------------------------------- */ 570 { 571 int k; 572 FILE *f; 573 574 f = fopen(filename, "wt"); 575 if(f == NULL) { nrerror("Can't open file in write_f32vector"); } 576 for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); } 577 fclose(f); 578 } 579 /* ----------------------------------------------------------------------------------------------- */ 580 IMAGE_EXPORT(void) write_f64vector_T_number(float64 *v,long nl,long nh, char *format, char *filename) 581 /* ----------------------------------------------------------------------------------------------- */ 582 { 583 int k; 584 FILE *f; 585 586 f = fopen(filename, "wt"); 587 if(f == NULL) { nrerror("Can't open file in write_f64vector"); } 588 for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); } 589 fclose(f); 590 } 591 /* ------------------------------------------------------------------------------------------- */ 592 IMAGE_EXPORT(void) write_rgb8vector_T_number(rgb8 *v,long nl,long nh, char *format, char *filename) 593 /* ------------------------------------------------------------------------------------------- */ 594 { 595 int k; 596 FILE *f; 597 598 f = fopen(filename, "wt"); 599 if(f == NULL) { nrerror("Can't open file in write_rgb8vector_T"); } 600 for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k].r, v[k].g, v[k].b); fputc('\n', f); } 601 fclose(f); 602 } 603 /* ----------------------------------------------------------------------------------------------- */ 604 IMAGE_EXPORT(void) write_rgbx8vector_T_number(rgbx8 *v,long nl,long nh, char *format, char *filename) 605 /* ----------------------------------------------------------------------------------------------- */ 606 { 607 int k; 608 FILE *f; 609 610 f = fopen(filename, "wt"); 611 if(f == NULL) { nrerror("Can't open file in write_rgb8vector_T"); } 612 for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k].r, v[k].g, v[k].b); fputc('\n', f); } 613 fclose(f); 614 } 290 FILE * f = fopen(filename, "wt"); 291 if (f == NULL) { 292 nrerror("Can't open file %s in %s\n", filename, __func__); 293 } 294 for (int32_t k = nl; k <= nh; k++) { 295 fprintf(f, "%3d", k); 296 fprintf(f, format, v[k].r, v[k].g, v[k].b); 297 fprintf(f, "\n"); 298 } 299 fclose(f); 300 } 301 302 615 303 616 304 /* … … 620 308 */ 621 309 622 /* ---------------------------------------------------------------------- */ 623 IMAGE_EXPORT(void) fread_si8vector(char *filename, sint8 *v,long nl,long nh) 624 /* ---------------------------------------------------------------------- */ 625 { 626 long ncol=nh-nl+1, nread; 627 FILE *f; 628 629 f = fopen(filename, "rb"); 630 if(f == NULL) nrerror("Can't open file in fread_si8vector"); 631 632 nread = fread(v+nl, sizeof(sint8), ncol, f); 633 if(nread != ncol) nrerror("fread_si8vector can't read the whole vector"); 634 fclose(f); 635 } 636 /* ---------------------------------------------------------------------- */ 637 IMAGE_EXPORT(void) fread_ui8vector(char *filename, uint8 *v,long nl,long nh) 638 /* ---------------------------------------------------------------------- */ 639 { 640 long ncol=nh-nl+1, nread; 641 FILE *f; 642 643 f = fopen(filename, "rb"); 644 if(f == NULL) nrerror("Can't open file in fread_ui8vector"); 645 646 nread = fread(v+nl, sizeof(uint8), ncol, f); 647 if(nread != ncol) nrerror("fread_ui8vector can't read the whole vector"); 648 fclose(f); 649 } 650 /* ------------------------------------------------------------------------ */ 651 IMAGE_EXPORT(void) fread_si16vector(char *filename, sint16 *v,long nl,long nh) 652 /* ------------------------------------------------------------------------ */ 653 { 654 long ncol=nh-nl+1, nread; 655 FILE *f; 656 657 f = fopen(filename, "rb"); 658 if(f == NULL) nrerror("Can't open file in fread_si16vector"); 659 660 nread = fread(v+nl, sizeof(int16), ncol, f); 661 if(nread != ncol) nrerror("fread_si16vector can't read the whole vector"); 662 fclose(f); 663 } 664 /* ------------------------------------------------------------------------ */ 665 IMAGE_EXPORT(void) fread_ui16vector(char *filename, uint16 *v,long nl,long nh) 666 /* ------------------------------------------------------------------------ */ 667 { 668 long ncol=nh-nl+1, nread; 669 FILE *f; 670 671 f = fopen(filename, "rb"); 672 if(f == NULL) nrerror("Can't open file in fread_ui16vector"); 673 674 nread = fread(v+nl, sizeof(int16), ncol, f); 675 if(nread != ncol) nrerror("fread_ui16vector can't read the whole vector"); 676 fclose(f); 677 } 678 /* ------------------------------------------------------------------------ */ 679 IMAGE_EXPORT(void) fread_si32vector(char *filename, sint32 *v,long nl,long nh) 680 /* ------------------------------------------------------------------------ */ 681 { 682 long ncol=nh-nl+1, nread; 683 FILE *f; 684 685 f = fopen(filename, "rb"); 686 if(f == NULL) nrerror("Can't open file in fread_si32vector"); 687 688 nread = fread(v+nl, sizeof(sint32), ncol, f); 689 if(nread != ncol) nrerror("fread_si32vector can't read the whole vector"); 690 fclose(f); 691 } 692 /* ------------------------------------------------------------------------ */ 693 IMAGE_EXPORT(void) fread_ui32vector(char *filename, uint32 *v,long nl,long nh) 694 /* ------------------------------------------------------------------------ */ 695 { 696 long ncol=nh-nl+1, nread; 697 FILE *f; 698 699 f = fopen(filename, "rb"); 700 if(f == NULL) nrerror("Can't open file in fread_ui32vector"); 701 702 nread = fread(v+nl, sizeof(uint32), ncol, f); 703 if(nread != ncol) nrerror("fread_ui32vector can't read the whole vector"); 704 fclose(f); 705 } 706 /* ------------------------------------------------------------------------ */ 707 IMAGE_EXPORT(void) fread_si64vector(char *filename, sint64 *v,long nl,long nh) 708 /* ------------------------------------------------------------------------ */ 709 { 710 long ncol=nh-nl+1, nread; 711 FILE *f; 712 713 f = fopen(filename, "rb"); 714 if(f == NULL) nrerror("Can't open file in fread_si64vector"); 715 716 nread = fread(v+nl, sizeof(sint64), ncol, f); 717 if(nread != ncol) nrerror("fread_si64vector can't read the whole vector"); 718 fclose(f); 719 } 720 /* ------------------------------------------------------------------------ */ 721 IMAGE_EXPORT(void) fread_ui64vector(char *filename, uint64 *v,long nl,long nh) 722 /* ------------------------------------------------------------------------ */ 723 { 724 long ncol=nh-nl+1, nread; 725 FILE *f; 726 727 f = fopen(filename, "rb"); 728 if(f == NULL) nrerror("Can't open file in fread_ui64vector"); 729 730 nread = fread(v+nl, sizeof(uint64), ncol, f); 731 if(nread != ncol) nrerror("fread_ui64vector can't read the whole vector"); 732 fclose(f); 733 } 734 /* ------------------------------------------------------------------------ */ 735 IMAGE_EXPORT(void) fread_f32vector(char *filename, float32 *v,long nl,long nh) 736 /* ------------------------------------------------------------------------ */ 737 { 738 long ncol=nh-nl+1, nread; 739 FILE *f; 740 741 f = fopen(filename, "rb"); 742 if(f == NULL) nrerror("Can't open file in fread_f32vector"); 743 744 nread = fread(v+nl, sizeof(float32), ncol, f); 745 if(nread != ncol) nrerror("fread_f32vector can't read the whole vector"); 746 fclose(f); 747 } 748 /* ------------------------------------------------------------------------ */ 749 IMAGE_EXPORT(void) fread_f64vector(char *filename, float64 *v,long nl,long nh) 750 /* ------------------------------------------------------------------------ */ 751 { 752 long ncol=nh-nl+1, nread; 753 FILE *f; 754 755 f = fopen(filename, "rb"); 756 if(f == NULL) nrerror("Can't open file in fread_f64vector"); 757 758 nread = fread(v+nl, sizeof(float64), ncol, f); 759 if(nread != ncol) nrerror("fread_f64vector can't read the whole vector"); 760 fclose(f); 761 } 762 /* ---------------------------------------------------------------------- */ 763 IMAGE_EXPORT(void) fread_rgb8vector(char *filename, rgb8 *v,long nl,long nh) 764 /* ---------------------------------------------------------------------- */ 765 { 766 long ncol=nh-nl+1, nread; 767 FILE *f; 768 769 f = fopen(filename, "rb"); 770 if(f == NULL) nrerror("Can't open file in fread_rgb8vector"); 771 772 nread = fread(v+nl, sizeof(float32), ncol, f); 773 if(nread != ncol) nrerror("fread_rgb8vector can't read the whole vector"); 774 fclose(f); 775 } 776 /* ------------------------------------------------------------------------ */ 777 IMAGE_EXPORT(void) fread_rgbx8vector(char *filename, rgbx8 *v,long nl,long nh) 778 /* ------------------------------------------------------------------------ */ 779 { 780 long ncol=nh-nl+1, nread; 781 FILE *f; 782 783 f = fopen(filename, "rb"); 784 if(f == NULL) nrerror("Can't open file in fread_rgbx8vector"); 785 786 nread = fread(v+nl, sizeof(float32), ncol, f); 787 if(nread != ncol) nrerror("fread_rgbx8vector can't read the whole vector"); 788 fclose(f); 789 } 310 #undef fread_type_vector 311 #define fread_type_vector(t) \ 312 void short_name(t,fread_,vector)(char * filename, t * v, int32_t nl, int32_t nh) \ 313 { \ 314 int32_t ncol = nh - nl + 1; \ 315 int32_t nread; \ 316 FILE * f = fopen(filename, "rb"); \ 317 if (f == NULL) { \ 318 nrerror("Can't open file %s in %s\n", filename, __func__); \ 319 } \ 320 \ 321 nread = fread(v + nl, sizeof(t), ncol, f); \ 322 if (nread != ncol) { \ 323 nrerror("%s can't read the whole vector", __func__); \ 324 } \ 325 fclose(f); \ 326 } 327 328 fread_type_vector(int8_t); 329 fread_type_vector(uint8_t); 330 fread_type_vector(int16_t); 331 fread_type_vector(uint16_t); 332 fread_type_vector(int32_t); 333 fread_type_vector(uint32_t); 334 fread_type_vector(int64_t); 335 fread_type_vector(uint64_t); 336 fread_type_vector(float); 337 fread_type_vector(double); 338 fread_type_vector(rgb8); 339 fread_type_vector(rgbx8); 340 341 790 342 /* ------------------- */ 791 343 /* -- fwrite_vector -- */ 792 344 /* ------------------- */ 793 /* ---------------------------------------------------------------------- */ 794 IMAGE_EXPORT(void) fwrite_si8vector(sint8 *v,long nl,long nh,char *filename) 795 /* ---------------------------------------------------------------------- */ 796 { 797 long ncol = nh-nl+1; 798 FILE *f; 799 800 f = fopen(filename, "wb"); 801 if(f == NULL) nrerror("Can't open file in fwrite_si8vector"); 802 fwrite(v+nl, sizeof(sint8), ncol, f); 803 fclose(f); 804 } 805 /* ---------------------------------------------------------------------- */ 806 IMAGE_EXPORT(void) fwrite_ui8vector(uint8 *v,long nl,long nh,char *filename) 807 /* ---------------------------------------------------------------------- */ 808 { 809 long ncol = nh-nl+1; 810 FILE *f; 811 812 f = fopen(filename, "wb"); 813 if(f == NULL) nrerror("Can't open file in fwrite_ui8vector"); 814 fwrite(v+nl, sizeof(uint8), ncol, f); 815 fclose(f); 816 } 817 /* ------------------------------------------------------------------------ */ 818 IMAGE_EXPORT(void) fwrite_si16vector(sint16 *v,long nl,long nh,char *filename) 819 /* ------------------------------------------------------------------------ */ 820 { 821 long ncol = nh-nl+1; 822 FILE *f; 823 824 f = fopen(filename, "wb"); 825 if(f == NULL) nrerror("Can't open file in fwrite_si16vector"); 826 fwrite(v+nl, sizeof(sint16), ncol, f); 827 fclose(f); 828 } 829 /* ------------------------------------------------------------------------- */ 830 IMAGE_EXPORT(void) fwrite_ui16vector(uint16 *v,long nl,long nh,char *filename) 831 /* ------------------------------------------------------------------------- */ 832 { 833 long ncol = nh-nl+1; 834 FILE *f; 835 836 f = fopen(filename, "wb"); 837 if(f == NULL) nrerror("Can't open file in fwrite_ui16vector"); 838 fwrite(v+nl, sizeof(uint16), ncol, f); 839 fclose(f); 840 } 841 /* ------------------------------------------------------------------------ */ 842 IMAGE_EXPORT(void) fwrite_si32vector(sint32 *v,long nl,long nh,char *filename) 843 /* ------------------------------------------------------------------------ */ 844 { 845 long ncol = nh-nl+1; 846 FILE *f; 847 848 f = fopen(filename, "wb"); 849 if(f == NULL) nrerror("Can't open file in fwrite_si32vector"); 850 fwrite(v+nl, sizeof(sint32), ncol, f); 851 fclose(f); 852 } 853 /* ------------------------------------------------------------------------ */ 854 IMAGE_EXPORT(void) fwrite_ui32vector(uint32 *v,long nl,long nh,char *filename) 855 /* ------------------------------------------------------------------------ */ 856 { 857 long ncol = nh-nl+1; 858 FILE *f; 859 860 f = fopen(filename, "wb"); 861 if(f == NULL) nrerror("Can't open file in fwrite_ui32vector"); 862 fwrite(v+nl, sizeof(uint32), ncol, f); 863 fclose(f); 864 } 865 /* ------------------------------------------------------------------------ */ 866 IMAGE_EXPORT(void) fwrite_si64vector(sint64 *v,long nl,long nh,char *filename) 867 /* ------------------------------------------------------------------------ */ 868 { 869 long ncol = nh-nl+1; 870 FILE *f; 871 872 f = fopen(filename, "wb"); 873 if(f == NULL) nrerror("Can't open file in fwrite_si64vector"); 874 fwrite(v+nl, sizeof(sint64), ncol, f); 875 fclose(f); 876 } 877 /* ------------------------------------------------------------------------ */ 878 IMAGE_EXPORT(void) fwrite_ui64vector(uint64 *v,long nl,long nh,char *filename) 879 /* ------------------------------------------------------------------------ */ 880 { 881 long ncol = nh-nl+1; 882 FILE *f; 883 884 f = fopen(filename, "wb"); 885 if(f == NULL) nrerror("Can't open file in fwrite_ui-'vector"); 886 fwrite(v+nl, sizeof(uint64), ncol, f); 887 fclose(f); 888 } 889 /* ------------------------------------------------------------------------ */ 890 IMAGE_EXPORT(void) fwrite_f32vector(float32 *v,long nl,long nh,char *filename) 891 /* ------------------------------------------------------------------------ */ 892 { 893 long ncol = nh-nl+1; 894 FILE *f; 895 896 f = fopen(filename, "wb"); 897 if(f == NULL) nrerror("Can't open file in f32write_vector"); 898 fwrite(v+nl, sizeof(float32), ncol, f); 899 fclose(f); 900 } 901 /* ------------------------------------------------------------------------ */ 902 IMAGE_EXPORT(void) fwrite_f64vector(float64 *v,long nl,long nh,char *filename) 903 /* ------------------------------------------------------------------------ */ 904 { 905 long ncol = nh-nl+1; 906 FILE *f; 907 908 f = fopen(filename, "wb"); 909 if(f == NULL) nrerror("Can't open file in f64write_vector"); 910 fwrite(v+nl, sizeof(float64), ncol, f); 911 fclose(f); 912 } 913 /* ---------------------------------------------------------------------- */ 914 IMAGE_EXPORT(void) fwrite_rgb8vector(rgb8 *v,long nl,long nh,char *filename) 915 /* ---------------------------------------------------------------------- */ 916 { 917 long ncol = nh-nl+1; 918 FILE *f; 919 920 f = fopen(filename, "wb"); 921 if(f == NULL) nrerror("Can't open file in write_rgb8vector"); 922 fwrite(v+nl, sizeof(rgb8), ncol, f); 923 fclose(f); 924 } 925 /* ------------------------------------------------------------------------ */ 926 IMAGE_EXPORT(void) fwrite_rgbx8vector(rgbx8 *v,long nl,long nh,char *filename) 927 /* ------------------------------------------------------------------------ */ 928 { 929 long ncol = nh-nl+1; 930 FILE *f; 931 932 f = fopen(filename, "wb"); 933 if(f == NULL) nrerror("Can't open file in write_rgbx8vector"); 934 fwrite(v+nl, sizeof(rgbx8), ncol, f); 935 fclose(f); 936 } 345 346 #undef fwrite_type_vector 347 #define fwrite_type_vector(t) \ 348 void short_name(t,fwrite_,vector)(t * v, int32_t nl, int32_t nh, char * filename) \ 349 { \ 350 int32_t ncol = nh - nl + 1; \ 351 FILE * f = fopen(filename, "rb"); \ 352 if (f == NULL) { \ 353 nrerror("Can't open file %s in %s\n", filename, __func__); \ 354 } \ 355 fwrite(v + nl, sizeof(t), ncol, f); \ 356 fclose(f); \ 357 } 358 359 fwrite_type_vector(int8_t); 360 fwrite_type_vector(uint8_t); 361 fwrite_type_vector(int16_t); 362 fwrite_type_vector(uint16_t); 363 fwrite_type_vector(int32_t); 364 fwrite_type_vector(uint32_t); 365 fwrite_type_vector(int64_t); 366 fwrite_type_vector(uint64_t); 367 fwrite_type_vector(float); 368 fwrite_type_vector(double); 369 fwrite_type_vector(rgb8); 370 fwrite_type_vector(rgbx8); 371 372 373 374 // Local Variables: 375 // tab-width: 4 376 // c-basic-offset: 4 377 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 378 // indent-tabs-mode: nil 379 // End: 380 381 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 382 -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrio1x.c
r772 r822 21 21 #include "nrio1x.h" 22 22 23 /* ---------------------------------------------------------------------------------------------------------- */ 24 IMAGE_EXPORT(void) display_bvector_circular(byte *v,long nl,long nh, long c0, long c1, char *format, char *name) 25 /* ---------------------------------------------------------------------------------------------------------- */ 26 { 27 long i, n=nh-nl+1; 28 29 if(name != NULL) puts(name); 30 31 for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n'); 32 } 33 /* ----------------------------------------------------------------------------------------------------------- */ 34 IMAGE_EXPORT(void) display_si16vector_circular(sint16 *v,long nl,long nh, long c0, long c1, char *format, char *name) 35 /* ----------------------------------------------------------------------------------------------------------- */ 36 { 37 long i, n=nh-nl+1; 38 39 if(name != NULL) puts(name); 40 41 for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n'); 42 } 43 /* --------------------------------------------------------------------------------------------------------- */ 44 IMAGE_EXPORT(void) display_ui32vector_circular(uint32 *v,long nl,long nh, long c0, long c1, char *format, char *name) 45 /* --------------------------------------------------------------------------------------------------------- */ 46 { 47 long i, n=nh-nl+1; 48 49 if(name != NULL) puts(name); 50 51 for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n'); 52 } 53 /* ---------------------------------------------------------------------------------------------------------- */ 54 IMAGE_EXPORT(void) display_f32vector_circular(float32 *v,long nl,long nh, long c0, long c1, char *format, char *name) 55 /* ---------------------------------------------------------------------------------------------------------- */ 56 { 57 long i, n=nh-nl+1; 58 59 if(name != NULL) puts(name); 60 61 for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n'); 62 } 63 /* ------------------------------------------------------------------------------------------------------------ */ 64 IMAGE_EXPORT(void) display_f64vector_circular(float64 *v,long nl,long nh, long c0, long c1, char *format, char *name) 65 /* ------------------------------------------------------------------------------------------------------------ */ 66 { 67 long i, n=nh-nl+1; 68 69 if(name != NULL) puts(name); 70 71 for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n'); 72 } 73 /* ----------------------------------------------------------------------------------------------------------------- */ 74 IMAGE_EXPORT(void) display_bvector_circular_number(byte *v,long nl,long nh, long c0, long c1, char *format, char *name) 75 /* ----------------------------------------------------------------------------------------------------------------- */ 76 { 77 long i, n=nh-nl+1; 78 79 if(name != NULL) puts(name); 80 81 putchar('#'); 82 for(i=c0; i<=c1; i++) { 83 printf(format, i%n+nl); 84 } 85 putchar('\n'); 86 putchar(' '); 87 for(i=c0; i<=c1; i++) { 88 printf(format, v[i%n+nl]); 89 } 90 putchar('\n'); 91 } 92 /* ------------------------------------------------------------------------------------------------------------------ */ 93 IMAGE_EXPORT(void) display_si16vector_circular_number(sint16 *v,long nl,long nh, long c0, long c1, char *format, char *name) 94 /* ------------------------------------------------------------------------------------------------------------------ */ 95 { 96 long i, n=nh-nl+1; 97 98 if(name != NULL) puts(name); 99 100 putchar('#'); for(i=c0; i<=c1; i++) { printf(format, i%n+nl); } putchar('\n'); 101 putchar(' '); for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n'); 102 } 103 /* ---------------------------------------------------------------------------------------------------------------- */ 104 IMAGE_EXPORT(void) display_ui32vector_circular_number(uint32 *v,long nl,long nh, long c0, long c1, char *format, char *name) 105 /* ---------------------------------------------------------------------------------------------------------------- */ 106 { 107 long i, n=nh-nl+1; 108 109 if(name != NULL) puts(name); 110 111 putchar('#'); for(i=c0; i<=c1; i++) { printf(format, i%n+nl); } putchar('\n'); 112 putchar(' '); for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n'); 113 } 114 /* ----------------------------------------------------------------------------------------------------------------- */ 115 IMAGE_EXPORT(void) display_f32vector_circular_number(float32 *v,long nl,long nh, long c0, long c1, char *format, char *name) 116 /* ----------------------------------------------------------------------------------------------------------------- */ 117 { 118 long i, n=nh-nl+1; 119 120 if(name != NULL) puts(name); 121 122 putchar('#'); for(i=c0; i<=c1; i++) { printf(format, i%n+nl); } putchar('\n'); 123 putchar(' '); for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n'); 124 } 125 /* ------------------------------------------------------------------------------------------------------------------- */ 126 IMAGE_EXPORT(void) display_dvector_circular_number(float64 *v,long nl,long nh, long c0, long c1, char *format, char *name) 127 /* ------------------------------------------------------------------------------------------------------------------- */ 128 { 129 long i, n=nh-nl+1; 130 131 if(name != NULL) puts(name); 132 133 putchar('#'); for(i=c0; i<=c1; i++) { printf(format, i%n+nl); } putchar('\n'); 134 putchar(' '); for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n'); 23 #undef display_type_vector_circular 24 #define display_type_vector_circular(t) \ 25 void short_name(t,display_,vector_circular)(t * v, int32_t nl, int32_t nh, int32_t c0, int32_t c1, char * format, char * name) \ 26 { \ 27 int32_t n = nh - nl + 1; \ 28 if (name != NULL) { \ 29 printf("%s\n", name); \ 30 } \ 31 for (int32_t i = c0; i <= c1; i++) { \ 32 printf(format, v[i % n + nl]); \ 33 } \ 34 printf("\n"); \ 135 35 } 136 36 137 /* ------------------------------------------------------------------------------------- */138 IMAGE_EXPORT(void) display_bvector_cycle(byte *v,long nl,long nh, char *format, char *name)139 /* ------------------------------------------------------------------------------------- */140 {141 long i;142 uint8 first, next;143 uint8 *displayed;144 37 145 if(name != NULL) printf("%s", name); 38 display_type_vector_circular(int8_t); 39 display_type_vector_circular(uint8_t); 40 display_type_vector_circular(int16_t); 41 display_type_vector_circular(uint16_t); 42 display_type_vector_circular(int32_t); 43 display_type_vector_circular(uint32_t); 44 display_type_vector_circular(int64_t); 45 display_type_vector_circular(uint64_t); 46 display_type_vector_circular(float); 47 display_type_vector_circular(double); 146 48 147 displayed = ui8vector0(nl, nh); 148 149 for(i=nl; i<=nh; i++) { 150 if(!displayed[i]) { 151 displayed[i] = 1; 152 printf(format, i); 153 first = (byte) i; 154 next = v[i]; 155 while(first != next) { 156 displayed[next] = 1; 157 printf(format, next); 158 next = v[next]; 159 } 160 putchar('\n'); 161 } 162 } 163 putchar('\n'); 164 free_ui8vector(displayed, nl, nh); 49 50 51 #undef display_type_vector_circular_number 52 #define display_type_vector_circular_number(t) \ 53 void short_name(t,display_,vector_circular_number)(t * v, int32_t nl, int32_t nh, int32_t c0, int32_t c1, char * format, char * name) \ 54 { \ 55 int32_t n = nh - nl + 1; \ 56 if (name != NULL) { \ 57 printf("%s", name); \ 58 } \ 59 printf("#"); \ 60 for (int32_t i = c0; i <= c1; i++) { \ 61 printf(format, i % n + nl); \ 62 } \ 63 printf("\n "); \ 64 for (int32_t i = c0; i <= c1; i++) { \ 65 printf(format, v[i % n + nl]); \ 66 } \ 67 printf("\n"); \ 165 68 } 166 /* -------------------------------------------------------------------------------------- */167 IMAGE_EXPORT(void) display_si16vector_cycle(sint16 *v,long nl,long nh, char *format, char *name)168 /* -------------------------------------------------------------------------------------- */169 {170 long i;171 uint16 first, next;172 uint8 *displayed;173 69 174 if(name != NULL) printf("%s", name);175 70 176 displayed = ui8vector0(nl, nh); 177 178 for(i=nl; i<=nh; i++) { 179 if(!displayed[i]) { 180 displayed[i] = 1; 181 printf(format, i); 182 first = (sint16) i; 183 next = v[i]; 184 while(first != next) { 185 displayed[next] = 1; 186 printf(format, next); 187 next = v[next]; 188 } 189 putchar('\n'); 190 } 191 } 192 putchar('\n'); 193 free_ui8vector(displayed, nl, nh); 71 display_type_vector_circular_number(int8_t); 72 display_type_vector_circular_number(uint8_t); 73 display_type_vector_circular_number(int16_t); 74 display_type_vector_circular_number(uint16_t); 75 display_type_vector_circular_number(int32_t); 76 display_type_vector_circular_number(uint32_t); 77 display_type_vector_circular_number(int64_t); 78 display_type_vector_circular_number(uint64_t); 79 display_type_vector_circular_number(float); 80 display_type_vector_circular_number(double); 81 82 83 84 #undef display_type_vector_cycle 85 #define display_type_vector_cycle(t) \ 86 void short_name(t,display_,vector_cycle)(t * v, int32_t nl, int32_t nh, char * format, char * name) \ 87 { \ 88 uint8_t first; \ 89 uint8_t next; \ 90 uint8_t * displayed; \ 91 \ 92 if (name != NULL) { \ 93 printf("%s", name); \ 94 } \ 95 displayed = ui8vector0(nl, nh); \ 96 for (int32_t i = nl; i <= nh; i++) { \ 97 if (!displayed[i]) { \ 98 displayed[i] = 1; \ 99 printf(format, i); \ 100 first = (t) i; \ 101 next = v[i]; \ 102 while (first != next) { \ 103 displayed[next] = 1; \ 104 printf(format, next); \ 105 next = v[next]; \ 106 } \ 107 printf("\n"); \ 108 } \ 109 } \ 110 printf("\n"); \ 111 free_ui8vector(displayed, nl, nh); \ 194 112 } 195 /* ---------------------------------------------------------------------------------------- */196 IMAGE_EXPORT(void) display_ui16vector_cycle(uint16 *v,long nl,long nh, char *format, char *name)197 /* ---------------------------------------------------------------------------------------- */198 {199 long i;200 uint16 first, next;201 uint8 *displayed;202 113 203 if(name != NULL) printf("%s", name);204 114 205 displayed = ui8vector0(nl, nh); 206 207 for(i=nl; i<=nh; i++) { 208 if(!displayed[i]) { 209 displayed[i] = 1; 210 printf(format, i); 211 first = (uint16) i; 212 next = v[i]; 213 while(first != next) { 214 displayed[next] = 1; 215 printf(format, next); 216 next = v[next]; 217 } 218 putchar('\n'); 219 } 220 } 221 putchar('\n'); 222 free_ui8vector(displayed, nl, nh); 223 } 115 display_type_vector_cycle(int8_t); 116 display_type_vector_cycle(uint8_t); 117 display_type_vector_cycle(int16_t); 118 display_type_vector_cycle(uint16_t); 119 display_type_vector_cycle(int32_t); 120 display_type_vector_cycle(uint32_t); 121 display_type_vector_cycle(int64_t); 122 display_type_vector_cycle(uint64_t); 123 display_type_vector_cycle(float); 124 display_type_vector_cycle(double); 125 126 127 // Local Variables: 128 // tab-width: 4 129 // c-basic-offset: 4 130 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 131 // indent-tabs-mode: nil 132 // End: 133 134 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 135 -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrio1xf.c
r772 r822 11 11 #include <stdio.h> 12 12 13 #include "nrc_os_config.h" 13 14 #include "mypredef.h" 14 15 #include "nrtype.h" … … 18 19 19 20 #include "nralloc1.h" 20 #include "nrio1x f.h"21 #include "nrio1x.h" 21 22 22 23 … … 24 25 /* -- write_vector_circular -- */ 25 26 /* --------------------------- */ 26 /* ------------------------------------------------------------------------------------------------------------ */27 IMAGE_EXPORT(void) write_bvector_circular(byte *v,long nl,long nh, long c0, long c1, char *format, char *filename)28 /* ------------------------------------------------------------------------------------------------------------ */29 {30 long i, n=nh-nl+1;31 FILE *f;32 27 33 f = fopen(filename, "wt"); 34 if(f == NULL) { nrerror("Can't open file in write_bvector_circular"); } 28 #undef write_type_vector_circular 29 #define write_type_vector_circular(t) \ 30 void short_name(t,write_,vector_circular)(t * v, int32_t nl, int32_t nh, int32_t c0, int32_t c1, char * format, char * filename) \ 31 { \ 32 int32_t n = nh - nl + 1; \ 33 FILE * f = fopen(filename, "wt"); \ 34 if (f == NULL) { \ 35 nrerror("Can't open file %s in %s\n", filename, __func__); \ 36 } \ 37 for (int32_t i = c0; i <= c1; i++) { \ 38 fprintf(f, format, v[i % n + nl]); \ 39 } \ 40 fprintf(f, "\n"); \ 41 fclose(f); \ 42 } 35 43 36 for(i=c0; i<=c1; i++) { fprintf(f, format, v[i%n+nl]);} fputc('\n', f); 37 fclose(f); 38 } 44 write_type_vector_circular(int8_t); 45 write_type_vector_circular(uint8_t); 46 write_type_vector_circular(int16_t); 47 write_type_vector_circular(uint16_t); 48 write_type_vector_circular(int32_t); 49 write_type_vector_circular(uint32_t); 50 write_type_vector_circular(int64_t); 51 write_type_vector_circular(uint64_t); 52 write_type_vector_circular(float); 53 write_type_vector_circular(double); 54 55 56 57 // Local Variables: 58 // tab-width: 4 59 // c-basic-offset: 4 60 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 61 // indent-tabs-mode: nil 62 // End: 63 64 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 65 -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrio2.c
r821 r822 49 49 */ 50 50 51 52 #undef display_type_matrix 53 #define display_type_matrix(t) \ 54 void short_name(t,display_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) \ 55 { \ 56 if (name != NULL) { \ 57 printf("%s\n", name); \ 58 } \ 59 \ 60 for (int32_t i = nrl; i <= nrh; i++) { \ 61 for (int32_t j = ncl; j <= nch; j++) { \ 62 printf(format, m[i][j]); \ 63 } \ 64 printf("\n"); \ 65 } \ 66 } 67 68 display_type_matrix(int8_t); 69 display_type_matrix(uint8_t); 70 display_type_matrix(int16_t); 71 display_type_matrix(uint16_t); 72 display_type_matrix(int32_t); 73 display_type_matrix(uint32_t); 74 display_type_matrix(int64_t); 75 display_type_matrix(uint64_t); 76 display_type_matrix(float); 77 display_type_matrix(double); 78 79 51 80 /* -------------------------------------------------------------------------------------------------------- */ 52 IMAGE_EXPORT(void) display_ui8matrix(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)81 void display_rgb8matrix(rgb8 ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) 53 82 /* -------------------------------------------------------------------------------------------------------- */ 54 83 { 55 long i,j;56 57 if(name != NULL) printf(name);58 59 for (i=nrl; i<=nrh; i++) {60 for (j=ncl; j<=nch; j++) {61 printf(format, m[i][j] );84 if (name != NULL) { 85 printf(name); 86 } 87 88 for (int32_t i = nrl; i <= nrh; i++) { 89 for (int32_t j = ncl; j <= nch; j++) { 90 printf(format, m[i][j].r, m[i][j].g, m[i][j].b); 62 91 } 63 92 printf("\n"); 64 93 } 65 94 } 66 /* -------------------------------------------------------------------------------------------------------- */ 67 IMAGE_EXPORT(void) display_si8matrix(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 68 /* -------------------------------------------------------------------------------------------------------- */ 69 { 70 long i,j; 71 72 if(name != NULL) printf(name); 73 74 for(i=nrl; i<=nrh; i++) { 75 for(j=ncl; j<=nch; j++) { 76 printf(format, m[i][j]); 95 96 /* ---------------------------------------------------------------------------------------------------------- */ 97 void display_rgbx8matrix(rgbx8 ** m,int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) 98 /* ---------------------------------------------------------------------------------------------------------- */ 99 { 100 if (name != NULL) { 101 printf(name); 102 } 103 104 for (int32_t i = nrl; i <= nrh; i++) { 105 for (int32_t j = ncl; j <= nch; j++) { 106 printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x); 77 107 } 78 108 printf("\n"); 79 109 } 80 110 } 81 /* ---------------------------------------------------------------------------------------------------------- */ 82 IMAGE_EXPORT(void) display_si16matrix(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 83 /* ---------------------------------------------------------------------------------------------------------- */ 84 { 85 long i,j; 86 87 if(name != NULL) printf(name); 88 89 for(i=nrl; i<=nrh; i++) { 90 for(j=ncl; j<=nch; j++) { 91 printf(format, m[i][j]); 92 } 93 printf("\n"); 94 } 95 } 96 /* ---------------------------------------------------------------------------------------------------------- */ 97 IMAGE_EXPORT(void) display_ui16matrix(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 98 /* ---------------------------------------------------------------------------------------------------------- */ 99 { 100 long i,j; 101 102 if(name != NULL) printf(name); 103 104 for(i=nrl; i<=nrh; i++) { 105 for(j=ncl; j<=nch; j++) { 106 printf(format, m[i][j]); 107 } 108 printf("\n"); 109 } 110 } 111 /* ---------------------------------------------------------------------------------------------------------- */ 112 IMAGE_EXPORT(void) display_si32matrix(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 113 /* ---------------------------------------------------------------------------------------------------------- */ 114 { 115 long i,j; 116 117 if(name != NULL) printf(name); 118 119 for(i=nrl; i<=nrh; i++) { 120 for(j=ncl; j<=nch; j++) { 121 printf(format, m[i][j]); 122 } 123 printf("\n"); 124 } 125 } 126 /* ---------------------------------------------------------------------------------------------------------- */ 127 IMAGE_EXPORT(void) display_ui32matrix(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 128 /* ---------------------------------------------------------------------------------------------------------- */ 129 { 130 long i,j; 131 132 if(name != NULL) printf(name); 133 134 for(i=nrl; i<=nrh; i++) { 135 for(j=ncl; j<=nch; j++) { 136 printf(format, m[i][j]); 137 } 138 printf("\n"); 139 } 140 } 141 /* ---------------------------------------------------------------------------------------------------------- */ 142 IMAGE_EXPORT(void) display_si64matrix(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 143 /* ---------------------------------------------------------------------------------------------------------- */ 144 { 145 long i,j; 146 147 if(name != NULL) printf(name); 148 149 for(i=nrl; i<=nrh; i++) { 150 for(j=ncl; j<=nch; j++) { 151 printf(format, m[i][j]); 152 } 153 printf("\n"); 154 } 155 } 156 /* --------------------------------------------------------------------------------------------------------- */ 157 IMAGE_EXPORT(void) display_i64matrix(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 158 /* --------------------------------------------------------------------------------------------------------- */ 159 { 160 long i,j; 161 162 if(name != NULL) printf(name); 163 164 for(i=nrl; i<=nrh; i++) { 165 for(j=ncl; j<=nch; j++) { 166 printf(format, m[i][j]); 167 } 168 printf("\n"); 169 } 170 } 171 /* ---------------------------------------------------------------------------------------------------------- */ 172 IMAGE_EXPORT(void) display_f32matrix(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 173 /* ---------------------------------------------------------------------------------------------------------- */ 174 { 175 long i,j; 176 177 if(name != NULL) printf(name); 178 179 for(i=nrl; i<=nrh; i++) { 180 for(j=ncl; j<=nch; j++) { 181 printf(format, m[i][j]); 182 } 183 printf("\n"); 184 } 185 } 186 /* ---------------------------------------------------------------------------------------------------------- */ 187 IMAGE_EXPORT(void) display_f64matrix(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 188 /* ---------------------------------------------------------------------------------------------------------- */ 189 { 190 long i,j; 191 192 if(name != NULL) printf(name); 193 194 for(i=nrl; i<=nrh; i++) { 195 for(j=ncl; j<=nch; j++) { 196 printf(format, m[i][j]); 197 } 198 printf("\n"); 199 } 200 } 201 /* -------------------------------------------------------------------------------------------------------- */ 202 IMAGE_EXPORT(void) display_rgb8matrix(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 203 /* -------------------------------------------------------------------------------------------------------- */ 204 { 205 long i,j; 206 207 if(name != NULL) printf(name); 208 209 for(i=nrl; i<=nrh; i++) { 210 for(j=ncl; j<=nch; j++) { 211 printf(format, m[i][j].r, m[i][j].g, m[i][j].b); 212 } 213 printf("\n"); 214 } 215 } 216 /* ---------------------------------------------------------------------------------------------------------- */ 217 IMAGE_EXPORT(void) display_rgbx8matrix(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 218 /* ---------------------------------------------------------------------------------------------------------- */ 219 { 220 long i,j; 221 222 if(name != NULL) printf(name); 223 224 for(i=nrl; i<=nrh; i++) { 225 for(j=ncl; j<=nch; j++) { 226 printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x); 227 } 228 printf("\n"); 229 } 230 } 231 /* 232 * ---------------------- 233 * --- display_matrix --- 234 * ---------------------- 235 */ 236 237 /* ---------------------------------------------------------------------------------------------------------- */ 238 IMAGE_EXPORT(void) display_si8matrix_T(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 239 /* ---------------------------------------------------------------------------------------------------------- */ 240 { 241 long i,j; 242 243 if(name != NULL) printf(name); 244 245 for(j=ncl; j<=nch; j++) { 246 for(i=nrl; i<=nrh; i++) { 247 printf(format, m[i][j]); 248 } 249 printf("\n"); 250 } 251 } 252 /* ---------------------------------------------------------------------------------------------------------- */ 253 IMAGE_EXPORT(void) display_ui8matrix_T(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 254 /* ---------------------------------------------------------------------------------------------------------- */ 255 { 256 long i,j; 257 258 if(name != NULL) printf(name); 259 260 for(j=ncl; j<=nch; j++) { 261 for(i=nrl; i<=nrh; i++) { 262 printf(format, m[i][j]); 263 } 264 printf("\n"); 265 } 266 } 267 /* ------------------------------------------------------------------------------------------------------------ */ 268 IMAGE_EXPORT(void) display_si16matrix_T(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 269 /* ------------------------------------------------------------------------------------------------------------ */ 270 { 271 long i,j; 272 273 if(name != NULL) printf(name); 274 275 for(j=ncl; j<=nch; j++) { 276 for(i=nrl; i<=nrh; i++) { 277 printf(format, m[i][j]); 278 } 279 printf("\n"); 280 } 281 } 282 /* ------------------------------------------------------------------------------------------------------------ */ 283 IMAGE_EXPORT(void) display_ui16matrix_T(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 284 /* ------------------------------------------------------------------------------------------------------------ */ 285 { 286 long i,j; 287 288 if(name != NULL) printf(name); 289 290 for(j=ncl; j<=nch; j++) { 291 for(i=nrl; i<=nrh; i++) { 292 printf(format, m[i][j]); 293 } 294 printf("\n"); 295 } 296 } 297 /* ------------------------------------------------------------------------------------------------------------ */ 298 IMAGE_EXPORT(void) display_si32matrix_T(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 299 /* ------------------------------------------------------------------------------------------------------------ */ 300 { 301 long i,j; 302 303 if(name != NULL) printf(name); 304 305 for(j=ncl; j<=nch; j++) { 306 for(i=nrl; i<=nrh; i++) { 307 printf(format, m[i][j]); 308 } 309 printf("\n"); 310 } 311 } 312 /* ---------------------------------------------------------------------------------------------------------- */ 313 IMAGE_EXPORT(void) display_ui32matrix_T(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 314 /* ---------------------------------------------------------------------------------------------------------- */ 315 { 316 long i,j; 317 318 if(name != NULL) printf(name); 319 320 for(j=ncl; j<=nch; j++) { 321 for(i=nrl; i<=nrh; i++) { 322 printf(format, m[i][j]); 323 } 324 printf("\n"); 325 } 326 } 327 /* ------------------------------------------------------------------------------------------------------------ */ 328 IMAGE_EXPORT(void) display_si64matrix_T(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 329 /* ------------------------------------------------------------------------------------------------------------ */ 330 { 331 long i,j; 332 333 if(name != NULL) printf(name); 334 335 for(j=ncl; j<=nch; j++) { 336 for(i=nrl; i<=nrh; i++) { 337 printf(format, m[i][j]); 338 } 339 printf("\n"); 340 } 341 } 342 /* ------------------------------------------------------------------------------------------------------------ */ 343 IMAGE_EXPORT(void) display_ui64matrix_T(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 344 /* ------------------------------------------------------------------------------------------------------------ */ 345 { 346 long i,j; 347 348 if(name != NULL) printf(name); 349 350 for(j=ncl; j<=nch; j++) { 351 for(i=nrl; i<=nrh; i++) { 352 printf(format, m[i][j]); 353 } 354 printf("\n"); 355 } 356 } 357 /* ------------------------------------------------------------------------------------------------------------ */ 358 IMAGE_EXPORT(void) display_f32matrix_T(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 359 /* ------------------------------------------------------------------------------------------------------------ */ 360 { 361 long i,j; 362 363 if(name != NULL) printf(name); 364 365 for(j=ncl; j<=nch; j++) { 366 for(i=nrl; i<=nrh; i++) { 367 printf(format, m[i][j]); 368 } 369 printf("\n"); 370 } 371 } 372 /* ------------------------------------------------------------------------------------------------------------ */ 373 IMAGE_EXPORT(void) display_f64matrix_T(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 374 /* ------------------------------------------------------------------------------------------------------------ */ 375 { 376 long i,j; 377 378 if(name != NULL) printf(name); 379 380 for(j=ncl; j<=nch; j++) { 381 for(i=nrl; i<=nrh; i++) { 382 printf(format, m[i][j]); 383 } 384 printf("\n"); 385 } 386 } 387 /* ---------------------------------------------------------------------------------------------------------- */ 388 IMAGE_EXPORT(void) display_rgb8matrix_T(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 389 /* ---------------------------------------------------------------------------------------------------------- */ 390 { 391 long i,j; 392 393 if(name != NULL) printf(name); 394 395 for(j=ncl; j<=nch; j++) { 396 for(i=nrl; i<=nrh; i++) { 397 printf(format, m[i][j].r, m[i][j].g, m[i][j].b); 398 } 399 printf("\n"); 400 } 401 } 402 /* ------------------------------------------------------------------------------------------------------------ */ 403 IMAGE_EXPORT(void) display_rgbx8matrix_T(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 404 /* ------------------------------------------------------------------------------------------------------------ */ 405 { 406 long i,j; 407 408 if(name != NULL) printf(name); 409 410 for(j=ncl; j<=nch; j++) { 411 for(i=nrl; i<=nrh; i++) { 412 printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x); 413 } 414 printf("\n"); 415 } 416 } 111 417 112 418 113 /* … … 422 117 */ 423 118 119 #undef display_type_matrix_T 120 #define display_type_matrix_T(t) \ 121 void short_name(t,display_,matrix_T)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) \ 122 { \ 123 if (name != NULL) { \ 124 printf("%s\n", name); \ 125 } \ 126 \ 127 for (int32_t j = ncl; j <= nch; j++) { \ 128 for (int32_t i = nrl; i <= nrh; i++) { \ 129 printf(format, m[i][j]); \ 130 } \ 131 printf("\n"); \ 132 } \ 133 } 134 135 display_type_matrix_T(int8_t); 136 display_type_matrix_T(uint8_t); 137 display_type_matrix_T(int16_t); 138 display_type_matrix_T(uint16_t); 139 display_type_matrix_T(int32_t); 140 display_type_matrix_T(uint32_t); 141 display_type_matrix_T(int64_t); 142 display_type_matrix_T(uint64_t); 143 display_type_matrix_T(float); 144 display_type_matrix_T(double); 145 146 147 /* -------------------------------------------------------------------------------------------------------- */ 148 void display_rgb8matrix_T(rgb8 ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) 149 /* -------------------------------------------------------------------------------------------------------- */ 150 { 151 if (name != NULL) { 152 printf(name); 153 } 154 155 for (int32_t j = ncl; j <= nch; j++) { 156 for (int32_t i = nrl; i <= nrh; i++) { 157 printf(format, m[i][j].r, m[i][j].g, m[i][j].b); 158 } 159 printf("\n"); 160 } 161 } 162 163 /* ---------------------------------------------------------------------------------------------------------- */ 164 void display_rgbx8matrix_T(rgbx8 ** m,int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) 165 /* ---------------------------------------------------------------------------------------------------------- */ 166 { 167 if (name != NULL) { 168 printf(name); 169 } 170 171 for (int32_t j = ncl; j <= nch; j++) { 172 for (int32_t i = nrl; i <= nrh; i++) { 173 printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x); 174 } 175 printf("\n"); 176 } 177 } 178 179 180 181 /* 182 * ----------------------------- 183 * --- display_matrix_number --- 184 * ----------------------------- 185 */ 186 187 #undef display_type_matrix_number 188 #define display_type_matrix_number(t) \ 189 void short_name(t,display_,matrix_number)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) \ 190 { \ 191 if (name != NULL) { \ 192 printf("%s\n", name); \ 193 } \ 194 printf("%5c", '#'); \ 195 for (int32_t j = ncl; j <= nch; j++) { \ 196 printf(format, j); \ 197 } \ 198 printf("\n"); \ 199 for (int32_t i = nrl; i <= nrh; i++) { \ 200 printf("[%3d]", i); \ 201 for (int32_t j = ncl; j <= nch; j++) { \ 202 printf(format, m[i][j]); \ 203 } \ 204 printf("\n"); \ 205 } \ 206 printf("\n"); \ 207 } 208 209 display_type_matrix_number(int8_t); 210 display_type_matrix_number(uint8_t); 211 display_type_matrix_number(int16_t); 212 display_type_matrix_number(uint16_t); 213 display_type_matrix_number(int32_t); 214 display_type_matrix_number(uint32_t); 215 display_type_matrix_number(int64_t); 216 display_type_matrix_number(uint64_t); 217 display_type_matrix_number(float); 218 display_type_matrix_number(double); 219 220 424 221 /* --------------------------------------------------------------------------------------------------------------- */ 425 IMAGE_EXPORT(void) display_si8matrix_number(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)222 void display_rgb8matrix_number(rgb8 ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) 426 223 /* --------------------------------------------------------------------------------------------------------------- */ 427 224 { 428 int i,j; 429 430 if(name != NULL) printf(name); 431 225 if (name != NULL) { 226 printf(name); 227 } 432 228 // 1ere ligne 433 229 printf("%5c", '#'); 434 for (j=ncl; j<=nch; j++) {230 for (int32_t j = ncl; j <= nch; j++) { 435 231 printf(format, j); 436 232 } 437 233 printf("\n"); 438 for (i=nrl; i<=nrh; i++) {234 for (int32_t i = nrl; i <= nrh; i++) { 439 235 printf("[%3d]", i); 440 for (j=ncl; j<=nch; j++) {441 printf(format, m[i][j] );236 for (int32_t j = ncl; j <= nch; j++) { 237 printf(format, m[i][j].r, m[i][j].g, m[i][j].b); 442 238 } 443 239 printf("\n"); … … 445 241 printf("\n"); 446 242 } 447 /* --------------------------------------------------------------------------------------------------------------- */ 448 IMAGE_EXPORT(void) display_ui8matrix_number(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 449 /* --------------------------------------------------------------------------------------------------------------- */ 450 { 451 int i,j; 452 453 if(name != NULL)printf(name);454 243 244 /* ----------------------------------------------------------------------------------------------------------------- */ 245 void display_rgbx8matrix_number(rgbx8 **m,int32_t nrl,int32_t nrh,int32_t ncl, int32_t nch, char *format, char *name) 246 /* ----------------------------------------------------------------------------------------------------------------- */ 247 { 248 if (name != NULL) { 249 printf(name); 250 } 455 251 // 1ere ligne 456 252 printf("%5c", '#'); 457 for (j=ncl; j<=nch; j++) {253 for (int32_t j = ncl; j <= nch; j++) { 458 254 printf(format, j); 459 255 } 460 256 printf("\n"); 461 for (i=nrl; i<=nrh; i++) {257 for (int32_t i = nrl; i <= nrh; i++) { 462 258 printf("[%3d]", i); 463 for (j=ncl; j<=nch; j++) {464 printf(format, m[i][j] );259 for (int32_t j = ncl; j <= nch; j++) { 260 printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x); 465 261 } 466 262 printf("\n"); … … 468 264 printf("\n"); 469 265 } 470 /* ----------------------------------------------------------------------------------------------------------------- */ 471 IMAGE_EXPORT(void) display_si16matrix_number(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 472 /* ----------------------------------------------------------------------------------------------------------------- */ 473 { 474 int i,j; 475 476 if(name != NULL) printf(name); 477 478 // 1ere ligne 479 printf("%5c", '#'); 480 for(j=ncl; j<=nch; j++) { 481 printf(format, j); 482 } 483 printf("\n"); 484 for(i=nrl; i<=nrh; i++) { 485 printf("[%3d]", i); 486 for(j=ncl; j<=nch; j++) { 487 printf(format, m[i][j]); 488 } 489 printf("\n"); 490 } 491 printf("\n"); 492 } 493 /* ----------------------------------------------------------------------------------------------------------------- */ 494 IMAGE_EXPORT(void) display_ui16matrix_number(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 495 /* ----------------------------------------------------------------------------------------------------------------- */ 496 { 497 int i,j; 498 499 if(name != NULL) printf(name); 500 501 // 1ere ligne 502 printf("%5c", '#'); 503 for(j=ncl; j<=nch; j++) { 504 printf(format, j); 505 } 506 printf("\n"); 507 for(i=nrl; i<=nrh; i++) { 508 printf("[%3d]", i); 509 for(j=ncl; j<=nch; j++) { 510 printf(format, m[i][j]); 511 } 512 printf("\n"); 513 } 514 printf("\n"); 515 } 516 /* ----------------------------------------------------------------------------------------------------------------- */ 517 IMAGE_EXPORT(void) display_si32matrix_number(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 518 /* ----------------------------------------------------------------------------------------------------------------- */ 519 { 520 int i,j; 521 522 if(name != NULL) printf(name); 523 524 // 1ere ligne 525 printf("%5c", '#'); 526 for(j=ncl; j<=nch; j++) { 527 printf(format, j); 528 } 529 printf("\n"); 530 for(i=nrl; i<=nrh; i++) { 531 printf("[%3d]", i); 532 for(j=ncl; j<=nch; j++) { 533 printf(format, m[i][j]); 534 } 535 printf("\n"); 536 } 537 printf("\n"); 538 } 539 /* ----------------------------------------------------------------------------------------------------------------- */ 540 IMAGE_EXPORT(void) display_ui32matrix_number(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 541 /* ----------------------------------------------------------------------------------------------------------------- */ 542 { 543 int i,j; 544 545 if(name != NULL) printf(name); 546 547 // 1ere ligne 548 printf("%5c", '#'); 549 for(j=ncl; j<=nch; j++) { 550 printf(format, j); 551 } 552 printf("\n"); 553 for(i=nrl; i<=nrh; i++) { 554 printf("[%3d]", i); 555 for(j=ncl; j<=nch; j++) { 556 printf(format, m[i][j]); 557 } 558 printf("\n"); 559 } 560 printf("\n"); 561 } 562 /* ----------------------------------------------------------------------------------------------------------------- */ 563 IMAGE_EXPORT(void) display_si64matrix_number(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 564 /* ----------------------------------------------------------------------------------------------------------------- */ 565 { 566 int i,j; 567 568 if(name != NULL) printf(name); 569 570 // 1ere ligne 571 printf("%5c", '#'); 572 for(j=ncl; j<=nch; j++) { 573 printf(format, j); 574 } 575 printf("\n"); 576 for(i=nrl; i<=nrh; i++) { 577 printf("[%3d]", i); 578 for(j=ncl; j<=nch; j++) { 579 printf(format, m[i][j]); 580 } 581 printf("\n"); 582 } 583 printf("\n"); 584 } 585 /* ----------------------------------------------------------------------------------------------------------------- */ 586 IMAGE_EXPORT(void) display_ui64matrix_number(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 587 /* ----------------------------------------------------------------------------------------------------------------- */ 588 { 589 int i,j; 590 591 if(name != NULL) printf(name); 592 593 // 1ere ligne 594 printf("%5c", '#'); 595 for(j=ncl; j<=nch; j++) { 596 printf(format, j); 597 } 598 printf("\n"); 599 for(i=nrl; i<=nrh; i++) { 600 printf("[%3d]", i); 601 for(j=ncl; j<=nch; j++) { 602 printf(format, m[i][j]); 603 } 604 printf("\n"); 605 } 606 printf("\n"); 607 } 608 /* ----------------------------------------------------------------------------------------------------------------- */ 609 IMAGE_EXPORT(void) display_f32matrix_number(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 610 /* ----------------------------------------------------------------------------------------------------------------- */ 611 { 612 int i,j; 613 614 if(name != NULL) printf(name); 615 616 // 1ere ligne 617 printf("%5c", '#'); 618 for(j=ncl; j<=nch; j++) { 619 printf(format, j); 620 } 621 printf("\n"); 622 for(i=nrl; i<=nrh; i++) { 623 printf("[%3d]", i); 624 for(j=ncl; j<=nch; j++) { 625 printf(format, m[i][j]); 626 } 627 printf("\n"); 628 } 629 printf("\n"); 630 } 631 /* ----------------------------------------------------------------------------------------------------------------- */ 632 IMAGE_EXPORT(void) display_f64matrix_number(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 633 /* ----------------------------------------------------------------------------------------------------------------- */ 634 { 635 int i,j; 636 637 if(name != NULL) printf(name); 638 639 // 1ere ligne 640 printf("%5c", '#'); 641 for(j=ncl; j<=nch; j++) { 642 printf(format, j); 643 } 644 printf("\n"); 645 for(i=nrl; i<=nrh; i++) { 646 printf("[%3d]", i); 647 for(j=ncl; j<=nch; j++) { 648 printf(format, m[i][j]); 649 } 650 printf("\n"); 651 } 652 printf("\n"); 653 } 654 /* --------------------------------------------------------------------------------------------------------------- */ 655 IMAGE_EXPORT(void) display_rgb8matrix_number(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 656 /* --------------------------------------------------------------------------------------------------------------- */ 657 { 658 int i,j; 659 660 if(name != NULL) printf(name); 661 662 // 1ere ligne 663 printf("%5c", '#'); 664 for(j=ncl; j<=nch; j++) { 665 printf(format, j); 666 } 667 printf("\n"); 668 for(i=nrl; i<=nrh; i++) { 669 printf("[%3d]", i); 670 for(j=ncl; j<=nch; j++) { 671 printf(format, m[i][j].r, m[i][j].g, m[i][j].b); 672 } 673 printf("\n"); 674 } 675 printf("\n"); 676 } 677 /* ----------------------------------------------------------------------------------------------------------------- */ 678 IMAGE_EXPORT(void) display_rgbx8matrix_number(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 679 /* ----------------------------------------------------------------------------------------------------------------- */ 680 { 681 int i,j; 682 683 if(name != NULL) printf(name); 684 685 // 1ere ligne 686 printf("%5c", '#'); 687 for(j=ncl; j<=nch; j++) { 688 printf(format, j); 689 } 690 printf("\n"); 691 for(i=nrl; i<=nrh; i++) { 692 printf("[%3d]", i); 693 for(j=ncl; j<=nch; j++) { 694 printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x); 695 } 696 printf("\n"); 697 } 698 printf("\n"); 699 } 266 267 700 268 701 269 /* … … 705 273 */ 706 274 707 // ------------------------------------------------------------------------------------------------ 708 void display_si8matrix_positive(sint8 **m, int i0, int i1, int j0, int j1, int iformat, char *name) 709 // ------------------------------------------------------------------------------------------------ 710 { 711 int i, j; 712 713 char *format, *str; 714 715 select_display_positive_parameters(iformat, &format, &str); 716 717 if(name != NULL) printf(name); 718 719 for(i=i0; i<=i1; i++) { 720 for(j=j0; j<=j1; j++) { 721 if(m[i][j]) { 722 printf(format, m[i][j]); 723 } else { 724 printf("%s", str); 725 } 726 } 727 printf("\n"); 728 } 729 } 730 // ------------------------------------------------------------------------------------------------ 731 void display_ui8matrix_positive(uint8 **m, int i0, int i1, int j0, int j1, int iformat, char *name) 732 // ------------------------------------------------------------------------------------------------ 733 { 734 int i, j; 735 736 char * format; 737 char * str; 738 739 select_display_positive_parameters(iformat, &format, &str); 740 741 if (name != NULL) { 742 printf("%s\n", name); 743 } 744 745 // @QM have to hack this function for the giet 746 for (i = i0; i <= i1; i++) { 747 for (j = j0; j <= j1; j++) { 748 if (m[i][j]) { 749 // For the giet 750 int a = m[i][j]; 751 int len = 0; 752 if (a == 0) { 753 len = 1; 754 } 755 else { 756 while (a != 0) { 757 a = a / 10; 758 len++; 759 } 760 } 761 for (int k = len; k < iformat; k++) { 762 printf(" "); 763 } 764 printf("%d", m[i][j]); 765 } 766 else { 767 printf("%s", str); 768 } 769 } 770 printf("\n"); 771 } 772 } 773 774 775 // -------------------------------------------------------------------------------------------------- 776 void display_si16matrix_positive(sint16 **m, int i0, int i1, int j0, int j1, int iformat, char *name) 777 // -------------------------------------------------------------------------------------------------- 778 { 779 int i, j; 780 781 char *format, *str; 782 783 select_display_positive_parameters(iformat, &format, &str); 784 785 if(name != NULL) printf(name); 786 787 for(i=i0; i<=i1; i++) { 788 for(j=j0; j<=j1; j++) { 789 if(m[i][j]) { 790 printf(format, m[i][j]); 791 } else { 792 printf("%s", str); 793 } 794 } 795 printf("\n"); 796 } 797 } 798 // -------------------------------------------------------------------------------------------------- 799 void display_ui16matrix_positive(uint16 **m, int i0, int i1, int j0, int j1, int iformat, char *name) 800 // -------------------------------------------------------------------------------------------------- 801 { 802 int i, j; 803 char *format, *str; 804 805 select_display_positive_parameters(iformat, &format, &str); 806 807 if(name != NULL) printf(name); 808 809 for(i=i0; i<=i1; i++) { 810 for(j=j0; j<=j1; j++) { 811 if(m[i][j]) { 812 printf(format, m[i][j]); 813 } else { 814 printf("%s", str); 815 } 816 } 817 printf("\n"); 818 } 819 } 820 // -------------------------------------------------------------------------------------------------- 821 void display_si32matrix_positive(sint32 **m, int i0, int i1, int j0, int j1, int iformat, char *name) 822 // -------------------------------------------------------------------------------------------------- 823 { 824 int i, j; 825 char *format, *str; 826 827 select_display_positive_parameters(iformat, &format, &str); 828 829 if(name != NULL) printf(name); 830 831 for(i=i0; i<=i1; i++) { 832 for(j=j0; j<=j1; j++) { 833 if(m[i][j]) { 834 printf(format, m[i][j]); 835 } else { 836 printf("%s", str); 837 } 838 } 839 printf("\n"); 840 } 841 } 842 // -------------------------------------------------------------------------------------------------- 843 void display_ui32matrix_positive(uint32 **m, int i0, int i1, int j0, int j1, int iformat, char *name) 844 // -------------------------------------------------------------------------------------------------- 845 { 846 int i, j; 847 char * format; 848 char * str; 849 850 select_display_positive_parameters(iformat, &format, &str); 851 852 if (name != NULL) { 853 printf("%s\n", name); 854 } 855 856 // @QM have to hack this function for the giet 857 for (i = i0; i <= i1; i++) { 858 for (j = j0; j <= j1; j++) { 859 if (m[i][j] != 0) { 860 int a = m[i][j]; 861 int len = 0; 862 if (a == 0) { 863 len = 1; 864 } 865 else { 866 while (a != 0) { 867 a = a / 10; 868 len++; 869 } 870 } 871 for (int k = len; k < iformat; k++) { 872 printf(" "); 873 } 874 printf("%d", m[i][j]); 875 } 876 else { 877 printf("%s", str); 878 } 879 } 880 printf("\n"); 881 } 882 883 } 884 // -------------------------------------------------------------------------------------------------- 885 void display_si64matrix_positive(sint64 **m, int i0, int i1, int j0, int j1, int iformat, char *name) 886 // -------------------------------------------------------------------------------------------------- 887 { 888 int i, j; 889 char *format, *str; 890 891 select_display_positive_parameters(iformat, &format, &str); 892 893 if(name != NULL) printf(name); 894 895 for(i=i0; i<=i1; i++) { 896 for(j=j0; j<=j1; j++) { 897 if(m[i][j]) { 898 printf(format, m[i][j]); 899 } else { 900 printf("%s", str); 901 } 902 } 903 printf("\n"); 904 } 905 } 906 // -------------------------------------------------------------------------------------------------- 907 void display_ui64matrix_positive(uint64 **m, int i0, int i1, int j0, int j1, int iformat, char *name) 908 // -------------------------------------------------------------------------------------------------- 909 { 910 int i, j; 911 char *format, *str; 912 913 select_display_positive_parameters(iformat, &format, &str); 914 915 if(name != NULL) printf(name); 916 917 for(i=i0; i<=i1; i++) { 918 for(j=j0; j<=j1; j++) { 919 if(m[i][j]) { 920 printf(format, m[i][j]); 921 } else { 922 printf("%s", str); 923 } 924 } 925 printf("\n"); 926 } 927 } 928 275 #if TARGET_OS != GIETVM 276 277 #undef display_type_matrix_positive 278 #define display_type_matrix_positive(t) \ 279 void short_name(t,display_,matrix_positive)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t iformat, char * name) \ 280 { \ 281 char * format; \ 282 char * str; \ 283 select_display_positive_parameters(iformat, &format, &str); \ 284 if (name != NULL) { \ 285 printf("%s\n", name); \ 286 } \ 287 for (int32_t i = i0; i <= i1; i++) { \ 288 for (int32_t j = j0; j <= j1; j++) { \ 289 if (m[i][j] != 0) { \ 290 printf(format, m[i][j]); \ 291 } \ 292 else { \ 293 printf("%s", str); \ 294 } \ 295 } \ 296 printf("\n"); \ 297 } \ 298 printf("\n"); \ 299 } 300 301 #else 302 303 #undef display_type_matrix_positive 304 #define display_type_matrix_positive(t) \ 305 void short_name(t,display_,matrix_positive)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t iformat, char * name) \ 306 { \ 307 char * format; \ 308 char * str; \ 309 select_display_positive_parameters(iformat, &format, &str); \ 310 if (name != NULL) { \ 311 printf("%s\n", name); \ 312 } \ 313 for (int32_t i = i0; i <= i1; i++) { \ 314 for (int32_t j = j0; j <= j1; j++) { \ 315 if (m[i][j] != 0) { \ 316 int32_t a = m[i][j]; \ 317 int32_t len = 0; \ 318 if (a == 0) { \ 319 len = 1; \ 320 } \ 321 else { \ 322 while (a != 0) { \ 323 a = a / 10; \ 324 len++; \ 325 } \ 326 } \ 327 for (int32_t k = len; k < iformat; k++) { \ 328 printf(" "); \ 329 } \ 330 printf(format, m[i][j]); \ 331 } \ 332 else { \ 333 printf("%s", str); \ 334 } \ 335 } \ 336 printf("\n"); \ 337 } \ 338 printf("\n"); \ 339 } 340 341 #endif 342 343 344 display_type_matrix_positive(int8_t); 345 display_type_matrix_positive(uint8_t); 346 display_type_matrix_positive(int16_t); 347 display_type_matrix_positive(uint16_t); 348 display_type_matrix_positive(int32_t); 349 display_type_matrix_positive(uint32_t); 350 display_type_matrix_positive(int64_t); 351 display_type_matrix_positive(uint64_t); 352 display_type_matrix_positive(float); 353 display_type_matrix_positive(double); 929 354 930 355 … … 974 399 975 400 /* ------------------------------------------------- */ 976 static void ReadPGMrow(int fd, int width, uint8 * line)401 static void ReadPGMrow(int32_t fd, int32_t width, uint8 * line) 977 402 /* ------------------------------------------------- */ 978 403 { 979 read(fd, &line[0], sizeof(uint8 ) * width);404 read(fd, &line[0], sizeof(uint8_t) * width); 980 405 } 981 406 982 407 983 408 /* -------------------------------------------------- */ 984 static void WritePGMrow(uint8 * line, int width, int fd)409 static void WritePGMrow(uint8_t * line, int32_t width, int32_t fd) 985 410 /* -------------------------------------------------- */ 986 411 { 987 write(fd, &line[0], sizeof(uint8 ) * width);412 write(fd, &line[0], sizeof(uint8_t) * width); 988 413 } 989 414 990 415 991 416 /* ----------------------------------------------------------------------------------------------- */ 992 IMAGE_EXPORT(uint8 **)LoadPGM_ui8matrix(char * filename, int * nrl, int * nrh, int * ncl, int * nch)417 uint8_t ** LoadPGM_ui8matrix(char * filename, int * nrl, int * nrh, int * ncl, int * nch) 993 418 /* ----------------------------------------------------------------------------------------------- */ 994 419 { 995 420 // only for P5 binary type, not for text type 996 421 997 int height, width, gris;998 uint8 ** m;999 int fd;422 int32_t height, width, gris; 423 uint8_t ** m; 424 int32_t fd; 1000 425 1001 426 char buffer[80]; 1002 int i;1003 427 (void) gris; 1004 428 … … 1026 450 m = ui8matrix(*nrl, *nrh, *ncl, *nch); 1027 451 1028 for (i = 0; i < height; i++) {452 for (int32_t i = 0; i < height; i++) { 1029 453 ReadPGMrow(fd, width, m[i]); 1030 454 } … … 1037 461 1038 462 /* ----------------------------------------------------------------------------------------------- */ 1039 IMAGE_EXPORT(void)SavePGM_ui8matrix(uint8 ** m, int nrl, int nrh, int ncl, int nch, char * filename)463 void SavePGM_ui8matrix(uint8 ** m, int nrl, int nrh, int ncl, int nch, char * filename) 1040 464 /* ----------------------------------------------------------------------------------------------- */ 1041 465 { 1042 int nrow = nrh - nrl + 1;1043 int ncol = nch - ncl + 1;466 int32_t nrow = nrh - nrl + 1; 467 int32_t ncol = nch - ncl + 1; 1044 468 1045 469 char buffer[80]; 1046 470 1047 int fd; 1048 int i; 471 int32_t fd; 1049 472 1050 473 //fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT); … … 1058 481 snprintf(buffer, 80, "P5\n%d %d\n255\n", ncol, nrow); 1059 482 write(fd, buffer, strlen(buffer)); 1060 for (i = nrl; i <= nrh; i++) {483 for (int32_t i = nrl; i <= nrh; i++) { 1061 484 WritePGMrow(m[i], ncol, fd); 1062 485 } … … 1068 491 1069 492 493 // Local Variables: 494 // tab-width: 4 495 // c-basic-offset: 4 496 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 497 // indent-tabs-mode: nil 498 // End: 499 500 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 501 -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrio2f.c
r772 r822 15 15 #include <stddef.h> 16 16 #include <stdlib.h> 17 17 #include <string.h> 18 #include <ctype.h> 19 20 #include "nrc_os_config.h" 18 21 #include "mypredef.h" 19 22 #include "nrtype.h" … … 34 37 */ 35 38 36 /* ---------------------------------------------------------------------------------------------------------- */ 37 IMAGE_EXPORT(void) write_si8matrix(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 38 /* ---------------------------------------------------------------------------------------------------------- */ 39 { 40 int i,j; 41 42 FILE *f; 43 44 f = fopen(filename, "wt"); 45 if(f == NULL) { 46 nrerror("Can't open file in write_si8matrix"); 47 } 48 49 for(i=nrl; i<=nrh; i++) { 50 for(j=ncl; j<=nch; j++) { 51 fprintf(f, format, m[i][j]); 52 } 53 fputc('\n', f); 54 } 55 fclose(f); 56 } 57 /* ---------------------------------------------------------------------------------------------------------- */ 58 IMAGE_EXPORT(void) write_ui8matrix(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 59 /* ---------------------------------------------------------------------------------------------------------- */ 60 { 61 int i,j; 62 63 FILE *f; 64 65 f = fopen(filename, "wt"); 66 if(f == NULL) { 67 nrerror("Can't open file in write_ui8matrix"); 68 } 69 70 for(i=nrl; i<=nrh; i++) { 71 for(j=ncl; j<=nch; j++) { 72 fprintf(f, format, m[i][j]); 73 } 74 fputc('\n', f); 75 } 76 fclose(f); 77 } 78 /* ------------------------------------------------------------------------------------------------------------ */ 79 IMAGE_EXPORT(void) write_si16matrix(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 80 /* ------------------------------------------------------------------------------------------------------------ */ 81 { 82 int i,j; 83 84 FILE *f; 85 86 f = fopen(filename, "wt"); 87 if(f == NULL) { 88 nrerror("Can't open file in write_si16matrix"); 89 } 90 91 for(i=nrl; i<=nrh; i++) { 92 for(j=ncl; j<=nch; j++) { 93 fprintf(f, format, m[i][j]); 94 } 95 fputc('\n', f); 96 } 97 fclose(f); 98 } 99 /* ------------------------------------------------------------------------------------------------------------ */ 100 IMAGE_EXPORT(void) write_ui16matrix(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 101 /* ------------------------------------------------------------------------------------------------------------ */ 102 { 103 int i,j; 104 105 FILE *f; 106 107 f = fopen(filename, "wt"); 108 if(f == NULL) { 109 nrerror("Can't open file in write_ui16matrix"); 110 } 111 112 for(i=nrl; i<=nrh; i++) { 113 for(j=ncl; j<=nch; j++) { 114 fprintf(f, format, m[i][j]); 115 } 116 fputc('\n', f); 117 } 118 fclose(f); 119 } 120 /* ------------------------------------------------------------------------------------------------------------ */ 121 IMAGE_EXPORT(void) write_si32matrix(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 122 /* ------------------------------------------------------------------------------------------------------------ */ 123 { 124 int i,j; 125 126 FILE *f; 127 128 f = fopen(filename, "wt"); 129 if(f == NULL) { 130 nrerror("Can't open file in write_si32matrix"); 131 } 132 133 for(i=nrl; i<=nrh; i++) { 134 for(j=ncl; j<=nch; j++) { 135 fprintf(f, format, m[i][j]); 136 } 137 fputc('\n', f); 138 } 139 fclose(f); 140 } 141 /* ------------------------------------------------------------------------------------------------------------ */ 142 IMAGE_EXPORT(void) write_ui32matrix(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 143 /* ------------------------------------------------------------------------------------------------------------ */ 144 { 145 int i,j; 146 147 FILE *f; 148 149 f = fopen(filename, "wt"); 150 if(f == NULL) { 151 nrerror("Can't open file in write_ui32matrix"); 152 } 153 154 for(i=nrl; i<=nrh; i++) { 155 for(j=ncl; j<=nch; j++) { 156 fprintf(f, format, m[i][j]); 157 } 158 fputc('\n', f); 159 } 160 fclose(f); 161 } 162 /* ------------------------------------------------------------------------------------------------------------ */ 163 IMAGE_EXPORT(void) write_si64matrix(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 164 /* ------------------------------------------------------------------------------------------------------------ */ 165 { 166 int i,j; 167 168 FILE *f; 169 170 f = fopen(filename, "wt"); 171 if(f == NULL) { 172 nrerror("Can't open file in write_si64matrix"); 173 } 174 175 for(i=nrl; i<=nrh; i++) { 176 for(j=ncl; j<=nch; j++) { 177 fprintf(f, format, m[i][j]); 178 } 179 fputc('\n', f); 180 } 181 fclose(f); 182 } 183 /* ------------------------------------------------------------------------------------------------------------ */ 184 IMAGE_EXPORT(void) write_ui64matrix(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 185 /* ------------------------------------------------------------------------------------------------------------ */ 186 { 187 int i,j; 188 189 FILE *f; 190 191 f = fopen(filename, "wt"); 192 if(f == NULL) { 193 nrerror("Can't open file in write_ui64matrix"); 194 } 195 196 for(i=nrl; i<=nrh; i++) { 197 for(j=ncl; j<=nch; j++) { 198 fprintf(f, format, m[i][j]); 199 } 200 fputc('\n', f); 201 } 202 fclose(f); 203 } 204 /* ------------------------------------------------------------------------------------------------------------ */ 205 IMAGE_EXPORT(void) write_f32matrix(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 206 /* ------------------------------------------------------------------------------------------------------------ */ 207 { 208 int i,j; 209 210 FILE *f; 211 212 f = fopen(filename, "wt"); 213 if(f == NULL) { 214 nrerror("Can't open file in write_f32matrix"); 215 } 216 217 for(i=nrl; i<=nrh; i++) { 218 for(j=ncl; j<=nch; j++) { 219 fprintf(f, format, m[i][j]); 220 } 221 fputc('\n', f); 222 } 223 fclose(f); 224 } 225 /* ------------------------------------------------------------------------------------------------------------ */ 226 IMAGE_EXPORT(void) write_f64matrix(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 227 /* ------------------------------------------------------------------------------------------------------------ */ 228 { 229 int i,j; 230 231 FILE *f; 232 233 f = fopen(filename, "wt"); 234 if(f == NULL) { 235 nrerror("Can't open file in write_f64matrix"); 236 } 237 238 for(i=nrl; i<=nrh; i++) { 239 for(j=ncl; j<=nch; j++) { 240 fprintf(f, format, m[i][j]); 241 } 242 fputc('\n', f); 243 } 244 fclose(f); 245 } 246 /* ---------------------------------------------------------------------------------------------------------- */ 247 IMAGE_EXPORT(void) write_rgb8matrix(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 248 /* ---------------------------------------------------------------------------------------------------------- */ 249 { 250 int i,j; 251 252 FILE *f; 253 254 f = fopen(filename, "wt"); 255 if(f == NULL) { 256 nrerror("Can't open file in write_rgb8matrix"); 257 } 258 259 for(i=nrl; i<=nrh; i++) { 260 for(j=ncl; j<=nch; j++) { 261 fprintf(f, format, m[i][j].r, m[i][j].g, m[i][j].b); 262 } 263 fputc('\n', f); 264 } 265 fclose(f); 266 } 267 /* ------------------------------------------------------------------------------------------------------------ */ 268 IMAGE_EXPORT(void) write_rgbx8matrix(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 269 /* ------------------------------------------------------------------------------------------------------------ */ 270 { 271 int i,j; 272 273 FILE *f; 274 275 f = fopen(filename, "wt"); 276 if(f == NULL) { 277 nrerror("Can't open file in write_rgbx8matrix"); 278 } 279 280 for(i=nrl; i<=nrh; i++) { 281 for(j=ncl; j<=nch; j++) { 282 fprintf(f, format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x); 283 } 284 fputc('\n', f); 285 } 286 fclose(f); 287 } 39 #undef write_type_matrix 40 #define write_type_matrix(t) \ 41 void short_name(t,write_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename) \ 42 { \ 43 FILE * f = fopen(filename, "wt"); \ 44 if (f == NULL) { \ 45 nrerror("Can't open file %s in %s", filename, __func__); \ 46 } \ 47 for (int32_t i = nrl; i <= nrh; i++) { \ 48 for (int32_t j = ncl; j <= nch; j++) { \ 49 fprintf(f, format, elem); \ 50 } \ 51 fprintf(f, "\n"); \ 52 } \ 53 fclose(f); \ 54 } 55 56 #undef elem 57 #define elem m[i][j] 58 write_type_matrix(int8_t); 59 write_type_matrix(uint8_t); 60 write_type_matrix(int16_t); 61 write_type_matrix(uint16_t); 62 write_type_matrix(int32_t); 63 write_type_matrix(uint32_t); 64 write_type_matrix(int64_t); 65 write_type_matrix(uint64_t); 66 write_type_matrix(float); 67 write_type_matrix(double); 68 #undef elem 69 #define elem m[i][j].r, m[i][j].g, m[i][j].b 70 write_type_matrix(rgb8); 71 #undef elem 72 #define elem m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x 73 write_type_matrix(rgbx8); 74 288 75 289 76 /* … … 293 80 */ 294 81 295 /* ------------------------------------------------------------------------------------------------------------ */ 296 IMAGE_EXPORT(void) write_si8matrix_T(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 297 /* ------------------------------------------------------------------------------------------------------------ */ 298 { 299 long i,j; 300 301 FILE *f; 302 303 f = fopen(filename, "wt"); 304 if(f == NULL) { 305 nrerror("Can't open file in write_si8matrix_T"); 306 } 307 308 for(j=ncl; j<=nch; j++) { 309 for(i=nrl; i<=nrh; i++) { 310 fprintf(f, format, m[i][j]); 311 } 312 fputc('\n', f); 313 } 314 fclose(f); 315 } 316 /* ------------------------------------------------------------------------------------------------------------ */ 317 IMAGE_EXPORT(void) write_ui8matrix_T(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 318 /* ------------------------------------------------------------------------------------------------------------ */ 319 { 320 long i,j; 321 322 FILE *f; 323 324 f = fopen(filename, "wt"); 325 if(f == NULL) { 326 nrerror("Can't open file in write_ui8matrix_T"); 327 } 328 329 for(j=ncl; j<=nch; j++) { 330 for(i=nrl; i<=nrh; i++) { 331 fprintf(f, format, m[i][j]); 332 } 333 fputc('\n', f); 334 } 335 fclose(f); 336 } 337 /* -------------------------------------------------------------------------------------------------------------- */ 338 IMAGE_EXPORT(void) write_si32matrix_T(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 339 /* -------------------------------------------------------------------------------------------------------------- */ 340 { 341 long i,j; 342 343 FILE *f; 344 345 f = fopen(filename, "wt"); 346 if(f == NULL) { 347 nrerror("Can't open file in write_si32matrix_T"); 348 } 349 350 for(j=ncl; j<=nch; j++) { 351 for(i=nrl; i<=nrh; i++) { 352 fprintf(f, format, m[i][j]); 353 } 354 fputc('\n', f); 355 } 356 fclose(f); 357 } 358 /* -------------------------------------------------------------------------------------------------------------- */ 359 IMAGE_EXPORT(void) write_ui32matrix_T(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 360 /* -------------------------------------------------------------------------------------------------------------- */ 361 { 362 long i,j; 363 364 FILE *f; 365 366 f = fopen(filename, "wt"); 367 if(f == NULL) { 368 nrerror("Can't open file in write_ui32matrix_T"); 369 } 370 371 for(j=ncl; j<=nch; j++) { 372 for(i=nrl; i<=nrh; i++) { 373 fprintf(f, format, m[i][j]); 374 } 375 fputc('\n', f); 376 } 377 fclose(f); 378 } 379 /* -------------------------------------------------------------------------------------------------------------- */ 380 IMAGE_EXPORT(void) write_si64matrix_T(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 381 /* -------------------------------------------------------------------------------------------------------------- */ 382 { 383 long i,j; 384 385 FILE *f; 386 387 f = fopen(filename, "wt"); 388 if(f == NULL) { 389 nrerror("Can't open file in write_si64matrix_T"); 390 } 391 392 for(j=ncl; j<=nch; j++) { 393 for(i=nrl; i<=nrh; i++) { 394 fprintf(f, format, m[i][j]); 395 } 396 fputc('\n', f); 397 } 398 fclose(f); 399 } 400 /* -------------------------------------------------------------------------------------------------------------- */ 401 IMAGE_EXPORT(void) write_ui64matrix_T(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 402 /* -------------------------------------------------------------------------------------------------------------- */ 403 { 404 long i,j; 405 406 FILE *f; 407 408 f = fopen(filename, "wt"); 409 if(f == NULL) { 410 nrerror("Can't open file in write_ui64matrix_T"); 411 } 412 413 for(j=ncl; j<=nch; j++) { 414 for(i=nrl; i<=nrh; i++) { 415 fprintf(f, format, m[i][j]); 416 } 417 fputc('\n', f); 418 } 419 fclose(f); 420 } 421 /* -------------------------------------------------------------------------------------------------------------- */ 422 IMAGE_EXPORT(void) write_f32matrix_T(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 423 /* -------------------------------------------------------------------------------------------------------------- */ 424 { 425 long i,j; 426 427 FILE *f; 428 429 f = fopen(filename, "wt"); 430 if(f == NULL) { 431 nrerror("Can't open file in write_f32matrix"); 432 } 433 434 for(j=ncl; j<=nch; j++) { 435 for(i=nrl; i<=nrh; i++) { 436 fprintf(f, format, m[i][j]); 437 } 438 fputc('\n', f); 439 } 440 fclose(f); 441 } 442 /* -------------------------------------------------------------------------------------------------------------- */ 443 IMAGE_EXPORT(void) write_f64matrix_T(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 444 /* -------------------------------------------------------------------------------------------------------------- */ 445 { 446 long i,j; 447 448 FILE *f; 449 450 f = fopen(filename, "wt"); 451 if(f == NULL) { 452 nrerror("Can't open file in write_f64matrix"); 453 } 454 455 for(j=ncl; j<=nch; j++) { 456 for(i=nrl; i<=nrh; i++) { 457 fprintf(f, format, m[i][j]); 458 } 459 fputc('\n', f); 460 } 461 fclose(f); 462 } 463 /* ------------------------------------------------------------------------------------------------------------ */ 464 IMAGE_EXPORT(void) write_rgb8matrix_T(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 465 /* ------------------------------------------------------------------------------------------------------------ */ 466 { 467 long i,j; 468 469 FILE *f; 470 471 f = fopen(filename, "wt"); 472 if(f == NULL) { 473 nrerror("Can't open file in write_rgb8matrix"); 474 } 475 476 for(j=ncl; j<=nch; j++) { 477 for(i=nrl; i<=nrh; i++) { 478 fprintf(f, format, m[i][j].r, m[i][j].g, m[i][j].b); 479 } 480 fputc('\n', f); 481 } 482 fclose(f); 483 } 484 /* -------------------------------------------------------------------------------------------------------------- */ 485 IMAGE_EXPORT(void) write_rgbx8matrix_T(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 486 /* -------------------------------------------------------------------------------------------------------------- */ 487 { 488 long i,j; 489 490 FILE *f; 491 492 f = fopen(filename, "wt"); 493 if(f == NULL) { 494 nrerror("Can't open file in write_rgb8matrix"); 495 } 496 497 for(j=ncl; j<=nch; j++) { 498 for(i=nrl; i<=nrh; i++) { 499 fprintf(f, format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x); 500 } 501 fputc('\n', f); 502 } 503 fclose(f); 504 } 82 83 #undef write_type_matrix_T 84 #define write_type_matrix_T(t) \ 85 void short_name(t,write_,matrix_T)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename) \ 86 { \ 87 FILE * f = fopen(filename, "wt"); \ 88 if (f == NULL) { \ 89 nrerror("Can't open file %s in %s", filename, __func__); \ 90 } \ 91 for (int32_t j = ncl; j <= nch; j++) { \ 92 for (int32_t i = nrl; i <= nrh; i++) { \ 93 fprintf(f, format, elem); \ 94 } \ 95 fprintf(f, "\n"); \ 96 } \ 97 fclose(f); \ 98 } 99 100 #undef elem 101 #define elem m[i][j] 102 write_type_matrix_T(int8_t); 103 write_type_matrix_T(uint8_t); 104 write_type_matrix_T(int16_t); 105 write_type_matrix_T(uint16_t); 106 write_type_matrix_T(int32_t); 107 write_type_matrix_T(uint32_t); 108 write_type_matrix_T(int64_t); 109 write_type_matrix_T(uint64_t); 110 write_type_matrix_T(float); 111 write_type_matrix_T(double); 112 #undef elem 113 #define elem m[i][j].r, m[i][j].g, m[i][j].b 114 write_type_matrix_T(rgb8); 115 #undef elem 116 #define elem m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x 117 write_type_matrix_T(rgbx8); 118 119 505 120 506 121 /* … … 510 125 */ 511 126 512 /* ----------------------------------------------------------------------------------------------------------------- */ 513 IMAGE_EXPORT(void) write_si8matrix_number(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 514 /* ----------------------------------------------------------------------------------------------------------------- */ 515 { 516 int i,j; 517 518 FILE *f; 519 520 f = fopen(filename, "wt"); 521 if(f == NULL) { 522 nrerror("Can't open file in write_si8matrix_number"); 523 } 524 525 // entete 526 fprintf(f, "%5c", '#'); 527 for(j=ncl; j<=nch; j++) { 528 fprintf(f, format, j); 529 } 530 fputc('\n', f); 531 532 for(i=nrl; i<=nrh; i++) { 533 fprintf(f, "[%3d]", i); 534 for(j=ncl; j<=nch; j++) { 535 fprintf(f, format, m[i][j]); 536 } 537 fputc('\n', f); 538 } 539 fclose(f); 540 } 541 /* ----------------------------------------------------------------------------------------------------------------- */ 542 IMAGE_EXPORT(void) write_ui8matrix_number(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 543 /* ----------------------------------------------------------------------------------------------------------------- */ 544 { 545 int i,j; 546 547 FILE *f; 548 549 f = fopen(filename, "wt"); 550 if(f == NULL) { 551 nrerror("Can't open file in write_ui8matrix_number"); 552 } 553 554 // entete 555 fprintf(f, "%5c", '#'); 556 for(j=ncl; j<=nch; j++) { 557 fprintf(f, format, j); 558 } 559 fputc('\n', f); 560 561 for(i=nrl; i<=nrh; i++) { 562 fprintf(f, "[%3d]", i); 563 for(j=ncl; j<=nch; j++) { 564 fprintf(f, format, m[i][j]); 565 } 566 fputc('\n', f); 567 } 568 fclose(f); 569 } 570 /* ------------------------------------------------------------------------------------------------------------------- */ 571 IMAGE_EXPORT(void) write_si16matrix_number(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 572 /* ------------------------------------------------------------------------------------------------------------------- */ 573 { 574 int i,j; 575 576 FILE *f; 577 578 f = fopen(filename, "wt"); 579 if(f == NULL) { 580 nrerror("Can't open file in write_si16matrix"); 581 } 582 583 // entete 584 fprintf(f, "%5c", '#'); 585 for(j=ncl; j<=nch; j++) { 586 fprintf(f, format, j); 587 } 588 fputc('\n', f); 589 590 for(i=nrl; i<=nrh; i++) { 591 fprintf(f, "[%3d]", i); 592 for(j=ncl; j<=nch; j++) { 593 fprintf(f, format, m[i][j]); 594 } 595 fputc('\n', f); 596 } 597 fclose(f); 598 } 599 /* ------------------------------------------------------------------------------------------------------------------- */ 600 IMAGE_EXPORT(void) write_ui16matrix_number(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 601 /* ------------------------------------------------------------------------------------------------------------------- */ 602 { 603 int i,j; 604 605 FILE *f; 606 607 f = fopen(filename, "wt"); 608 if(f == NULL) { 609 nrerror("Can't open file in write_ui16matrix"); 610 } 611 612 // entete 613 fprintf(f, "%5c", '#'); 614 for(j=ncl; j<=nch; j++) { 615 fprintf(f, format, j); 616 } 617 fputc('\n', f); 618 619 for(i=nrl; i<=nrh; i++) { 620 fprintf(f, "[%3d]", i); 621 for(j=ncl; j<=nch; j++) { 622 fprintf(f, format, m[i][j]); 623 } 624 fputc('\n', f); 625 } 626 fclose(f); 627 } 628 /* ------------------------------------------------------------------------------------------------------------------- */ 629 IMAGE_EXPORT(void) write_si32matrix_number(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 630 /* ------------------------------------------------------------------------------------------------------------------- */ 631 { 632 int i,j; 633 634 FILE *f; 635 636 f = fopen(filename, "wt"); 637 if(f == NULL) { 638 nrerror("Can't open file in write_si32matrix"); 639 } 640 641 // entete 642 fprintf(f, "%5c", '#'); 643 for(j=ncl; j<=nch; j++) { 644 fprintf(f, format, j); 645 } 646 fputc('\n', f); 647 648 for(i=nrl; i<=nrh; i++) { 649 fprintf(f, "[%3d]", i); 650 for(j=ncl; j<=nch; j++) { 651 fprintf(f, format, m[i][j]); 652 } 653 fputc('\n', f); 654 } 655 fclose(f); 656 } 657 /* ------------------------------------------------------------------------------------------------------------------- */ 658 IMAGE_EXPORT(void) write_ui32matrix_number(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 659 /* ------------------------------------------------------------------------------------------------------------------- */ 660 { 661 int i,j; 662 663 FILE *f; 664 665 f = fopen(filename, "wt"); 666 if(f == NULL) { 667 nrerror("Can't open file in write_ui32matrix"); 668 } 669 670 // entete 671 fprintf(f, "%5c", '#'); 672 for(j=ncl; j<=nch; j++) { 673 fprintf(f, format, j); 674 } 675 fputc('\n', f); 676 677 for(i=nrl; i<=nrh; i++) { 678 fprintf(f, "[%3d]", i); 679 for(j=ncl; j<=nch; j++) { 680 fprintf(f, format, m[i][j]); 681 } 682 fputc('\n', f); 683 } 684 fclose(f); 685 } 686 /* ------------------------------------------------------------------------------------------------------------------- */ 687 IMAGE_EXPORT(void) write_si64matrix_number(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 688 /* ------------------------------------------------------------------------------------------------------------------- */ 689 { 690 int i,j; 691 692 FILE *f; 693 694 f = fopen(filename, "wt"); 695 if(f == NULL) { 696 nrerror("Can't open file in write_si64matrix"); 697 } 698 699 // entete 700 fprintf(f, "%5c", '#'); 701 for(j=ncl; j<=nch; j++) { 702 fprintf(f, format, j); 703 } 704 fputc('\n', f); 705 706 for(i=nrl; i<=nrh; i++) { 707 fprintf(f, "[%3d]", i); 708 for(j=ncl; j<=nch; j++) { 709 fprintf(f, format, m[i][j]); 710 } 711 fputc('\n', f); 712 } 713 fclose(f); 714 } 715 /* ------------------------------------------------------------------------------------------------------------------- */ 716 IMAGE_EXPORT(void) write_ui64matrix_number(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 717 /* ------------------------------------------------------------------------------------------------------------------- */ 718 { 719 int i,j; 720 721 FILE *f; 722 723 f = fopen(filename, "wt"); 724 if(f == NULL) { 725 nrerror("Can't open file in write_ui64matrix"); 726 } 727 728 // entete 729 fprintf(f, "%5c", '#'); 730 for(j=ncl; j<=nch; j++) { 731 fprintf(f, format, j); 732 } 733 fputc('\n', f); 734 735 for(i=nrl; i<=nrh; i++) { 736 fprintf(f, "[%3d]", i); 737 for(j=ncl; j<=nch; j++) { 738 fprintf(f, format, m[i][j]); 739 } 740 fputc('\n', f); 741 } 742 fclose(f); 743 } 744 /* ------------------------------------------------------------------------------------------------------------------- */ 745 IMAGE_EXPORT(void) write_f32matrix_number(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 746 /* ------------------------------------------------------------------------------------------------------------------- */ 747 { 748 int i,j; 749 750 FILE *f; 751 752 f = fopen(filename, "wt"); 753 if(f == NULL) { 754 nrerror("Can't open file in write_f32matrix_number"); 755 } 756 757 // entete 758 fprintf(f, "%4d", 0); 759 for(j=ncl; j<=nch; j++) { 760 fprintf(f, format, (float32)j); 761 } 762 fputc('\n', f); 763 764 for(i=nrl; i<=nrh; i++) { 765 fprintf(f, "%4d", i); 766 for(j=ncl; j<=nch; j++) { 767 fprintf(f, format, m[i][j]); 768 } 769 fputc('\n', f); 770 } 771 fclose(f); 772 } 773 /* ------------------------------------------------------------------------------------------------------------------- */ 774 IMAGE_EXPORT(void) write_f64matrix_number(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 775 /* ------------------------------------------------------------------------------------------------------------------- */ 776 { 777 int i,j; 778 779 FILE *f; 780 781 f = fopen(filename, "wt"); 782 if(f == NULL) { 783 nrerror("Can't open file in write_f64matrix_number"); 784 } 785 786 // entete 787 fprintf(f, "%4d", 0); 788 for(j=ncl; j<=nch; j++) { 789 fprintf(f, format, (float32)j); 790 } 791 fputc('\n', f); 792 793 for(i=nrl; i<=nrh; i++) { 794 fprintf(f, "%4d", i); 795 for(j=ncl; j<=nch; j++) { 796 fprintf(f, format, m[i][j]); 797 } 798 fputc('\n', f); 799 } 800 fclose(f); 801 } 802 /* ----------------------------------------------------------------------------------------------------------------- */ 803 IMAGE_EXPORT(void) write_rgb8matrix_number(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 804 /* ----------------------------------------------------------------------------------------------------------------- */ 805 { 806 int i,j; 807 808 FILE *f; 809 810 f = fopen(filename, "wt"); 811 if(f == NULL) { 812 nrerror("Can't open file in write_rgb8matrix_number"); 813 } 814 815 // entete 816 fprintf(f, "%4d", 0); 817 for(j=ncl; j<=nch; j++) { 818 fprintf(f, format, (float32)j); 819 } 820 fputc('\n', f); 821 822 for(i=nrl; i<=nrh; i++) { 823 fprintf(f, "%4d", i); 824 for(j=ncl; j<=nch; j++) { 825 fprintf(f, format, m[i][j].r, m[i][j].g, m[i][j].b); 826 } 827 fputc('\n', f); 828 } 829 fclose(f); 830 } 831 /* ------------------------------------------------------------------------------------------------------------------- */ 832 IMAGE_EXPORT(void) write_rgb8xmatrix_number(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 833 /* ------------------------------------------------------------------------------------------------------------------- */ 834 { 835 int i,j; 836 837 FILE *f; 838 839 f = fopen(filename, "wt"); 840 if(f == NULL) { 841 nrerror("Can't open file in write_rgbx8matrix_number"); 842 } 843 844 // entete 845 fprintf(f, "%4d", 0); 846 for(j=ncl; j<=nch; j++) { 847 fprintf(f, format, (float32)j); 848 } 849 fputc('\n', f); 850 851 for(i=nrl; i<=nrh; i++) { 852 fprintf(f, "%4d", i); 853 for(j=ncl; j<=nch; j++) { 854 fprintf(f, format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x); 855 } 856 fputc('\n', f); 857 } 858 fclose(f); 859 } 127 128 #undef write_type_matrix_number 129 #define write_type_matrix_number(t) \ 130 void short_name(t,write_,matrix_number)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename) \ 131 { \ 132 FILE * f = fopen(filename, "wt"); \ 133 if (f == NULL) { \ 134 nrerror("Can't open file %s in %s", filename, __func__); \ 135 } \ 136 fprintf(f, "%5c", '#'); \ 137 for (int32_t j = ncl; j <= nch; j++) { \ 138 fprintf(f, format, j); \ 139 } \ 140 fprintf(f, "\n"); \ 141 for (int32_t i = nrl; i <= nrh; i++) { \ 142 fprintf(f, "[%3d]", i); \ 143 for (int32_t j = ncl; j <= nch; j++) { \ 144 fprintf(f, format, m[i][j]); \ 145 } \ 146 fprintf(f, "\n"); \ 147 } \ 148 fclose(f); \ 149 } 150 151 152 #undef elem 153 #define elem m[i][j] 154 write_type_matrix_number(int8_t); 155 write_type_matrix_number(uint8_t); 156 write_type_matrix_number(int16_t); 157 write_type_matrix_number(uint16_t); 158 write_type_matrix_number(int32_t); 159 write_type_matrix_number(uint32_t); 160 write_type_matrix_number(int64_t); 161 write_type_matrix_number(uint64_t); 162 write_type_matrix_number(float); 163 write_type_matrix_number(double); 164 #undef elem 165 #define elem m[i][j].r, m[i][j].g, m[i][j].b 166 write_type_matrix_number(rgb8); 167 #undef elem 168 #define elem m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x 169 write_type_matrix_number(rgbx8); 170 171 860 172 /* 861 173 * ----------------------------- … … 863 175 * ----------------------------- 864 176 */ 865 /* ------------------------------------------------------------------------------------------------------------------- */ 866 IMAGE_EXPORT(void) write_si8matrix_T_number(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 867 /* ------------------------------------------------------------------------------------------------------------------- */ 868 { 869 int i,j; 870 871 FILE *f; 872 873 f = fopen(filename, "wt"); 874 if(f == NULL) { 875 nrerror("Can't open file in write_si8matrix_T_number"); 876 } 877 878 fprintf(f, "%5c", '#'); 879 for(i=nrl; i<=nrh; i++) { 880 fprintf(f, format, i); 881 } 882 fputc('\n', f); 883 884 for(j=ncl; j<=nch; j++) { 885 fprintf(f, "[%3d]", j); 886 for(i=nrl; i<=nrh; i++) { 887 fprintf(f, format, m[i][j]); 888 } 889 fputc('\n', f); 890 } 891 fclose(f); 892 } 893 /* ------------------------------------------------------------------------------------------------------------------- */ 894 IMAGE_EXPORT(void) write_ui8matrix_T_number(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 895 /* ------------------------------------------------------------------------------------------------------------------- */ 896 { 897 int i,j; 898 899 FILE *f; 900 901 f = fopen(filename, "wt"); 902 if(f == NULL) { 903 nrerror("Can't open file in write_ui8matrix_T_number"); 904 } 905 906 fprintf(f, "%5c", '#'); 907 for(i=nrl; i<=nrh; i++) { 908 fprintf(f, format, i); 909 } 910 fputc('\n', f); 911 912 913 for(j=ncl; j<=nch; j++) { 914 fprintf(f, "[%3d]", j); 915 for(i=nrl; i<=nrh; i++) { 916 fprintf(f, format, m[i][j]); 917 } 918 fputc('\n', f); 919 } 920 fclose(f); 921 } 922 /* --------------------------------------------------------------------------------------------------------------------- */ 923 IMAGE_EXPORT(void) write_si16matrix_T_number(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 924 /* --------------------------------------------------------------------------------------------------------------------- */ 925 { 926 int i,j; 927 928 FILE *f; 929 930 f = fopen(filename, "wt"); 931 if(f == NULL) { 932 nrerror("Can't open file in write_si16matrix_T_number"); 933 } 934 935 fprintf(f, "%5c", '#'); 936 for(i=nrl; i<=nrh; i++) { 937 fprintf(f, format, (float)i); 938 } 939 fputc('\n', f); 940 941 for(j=ncl; j<=nch; j++) { 942 fprintf(f, "[%3d]", j); 943 for(i=nrl; i<=nrh; i++) { 944 fprintf(f, format, m[i][j]); 945 } 946 fputc('\n', f); 947 } 948 fclose(f); 949 } 950 /* --------------------------------------------------------------------------------------------------------------------- */ 951 IMAGE_EXPORT(void) write_ui16matrix_T_number(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 952 /* --------------------------------------------------------------------------------------------------------------------- */ 953 { 954 int i,j; 955 956 FILE *f; 957 958 f = fopen(filename, "wt"); 959 if(f == NULL) { 960 nrerror("Can't open file in write_ui16matrix_T_number"); 961 } 962 963 fprintf(f, "%5c", '#'); 964 for(i=nrl; i<=nrh; i++) { 965 fprintf(f, format, (float)i); 966 } 967 fputc('\n', f); 968 969 for(j=ncl; j<=nch; j++) { 970 fprintf(f, "[%3d]", j); 971 for(i=nrl; i<=nrh; i++) { 972 fprintf(f, format, m[i][j]); 973 } 974 fputc('\n', f); 975 } 976 fclose(f); 977 } 978 /* --------------------------------------------------------------------------------------------------------------------- */ 979 IMAGE_EXPORT(void) write_si32matrix_T_number(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 980 /* --------------------------------------------------------------------------------------------------------------------- */ 981 { 982 int i,j; 983 984 FILE *f; 985 986 f = fopen(filename, "wt"); 987 if(f == NULL) { 988 nrerror("Can't open file in write_si32matrix_T_number"); 989 } 990 991 fprintf(f, "%5c", '#'); 992 for(i=nrl; i<=nrh; i++) { 993 fprintf(f, format, (float)i); 994 } 995 fputc('\n', f); 996 997 for(j=ncl; j<=nch; j++) { 998 fprintf(f, "[%3d]", j); 999 for(i=nrl; i<=nrh; i++) { 1000 fprintf(f, format, m[i][j]); 1001 } 1002 fputc('\n', f); 1003 } 1004 fclose(f); 1005 } 1006 1007 /* --------------------------------------------------------------------------------------------------------------------- */ 1008 IMAGE_EXPORT(void) write_ui32matrix_T_number(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 1009 /* --------------------------------------------------------------------------------------------------------------------- */ 1010 { 1011 int i,j; 1012 1013 FILE *f; 1014 1015 f = fopen(filename, "wt"); 1016 if(f == NULL) { 1017 nrerror("Can't open file in write_ui32matrix_T_number"); 1018 } 1019 1020 fprintf(f, "%5c", '#'); 1021 for(i=nrl; i<=nrh; i++) { 1022 fprintf(f, format, (float)i); 1023 } 1024 fputc('\n', f); 1025 1026 1027 for(j=ncl; j<=nch; j++) { 1028 fprintf(f, "[%3d]", j); 1029 for(i=nrl; i<=nrh; i++) { 1030 fprintf(f, format, m[i][j]); 1031 } 1032 fputc('\n', f); 1033 } 1034 fclose(f); 1035 } 1036 /* --------------------------------------------------------------------------------------------------------------------- */ 1037 IMAGE_EXPORT(void) write_si64matrix_T_number(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 1038 /* --------------------------------------------------------------------------------------------------------------------- */ 1039 { 1040 int i,j; 1041 1042 FILE *f; 1043 1044 f = fopen(filename, "wt"); 1045 if(f == NULL) { 1046 nrerror("Can't open file in write_si64matrix_T_number"); 1047 } 1048 1049 fprintf(f, "%5c", '#'); 1050 for(i=nrl; i<=nrh; i++) { 1051 fprintf(f, format, (float)i); 1052 } 1053 fputc('\n', f); 1054 1055 for(j=ncl; j<=nch; j++) { 1056 fprintf(f, "[%3d]", j); 1057 for(i=nrl; i<=nrh; i++) { 1058 fprintf(f, format, m[i][j]); 1059 } 1060 fputc('\n', f); 1061 } 1062 fclose(f); 1063 } 1064 /* --------------------------------------------------------------------------------------------------------------------- */ 1065 IMAGE_EXPORT(void) write_ui64matrix_T_number(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 1066 /* --------------------------------------------------------------------------------------------------------------------- */ 1067 { 1068 int i,j; 1069 1070 FILE *f; 1071 1072 f = fopen(filename, "wt"); 1073 if(f == NULL) { 1074 nrerror("Can't open file in write_ui64matrix_T_number"); 1075 } 1076 1077 fprintf(f, "%5c", '#'); 1078 for(i=nrl; i<=nrh; i++) { 1079 fprintf(f, format, (float)i); 1080 } 1081 fputc('\n', f); 1082 1083 for(j=ncl; j<=nch; j++) { 1084 fprintf(f, "[%3d]", j); 1085 for(i=nrl; i<=nrh; i++) { 1086 fprintf(f, format, m[i][j]); 1087 } 1088 fputc('\n', f); 1089 } 1090 fclose(f); 1091 } 1092 1093 /* --------------------------------------------------------------------------------------------------------------------- */ 1094 IMAGE_EXPORT(void) write_f32matrix_T_number(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 1095 /* --------------------------------------------------------------------------------------------------------------------- */ 1096 { 1097 int i,j; 1098 1099 FILE *f; 1100 1101 f = fopen(filename, "wt"); 1102 if(f == NULL) { 1103 nrerror("Can't open file in write_f32matrix_T_number"); 1104 } 1105 1106 fprintf(f, "%5c", '#'); 1107 for(i=nrl; i<=nrh; i++) { 1108 fprintf(f, format, (float)i); 1109 } 1110 fputc('\n', f); 1111 1112 for(j=ncl; j<=nch; j++) { 1113 fprintf(f, "[%3d]", j); 1114 for(i=nrl; i<=nrh; i++) { 1115 fprintf(f, format, m[i][j]); 1116 } 1117 fputc('\n', f); 1118 } 1119 fclose(f); 1120 } 1121 /* --------------------------------------------------------------------------------------------------------------------- */ 1122 IMAGE_EXPORT(void) write_f64matrix_T_number(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 1123 /* --------------------------------------------------------------------------------------------------------------------- */ 1124 { 1125 int i,j; 1126 1127 FILE *f; 1128 1129 f = fopen(filename, "wt"); 1130 if(f == NULL) { 1131 nrerror("Can't open file in write_f64matrix_T_number"); 1132 } 1133 1134 fprintf(f, "%5c", '#'); 1135 for(i=nrl; i<=nrh; i++) { 1136 fprintf(f, format, (float)i); 1137 } 1138 fputc('\n', f); 1139 1140 for(j=ncl; j<=nch; j++) { 1141 fprintf(f, "[%3d]", j); 1142 for(i=nrl; i<=nrh; i++) { 1143 fprintf(f, format, m[i][j]); 1144 } 1145 fputc('\n', f); 1146 } 1147 fclose(f); 1148 } 1149 /* ------------------------------------------------------------------------------------------------------------------- */ 1150 IMAGE_EXPORT(void) write_rgb8matrix_T_number(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 1151 /* ------------------------------------------------------------------------------------------------------------------- */ 1152 { 1153 int i,j; 1154 1155 FILE *f; 1156 1157 f = fopen(filename, "wt"); 1158 if(f == NULL) { 1159 nrerror("Can't open file in write_rgb8matrix_T_number"); 1160 } 1161 1162 fprintf(f, "%5c", '#'); 1163 for(i=nrl; i<=nrh; i++) { 1164 fprintf(f, format, (float)i); 1165 } 1166 fputc('\n', f); 1167 1168 for(j=ncl; j<=nch; j++) { 1169 fprintf(f, "[%3d]", j); 1170 for(i=nrl; i<=nrh; i++) { 1171 fprintf(f, format, m[i][j]); 1172 } 1173 fputc('\n', f); 1174 } 1175 fclose(f); 1176 } 1177 /* --------------------------------------------------------------------------------------------------------------------- */ 1178 IMAGE_EXPORT(void) write_rgbx8matrix_T_number(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename) 1179 /* --------------------------------------------------------------------------------------------------------------------- */ 1180 { 1181 int i,j; 1182 1183 FILE *f; 1184 1185 f = fopen(filename, "wt"); 1186 if(f == NULL) { 1187 nrerror("Can't open file in write_rgbx8matrix_T_number"); 1188 } 1189 1190 fprintf(f, "%5c", '#'); 1191 for(i=nrl; i<=nrh; i++) { 1192 fprintf(f, format, (float)i); 1193 } 1194 fputc('\n', f); 1195 1196 for(j=ncl; j<=nch; j++) { 1197 fprintf(f, "[%3d]", j); 1198 for(i=nrl; i<=nrh; i++) { 1199 fprintf(f, format, m[i][j]); 1200 } 1201 fputc('\n', f); 1202 } 1203 fclose(f); 1204 } 177 178 179 #undef write_type_matrix_T_number 180 #define write_type_matrix_T_number(t) \ 181 void short_name(t,write_,matrix_T_number)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename) \ 182 { \ 183 FILE * f = fopen(filename, "wt"); \ 184 if (f == NULL) { \ 185 nrerror("Can't open file %s in %s", filename, __func__); \ 186 } \ 187 fprintf(f, "%5c", '#'); \ 188 for (int32_t i = nrl; i <= nrh; i++) { \ 189 fprintf(f, format, i); \ 190 } \ 191 fprintf(f, "\n"); \ 192 for (int32_t j = ncl; j <= nch; j++) { \ 193 fprintf(f, "[%3d]", j); \ 194 for (int32_t i = nrl; i <= nrh; i++) { \ 195 fprintf(f, format, m[i][j]); \ 196 } \ 197 fprintf(f, "\n"); \ 198 } \ 199 fclose(f); \ 200 } 201 202 203 #undef elem 204 #define elem m[i][j] 205 write_type_matrix_T_number(int8_t); 206 write_type_matrix_T_number(uint8_t); 207 write_type_matrix_T_number(int16_t); 208 write_type_matrix_T_number(uint16_t); 209 write_type_matrix_T_number(int32_t); 210 write_type_matrix_T_number(uint32_t); 211 write_type_matrix_T_number(int64_t); 212 write_type_matrix_T_number(uint64_t); 213 write_type_matrix_T_number(float); 214 write_type_matrix_T_number(double); 215 #undef elem 216 #define elem m[i][j].r, m[i][j].g, m[i][j].b 217 write_type_matrix_T_number(rgb8); 218 #undef elem 219 #define elem m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x 220 write_type_matrix_T_number(rgbx8); 221 222 1205 223 /* 1206 224 * --------------------- … … 1209 227 */ 1210 228 1211 /* ----------------------------------------------------------------------------------------------- */ 1212 IMAGE_EXPORT(void) fwrite_si8matrix(sint8 **m,long nrl, long nrh, long ncl, long nch, char *filename) 1213 /* ----------------------------------------------------------------------------------------------- */ 1214 { 1215 long i, ncol = nch-ncl+1; 1216 FILE *f; 1217 1218 f = fopen(filename, "wb"); 1219 if(f == NULL) nrerror("Can't open file in fwrite_si8matrix"); 1220 1221 for(i=nrl; i<=nrh; i++) { 1222 fwrite(m[i]+nrl, sizeof(sint8), ncol, f); 1223 } 1224 fclose(f); 1225 } 1226 /* ------------------------------------------------------------------------------------------------ */ 1227 IMAGE_EXPORT(void) fwrite_ui8matrix(uint8 **m, long nrl, long nrh, long ncl, long nch, char *filename) 1228 /* ------------------------------------------------------------------------------------------------ */ 1229 { 1230 long i, ncol = nch-ncl+1; 1231 FILE *f; 1232 1233 f = fopen(filename, "wb"); 1234 if(f == NULL) nrerror("Can't open file in fwrite_ui8matrix"); 1235 1236 for(i=nrl; i<=nrh; i++) { 1237 fwrite(m[i]+nrl, sizeof(int8), ncol, f); 1238 } 1239 fclose(f); 1240 } 1241 /* ------------------------------------------------------------------------------------------------- */ 1242 IMAGE_EXPORT(void) fwrite_si16matrix(sint16 **m,long nrl, long nrh, long ncl, long nch, char *filename) 1243 /* ------------------------------------------------------------------------------------------------- */ 1244 { 1245 long i, ncol = nch-ncl+1; 1246 FILE *f; 1247 1248 f = fopen(filename, "wb"); 1249 if(f == NULL) 1250 nrerror("Can't open file in fwrite_i16matrix"); 1251 1252 for(i=nrl; i<=nrh; i++) { 1253 fwrite(m[i]+nrl, sizeof(sint16), ncol, f); 1254 } 1255 fclose(f); 1256 } 1257 /* ------------------------------------------------------------------------------------------------- */ 1258 IMAGE_EXPORT(void) fwrite_ui16matrix(uint16 **m,long nrl, long nrh, long ncl, long nch, char *filename) 1259 /* ------------------------------------------------------------------------------------------------- */ 1260 { 1261 long i, ncol = nch-ncl+1; 1262 FILE *f; 1263 1264 f = fopen(filename, "wb"); 1265 if(f == NULL) 1266 nrerror("Can't open file in fwrite_ui16matrix"); 1267 1268 for(i=nrl; i<=nrh; i++) { 1269 fwrite(m[i]+nrl, sizeof(uint16), ncol, f); 1270 } 1271 fclose(f); 1272 } 1273 /* ------------------------------------------------------------------------------------------------- */ 1274 IMAGE_EXPORT(void) fwrite_si32matrix(sint32 **m,long nrl, long nrh, long ncl, long nch, char *filename) 1275 /* ------------------------------------------------------------------------------------------------- */ 1276 { 1277 long i, ncol = nch-ncl+1; 1278 FILE *f; 1279 1280 f = fopen(filename, "wb"); 1281 if(f == NULL) 1282 nrerror("Can't open file in fwrite_si32matrix"); 1283 1284 for(i=nrl; i<=nrh; i++) { 1285 fwrite(m[i]+nrl, sizeof(sint32), ncol, f); 1286 } 1287 fclose(f); 1288 } 1289 /* ------------------------------------------------------------------------------------------------- */ 1290 IMAGE_EXPORT(void) fwrite_ui32matrix(uint32 **m,long nrl, long nrh, long ncl, long nch, char *filename) 1291 /* ------------------------------------------------------------------------------------------------- */ 1292 { 1293 long i, ncol = nch-ncl+1; 1294 FILE *f; 1295 1296 f = fopen(filename, "wb"); 1297 if(f == NULL) 1298 nrerror("Can't open file in fwrite_ui32matrix"); 1299 1300 for(i=nrl; i<=nrh; i++) { 1301 fwrite(m[i]+nrl, sizeof(uint32), ncol, f); 1302 } 1303 fclose(f); 1304 } 1305 /* ----------------------------------------------------------------------------------------------- */ 1306 IMAGE_EXPORT(void) fwrite_si64matrix(sint64 **m,long nrl,long nrh,long ncl, long nch, char *filename) 1307 /* ----------------------------------------------------------------------------------------------- */ 1308 { 1309 long i, ncol = nch-ncl+1; 1310 FILE *f; 1311 1312 f = fopen(filename, "wb"); 1313 if(f == NULL) 1314 nrerror("Can't open file in fwrite_si64matrix"); 1315 1316 for(i=nrl; i<=nrh; i++) { 1317 fwrite(m[i]+nrl, sizeof(sint64), ncol, f); 1318 } 1319 fclose(f); 1320 } 1321 /* ----------------------------------------------------------------------------------------------- */ 1322 IMAGE_EXPORT(void) fwrite_ui64matrix(uint64 **m,long nrl,long nrh,long ncl, long nch, char *filename) 1323 /* ----------------------------------------------------------------------------------------------- */ 1324 { 1325 long i, ncol = nch-ncl+1; 1326 FILE *f; 1327 1328 f = fopen(filename, "wb"); 1329 if(f == NULL) 1330 nrerror("Can't open file in fwrite_ui64matrix"); 1331 1332 for(i=nrl; i<=nrh; i++) { 1333 fwrite(m[i]+nrl, sizeof(uint64), ncol, f); 1334 } 1335 fclose(f); 1336 } 1337 /* ----------------------------------------------------------------------------------------------- */ 1338 IMAGE_EXPORT(void) fwrite_f32matrix(float32 **m,long nrl,long nrh,long ncl, long nch, char *filename) 1339 /* ----------------------------------------------------------------------------------------------- */ 1340 { 1341 long i, ncol = nch-ncl+1; 1342 FILE *f; 1343 1344 f = fopen(filename, "wb"); 1345 if(f == NULL) nrerror("Can't open file in fwrite_f32matrix"); 1346 1347 for(i=nrl; i<=nrh; i++) { 1348 fwrite(m[i]+nrl, sizeof(float32), ncol, f); 1349 } 1350 fclose(f); 1351 } 1352 /* ----------------------------------------------------------------------------------------------- */ 1353 IMAGE_EXPORT(void) fwrite_f64matrix(float64 **m,long nrl,long nrh,long ncl, long nch, char *filename) 1354 /* ----------------------------------------------------------------------------------------------- */ 1355 { 1356 long i, ncol = nch-ncl+1; 1357 FILE *f; 1358 1359 f = fopen(filename, "wb"); 1360 if(f == NULL) nrerror("Can't open file in f64write_matrix"); 1361 1362 for(i=nrl; i<=nrh; i++) { 1363 fwrite(m[i]+nrl, sizeof(float64), ncol, f); 1364 } 1365 fclose(f); 1366 } 1367 /* --------------------------------------------------------------------------------------------- */ 1368 IMAGE_EXPORT(void) fwrite_rgb8matrix(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *filename) 1369 /* --------------------------------------------------------------------------------------------- */ 1370 { 1371 long i, ncol = nch-ncl+1; 1372 FILE *f; 1373 1374 f = fopen(filename, "wb"); 1375 if(f == NULL) nrerror("Can't open file in fwrite_rgb8matrix"); 1376 1377 for(i=nrl; i<=nrh; i++) { 1378 fwrite(m[i]+nrl, sizeof(rgb8), ncol, f); 1379 } 1380 fclose(f); 1381 } 1382 /* ----------------------------------------------------------------------------------------------- */ 1383 IMAGE_EXPORT(void) fwrite_rgbx8matrix(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *filename) 1384 /* ----------------------------------------------------------------------------------------------- */ 1385 { 1386 long i, ncol = nch-ncl+1; 1387 FILE *f; 1388 1389 f = fopen(filename, "wb"); 1390 if(f == NULL) nrerror("Can't open file in fwrite_rgbx8matrix"); 1391 1392 for(i=nrl; i<=nrh; i++) { 1393 fwrite(m[i]+nrl, sizeof(rgbx8), ncol, f); 1394 } 1395 fclose(f); 1396 } 229 #undef fwrite_type_matrix 230 #define fwrite_type_matrix(t) \ 231 void short_name(t,fwrite_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * filename) \ 232 { \ 233 int32_t ncol = nch - ncl + 1; \ 234 FILE * f = fopen(filename, "wb"); \ 235 if (f == NULL) { \ 236 nrerror("Can't open file %s in %s", filename, __func__); \ 237 } \ 238 for (int32_t i = nrl; i <= nrh; i++) { \ 239 fwrite(m[i] + nrl, sizeof(t), ncol, f); \ 240 } \ 241 fclose(f); \ 242 } 243 244 fwrite_type_matrix(int8_t); 245 fwrite_type_matrix(uint8_t); 246 fwrite_type_matrix(int16_t); 247 fwrite_type_matrix(uint16_t); 248 fwrite_type_matrix(int32_t); 249 fwrite_type_matrix(uint32_t); 250 fwrite_type_matrix(int64_t); 251 fwrite_type_matrix(uint64_t); 252 fwrite_type_matrix(float); 253 fwrite_type_matrix(double); 254 fwrite_type_matrix(rgb8); 255 fwrite_type_matrix(rgbx8); 256 257 1397 258 1398 259 /* … … 1402 263 */ 1403 264 1404 /* -------------------------------------------------------------------------------------------- */ 1405 IMAGE_EXPORT(void) fread_si8matrix(char *filename, sint8 **m,long nrl,long nrh,long ncl, long nch) 1406 /* -------------------------------------------------------------------------------------------- */ 1407 { 1408 long i, ncol = nch-ncl+1, nread; 1409 FILE *f; 1410 1411 f = fopen(filename, "rb"); 1412 if(f == NULL) nrerror("Can't open file in fread_i8matrix"); 1413 1414 for(i=nrl; i<=nrh; i++) { 1415 nread = fread(m[i]+ncl, sizeof(sint8), ncol, f); 1416 if(nread != ncol) nrerror("fread_si8matrix : can't read data"); 1417 } 1418 fclose(f); 1419 } 1420 /* -------------------------------------------------------------------------------------------- */ 1421 IMAGE_EXPORT(void) fread_ui8matrix(char *filename, uint8 **m,long nrl,long nrh,long ncl, long nch) 1422 /* -------------------------------------------------------------------------------------------- */ 1423 { 1424 long i, ncol = nch-ncl+1, nread; 1425 FILE *f; 1426 1427 f = fopen(filename, "rb"); 1428 if(f == NULL) nrerror("Can't open file in fread_ui8matrix"); 1429 1430 for(i=nrl; i<=nrh; i++) { 1431 nread = fread(m[i]+ncl, sizeof(uint8), ncol, f); 1432 if(nread != ncol) nrerror("fread_ui8matrix : can't read data"); 1433 } 1434 fclose(f); 1435 } 1436 /* ---------------------------------------------------------------------------------------------- */ 1437 IMAGE_EXPORT(void) fread_si32matrix(char *filename, sint32 **m,long nrl,long nrh,long ncl, long nch) 1438 /* ---------------------------------------------------------------------------------------------- */ 1439 { 1440 long i, ncol = nch-ncl+1, nread; 1441 FILE *f; 1442 1443 f = fopen(filename, "rb"); 1444 if(f == NULL) 1445 nrerror("Can't open file in fread_si32matrix"); 1446 1447 for(i=nrl; i<=nrh; i++) { 1448 nread = fread(m[i]+ncl, sizeof(sint32), ncol, f); 1449 if(nread != ncol) nrerror("fread_si32matrix : can't read data"); 1450 } 1451 fclose(f); 1452 } 1453 /* ---------------------------------------------------------------------------------------------- */ 1454 IMAGE_EXPORT(void) fread_ui32matrix(char *filename, uint32 **m,long nrl,long nrh,long ncl, long nch) 1455 /* ---------------------------------------------------------------------------------------------- */ 1456 { 1457 long i, ncol = nch-ncl+1, nread; 1458 FILE *f; 1459 1460 f = fopen(filename, "rb"); 1461 if(f == NULL) 1462 nrerror("Can't open file in fread_ui32matrix"); 1463 1464 for(i=nrl; i<=nrh; i++) { 1465 nread = fread(m[i]+ncl, sizeof(uint32), ncol, f); 1466 if(nread != ncol) nrerror("fread_ui32matrix : can't read data"); 1467 } 1468 fclose(f); 1469 } 1470 /* ---------------------------------------------------------------------------------------------- */ 1471 IMAGE_EXPORT(void) fread_si64matrix(char *filename, sint64 **m,long nrl,long nrh,long ncl, long nch) 1472 /* ---------------------------------------------------------------------------------------------- */ 1473 { 1474 long i, ncol = nch-ncl+1, nread; 1475 FILE *f; 1476 1477 f = fopen(filename, "rb"); 1478 if(f == NULL) 1479 nrerror("Can't open file in fread_si64matrix"); 1480 1481 for(i=nrl; i<=nrh; i++) { 1482 nread = fread(m[i]+ncl, sizeof(sint32), ncol, f); 1483 if(nread != ncol) nrerror("fread_si64matrix : can't read data"); 1484 } 1485 fclose(f); 1486 } 1487 /* ---------------------------------------------------------------------------------------------- */ 1488 IMAGE_EXPORT(void) fread_ui64matrix(char *filename, uint64 **m,long nrl,long nrh,long ncl, long nch) 1489 /* ---------------------------------------------------------------------------------------------- */ 1490 { 1491 long i, ncol = nch-ncl+1, nread; 1492 FILE *f; 1493 1494 f = fopen(filename, "rb"); 1495 if(f == NULL) 1496 nrerror("Can't open file in fread_ui64matrix"); 1497 1498 for(i=nrl; i<=nrh; i++) { 1499 nread = fread(m[i]+ncl, sizeof(uint64), ncol, f); 1500 if(nread != ncol) nrerror("fread_ui64matrix : can't read data"); 1501 } 1502 fclose(f); 1503 } 1504 /* ---------------------------------------------------------------------------------------------- */ 1505 IMAGE_EXPORT(void) fread_f32matrix(char *filename, float32 **m,long nrl,long nrh,long ncl, long nch) 1506 /* ---------------------------------------------------------------------------------------------- */ 1507 { 1508 long i, ncol = nch-ncl+1, nread; 1509 FILE *f; 1510 1511 f = fopen(filename, "rb"); 1512 if(f == NULL) nrerror("Can't open file in fread_f32matrix"); 1513 1514 for(i=nrl; i<=nrh; i++) { 1515 nread = fread(m[i]+ncl, sizeof(float32), ncol, f); 1516 if(nread != ncol) nrerror("fread_f32matrix : can't read data"); 1517 } 1518 fclose(f); 1519 } 1520 /* ---------------------------------------------------------------------------------------------- */ 1521 IMAGE_EXPORT(void) fread_f64matrix(char *filename, float64 **m,long nrl,long nrh,long ncl, long nch) 1522 /* ---------------------------------------------------------------------------------------------- */ 1523 { 1524 long i, ncol = nch-ncl+1, nread; 1525 FILE *f; 1526 1527 f = fopen(filename, "rb"); 1528 if(f == NULL) nrerror("Can't open file in fread_f64matrix"); 1529 1530 for(i=nrl; i<=nrh; i++) { 1531 nread = fread(m[i]+ncl, sizeof(float64), ncol, f); 1532 if(nread != ncol) nrerror("fread_f64matrix : can't read data"); 1533 } 1534 fclose(f); 1535 } 1536 /* -------------------------------------------------------------------------------------------- */ 1537 IMAGE_EXPORT(void) fread_rgb8matrix(char *filename, rgb8 **m,long nrl,long nrh,long ncl, long nch) 1538 /* -------------------------------------------------------------------------------------------- */ 1539 { 1540 long i, ncol = nch-ncl+1, nread; 1541 FILE *f; 1542 1543 f = fopen(filename, "rb"); 1544 if(f == NULL) nrerror("Can't open file in fread_rgb8matrix"); 1545 1546 for(i=nrl; i<=nrh; i++) { 1547 nread = fread(m[i]+ncl, sizeof(rgb8), ncol, f); 1548 if(nread != ncol) nrerror("fread_rgb8matrix : can't read data"); 1549 } 1550 fclose(f); 1551 } 1552 /* ---------------------------------------------------------------------------------------------- */ 1553 IMAGE_EXPORT(void) fread_rgbx8matrix(char *filename, rgbx8 **m,long nrl,long nrh,long ncl, long nch) 1554 /* ---------------------------------------------------------------------------------------------- */ 1555 { 1556 long i, ncol = nch-ncl+1, nread; 1557 FILE *f; 1558 1559 f = fopen(filename, "rb"); 1560 if(f == NULL) nrerror("Can't open file in fread_rgbx8matrix"); 1561 1562 for(i=nrl; i<=nrh; i++) { 1563 nread = fread(m[i]+ncl, sizeof(rgbx8), ncol, f); 1564 if(nread != ncol) nrerror("fread_rgbx8matrix : can't read data"); 1565 } 1566 fclose(f); 1567 } 1568 // -------------------------------------------------------------------------------------------------- 1569 void write_ui8matrix_positive(uint8 **m, int i0, int i1, int j0, int j1, int iformat, char *filename) 1570 // -------------------------------------------------------------------------------------------------- 1571 { 1572 int i, j; 1573 char *format, *str; 1574 FILE *f; 1575 1576 select_display_positive_parameters(iformat, &format, &str); 1577 1578 f = fopen(filename, "wt"); 1579 if(f == NULL) { 1580 nrerror("Can't open file in write_ui8matrix_positive"); 1581 } 1582 1583 for(i=i0; i<=i1; i++) { 1584 for(j=j0; j<=j1; j++) { 1585 if(m[i][j]) { 1586 fprintf(f, format, m[i][j]); 1587 } else { 1588 fprintf(f, "%s", str); 1589 } 1590 } 1591 fputc('\n', f); 1592 } 1593 fclose(f); 1594 } 1595 1596 // ---------------------------------------------------------------------------------------------------- 1597 void write_ui16matrix_positive(uint16 **m, int i0, int i1, int j0, int j1, int iformat, char *filename) 1598 // ---------------------------------------------------------------------------------------------------- 1599 { 1600 int i, j; 1601 char *format, *str; 1602 FILE *f; 1603 1604 select_display_positive_parameters(iformat, &format, &str); 1605 1606 f = fopen(filename, "wt"); 1607 if(f == NULL) { 1608 nrerror("Can't open file in write_ui16matrix_positive"); 1609 } 1610 1611 for(i=i0; i<=i1; i++) { 1612 for(j=j0; j<=j1; j++) { 1613 if(m[i][j]) { 1614 fprintf(f, format, m[i][j]); 1615 } else { 1616 fprintf(f, "%s", str); 1617 } 1618 } 1619 fputc('\n', f); 1620 } 1621 fclose(f); 1622 } 1623 // --------------------------------------------------------------------------------------------------- 1624 void write_ui32matrix_positive(uint32 **m,int i0, int i1, int j0, int j1, int iformat, char *filename) 1625 // --------------------------------------------------------------------------------------------------- 1626 { 1627 int i, j; 1628 char *format, *str; 1629 FILE *f; 1630 1631 select_display_positive_parameters(iformat, &format, &str); 1632 1633 f = fopen(filename, "wt"); 1634 if(f == NULL) { 1635 nrerror("Can't open file in write_ui32matrix_positive"); 1636 } 1637 1638 for(i=i0; i<=i1; i++) { 1639 for(j=j0; j<=j1; j++) { 1640 if(m[i][j]) { 1641 fprintf(f, format, m[i][j]); 1642 } else { 1643 fprintf(f, "%s", str); 1644 } 1645 } 1646 fputc('\n', f); 1647 } 1648 fclose(f); 1649 } 265 #undef fread_type_matrix 266 #define fread_type_matrix(t) \ 267 void short_name(t,fread_,matrix)(char * filename, t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ 268 { \ 269 int32_t ncol = nch - ncl + 1; \ 270 int32_t nread; \ 271 FILE * f = fopen(filename, "rb"); \ 272 if (f == NULL) { \ 273 nrerror("Can't open file %s in %s", filename, __func__); \ 274 } \ 275 for (int32_t i = nrl; i <= nrh; i++) { \ 276 nread = fread(m[i] + ncl, sizeof(t), ncol, f); \ 277 if (nread != ncol) { \ 278 nrerror("%s : can't read data", __func__); \ 279 } \ 280 } \ 281 fclose(f); \ 282 } 283 284 fread_type_matrix(int8_t); 285 fread_type_matrix(uint8_t); 286 fread_type_matrix(int16_t); 287 fread_type_matrix(uint16_t); 288 fread_type_matrix(int32_t); 289 fread_type_matrix(uint32_t); 290 fread_type_matrix(int64_t); 291 fread_type_matrix(uint64_t); 292 fread_type_matrix(float); 293 fread_type_matrix(double); 294 fread_type_matrix(rgb8); 295 fread_type_matrix(rgbx8); 296 297 298 299 #undef write_type_matrix_positive 300 #define write_type_matrix_positive(t) \ 301 void short_name(t,write_,matrix_positive)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t iformat, char * filename) \ 302 { \ 303 char * format; \ 304 char * str; \ 305 FILE * f; \ 306 select_display_positive_parameters(iformat, &format, &str); \ 307 f = fopen(filename, "wt"); \ 308 if (f == NULL) { \ 309 nrerror("Can't open file %s in %s", filename, __func__); \ 310 } \ 311 for (int32_t i = i0; i <= i1; i++) { \ 312 for (int32_t j = j0; j <= j1; j++) { \ 313 if (m[i][j] != 0) { \ 314 fprintf(f, format, m[i][j]); \ 315 } \ 316 else { \ 317 fprintf(f, "%s", str); \ 318 } \ 319 } \ 320 fprintf(f, "\n"); \ 321 } \ 322 fclose(f); \ 323 } 324 325 write_type_matrix_positive(uint8_t); 326 write_type_matrix_positive(uint16_t); 327 write_type_matrix_positive(uint32_t); 328 1650 329 1651 330 /* ------------------------ */ … … 1653 332 /* ------------------------ */ 1654 333 1655 PRIVATE char *readitem (FILE *file, char *buffer);1656 PRIVATE void ReadPGMrow (FILE *file, int width, uint8 *line);1657 PRIVATE void WritePGMrow(uint8 *line, int width, FILE *file);1658 334 1659 335 /* ------------------------------------------ */ 1660 PRIVATE char *readitem(FILE *file, char *buffer)336 static char * readitem(FILE * file, char * buffer) 1661 337 /* ------------------------------------------ */ 1662 // read a word 1663 // public domain function: author is unknown 1664 { 1665 char *aux; 1666 int k; 1667 1668 k=0; 1669 aux=buffer; 1670 while (!feof(file)) 1671 { 1672 *aux=fgetc(file); 1673 switch(k) 1674 { 1675 case 0: 1676 if (*aux=='#') k=1; 1677 if (isalnum(*aux)) k=2, aux++; 1678 break; 1679 case 1: 1680 if (*aux==0xA) k=0; 1681 break; 1682 case 2: 1683 if (!isalnum(*aux)) 1684 { 1685 *aux=0; 1686 return buffer; 1687 } 1688 aux++; 1689 break; 338 // read a word 339 // public domain function: author is unknown 340 { 341 char * aux; 342 int32_t k; 343 344 k = 0; 345 aux = buffer; 346 while (!feof(file)) { 347 *aux = fgetc(file); 348 switch (k) { 349 case 0: 350 if (*aux == '#') { 351 k = 1; 352 } 353 if (isalnum(*aux)) { 354 k = 2; 355 aux++; 356 } 357 break; 358 case 1: 359 if (*aux == 0xA) { 360 k = 0; 361 } 362 break; 363 case 2: 364 if (!isalnum(*aux)) { 365 *aux = 0; 366 return buffer; 367 } 368 aux++; 369 break; 1690 370 } 1691 371 } 1692 *aux =0;372 *aux = 0; 1693 373 return buffer; 1694 374 } 375 1695 376 /* ----------------------------------------------------- */ 1696 PRIVATE void ReadPGMrow(FILE *file, int width, uint8 *line)377 static void ReadPGMrow(FILE * file, int32_t width, uint8_t * line) 1697 378 /* ----------------------------------------------------- */ 1698 379 { 1699 380 // file is already open (in read) and will not be closed at the end 1700 fread(&(line[0]), sizeof(uint8), width, file); 1701 } 381 fread(&(line[0]), sizeof(uint8_t), width, file); 382 } 383 384 1702 385 /* ------------------------------------------------------- */ 1703 PRIVATE void WritePGMrow(uint8 *line, int width, FILE *file)386 static void WritePGMrow(uint8_t * line, int32_t width, FILE * file) 1704 387 /* ------------------------------------------------------- */ 1705 388 { 1706 389 // file is already open (in read) and will not be closed at the end 1707 fwrite(&(line[0]), sizeof(uint8), width, file); 1708 } 390 fwrite(&(line[0]), sizeof(uint8_t), width, file); 391 } 392 393 1709 394 /* --------------------------------------------------------------------------------------- */ 1710 IMAGE_EXPORT(uint8 **) LoadPGM_ui8matrix(char *filename, int *nrl, int *nrh, int *ncl, int *nch)395 uint8_t ** LoadPGM_ui8matrix(char * filename, int32_t * nrl, int32_t * nrh, int32_t * ncl, int32_t * nch) 1711 396 /* --------------------------------------------------------------------------------------- */ 1712 397 { 1713 398 // only for P5 binary type, not for text type 1714 1715 int height, width, gris;1716 uint8 **m;1717 FILE * file;1718 1719 char * buffer;399 400 int32_t height, width, gris; 401 uint8_t ** m; 402 FILE * file; 403 404 char * buffer; 1720 405 char msg[1024]; 1721 //char c; 1722 int i; 1723 1724 buffer = (char*) calloc(80, sizeof(char)); 406 (void) gris; 407 408 buffer = (char *) calloc(80, sizeof(char)); 1725 409 1726 410 // open file 1727 file = fopen(filename,"rb"); 1728 if (file==NULL) { 1729 //nrerror("ouverture du fichier impossible\n"); 1730 sprintf(msg, "ouverture du fichier %s impossible dans LoadPGM_ui8matrix\n", filename); 411 file = fopen(filename, "rb"); 412 if (file == NULL) { 413 snprintf(msg, 1024, "ouverture du fichier %s impossible dans %s\n", filename, __func__); 1731 414 nrerror(msg); 1732 415 } 1733 416 1734 417 // read PGM header 1735 418 readitem(file, buffer); 1736 /*fscanf(fichier, "%s", buffer);*/1737 if(strcmp(buffer, "P5") != 0) nrerror("entete du fichier %s invalide\n");1738 //nrerror("entete du fichier %s invalide\n", filename);1739 419 if (strcmp(buffer, "P5") != 0) { 420 nrerror("Entete du fichier %s invalide\n", filename); 421 } 422 1740 423 width = atoi(readitem(file, buffer)); 1741 424 height = atoi(readitem(file, buffer)); 1742 425 gris = atoi(readitem(file, buffer)); 1743 426 1744 427 *nrl = 0; 1745 428 *nrh = height - 1; … … 1747 430 *nch = width - 1; 1748 431 m = ui8matrix(*nrl, *nrh, *ncl, *nch); 1749 1750 for(i =0; i<height; i++) {432 433 for(int32_t i = 0; i < height; i++) { 1751 434 ReadPGMrow(file, width, m[i]); 1752 435 } 1753 436 1754 437 fclose(file); 1755 438 free(buffer); 1756 439 1757 440 return m; 1758 441 } 1759 /* ---------------------------------------------------------------------------------------- */ 1760 IMAGE_EXPORT(uint8 **) LoadPGM_bmatrix(char *filename, int *nrl, int *nrh, int *ncl, int *nch) 1761 /* ---------------------------------------------------------------------------------------- */ 442 443 444 /* ----------------------------------------------------------------------------------------------- */ 445 void LoadPGM_ui8matrix2(char * filename, int32_t * nrl, int32_t * nrh, int32_t * ncl, int32_t * nch, uint8_t ** m) 446 /* ----------------------------------------------------------------------------------------------- */ 1762 447 { 1763 448 // only for P5 binary type, not for text type 1764 1765 int height, width, gris; 1766 uint8 **m; 1767 FILE *file; 1768 1769 char *buffer; 449 int32_t height, width, gris; 450 FILE * file; 451 452 char * buffer; 1770 453 char msg[1024]; 1771 //char c; 1772 int i; 1773 1774 buffer = (char*) calloc(80, sizeof(char)); 1775 1776 // open file 1777 file = fopen(filename,"rb"); 1778 if (file==NULL) { 1779 //nrerror("ouverture du fichier impossible\n"); 1780 sprintf(msg, "ouverture du fichier %s impossible dans SavePGM_bmatrix\n", filename); 454 (void) gris; 455 456 buffer = (char *) calloc(80, sizeof(char)); 457 /* ouverture du fichier */ 458 file = fopen(filename, "rb"); 459 if (file == NULL) { 460 snprintf(msg, 1024, "ouverture du fichier %s impossible dans %s\n", filename, __func__); 1781 461 nrerror(msg); 1782 462 } 1783 1784 / / read PGM header463 464 /* lecture de l'entete du fichier pgm */ 1785 465 readitem(file, buffer); 1786 /*fscanf(fichier, "%s", buffer);*/ 1787 if(strcmp(buffer, "P5") != 0) 1788 nrerror("entete du fichier %s invalide\n"); 1789 //nrerror("entete du fichier %s invalide\n", filename); 1790 466 if (strcmp(buffer, "P5") != 0) { 467 nrerror("Entete du fichier %s invalide\n", filename); 468 } 469 1791 470 width = atoi(readitem(file, buffer)); 1792 471 height = atoi(readitem(file, buffer)); 1793 472 gris = atoi(readitem(file, buffer)); 1794 473 1795 474 *nrl = 0; 1796 475 *nrh = height - 1; 1797 476 *ncl = 0; 1798 477 *nch = width - 1; 1799 m = ui8matrix(*nrl, *nrh, *ncl, *nch); 1800 1801 for(i=0; i<height; i++) { 478 479 for (int32_t i = 0; i < height; i++) { 1802 480 ReadPGMrow(file, width, m[i]); 1803 481 } 1804 482 1805 483 fclose(file); 1806 484 free(buffer); 1807 1808 return m; 1809 } 1810 /* -------------------------------------------------------------------------------------------- ---*/1811 IMAGE_EXPORT(void) LoadPGM_bmatrix2(char *filename, int *nrl, int *nrh, int *ncl, int *nch, uint8 **m)1812 /* -------------------------------------------------------------------------------------------- ---*/485 } 486 487 488 /* -------------------------------------------------------------------------------------------- */ 489 void MLoadPGM_ui8matrix(char * filename, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint8_t ** m) 490 /* -------------------------------------------------------------------------------------------- */ 1813 491 { 1814 492 // only for P5 binary type, not for text type 1815 1816 int height, width, gris; 1817 FILE *file; 1818 1819 char *buffer; 493 int32_t height, width, gris; 494 FILE * file; 495 496 char * buffer; 1820 497 char msg[1024]; 1821 int i;1822 1823 buffer = (char *) calloc(80, sizeof(char));498 (void) gris; 499 500 buffer = (char *) calloc(80, sizeof(char)); 1824 501 /* ouverture du fichier */ 1825 file = fopen(filename,"rb"); 1826 if (file==NULL) { 1827 //nrerror("ouverture du fichier impossible\n"); 1828 sprintf(msg, "ouverture du fichier %s impossible dans SavePGM_bmatrix\n", filename); 502 file = fopen(filename, "rb"); 503 if (file == NULL) { 504 snprintf(msg, 1024, "ouverture du fichier %s impossible dans %s\n", filename, __func__); 1829 505 nrerror(msg); 1830 506 } 1831 507 1832 508 /* lecture de l'entete du fichier pgm */ 1833 509 readitem(file, buffer); 1834 /*fscanf(fichier, "%s", buffer);*/ 1835 if(strcmp(buffer, "P5") != 0) 1836 nrerror("entete du fichier %s invalide\n"); 1837 //nrerror("entete du fichier %s invalide\n", filename); 1838 510 if (strcmp(buffer, "P5") != 0) { 511 nrerror("Entete du fichier %s invalide\n", filename); 512 } 513 1839 514 width = atoi(readitem(file, buffer)); 1840 515 height = atoi(readitem(file, buffer)); 1841 516 gris = atoi(readitem(file, buffer)); 1842 1843 *nrl = 0; 1844 *nrh = height - 1; 1845 *ncl = 0; 1846 *nch = width - 1; 1847 1848 for(i=0; i<height; i++) { 517 518 for (int32_t i = 0; i < height; i++) { 1849 519 ReadPGMrow(file, width, m[i]); 1850 520 } 1851 521 1852 522 fclose(file); 1853 523 free(buffer); 1854 524 } 1855 /* -------------------------------------------------------------------------------------------- */ 1856 IMAGE_EXPORT(void) MLoadPGM_bmatrix(char *filename, int nrl, int nrh, int ncl, int nch, uint8 **m) 1857 /* ------------------------------------------------------------------------------------------ --*/1858 { 1859 // only for P5 binary type, not for text type 1860 1861 int height, width, gris;1862 FILE *file;1863 1864 char *buffer;525 526 527 /* ------------------------------------------------------------------------------------------ */ 528 void SavePGM_ui8matrix(uint8_t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * filename) 529 /* ------------------------------------------------------------------------------------------ */ 530 { 531 int nrow = nrh - nrl + 1; 532 int ncol = nch - ncl + 1; 533 534 char buffer[80]; 1865 535 char msg[1024]; 1866 1867 int i; 1868 1869 buffer = (char*) calloc(80, sizeof(char)); 536 537 FILE * file; 538 539 file = fopen(filename, "wb"); 540 if (file == NULL) { 541 snprintf(msg, 1024, "ouverture du fichier %s impossible dans %s\n", filename, __func__); 542 nrerror(msg); 543 } 544 545 /* enregistrement de l'image au format rpgm */ 546 snprintf(buffer, 80, "P5\n%d %d\n255\n", ncol, nrow); 547 fwrite(buffer, strlen(buffer), 1, file); 548 for (int32_t i = nrl; i <= nrh; i++) { 549 WritePGMrow(m[i], ncol, file); 550 } 551 552 /* fermeture du fichier */ 553 fclose(file); 554 } 555 556 557 /* --------------------------- */ 558 /* -- PNM IO for rgb8matrix -- */ 559 /* --------------------------- */ 560 561 /* ------------------------------------------------------ */ 562 static void ReadPNMrow(FILE * file, int32_t width, uint8_t * line) 563 /* ------------------------------------------------------ */ 564 { 565 /* Le fichier est ouvert (en lecture) et ne sera pas ferme a la fin */ 566 fread(&(line[0]), sizeof(uint8_t), 3 * sizeof(uint8_t) * width, file); 567 } 568 569 570 /* ------------------------------------------------------- */ 571 static void WritePNMrow(uint8_t * line, int32_t width, FILE * file) 572 /* ------------------------------------------------------- */ 573 { 574 /* Le fichier est deja ouvert et ne sera pas ferme a la fin */ 575 fwrite(&(line[0]), sizeof(uint8_t), 3 * sizeof(uint8_t) * width, file); 576 } 577 578 579 /* ------------------------------------------------------------------------------------------ */ 580 rgb8 ** LoadPPM_rgb8matrix(char * filename, int32_t * nrl, int32_t * nrh, int32_t * ncl, int32_t * nch) 581 /* ------------------------------------------------------------------------------------------ */ 582 { 583 /* cette version ne lit plus que le type P6 */ 584 int32_t height, width, gris; 585 rgb8 ** m; 586 FILE * file; 587 588 char * buffer; 589 char msg[1024]; 590 (void) gris; 591 592 buffer = (char *) calloc(80, sizeof(char)); 1870 593 /* ouverture du fichier */ 1871 594 file = fopen(filename,"rb"); 1872 if (file==NULL) { 1873 //nrerror("ouverture du fichier impossible\n"); 1874 sprintf(msg, "ouverture du fichier %s impossible dans SavePGM_bmatrix\n", filename); 595 if (file == NULL) { 596 snprintf(msg, 1024, "ouverture du fichier %s impossible dans %s\n", filename, __func__); 1875 597 nrerror(msg); 1876 598 } 1877 599 1878 600 /* lecture de l'entete du fichier pgm */ 1879 601 readitem(file, buffer); 1880 /*fscanf(fichier, "%s", buffer);*/ 1881 if(strcmp(buffer, "P5") != 0) 1882 nrerror("entete du fichier %s invalide\n"); 1883 //nrerror("entete du fichier %s invalide\n", filename); 1884 602 if (strcmp(buffer, "P6") != 0) { 603 nrerror("Entete du fichier %s invalide\n", filename); 604 } 605 1885 606 width = atoi(readitem(file, buffer)); 1886 607 height = atoi(readitem(file, buffer)); 1887 608 gris = atoi(readitem(file, buffer)); 1888 1889 for(i=0; i<height; i++) { 1890 ReadPGMrow(file, width, m[i]); 1891 } 1892 1893 fclose(file); 1894 free(buffer); 1895 } 1896 /* ------------------------------------------------------------------------------------------ */ 1897 IMAGE_EXPORT(void) SavePGM_bmatrix(uint8 **m, int nrl, int nrh, int ncl, int nch, char *filename) 1898 /* ------------------------------------------------------------------------------------------ */ 1899 { 1900 int nrow = nrh-nrl+1; 1901 int ncol = nch-ncl+1; 1902 1903 char buffer[80]; 1904 char msg[1024]; 1905 1906 FILE *file; 1907 int i; 1908 1909 file = fopen(filename, "wb"); 1910 if (file == NULL) { 1911 //nrerror("ouverture du fichier %s impossible dans SavePGM_bmatrix\n", filename); 1912 sprintf(msg, "ouverture du fichier %s impossible dans SavePGM_bmatrix\n", filename); 1913 nrerror(msg); 1914 } 1915 1916 /* enregistrement de l'image au format rpgm */ 1917 sprintf(buffer,"P5\n%d %d\n255\n",ncol, nrow); 1918 fwrite(buffer,strlen(buffer),1,file); 1919 for(i=nrl; i<=nrh; i++) 1920 WritePGMrow(m[i], ncol, file); 1921 1922 /* fermeture du fichier */ 1923 fclose(file); 1924 } 1925 /* --------------------------------------------------------------------------------------------- */ 1926 IMAGE_EXPORT(void) SavePGM_ui8matrix(uint8 **m, int nrl, int nrh, int ncl, int nch, char *filename) 1927 /* --------------------------------------------------------------------------------------------- */ 1928 { 1929 int nrow = nrh-nrl+1; 1930 int ncol = nch-ncl+1; 1931 1932 char buffer[80]; 1933 char msg[1024]; 1934 1935 FILE *file; 1936 int i; 1937 1938 file = fopen(filename, "wb"); 1939 if (file == NULL) { 1940 //nrerror("ouverture du fichier %s impossible dans SavePGM_bmatrix\n", filename); 1941 sprintf(msg, "ouverture du fichier %s impossible dans SavePGM_bmatrix\n", filename); 1942 nrerror(msg); 1943 } 1944 1945 /* enregistrement de l'image au format rpgm */ 1946 sprintf(buffer,"P5\n%d %d\n255\n",ncol, nrow); 1947 fwrite(buffer,strlen(buffer),1,file); 1948 for(i=nrl; i<=nrh; i++) 1949 WritePGMrow(m[i], ncol, file); 1950 1951 /* fermeture du fichier */ 1952 fclose(file); 1953 } 1954 /* --------------------------- */ 1955 /* -- PNM IO for rgb8matrix -- */ 1956 /* --------------------------- */ 1957 1958 /* ------------------------------------------------------ */ 1959 PRIVATE void ReadPNMrow(FILE *file, int width, byte *line) 1960 /* ------------------------------------------------------ */ 1961 { 1962 /* Le fichier est ouvert (en lecture) et ne sera pas ferme a la fin */ 1963 fread(&(line[0]), sizeof(byte), 3*sizeof(byte)*width, file); 1964 } 1965 /* ------------------------------------------------------- */ 1966 PRIVATE void WritePNMrow(byte *line, int width, FILE *file) 1967 /* ------------------------------------------------------- */ 1968 { 1969 /* Le fichier est deja ouvert et ne sera pas ferme a la fin */ 1970 1971 fwrite(&(line[0]), sizeof(byte), 3*sizeof(byte)*width, file); 1972 } 1973 /* ------------------------------------------------------------------------------------------ */ 1974 IMAGE_EXPORT(rgb8 **) LoadPPM_rgb8matrix(char *filename, int *nrl, int *nrh, int *ncl, int *nch) 1975 /* ------------------------------------------------------------------------------------------ */ 1976 { 1977 /* cette version ne lit plus que le type P6 */ 1978 1979 int height, width, gris; 1980 rgb8 **m; 1981 FILE *file; 1982 //int format; 1983 1984 char *buffer; 1985 char msg[1024]; 1986 //char c; 1987 int i; 1988 1989 buffer = (char*) calloc(80, sizeof(char)); 1990 /* ouverture du fichier */ 1991 file = fopen(filename,"rb"); 1992 if (file==NULL) { 1993 //nrerror("ouverture du fichier impossible\n"); 1994 sprintf(msg, "ouverture du fichier %s impossible dans SavePGM_bmatrix\n", filename); 1995 nrerror(msg); 1996 } 1997 1998 /* lecture de l'entete du fichier pgm */ 1999 readitem(file, buffer); 2000 /*fscanf(fichier, "%s", buffer);*/ 2001 if(strcmp(buffer, "P6") != 0) 2002 nrerror("entete du fichier %s invalide\n"); 2003 //nrerror("entete du fichier %s invalide\n", filename); 2004 2005 width = atoi(readitem(file, buffer)); 2006 height = atoi(readitem(file, buffer)); 2007 gris = atoi(readitem(file, buffer)); 2008 609 2009 610 *nrl = 0; 2010 611 *nrh = height - 1; … … 2012 613 *nch = width - 1; 2013 614 m = rgb8matrix(*nrl, *nrh, *ncl, *nch); 2014 2015 for (i=0; i<height; i++) {2016 ReadPNMrow(file, width, ( byte*)m[i]);2017 } 2018 615 616 for (int32_t i = 0; i < height; i++) { 617 ReadPNMrow(file, width, (uint8_t *) m[i]); 618 } 619 2019 620 fclose(file); 2020 621 free(buffer); 2021 622 2022 623 return m; 2023 624 } 625 626 2024 627 /* -------------------------------------------------------------------------------------------------- */ 2025 IMAGE_EXPORT(void) LoadPPM_rgb8matrix2(char *filename, int *nrl, int *nrh, int *ncl, int *nch, rgb8 **m)2026 /* -------------------------------------------------------------------------------------------------- */628 void LoadPPM_rgb8matrix2(char * filename, int * nrl, int * nrh, int * ncl, int * nch, rgb8 ** m) 629 /* -------------------------------------------------------------------------------------------------- */ 2027 630 { 2028 631 /* cette version ne lit plus que le type P6 */ 2029 2030 632 int height, width, gris; 2031 FILE *file; 2032 //int format; 2033 2034 char *buffer; 633 FILE * file; 634 635 char * buffer; 2035 636 char msg[1024]; 2036 //char c; 2037 int i; 2038 2039 buffer = (char*) calloc(80, sizeof(char)); 637 (void) gris; 638 639 buffer = (char *) calloc(80, sizeof(char)); 2040 640 /* ouverture du fichier */ 2041 file = fopen(filename,"rb"); 2042 if (file==NULL) { 2043 //nrerror("ouverture du fichier impossible\n"); 2044 sprintf(msg, "ouverture du fichier %s impossible dans LoadPPM_rgb8matrix2\n", filename); 641 file = fopen(filename, "rb"); 642 if (file == NULL) { 643 snprintf(msg, 1024, "ouverture du fichier %s impossible dans LoadPPM_rgb8matrix2\n", filename); 2045 644 nrerror(msg); 2046 645 } 2047 646 2048 647 /* lecture de l'entete du fichier pgm */ 2049 648 readitem(file, buffer); 2050 /*fscanf(fichier, "%s", buffer);*/2051 if(strcmp(buffer, "P6") != 0)2052 nrerror("entete du fichier %s invalide\n");649 if (strcmp(buffer, "P6") != 0) { 650 nrerror("Entete du fichier %s invalide\n", filename); 651 } 2053 652 //nrerror("entete du fichier %s invalide\n", filename); 2054 653 2055 654 width = atoi(readitem(file, buffer)); 2056 655 height = atoi(readitem(file, buffer)); 2057 656 gris = atoi(readitem(file, buffer)); 2058 657 2059 658 *nrl = 0; 2060 659 *nrh = height - 1; 2061 660 *ncl = 0; 2062 661 *nch = width - 1; 2063 2064 for (i=0; i<height; i++) {2065 ReadPNMrow(file, width, ( byte*)m[i]);662 663 for (int32_t i = 0; i < height; i++) { 664 ReadPNMrow(file, width, (uint8_t *) m[i]); 2066 665 } 2067 666 fclose(file); 2068 667 free(buffer); 2069 668 } 669 670 2070 671 /* ------------------------------------------------------------------------------------------------- */ 2071 IMAGE_EXPORT(void) SavePPM_rgb8matrix(rgb8 **m, int nrl, int nrh, int ncl, int nch, char *filename)672 void SavePPM_rgb8matrix(rgb8 ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * filename) 2072 673 /* ------------------------------------------------------------------------------------------------- */ 2073 674 { 2074 int nrow = nrh-nrl+1;2075 int ncol = nch-ncl+1;2076 675 int32_t nrow = nrh - nrl + 1; 676 int32_t ncol = nch - ncl + 1; 677 2077 678 char buffer[80]; 2078 679 char msg[1024]; 2079 2080 FILE *file; 2081 int i; 2082 680 681 FILE * file; 682 2083 683 file = fopen(filename, "wb"); 2084 684 if (file == NULL) { 2085 //nrerror("ouverture du fichier %s impossible dans SavePGM_bmatrix\n", filename); 2086 //nrerror("ouverture du fichier %s impossible dans SavePPM_bmatrix\n"); 2087 sprintf(msg, "ouverture du fichier %s impossible dans SavePPM_rgb8matrix\n", filename); 2088 685 snprintf(msg, 1024, "ouverture du fichier %s impossible dans %s\n", filename, __func__); 2089 686 nrerror(msg); 2090 687 } 2091 688 2092 689 /* enregistrement de l'image au format rpgm */ 2093 2094 sprintf(buffer,"P6\n%d %d\n255\n",ncol, nrow);2095 f write(buffer,strlen(buffer),1,file);2096 for(i=nrl; i<=nrh; i++)2097 WritePNMrow((byte*)m[i], ncol, file);2098 690 snprintf(buffer, 80, "P6\n%d %d\n255\n", ncol, nrow); 691 fwrite(buffer, strlen(buffer), 1, file); 692 for (int32_t i = nrl; i <= nrh; i++) { 693 WritePNMrow((uint8_t *) m[i], ncol, file); 694 } 695 2099 696 /* fermeture du fichier */ 2100 697 fclose(file); 2101 698 } 699 700 701 // Local Variables: 702 // tab-width: 4 703 // c-basic-offset: 4 704 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 705 // indent-tabs-mode: nil 706 // End: 707 708 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 709 -
soft/giet_vm/applications/rosenfeld/src-par/mca.c
r821 r822 42 42 { 43 43 printf("MCA ERROR: %s\n", msg); 44 printf("now exiting to system...\n");45 44 exit(1); 46 45 } … … 164 163 MCA * mca_par; 165 164 166 printf("*** %s ***\n", __func__);167 MCA_VERBOSE 1(printf(" height = %d\n", height));168 MCA_VERBOSE 1(printf(" width = %d\n", width));165 MCA_VERBOSE1(printf("*** %s ***\n", __func__)); 166 MCA_VERBOSE2(printf(" height = %d\n", height)); 167 MCA_VERBOSE2(printf(" width = %d\n", width)); 169 168 170 169 // array of pointers to mca workers … … 179 178 height_mod = height % np; 180 179 181 MCA_VERBOSE 1(printf(" height_par = %d x %d + %d\n", height_par, np, height_mod));182 MCA_VERBOSE 1(printf(" ========================\n"));180 MCA_VERBOSE2(printf(" height_par = %d x %d + %d\n", height_par, np, height_mod)); 181 MCA_VERBOSE2(printf(" ========================\n")); 183 182 184 183 i1_par_previous = 0; … … 186 185 // puissance de 2 de chaque bande 187 186 ne_par = height_par * width + 1; 188 MCA_VERBOSE 1(printf(" ne_par = %d\n", ne_par));187 MCA_VERBOSE2(printf(" ne_par = %d\n", ne_par)); 189 188 pw2 = i32log2(ne_par); 190 189 if (ne_par > (1 << pw2)) { … … 192 191 } 193 192 nemax_par = 1 << pw2; 194 195 MCA_VERBOSE1(printf(" nemax_par = %d\n", nemax_par)); 193 mca->alpha = pw2; 194 195 MCA_VERBOSE2(printf(" nemax_par = %d\n", nemax_par)); 196 196 197 197 nb_level = i32log2(np); … … 230 230 // -- constructor -- // 231 231 // ----------------- // 232 MCA_VERBOSE 2(printf("-- p = %d ----------------\n", p));232 MCA_VERBOSE3(printf("-- p = %d ----------------\n", p)); 233 233 234 234 // alloc of mca workers into array of pointers … … 245 245 x = (p / NB_PROCS_MAX) / Y_SIZE; 246 246 y = (p / NB_PROCS_MAX) % Y_SIZE; 247 MCA_VERBOSE 2(printf("p = %d (x = %d, y = %d)\n", p, x, y));247 MCA_VERBOSE3(printf("p = %d (x = %d, y = %d)\n", p, x, y)); 248 248 #endif 249 249 … … 268 268 i1_par_previous = i1_par; 269 269 270 MCA_VERBOSE 2(printf("i0_par = %d\n", i0_par));271 MCA_VERBOSE 2(printf("i1_par = %d\n", i1_par));270 MCA_VERBOSE3(printf("i0_par = %d\n", i0_par)); 271 MCA_VERBOSE3(printf("i1_par = %d\n", i1_par)); 272 272 273 273 // etiquettes … … 281 281 } 282 282 283 MCA_VERBOSE 2(printf("e0_par = %d\n", e0_par));284 MCA_VERBOSE 2(printf("e1_par = %d\n", e1_par));283 MCA_VERBOSE3(printf("e0_par = %d\n", e0_par)); 284 MCA_VERBOSE3(printf("e1_par = %d\n", e1_par)); 285 285 286 286 mca_par->width = width; … … 313 313 if (p == 0) { 314 314 mca_par->T = remote_ui32vector(e0_par - 1, e1_par, x, y); // car e0 = 1, on a besoin que T[0] = 0 pour FindRoot 315 #if FEATURES316 315 mca_par->stats = remote_RegionStatsVector(e0_par - 1, e1_par, x, y); 317 #endif318 316 } 319 317 else { 320 318 mca_par->T = remote_ui32vector(e0_par, e1_par, x, y); 321 #if FEATURES322 319 mca_par->stats = remote_RegionStatsVector(e0_par, e1_par, x, y); 323 #endif324 320 } 325 321 326 322 mca_par->D = (uint32 **) remote_vvector(0, np - 1, x, y); 327 #if FEATURES328 323 mca_par->F = (RegionStats **) remote_vvector(0, np - 1, x, y); 329 #endif330 324 #else // !GIETVM 331 325 mca_par->X = ui8matrix (i0_par, i1_par, 0, width - 1); … … 334 328 if (p == 0) { 335 329 mca_par->T = ui32vector(e0_par - 1, e1_par); // car e0 = 1, on a besoin que T[0] = 0 pour FindRoot 336 #if FEATURES337 330 mca_par->stats = RegionStatsVector(e0_par - 1, e1_par); 338 339 #endif340 331 } 341 332 else { 342 333 mca_par->T = ui32vector(e0_par, e1_par); 343 #if FEATURES344 334 mca_par->stats = RegionStatsVector(e0_par, e1_par); 345 #endif346 335 } 347 336 348 337 mca_par->D = (uint32 **) vvector(0, np - 1); 349 #if FEATURES350 338 mca_par->F = (RegionStats **) vvector(0, np - 1); 351 #endif352 339 #endif 353 MCA_VERBOSE 2(printf("X = %p\n", mca_par->X));354 MCA_VERBOSE 2(printf("E = %p\n", mca_par->E));355 MCA_VERBOSE 2(printf("T = %p\n", mca_par->T));356 MCA_VERBOSE 2(printf("D = %p\n", mca_par->D));340 MCA_VERBOSE3(printf("X = %p\n", mca_par->X)); 341 MCA_VERBOSE3(printf("E = %p\n", mca_par->E)); 342 MCA_VERBOSE3(printf("T = %p\n", mca_par->T)); 343 MCA_VERBOSE3(printf("D = %p\n", mca_par->D)); 357 344 } // p 358 345 … … 365 352 uint32 e1 = mca_par->e1; 366 353 367 MCA_VERBOSE 2(printf("p = %d T[%d..%d]\n", p, e0, e1));354 MCA_VERBOSE3(printf("p = %d T[%d..%d]\n", p, e0, e1)); 368 355 if (p == 0) { 369 356 set_ui32vector_j(T, e0 - 1, e1); // car e0 = 1, on a besoin que T[0] = 0 pour FindRoot … … 372 359 set_ui32vector_j(T, e0, e1); 373 360 } 374 MCA_VERBOSE 2(printf("\n"));375 } 376 377 MCA_VERBOSE 2(printf("display des tables d'EQ\n"));361 MCA_VERBOSE3(printf("\n")); 362 } 363 364 MCA_VERBOSE3(printf("display des tables d'EQ\n")); 378 365 for (int p = 0; p < np; p++) { 379 366 MCA * mca_par = mcas[p]; … … 383 370 uint32 e1 = mca_par->e1; 384 371 385 MCA_VERBOSE 2(printf("p = %d T[%d..%d]\n", p, e0, e1));386 if (p == 0) { 387 MCA_VERBOSE 2(display_ui32vector_number(T, e0 - 1, e0 + 10, "%5d", "T"));388 } 389 else { 390 MCA_VERBOSE 2(display_ui32vector_number(T, e0, e0 + 10, "%5d", "T"));391 } 392 MCA_VERBOSE 2(printf("\n"));372 MCA_VERBOSE3(printf("p = %d T[%d..%d]\n", p, e0, e1)); 373 if (p == 0) { 374 MCA_VERBOSE3(display_ui32vector_number(T, e0 - 1, e0 + 10, "%5d", "T")); 375 } 376 else { 377 MCA_VERBOSE3(display_ui32vector_number(T, e0, e0 + 10, "%5d", "T")); 378 } 379 MCA_VERBOSE3(printf("\n")); 393 380 } 394 381 //exit(-1); … … 399 386 400 387 // table d'indirection distribuee D 401 MCA_VERBOSE 2(printf("nemax_par = %d\n", nemax_par));388 MCA_VERBOSE3(printf("nemax_par = %d\n", nemax_par)); 402 389 for (int p = 0; p < np; p++) { 403 390 MCA * mca_p = mcas[p]; … … 409 396 uint32 * T = mca_k->T; 410 397 D[k] = T + k * nemax_par; // il faut soustraire le "MSB" 411 #if FEATURES412 398 RegionStats * stat = mca_k->stats; 413 399 F[k] = stat + k * nemax_par; // il faut soustraire le "MSB" 414 #endif415 400 } // k 416 401 } // p 417 402 418 MCA_VERBOSE 2(printf("table d'indirection distribuee D\n"));419 420 for (int p = 0; p < np; p++) { 421 MCA_VERBOSE 2(printf("== p = %d ==========\n", p));403 MCA_VERBOSE3(printf("table d'indirection distribuee D\n")); 404 405 for (int p = 0; p < np; p++) { 406 MCA_VERBOSE3(printf("== p = %d ==========\n", p)); 422 407 423 408 MCA * mca_p = mcas[p]; … … 430 415 uint32 e0 = mca_k->e0; 431 416 uint32 e1 = mca_k->e1; 432 MCA_VERBOSE2(display_ui32vector_number(T, e0, e0 + 9, "%5d", "T")); 433 MCA_VERBOSE2(display_ui32vector(D[k], 0, 9, "%5d", "D\n")); 434 } 435 MCA_VERBOSE2(printf("\n")); 436 } 437 438 /**/ 439 //exit(-1); 440 441 //printf("[MCA_Initialize] positionnement des pointeurs de lignes (i0-1) et (i1+1)"); 442 443 for (int p = 0; p < np; p++) { 444 445 //printf(" --p = %d ------------------\n", p); 446 // cas general 447 417 MCA_VERBOSE3(display_ui32vector_number(T, e0, e0 + 9, "%5d", "T")); 418 MCA_VERBOSE3(display_ui32vector(D[k], 0, 9, "%5d", "D\n")); 419 } 420 MCA_VERBOSE3(printf("\n")); 421 } 422 423 for (int p = 0; p < np; p++) { 448 424 if (p > 0) { 449 425 //printf("i0_(%d) = %d i1_{%d} = %d\n", p, mcas[p]->i0, p-1, mcas[p-1]->i1); … … 476 452 (void) mca_par; 477 453 478 printf("*** MCA_Display_Parameters ***\n");479 480 MCA_VERBOSE 1(printf(" height = %d\n", mca->height));481 MCA_VERBOSE 1(printf(" width = %d\n", mca->width));482 MCA_VERBOSE 1(printf(" np = %d\n", mca->np));454 MCA_VERBOSE1(printf("*** MCA_Display_Parameters ***\n")); 455 456 MCA_VERBOSE2(printf(" height = %d\n", mca->height)); 457 MCA_VERBOSE2(printf(" width = %d\n", mca->width)); 458 MCA_VERBOSE2(printf(" np = %d\n", mca->np)); 483 459 484 460 for (int p = 0; p < np; p++) { 485 461 mca_par = mcas[p]; 486 462 487 MCA_VERBOSE 2(printf("Display MCA[%d]\n", p));488 MCA_VERBOSE 2(printf("p = %d\n", mca_par->p));489 MCA_VERBOSE 2(printf("i0 = %8d i1 = %8d\n", mca_par->i0, mca_par->i1));490 MCA_VERBOSE 2(printf("j0 = %8d j1 = %8d\n", mca_par->j0, mca_par->j1));491 MCA_VERBOSE 2(printf("e0 = %8d e1 = %8d\n", mca_par->e0, mca_par->e1));463 MCA_VERBOSE3(printf("Display MCA[%d]\n", p)); 464 MCA_VERBOSE3(printf("p = %d\n", mca_par->p)); 465 MCA_VERBOSE3(printf("i0 = %8d i1 = %8d\n", mca_par->i0, mca_par->i1)); 466 MCA_VERBOSE3(printf("j0 = %8d j1 = %8d\n", mca_par->j0, mca_par->j1)); 467 MCA_VERBOSE3(printf("e0 = %8d e1 = %8d\n", mca_par->e0, mca_par->e1)); 492 468 } 493 469 } … … 507 483 uint32 e0, e1; 508 484 509 printf("*** MCA_Finalize ***\n");485 MCA_VERBOSE1(printf("*** MCA_Finalize ***\n")); 510 486 511 487 #if PYR_BARRIERS … … 532 508 if (p == 0) { 533 509 free_ui32vector(mca_par->T, e0 - 1, e1); // car e0 = 1, on a besoin que T[0] = 0 pour FindRoot 534 #if FEATURES535 510 free_RegionStatsVector(mca_par->stats, e0 - 1, e1); 536 #endif537 511 } 538 512 else { 539 513 free_ui32vector(mca_par->T, e0, e1); 540 #if FEATURES541 514 free_RegionStatsVector(mca_par->stats, e0, e1); 542 #endif543 515 } 544 516 545 517 free_vvector((void **) mca_par->D, 0, np - 1); 546 #if FEATURES547 518 free_vvector((void **) mca_par->F, 0, np - 1); 548 #endif549 519 free(mca_par); 550 520 } … … 564 534 565 535 if (mca->p == 0) { 566 printf("*** MCA_Scatter_ImageX ***\n");536 MCA_VERBOSE1(printf("*** MCA_Scatter_ImageX ***\n")); 567 537 } 568 538 … … 593 563 594 564 if (mca->p == 0) { 595 printf("*** MCA_Gather_ImageL ***\n");565 MCA_VERBOSE1(printf("*** MCA_Gather_ImageL ***\n")); 596 566 } 597 567 -
soft/giet_vm/applications/rosenfeld/src-par/mca_main.c
r821 r822 126 126 127 127 128 // QM : The cost of this function is horrible129 // but it is only for testing purpose130 128 // Renumbers object in a contiguous way, for an image which has already 131 129 // been processed with several threads 132 // ------------------------------------------------------------------ --133 static void renumber_image( uint32 ** E, int i0, int i1, int j0, int j1)134 // ------------------------------------------------------------------ --135 { 136 int size = 10;137 int idx = 1; // next label to give, first invalid index in the equiv table138 uint32 * equiv = malloc(sizeof(uint32) * size);139 equiv[0] = 0; // unused 140 int found;141 142 for (int i = i0; i <= i1; i++) {143 for (int j = j0; j <= j1; j++) {144 if (E[i][j] != 0) {145 found = 0;146 for (int k = 1; k < idx; k++) {147 if (equiv[k] == E[i][j]) {148 E[i][j] = k;149 found = 1;150 break;151 }152 }153 if (found == 0) {154 equiv[idx] = E[i][j];155 E[i][j] = idx;156 idx += 1;157 if (idx == size) {158 size = size * 2;159 equiv = realloc(equiv, sizeof(uint32) * size);160 }161 }130 // ------------------------------------------------------------------ 131 static void renumber_image(MCA * mca, int i0, int i1, int j0, int j1) 132 // ------------------------------------------------------------------ 133 { 134 int32_t na = 0; 135 uint32_t ** E = mca->E; 136 uint32_t ** D = mca->mcas[0]->D; 137 138 uint32_t shift = mca->alpha; 139 uint32_t mask = (1 << shift) - 1; 140 141 for (int32_t p = 0; p < mca->np; p++) { 142 MCA * mca_par = mca->mcas[p]; 143 uint32 * T = mca_par->T; 144 for (uint32_t e = mca_par->e0; e <= mca_par->ne; e++) { 145 if (T[e] != e) { 146 // FindRoot_Dist 147 uint32_t r = T[e]; 148 uint32_t a = e; 149 do { 150 uint32_t e1 = r >> shift; 151 uint32_t e0 = r & mask; 152 a = r; 153 r = D[e1][e0]; 154 } while (r < a); 155 T[e] = r; 156 } 157 else { 158 na += 1; 159 T[e] = na; 162 160 } 163 161 } 164 162 } 165 free(equiv); 163 164 for (int32_t i = i0; i <= i1; i++) { 165 for (int32_t j = j0; j <= j1; j++) { 166 if (E[i][j] != 0) { 167 uint32_t e0 = E[i][j] & mask; 168 uint32_t e1 = E[i][j] >> shift; 169 E[i][j] = D[e1][e0]; 170 } 171 } 172 } 166 173 } 167 174 … … 203 210 204 211 display_ui8matrix_positive(mca->X, i0, i1, j0, j1, 5, "X0"); 205 #if FEATURES206 for (int i = 1; i < num_threads; i++) {207 pthread_create(&thread_table[i], NULL, MCA_Label_Features_Rosenfeld, (void *) mca->mcas[i]);208 }209 MCA_Label_Features_Rosenfeld(mca->mcas[0]);210 #else211 212 for (int i = 1; i < num_threads; i++) { 212 213 pthread_create(&thread_table[i], NULL, MCA_Label_Rosenfeld, (void *) mca->mcas[i]); 213 214 } 215 214 216 MCA_Label_Rosenfeld(mca->mcas[0]); 215 #endif 217 216 218 for (int i = 1; i < num_threads; i++) { 217 219 pthread_join(thread_table[i], NULL); … … 221 223 222 224 // -- free -- 223 printf("Finalize\n");225 MCA_VERBOSE1(printf("Finalize\n")); 224 226 MCA_Finalize(mca); 225 227 226 printf("Free_matrix\n");228 MCA_VERBOSE1(printf("Free_matrix\n")); 227 229 free_ui8matrix (X0, i0, i1, j0, j1); 228 230 free_ui32matrix(E, i0, i1, j0, j1); … … 249 251 Palette_18ColorsBW(palette); 250 252 251 printf("Loading file %s... ", infile);253 MCA_VERBOSE1(printf("Loading file %s... ", infile)); 252 254 X = LoadPGM_ui8matrix(infile, &i0, &i1, &j0, &j1); 253 printf("done.\n");254 255 printf("Allocating memory... ");255 MCA_VERBOSE1(printf("done.\n")); 256 257 MCA_VERBOSE1(printf("Allocating memory... ")); 256 258 height = i1 - i0 + 1; 257 259 width = j1 - j0 + 1; … … 265 267 // pre-traitements 266 268 binarisation_ui8matrix(X, i0, i1, j0, j1, 20, 1, X); // pour le traitement 267 printf("done.\n");268 269 printf("Allocating and initializing MCA... \n");269 MCA_VERBOSE1(printf("done.\n")); 270 271 MCA_VERBOSE1(printf("Allocating and initializing MCA... \n")); 270 272 mca = MCA_pConstructor_Empty(); 271 273 … … 279 281 MCA_Initialize(mca); 280 282 MCA_Display_Parameters(mca); 281 printf("End of MCA allocation and initialization.\n");283 MCA_VERBOSE1(printf("End of MCA allocation and initialization.\n")); 282 284 283 285 CLOCK_APP_CREATE; 284 #if FEATURES285 for (int i = 1; i < num_threads; i++) {286 pthread_create(&thread_table[i], NULL, MCA_Label_Features_Rosenfeld, (void *) mca->mcas[i]);287 }288 MCA_Label_Features_Rosenfeld(mca->mcas[0]);289 #else290 286 for (int i = 1; i < num_threads; i++) { 291 287 pthread_create(&thread_table[i], NULL, MCA_Label_Rosenfeld, (void *) mca->mcas[i]); 292 288 } 289 293 290 MCA_Label_Rosenfeld(mca->mcas[0]); 294 #endif 291 295 292 for (int i = 1; i < num_threads; i++) { 296 293 pthread_join(thread_table[i], NULL); … … 300 297 if (generate_output_image) { 301 298 #if TARGET_OS != GIETVM 302 renumber_image(mca ->E, i0, i1, j0, j1);299 renumber_image(mca, i0, i1, j0, j1); 303 300 #else 304 301 printf("Warning: the output image has not been renumbered, it cannot be used as a comparison with the reference\n"); 305 302 #endif 306 303 mod_ui32matrix_ui8matrix(mca->E, i0, i1, j0, j1, E8); 307 printf("Saving file %s for verification... ", outfile);304 MCA_VERBOSE1(printf("Saving file %s for verification... ", outfile)); 308 305 SaveBMP2_ui8matrix(E8, width, height, palette, outfile); 309 printf("done.\n");306 MCA_VERBOSE1(printf("done.\n")); 310 307 } 311 308 312 309 MCA_Finalize(mca); 313 printf("Deallocating memory...");310 MCA_VERBOSE1(printf("Deallocating memory...")); 314 311 free_ui8matrix (X, i0, i1, j0, j1); 315 312 free_ui8matrix (E8, i0, i1, j0, j1); 316 313 free_ui32matrix(E, i0, i1, j0, j1); 317 printf("done.\n");314 MCA_VERBOSE1(printf("done.\n")); 318 315 } 319 316 … … 353 350 int num_threads = DEFAULT_NTHREADS; 354 351 355 printf("*** Starting application Rosenfeld ***\n");352 MCA_VERBOSE1(printf("*** Starting application Rosenfeld ***\n")); 356 353 357 354 #if TARGET_OS != GIETVM // @QM I think the giet has some random (uninitialized) values for argc and argv … … 410 407 } 411 408 412 printf("Parameters:\n");413 printf("- Number of threads: %d\n", num_threads);414 printf("- Input file: %s\n", infile);415 printf("- Output file: %s\n", outfile);409 MCA_VERBOSE1(printf("Parameters:\n")); 410 MCA_VERBOSE1(printf("- Number of threads: %d\n", num_threads)); 411 MCA_VERBOSE1(printf("- Input file: %s\n", infile)); 412 MCA_VERBOSE1(printf("- Output file: %s\n", outfile)); 416 413 #if FAST 417 printf("- Using decision trees (fast): yes\n");414 MCA_VERBOSE1(printf("- Using decision trees (fast): yes\n")); 418 415 #elif SLOW 419 printf("- Using decision trees (fast): no\n");416 MCA_VERBOSE1(printf("- Using decision trees (fast): no\n")); 420 417 #endif 421 418 #if FEATURES 422 printf("- Computing features: yes\n"); 423 #else 424 printf("- Computing features: no\n"); 419 MCA_VERBOSE1(printf("- Computing features: yes\n")); 420 #else 421 MCA_VERBOSE1(printf("- Computing features: no\n")); 422 #endif 423 #if PARMERGE 424 MCA_VERBOSE1(printf("- Parallel Merge: yes\n")); 425 #else 426 MCA_VERBOSE1(printf("- Parallel Merge: no\n")); 427 #endif 428 #if ARSP 429 MCA_VERBOSE1(printf("- Optimization ARemSP: yes\n")); 430 #else 431 MCA_VERBOSE1(printf("- Optimization ARemSP: no\n")); 432 #endif 433 #if PYR_BARRIERS 434 MCA_VERBOSE1(printf("- Pyramidal Barriers: yes\n")); 435 #else 436 MCA_VERBOSE1(printf("- Pyramidal Barriers: no\n")); 425 437 #endif 426 438 … … 428 440 #if TARGET_OS == GIETVM 429 441 giet_tty_alloc(1); 430 printf("Initializing heaps... ");442 MCA_VERBOSE1(printf("Initializing heaps... ")); 431 443 for (int i = 0; i < X_SIZE; i++) { 432 444 for (int j = 0; j < X_SIZE; j++) { … … 434 446 } 435 447 } 436 printf("done.\n");448 MCA_VERBOSE1(printf("done.\n")); 437 449 #endif 438 450 … … 443 455 } 444 456 457 // Local Variables: 458 // tab-width: 4 459 // c-basic-offset: 4 460 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 461 // indent-tabs-mode: nil 462 // End: 463 464 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 465 -
soft/giet_vm/applications/rosenfeld/src-par/mca_rosenfeld.c
r821 r822 61 61 r = T[r]; 62 62 } 63 if (r == 0) { 64 printf("e = %d\n",e); 65 assert(0); 66 } 63 64 assert(r != 0); 67 65 return r; 68 66 } … … 81 79 int mask = (1 << shift) - 1; 82 80 83 MCA_VERBOSE 2(printf("%s(%d, %d) \n", __func__, r, shift));81 MCA_VERBOSE3(printf("%s(%d, %d) \n", __func__, r, shift)); 84 82 do { 85 83 e = r; … … 87 85 e0 = r & mask; 88 86 r = D[e1][e0]; 89 MCA_VERBOSE 2(printf("%s: D(%d) = D[%d,%d] = %d (alpha = %d)\n", __func__, e, e1, e0, r, shift));87 MCA_VERBOSE3(printf("%s: D(%d) = D[%d,%d] = %d (alpha = %d)\n", __func__, e, e1, e0, r, shift)); 90 88 } while (r < e); 91 MCA_VERBOSE 2(printf("%s = %d \n\n", __func__, r));89 MCA_VERBOSE3(printf("%s = %d \n\n", __func__, r)); 92 90 assert(r != 0); 93 91 return r; … … 112 110 113 111 #if FEATURES && !PARMERGE 114 // ---------------------------------------------------------------------------------------------------- 115 void SetRoot_Features_Rosenfeld_Dist(uint32 ** D, uint32 root, uint32 eps, int shift, RegionStats ** F)116 // ---------------------------------------------------------------------------------------------------- 112 // ----------------------------------------------------------------------------------------------------------- 113 static void SetRoot_Features_Rosenfeld_Dist(uint32 ** D, uint32 root, uint32 eps, int shift, RegionStats ** F) 114 // ----------------------------------------------------------------------------------------------------------- 117 115 { 118 116 assert(root != 0 && eps != 0); 119 117 120 MCA_VERBOSE 2(printf("F(%d) += F(%d)\n", eps, root));118 MCA_VERBOSE3(printf("F(%d) += F(%d)\n", eps, root)); 121 119 122 120 int mask = (1 << shift) - 1; 123 121 124 // SetRoot_Rosenfeld_Dist125 122 uint32 r1 = root >> shift; 126 123 uint32 r0 = root & mask; … … 148 145 149 146 #if FEATURES && PARMERGE 150 // ------------------------------------------------------------------------------------------------------------- 151 bool SetRoot_Parallel_Features_Rosenfeld_Dist(uint32 ** D, uint32 root, uint32 eps, int shift, RegionStats ** F)152 // ------------------------------------------------------------------------------------------------------------- 147 // -------------------------------------------------------------------------------------------------------------------- 148 static bool SetRoot_Parallel_Features_Rosenfeld_Dist(uint32 ** D, uint32 root, uint32 eps, int shift, RegionStats ** F) 149 // -------------------------------------------------------------------------------------------------------------------- 153 150 { 154 151 assert(root != 0 && eps != 0); 155 152 156 MCA_VERBOSE 2(printf("F(%d) += F(%d)\n", eps, root));153 MCA_VERBOSE3(printf("F(%d) += F(%d)\n", eps, root)); 157 154 158 155 int mask = (1 << shift) - 1; 159 156 160 // SetRoot_Rosenfeld_Dist161 157 uint32 r1 = root >> shift; 162 158 uint32 r0 = root & mask; … … 177 173 } 178 174 if (D[r1][r0] != root) { 179 // Someone change the root of epsilon, need to find the new root175 // Someone change the root of "root", need to find the new root 180 176 printf("race cond 2\n"); 181 177 pthread_spin_unlock(&F[e1][e0].lock); … … 249 245 250 246 251 #if FAST && !FEATURES 247 #if FAST && !FEATURES && !PARMERGE && !ARSP 252 248 // --------------------------------------------------------------------------------------- 253 249 static void vuse2_Rosenfeld_Dist(uint32 ed, uint32 el, uint32 * T, uint32 ** D, int alpha) … … 273 269 } 274 270 } 275 #endif // FAST && !FEATURES 276 277 278 #if FAST && !FEATURES 271 272 // FAST && !FEATURES && !PARMERGE && !ARSP 273 279 274 // ----------------------------------------------------------------------------------------------------- 280 275 static void vuse3_Rosenfeld_Dist(uint32 ed1, uint32 ed2, uint32 el3, uint32 * T, uint32 ** D, int alpha) … … 284 279 uint32 r2 = FindRoot_Dist(D, ed2, alpha); 285 280 286 // QM287 //uint32 r3 = FindRoot(T, el3); // local - distant288 281 uint32 r3 = T[el3]; // local - distant 289 282 r3 = FindRoot_Dist(D, r3, alpha); … … 297 290 uint32 eps = ui32Min3(r1, r2, r3); // forcement positifs car appel depuis optimizedBorder qui a fait un test 298 291 292 // On ne fait pas le test car on peut faire le SetRoot plusieurs fois sur le même élément (on n'accumule pas de stats) 299 293 if (r1 > eps) { 300 294 SetRoot_Rosenfeld_Dist(D, r1, eps, alpha); 301 295 } 302 //r2 = T[r2]; // @QM est-ce indispensable s'il n'y a pas de features ? (cf. slow no features)303 // comment est-on sur que r2 (ou r3) est local ???304 296 if (r2 > eps) { 305 297 SetRoot_Rosenfeld_Dist(D, r2, eps, alpha); 306 298 } 307 //r3 = T[r3];308 299 if (r3 > eps) { 309 300 SetRoot_Rosenfeld_Dist(D, r3, eps, alpha); 310 301 } 311 302 } 312 #endif // FAST && !FEATURES 313 314 315 #if FAST && FEATURES && !PARMERGE 316 // ----------------------------------------------------------------------------------------------------------- 317 void vuse2_Features_Rosenfeld_Dist(uint32 ed, uint32 el, uint32 * T, uint32 ** D, int alpha, RegionStats ** F)318 // ----------------------------------------------------------------------------------------------------------- 303 #endif // FAST && !FEATURES && !PARMERGE && !ARSP 304 305 306 #if FAST && FEATURES && !PARMERGE && !ARSP 307 // ------------------------------------------------------------------------------------------------------------------ 308 static void vuse2_Features_Rosenfeld_Dist(uint32 ed, uint32 el, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 309 // ------------------------------------------------------------------------------------------------------------------ 319 310 { 320 311 assert(ed != 0 && el != 0); … … 341 332 } 342 333 } 343 #endif // FAST && FEATURES && !PARMERGE 344 345 346 #if FAST && FEATURES && !PARMERGE 347 // ------------------------------------------------------------------------------------------------------------------------- 348 void vuse3_Features_Rosenfeld_Dist(uint32 ed1, uint32 ed2, uint32 el3, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 349 // ------------------------------------------------------------------------------------------------------------------------- 334 335 // FAST && FEATURES && !PARMERGE && !ARSP 336 337 // -------------------------------------------------------------------------------------------------------------------------------- 338 static void vuse3_Features_Rosenfeld_Dist(uint32 ed1, uint32 ed2, uint32 el3, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 339 // -------------------------------------------------------------------------------------------------------------------------------- 350 340 { 351 341 assert(ed1 != 0 && ed2 != 0 && el3 != 0); … … 354 344 uint32 r2 = FindRoot_Dist(D, ed2, alpha); 355 345 356 //uint32 r3 = FindRoot(T, el3); // local - distant357 346 uint32 r3 = T[el3]; // local - distant 358 347 assert(r3 != 0); … … 370 359 SetRoot_Features_Rosenfeld_Dist(D, r1, eps, alpha, F); 371 360 } 372 //r2 = T[r2];373 361 if (r2 > eps && r2 != r1) { 374 362 SetRoot_Features_Rosenfeld_Dist(D, r2, eps, alpha, F); 375 363 } 376 //r3 = T[r3];377 364 if (r3 > eps && r3 != r2 && r3 != r1) { 378 365 SetRoot_Features_Rosenfeld_Dist(D, r3, eps, alpha, F); 379 366 } 380 367 } 381 #endif // FAST && FEATURES && !PARMERGE 382 383 384 #if FAST && FEATURES && PARMERGE 385 // -------------------------------------------------------------------------------------------------------------------- 386 void vuse2_Parallel_Features_Rosenfeld_Dist(uint32 ed, uint32 el, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 387 // -------------------------------------------------------------------------------------------------------------------- 368 #endif // FAST && FEATURES && !PARMERGE && !ARSP 369 370 371 #if FAST && !FEATURES && PARMERGE && ARSP 372 // ---------------------------------------------------------------------------------------------------------------- 373 static bool SetRoot_Parallel_Arsp_Rosenfeld_Dist(uint32 ** D, uint32 root, uint32 eps, int shift, RegionStats ** F) 374 // ---------------------------------------------------------------------------------------------------------------- 375 { 376 assert(root != 0 && eps != 0); 377 378 MCA_VERBOSE3(printf("F(%d) += F(%d)\n", eps, root)); 379 380 uint32_t mask = (1 << shift) - 1; 381 382 uint32_t r1 = root >> shift; 383 uint32_t r0 = root & mask; 384 385 pthread_spin_lock(&F[r1][r0].lock); 386 if (D[r1][r0] != root) { 387 pthread_spin_unlock(&F[r1][r0].lock); 388 return false; 389 } 390 391 D[r1][r0] = eps; 392 393 pthread_spin_unlock(&F[r1][r0].lock); 394 return true; 395 } 396 397 // FAST && !FEATURES && PARMERGE && ARSP 398 399 // ------------------------------------------------------------------------------------------------------------------------------ 400 static inline bool FindSmallerAncestor_Link(uint32 ** D, uint32_t rl, uint32_t el, uint32_t rd, uint32_t shift, RegionStats ** F) 401 // ------------------------------------------------------------------------------------------------------------------------------ 402 { 403 bool ok; 404 uint32_t el1, el0; 405 uint32_t mask = (1 << shift) - 1; 406 while (rl < el && rl > rd) { 407 el = rl; 408 el1 = rl >> shift; 409 el0 = rl & mask; 410 rl = D[el1][el0]; 411 } 412 if (rd != rl) { 413 if (rl == el && rl > rd) { 414 // L'ordre s'est inversé : on fait pointer rl vers rd 415 ok = SetRoot_Parallel_Arsp_Rosenfeld_Dist(D, rl, rd, shift, F); 416 } 417 else { 418 // On fait pointer rd vers rl 419 ok = SetRoot_Parallel_Arsp_Rosenfeld_Dist(D, rd, rl, shift, F); 420 } 421 } 422 else { 423 ok = true; 424 } 425 return ok; 426 } 427 428 // FAST && !FEATURES && PARMERGE && ARSP 429 430 // ----------------------------------------------------------------------------------------------------------------------- 431 static void vuse2_Parallel_Arsp_Rosenfeld_Dist(uint32 ed, uint32 el, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 432 // ----------------------------------------------------------------------------------------------------------------------- 433 { 434 assert(ed != 0 && el != 0); 435 436 uint32_t shift = alpha; 437 uint32_t mask = (1 << shift) - 1; 438 439 uint32_t rd = ed; 440 uint32_t rl = el; 441 442 uint32_t ed1; 443 uint32_t el1; 444 uint32_t ed0; 445 uint32_t el0; 446 447 bool ok; 448 449 // Fusion ed - el 450 do { 451 do { 452 ed = rd; 453 el = rl; 454 ed1 = rd >> shift; 455 el1 = rl >> shift; 456 ed0 = rd & mask; 457 el0 = rl & mask; 458 rd = D[ed1][ed0]; 459 rl = D[el1][el0]; 460 } while (rl < el && rd < ed); 461 462 assert(rl != 0 && rd != 0); 463 464 if (rd != rl) { 465 if (rd == ed) { 466 ok = FindSmallerAncestor_Link(D, rl, el, rd, shift, F); 467 } 468 else { 469 assert(rl == el); 470 ok = FindSmallerAncestor_Link(D, rd, ed, rl, shift, F); 471 } 472 } 473 else { 474 ok = true; 475 } 476 } while (!ok); 477 } 478 479 // FAST && !FEATURES && PARMERGE && ARSP 480 481 // ------------------------------------------------------------------------------------------------------------------------------------- 482 static void vuse3_Parallel_Arsp_Rosenfeld_Dist(uint32 ed1, uint32 ed2, uint32 el3, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 483 // ------------------------------------------------------------------------------------------------------------------------------------- 484 { 485 assert(ed1 != 0 && ed2 != 0 && el3 != 0); 486 487 uint32_t shift = alpha; 488 uint32_t mask = (1 << shift) - 1; 489 490 uint32_t r1 = ed1; 491 uint32_t r2 = ed2; 492 uint32_t r3 = el3; 493 494 uint32_t e11; 495 uint32_t e21; 496 uint32_t e31; 497 uint32_t e10; 498 uint32_t e20; 499 uint32_t e30; 500 501 uint32_t r0; 502 uint32_t ed0; 503 uint32_t e00; 504 uint32_t e01; 505 506 // Pas d'init pour que valgrind détecte une erreur si bool est lu sans être affecté 507 bool ok; 508 509 // Fusion ed1 - ed2 510 do { 511 do { 512 ed1 = r1; 513 ed2 = r2; 514 e11 = r1 >> shift; 515 e21 = r2 >> shift; 516 e10 = r1 & mask; 517 e20 = r2 & mask; 518 r1 = D[e11][e10]; 519 r2 = D[e21][e20]; 520 } while (r1 < ed1 && r2 < ed2); 521 522 assert(r1 != 0 && r2 != 0); 523 524 if (r1 != r2) { 525 if (r1 == ed1) { 526 ok = FindSmallerAncestor_Link(D, r2, ed2, r1, shift, F); 527 } 528 else { 529 assert(r2 == ed2); 530 ok = FindSmallerAncestor_Link(D, r1, ed1, r2, shift, F); 531 } 532 } 533 else { 534 ok = true; 535 } 536 } while (!ok); 537 538 // Fusion r0 = min(r1, r2) avec r3 539 if (r1 < r2) { 540 r0 = r1; 541 ed0 = r1; 542 e00 = e10; 543 e01 = e11; 544 } 545 else { 546 r0 = r2; 547 ed0 = r2; 548 e00 = e20; 549 e01 = e21; 550 } 551 552 // r0 est déjà une racine 553 goto r0_is_root; 554 do { 555 do { 556 ed0 = r0; 557 el3 = r3; 558 e01 = r0 >> shift; 559 e31 = r3 >> shift; 560 e00 = r0 & mask; 561 e30 = r3 & mask; 562 r0 = D[e01][e00]; 563 r3 = D[e31][e30]; 564 } while (r0 < ed0 && r3 < el3); 565 566 assert(r0 != 0 && r3 != 0); 567 568 if (r0 != r3) { 569 if (r0 == ed0) { 570 r0_is_root: 571 ok = FindSmallerAncestor_Link(D, r3, el3, r0, shift, F); 572 } 573 else { 574 assert(r3 == el3); 575 ok = FindSmallerAncestor_Link(D, r0, ed0, r3, shift, F); 576 } 577 } 578 else { 579 ok = true; 580 } 581 } while (!ok); 582 } 583 #endif // FAST && !FEATURES && PARMERGE && ARSP 584 585 586 587 #if FAST && FEATURES && PARMERGE && !ARSP 588 // --------------------------------------------------------------------------------------------------------------------------- 589 static void vuse2_Parallel_Features_Rosenfeld_Dist(uint32 ed, uint32 el, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 590 // --------------------------------------------------------------------------------------------------------------------------- 388 591 { 389 592 bool ok; … … 414 617 } while (!ok); 415 618 } 416 #endif // FAST && FEATURES && PARMERGE 417 418 419 #if FAST && FEATURES && PARMERGE 420 // ---------------------------------------------------------------------------------------------------------------------------------- 421 void vuse3_Parallel_Features_Rosenfeld_Dist(uint32 ed1, uint32 ed2, uint32 el3, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 422 // ---------------------------------------------------------------------------------------------------------------------------------- 619 620 // FAST && FEATURES && PARMERGE && !ARSP 621 622 // ----------------------------------------------------------------------------------------------------------------------------------------- 623 static void vuse3_Parallel_Features_Rosenfeld_Dist(uint32 ed1, uint32 ed2, uint32 el3, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 624 // ----------------------------------------------------------------------------------------------------------------------------------------- 423 625 { 424 626 bool ok1, ok2, ok3; … … 457 659 } while (!(ok1 && ok2 && ok3)); 458 660 } 459 #endif // FAST && FEATURES && PARMERGE 460 461 462 463 464 #if FAST && !FEATURES 465 // ------------------------------------------------------------------------------------------------------ 466 static void optimizedBorder_Rosenfeld_Dist(uint32 ** E, int i, int j, uint32 * T, uint32 ** D, int alpha) 467 // ------------------------------------------------------------------------------------------------------ 661 #endif // FAST && FEATURES && PARMERGE && !ARSP 662 663 664 665 #if FAST 666 // ------------------------------------------------------------------------------------------------------------------------ 667 static void optimizedBorder_Rosenfeld_Dist(uint32 ** E, int i, int j, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 668 // ------------------------------------------------------------------------------------------------------------------------ 468 669 { 469 670 uint32 a, b, c, x; … … 473 674 b = E[i - 1][j]; 474 675 if (b) { 475 vuse2_Rosenfeld _Dist(b, x, T, D, alpha); // dist, local676 vuse2_Rosenfeld(b, x, T, D, alpha, F); // dist, local 476 677 } 477 678 else { … … 480 681 a = E[i - 1][j - 1]; 481 682 if (a) { 482 vuse3_Rosenfeld _Dist(a, c, x, T, D, alpha); // dist, local683 vuse3_Rosenfeld(a, c, x, T, D, alpha, F); // dist, local 483 684 } 484 685 else { 485 vuse2_Rosenfeld _Dist(c, x, T, D, alpha); // dist, local686 vuse2_Rosenfeld(c, x, T, D, alpha, F); // dist, local 486 687 } 487 688 } … … 489 690 a = E[i - 1][j - 1]; 490 691 if (a) { 491 vuse2_Rosenfeld _Dist(a, x, T, D, alpha); // dist, local692 vuse2_Rosenfeld(a, x, T, D, alpha, F); // dist, local 492 693 } 493 694 } … … 495 696 } 496 697 } 497 #endif // FAST && !FEATURES 498 499 500 #if FAST && !FEATURES 501 // --------------------------------------------------------------------------------------------------- 502 static void optimizedBorderLeft_Rosenfeld_Dist(uint32 ** E, int i, int j, uint32 * T, uint32 ** D, int alpha) 503 // --------------------------------------------------------------------------------------------------- 698 699 // FAST 700 701 // ---------------------------------------------------------------------------------------------------------------------------- 702 static void optimizedBorderLeft_Rosenfeld_Dist(uint32 ** E, int i, int j, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 703 // ---------------------------------------------------------------------------------------------------------------------------- 504 704 { 505 705 uint32 x = E[i][j]; … … 507 707 uint32 b = E[i - 1][j]; 508 708 if (b) { 509 vuse2_Rosenfeld _Dist(b, x, T, D, alpha); // dist, local709 vuse2_Rosenfeld(b, x, T, D, alpha, F); // dist, local 510 710 } 511 711 else { 512 712 uint32 c = E[i - 1][j + 1]; 513 713 if (c) { 514 vuse2_Rosenfeld_Dist(c, x, T, D, alpha); // dist, local 515 } 516 } 517 } 518 } 519 #endif // FAST && !FEATURES 520 521 522 #if FAST && !FEATURES 523 // ----------------------------------------------------------------------------------------------------------- 524 static void optimizedBorderRight_Rosenfeld_Dist(uint32 ** E, int i, int j, uint32 * T, uint32 ** D, int alpha) 525 // ----------------------------------------------------------------------------------------------------------- 714 vuse2_Rosenfeld(c, x, T, D, alpha, F); // dist, local 715 } 716 } 717 } 718 } 719 720 // FAST 721 722 // ----------------------------------------------------------------------------------------------------------------------------- 723 static void optimizedBorderRight_Rosenfeld_Dist(uint32 ** E, int i, int j, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 724 // ----------------------------------------------------------------------------------------------------------------------------- 526 725 { 527 726 // copie de optimizedBorder_Rosenfeld … … 533 732 if (x) { 534 733 if (b) { 535 vuse2_Rosenfeld _Dist(b, x, T, D, alpha); // dist, local734 vuse2_Rosenfeld(b, x, T, D, alpha, F); // dist, local 536 735 } 537 736 else { 538 737 uint32 a = E[i - 1][j - 1]; 539 738 if (a) { 540 vuse2_Rosenfeld_Dist(a, x, T, D, alpha); // dist, local 541 } 542 } 543 } 544 } 545 #endif // FAST && !FEATURES 546 547 548 #if FAST && !FEATURES 549 // ------------------------------------------------------------------------------------------------------------------------ 550 static void borderMerging_Fast_Rosenfeld_Dist(uint8 **X, int i, int width, uint32 ** E, uint32 * T, uint32 ** D, int alpha) 551 // ------------------------------------------------------------------------------------------------------------------------ 739 vuse2_Rosenfeld(a, x, T, D, alpha, F); // dist, local 740 } 741 } 742 } 743 } 744 745 // FAST 746 747 // ------------------------------------------------------------------------------------------------------------------------------------------- 748 static void borderMerging_Fast_Rosenfeld_Dist(uint8 ** X, int i, int width, uint32 ** E, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 749 // ------------------------------------------------------------------------------------------------------------------------------------------- 552 750 { 553 751 // Prologue 554 optimizedBorderLeft_Rosenfeld_Dist(E, i, 0, T, D, alpha );752 optimizedBorderLeft_Rosenfeld_Dist(E, i, 0, T, D, alpha, F); 555 753 // Boucle principale 556 754 for (int j = 1; j < width - 1; j++) { 557 optimizedBorder_Rosenfeld_Dist(E, i, j, T, D, alpha );755 optimizedBorder_Rosenfeld_Dist(E, i, j, T, D, alpha, F); 558 756 } 559 757 // Epilogue 560 optimizedBorderRight_Rosenfeld_Dist(E, i, width - 1, T, D, alpha); 561 } 562 #endif // FAST && !FEATURES 563 564 565 #if SLOW && !FEATURES 566 // ------------------------------------------------------------------------------------------------------------------------- 567 static void borderMerging_Slow_Rosenfeld_Dist(uint8 ** X, int i, int width, uint32 ** E, uint32 * T, uint32 ** D, int alpha) 568 // ------------------------------------------------------------------------------------------------------------------------- 569 { 570 int j; 758 optimizedBorderRight_Rosenfeld_Dist(E, i, width - 1, T, D, alpha, F); 759 } 760 #endif // FAST 761 762 763 764 #if SLOW 765 // ------------------------------------------------------------------------------------------------------------------------------------------- 766 static void borderMerging_Slow_Rosenfeld_Dist(uint8 ** X, int i, int width, uint32 ** E, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 767 // ------------------------------------------------------------------------------------------------------------------------------------------- 768 { 769 int j = 0; 571 770 572 771 uint32 eps; … … 577 776 // -- prologue -- 578 777 // -------------- 579 MCA_VERBOSE2(printf("[%s] i = %d\n", __func__, i)); 580 581 j = 0; 778 MCA_VERBOSE3(printf("[%s] i = %d\n", __func__, i)); 779 582 780 ex = E[i][j]; 583 781 584 782 if (ex) { 585 783 586 MCA_VERBOSE2(printf("[%s] j = %d\n", __func__, j)); 587 588 e2 = E[i - 1][j]; 589 e3 = E[i - 1][j + 1]; 590 591 // test pour eviter acces distant 592 r2 = e2 ? FindRoot_Dist(D, e2, alpha) : 0; 593 r3 = e3 ? FindRoot_Dist(D, e3, alpha) : 0; 594 595 rx = T[ex]; 596 rx = FindRoot_Dist(D, rx, alpha); 597 598 MCA_VERBOSE2(printf("\n")); 599 MCA_VERBOSE2(printf("e2 = %4d -> %4d\n", e2, r2)); 600 MCA_VERBOSE2(printf("e3 = %4d -> %4d\n", e3, r3)); 601 MCA_VERBOSE2(printf("ex = %4d -> %4d\n", ex, rx)); 602 603 eps = ui32MinNonNul3(r2, r3, rx); 604 605 // Quick-Union 606 if (r2 > eps) { 607 SetRoot_Rosenfeld_Dist(D, r2, eps, alpha); 608 MCA_VERBOSE2(printf("D[%4d] <- %d\n", r2, eps)); 609 } 610 if (r3 > eps) { 611 SetRoot_Rosenfeld_Dist(D, r3, eps, alpha); 612 MCA_VERBOSE2(printf("D[%4d] <- %d\n", r3, eps)); 613 } 614 if (rx > eps) { 615 SetRoot_Rosenfeld_Dist(D, rx, eps, alpha); 616 MCA_VERBOSE2(printf("D[%4d] <- %d\n", rx, eps)); 617 } 618 MCA_VERBOSE2(printf("\n")); 619 } 620 621 // ----------------------- 622 // -- boucle principale -- 623 // ----------------------- 624 625 for (j = 0 + 1; j < width - 1; j++) { 626 627 ex = E[i][j]; 628 629 // que le cas general (pour faire un code simple) 630 if (ex) { 631 MCA_VERBOSE2(printf("[%s] j = %d\n", __func__, j)); 632 633 e1 = E[i - 1][j - 1]; 634 e2 = E[i - 1][j]; 635 e3 = E[i - 1][j + 1]; 636 637 // test pour eviter acces distant 638 r1 = e1 ? FindRoot_Dist(D, e1, alpha) : 0; 639 r2 = e2 ? FindRoot_Dist(D, e2, alpha) : 0; 640 r3 = e3 ? FindRoot_Dist(D, e3, alpha) : 0; 641 642 rx = T[ex]; 643 rx = FindRoot_Dist(D, rx, alpha); 644 645 MCA_VERBOSE2(printf("\n")); 646 MCA_VERBOSE2(printf("e1 = %4d -> %4d\n", e1, r1)); 647 MCA_VERBOSE2(printf("e2 = %4d -> %4d\n", e2, r2)); 648 MCA_VERBOSE2(printf("e3 = %4d -> %4d\n", e3, r3)); 649 MCA_VERBOSE2(printf("ex = %4d -> %4d\n", ex, rx)); 650 651 eps = ui32MinNonNul4(r1, r2, r3, rx); 652 653 // Quick-Union 654 if (r1 > eps) { 655 SetRoot_Rosenfeld_Dist(D, r1, eps, alpha); 656 MCA_VERBOSE2(printf("D[%4d] <- %d\n", r1, eps)); 657 } 658 if (r2 > eps) { 659 SetRoot_Rosenfeld_Dist(D, r2, eps, alpha); 660 MCA_VERBOSE2(printf("D[%4d] <- %d\n", r2, eps)); 661 } 662 if (r3 > eps) { 663 SetRoot_Rosenfeld_Dist(D, r3, eps, alpha); 664 MCA_VERBOSE2(printf("D[%4d] <- %d\n", r3, eps)); 665 } 666 if (rx > eps) { 667 SetRoot_Rosenfeld_Dist(D, rx, eps, alpha); 668 MCA_VERBOSE2(printf("D[%4d] <- %d\n", rx, eps)); 669 } 670 MCA_VERBOSE2(printf("\n")); 671 // attention SetRoot fait un while inutile 672 } 673 } 674 675 // -------------- 676 // -- epilogue -- 677 // -------------- 678 679 j = width - 1; 680 ex = E[i][j]; 681 682 if (ex) { 683 684 MCA_VERBOSE2(printf("[%s] j = %d\n", __func__, j)); 685 686 e1 = E[i - 1][j - 1]; 687 e2 = E[i - 1][j]; 688 689 // test pour eviter acces distant 690 r1 = e1 ? FindRoot_Dist(D, e1, alpha) : 0; 691 r2 = e2 ? FindRoot_Dist(D, e2, alpha) : 0; 692 693 rx = T[ex]; 694 rx = FindRoot_Dist(D, rx, alpha); 695 696 MCA_VERBOSE2(printf("\n")); 697 MCA_VERBOSE2(printf("e1 = %4d -> %4d\n", e1, r1)); 698 MCA_VERBOSE2(printf("e2 = %4d -> %4d\n", e2, r2)); 699 MCA_VERBOSE2(printf("ex = %4d -> %4d\n", ex, rx)); 700 701 eps = ui32MinNonNul3(r1, r2, rx); 702 703 // Quick-Union 704 if (r1 > eps) { 705 SetRoot_Rosenfeld_Dist(D, r1, eps, alpha); 706 MCA_VERBOSE2(printf("D[%4d] <- %d\n", r1, eps)); 707 } 708 if (r2 > eps) { 709 SetRoot_Rosenfeld_Dist(D, r2, eps, alpha); 710 MCA_VERBOSE2(printf("D[%4d] <- %d\n", r2, eps)); 711 } 712 if (rx > eps) { 713 SetRoot_Rosenfeld_Dist(D, rx, eps, alpha); 714 MCA_VERBOSE2(printf("D[%4d] <- %d\n", rx, eps)); 715 } 716 MCA_VERBOSE2(printf("\n")); 717 } 718 return; 719 } 720 #endif // SLOW && !FEATURES 721 722 723 #if SLOW && FEATURES 724 // ---------------------------------------------------------------------------------------------------------------------------------------------------- 725 static void borderMerging_Slow_Features_Rosenfeld_Dist(uint8 ** X, int i, int width, uint32 ** E, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 726 // ---------------------------------------------------------------------------------------------------------------------------------------------------- 727 { 728 int j = 0; 729 730 uint32 eps; 731 732 uint32 e1, e2, e3, ex; 733 uint32 r1, r2, r3, rx; 734 735 // -------------- 736 // -- prologue -- 737 // -------------- 738 MCA_VERBOSE2(printf("[%s] i = %d\n", __func__, i)); 739 740 ex = E[i][j]; 741 742 if (ex) { 743 744 MCA_VERBOSE2(printf("[%s] j = %d\n", __func__, j)); 784 MCA_VERBOSE3(printf("[%s] j = %d\n", __func__, j)); 745 785 746 786 e2 = E[i - 1][j]; … … 758 798 eps = ui32MinNonNul3(r2, r3, rx); 759 799 760 MCA_VERBOSE 2(printf("\n"));761 MCA_VERBOSE 2(printf("e2 = %5d -> r2 = %5d\n", e2, r2));762 MCA_VERBOSE 2(printf("e3 = %5d -> r3 = %5d\n", e3, r3));763 MCA_VERBOSE 2(printf("ex = %5d -> rx = %5d\n", ex, rx));764 MCA_VERBOSE 2(printf("eps = %5d\n", eps));800 MCA_VERBOSE3(printf("\n")); 801 MCA_VERBOSE3(printf("e2 = %5d -> r2 = %5d\n", e2, r2)); 802 MCA_VERBOSE3(printf("e3 = %5d -> r3 = %5d\n", e3, r3)); 803 MCA_VERBOSE3(printf("ex = %5d -> rx = %5d\n", ex, rx)); 804 MCA_VERBOSE3(printf("eps = %5d\n", eps)); 765 805 766 806 // Quick-Union 767 // @QM768 807 if (r2 > eps) { 769 SetRoot_Features_Rosenfeld_Dist(D, r2, eps, alpha, F); 770 MCA_VERBOSE2(printf("D[%5d] <- %d\n", r2, eps)); 771 } 772 if (r3 > 0) { 773 r3 = FindRoot_Dist(D, r3, alpha); 808 SetRoot_Rosenfeld(D, r2, eps, alpha, F); 809 MCA_VERBOSE3(printf("D[%5d] <- %d\n", r2, eps)); 774 810 } 775 811 // Pour le cas où r2 == r3, il ne faut pas ajouter deux fois les features 776 //if (r3 > eps && r3 != r2) { 777 if (r3 > eps) { 778 SetRoot_Features_Rosenfeld_Dist(D, r3, eps, alpha, F); 779 MCA_VERBOSE2(printf("D[%5d] <- %d\n", r3, eps)); 780 } 781 rx = FindRoot_Dist(D, rx, alpha); 782 //if (rx > eps && rx != r3 && rx != r2) { 783 if (rx > eps) { 784 SetRoot_Features_Rosenfeld_Dist(D, rx, eps, alpha, F); 785 MCA_VERBOSE2(printf("D[%5d] <- %d\n", rx, eps)); 786 } 787 MCA_VERBOSE2(printf("---------------------------\n")); 812 //if (r3 > 0) { 813 // r3 = FindRoot_Dist(D, r3, alpha); 814 //} 815 //if (r3 > eps) { 816 if (r3 > eps && r3 != r2) { 817 SetRoot_Rosenfeld(D, r3, eps, alpha, F); 818 MCA_VERBOSE3(printf("D[%5d] <- %d\n", r3, eps)); 819 } 820 //rx = FindRoot_Dist(D, rx, alpha); 821 //if (rx > eps) { 822 if (rx > eps && rx != r3 && rx != r2) { 823 SetRoot_Rosenfeld(D, rx, eps, alpha, F); 824 MCA_VERBOSE3(printf("D[%5d] <- %d\n", rx, eps)); 825 } 826 MCA_VERBOSE3(printf("---------------------------\n")); 788 827 } 789 828 } … … 799 838 if (ex) { 800 839 801 MCA_VERBOSE 2(printf("[%s] j = %d\n", __func__, j));840 MCA_VERBOSE3(printf("[%s] j = %d\n", __func__, j)); 802 841 803 842 e1 = E[i - 1][j - 1]; … … 816 855 eps = ui32MinNonNul4(r1, r2, r3, rx); 817 856 818 MCA_VERBOSE2(printf("\n")); 819 MCA_VERBOSE2(printf("e1 = %5d -> r1 = %5d\n", e1, r1)); 820 MCA_VERBOSE2(printf("e2 = %5d -> r2 = %5d\n", e2, r2)); 821 MCA_VERBOSE2(printf("e3 = %5d -> r3 = %5d\n", e3, r3)); 822 MCA_VERBOSE2(printf("ex = %5d -> rx = %5d\n", ex, rx)); 823 MCA_VERBOSE2(printf("eps = %5d\n", eps)); 857 MCA_VERBOSE3(printf("\n")); 858 MCA_VERBOSE3(printf("e1 = %5d -> r1 = %5d\n", e1, r1)); 859 MCA_VERBOSE3(printf("e2 = %5d -> r2 = %5d\n", e2, r2)); 860 MCA_VERBOSE3(printf("e3 = %5d -> r3 = %5d\n", e3, r3)); 861 MCA_VERBOSE3(printf("ex = %5d -> rx = %5d\n", ex, rx)); 862 MCA_VERBOSE3(printf("eps = %5d\n", eps)); 863 824 864 825 865 // Quick-Union 826 // @QM827 866 if (r1 > eps) { 828 SetRoot_ Features_Rosenfeld_Dist(D, r1, eps, alpha, F);829 MCA_VERBOSE 2(printf("D[%5d] <- %d\n", r1, eps));867 SetRoot_Rosenfeld(D, r1, eps, alpha, F); 868 MCA_VERBOSE3(printf("D[%5d] <- %d\n", r1, eps)); 830 869 } 831 if (r2 > 0) { 832 r2 = FindRoot_Dist(D, r2, alpha); 870 //if (r2 > 0) { 871 // r2 = FindRoot_Dist(D, r2, alpha); 872 //} 873 if (r2 > eps && r2 != r1) { 874 //if (r2 > eps) { 875 SetRoot_Rosenfeld(D, r2, eps, alpha, F); 876 MCA_VERBOSE3(printf("D[%5d] <- %d\n", r2, eps)); 833 877 } 834 //if (r2 > eps && r2 != r1) { 835 if (r2 > eps) { 836 SetRoot_Features_Rosenfeld_Dist(D, r2, eps, alpha, F); 837 MCA_VERBOSE2(printf("D[%5d] <- %d\n", r2, eps)); 878 //if (r3 > 0) { 879 // r3 = FindRoot_Dist(D, r3, alpha); 880 //} 881 if (r3 > eps && r3 != r2 && r3 != r1) { 882 //if (r3 > eps) { 883 SetRoot_Rosenfeld(D, r3, eps, alpha, F); 884 MCA_VERBOSE3(printf("D[%5d] <- %d\n", r3, eps)); 838 885 } 839 if (r3 > 0) { 840 r3 = FindRoot_Dist(D, r3, alpha); 886 //rx = FindRoot_Dist(D, rx, alpha); 887 if (rx > eps && rx != r3 && rx != r2 && rx != r1) { 888 //if (rx > eps) { 889 SetRoot_Rosenfeld(D, rx, eps, alpha, F); 890 MCA_VERBOSE3(printf("D[%5d] <- %d\n", rx, eps)); 841 891 } 842 //if (r3 > eps && r3 != r2 && r3 != r1) { 843 if (r3 > eps) { 844 SetRoot_Features_Rosenfeld_Dist(D, r3, eps, alpha, F); 845 MCA_VERBOSE2(printf("D[%5d] <- %d\n", r3, eps)); 846 } 847 rx = FindRoot_Dist(D, rx, alpha); 848 //if (rx > eps && rx != r3 && rx != r2 && rx != r1) { 849 if (rx > eps) { 850 SetRoot_Features_Rosenfeld_Dist(D, rx, eps, alpha, F); 851 MCA_VERBOSE2(printf("D[%5d] <- %d\n", rx, eps)); 852 } 853 MCA_VERBOSE2(puts("---------------------------\n")); 854 855 // attention SetRoot fait un while inutile 892 MCA_VERBOSE3(puts("---------------------------\n")); 856 893 } 857 894 } … … 867 904 if (ex) { 868 905 869 MCA_VERBOSE 2(printf("[%s] j = %d\n", __func__, j));906 MCA_VERBOSE3(printf("[%s] j = %d\n", __func__, j)); 870 907 871 908 e1 = E[i - 1][j - 1]; … … 883 920 eps = ui32MinNonNul3(r1, r2, rx); 884 921 885 MCA_VERBOSE 2(printf("\n"));886 MCA_VERBOSE 2(printf("e1 = %5d -> r1 = %5d\n", e1, r1));887 MCA_VERBOSE 2(printf("e2 = %5d -> r2 = %5d\n", e2, r2));888 MCA_VERBOSE 2(printf("ex = %5d -> rx = %5d\n", ex, rx));889 MCA_VERBOSE 2(printf("eps = %5d\n", eps));922 MCA_VERBOSE3(printf("\n")); 923 MCA_VERBOSE3(printf("e1 = %5d -> r1 = %5d\n", e1, r1)); 924 MCA_VERBOSE3(printf("e2 = %5d -> r2 = %5d\n", e2, r2)); 925 MCA_VERBOSE3(printf("ex = %5d -> rx = %5d\n", ex, rx)); 926 MCA_VERBOSE3(printf("eps = %5d\n", eps)); 890 927 891 928 // Quick-Union 892 929 if (r1 > eps) { 893 SetRoot_Features_Rosenfeld_Dist(D, r1, eps, alpha, F); 894 MCA_VERBOSE2(printf("D[%5d] <- %d\n", r1, eps)); 895 } 896 if (r2 > 0) { 897 r2 = FindRoot_Dist(D, r2, alpha); 898 } 899 //if (r2 > eps && r2 != r1) { 900 if (r2 > eps) { 901 SetRoot_Features_Rosenfeld_Dist(D, r2, eps, alpha, F); 902 MCA_VERBOSE2(printf("D[%5d] <- %d\n", r2, eps)); 903 } 904 rx = FindRoot_Dist(D, rx, alpha); 905 //if (rx > eps && rx != r2 && rx != r1) { 906 if (rx > eps) { 907 SetRoot_Features_Rosenfeld_Dist(D, rx, eps, alpha, F); 908 MCA_VERBOSE2(printf("D[%5d] <- %d\n", rx, eps)); 909 } 910 MCA_VERBOSE2(printf("---------------------------\n")); 911 } 912 } 913 return; 914 } 915 #endif // SLOW && FEATURES 916 917 918 #if FAST && FEATURES && !PARMERGE 919 // -------------------------------------------------------------------------------------------------------------------------- 920 void optimizedBorder_Features_Rosenfeld_Dist(uint32 ** E, int i, int j, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 921 // -------------------------------------------------------------------------------------------------------------------------- 922 { 923 // copie de optimizedBorder_Rosenfeld 924 uint32 a, b, c, x; 925 926 x = E[i][j]; 927 928 if (x) { 929 b = E[i - 1][j]; 930 if (b) { 931 vuse2_Features_Rosenfeld_Dist(b, x, T, D, alpha, F); // dist, local 932 } 933 else { 934 c = E[i - 1][j + 1]; 935 if (c) { 936 a = E[i - 1][j - 1]; 937 if (a) { 938 vuse3_Features_Rosenfeld_Dist(a, c, x, T, D, alpha, F); // dist, local 939 } 940 else { 941 vuse2_Features_Rosenfeld_Dist(c, x, T, D, alpha, F); // dist, local 942 } 943 } 944 else { 945 a = E[i - 1][j - 1]; 946 if (a) { 947 vuse2_Features_Rosenfeld_Dist(a, x, T, D, alpha, F); // dist, local 948 } 949 } 950 } 951 } 952 } 953 #endif // FAST && FEATURES && !PARMERGE 954 955 956 #if FAST && FEATURES && !PARMERGE 957 // ------------------------------------------------------------------------------------------------------------------------------ 958 void optimizedBorderLeft_Features_Rosenfeld_Dist(uint32 ** E, int i, int j, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 959 // ------------------------------------------------------------------------------------------------------------------------------ 960 { 961 uint32 x = E[i][j]; 962 963 if (x) { 964 uint32 b = E[i - 1][j]; 965 if (b) { 966 vuse2_Features_Rosenfeld_Dist(b, x, T, D, alpha, F); // dist, local 967 } 968 else { 969 uint32 c = E[i - 1][j + 1]; 970 if (c) { 971 vuse2_Features_Rosenfeld_Dist(c, x, T, D, alpha, F); // dist, local 972 } 973 } 974 } 975 } 976 #endif // FAST && FEATURES && !PARMERGE 977 978 979 #if FAST && FEATURES && !PARMERGE 980 // ------------------------------------------------------------------------------------------------------------------------------- 981 void optimizedBorderRight_Features_Rosenfeld_Dist(uint32 ** E, int i, int j, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 982 // ------------------------------------------------------------------------------------------------------------------------------- 983 { 984 // copie de optimizedBorder_Rosenfeld 985 // test d'existance de ex en local local 986 987 uint32 x = E[i][j]; 988 989 if (x) { 990 uint32 b = E[i - 1][j]; 991 if (b) { 992 vuse2_Features_Rosenfeld_Dist(b, x, T, D, alpha, F); // dist, local 993 } 994 else { 995 uint32 a = E[i - 1][j - 1]; 996 if (a) { 997 vuse2_Features_Rosenfeld_Dist(a, x, T, D, alpha, F); // dist, local 998 } 999 } 1000 } 1001 } 1002 #endif // FAST && FEATURES && !PARMERGE 1003 1004 1005 #if FAST && FEATURES && PARMERGE 1006 // ----------------------------------------------------------------------------------------------------------------------------------- 1007 void optimizedBorder_Parallel_Features_Rosenfeld_Dist(uint32 ** E, int i, int j, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 1008 // ----------------------------------------------------------------------------------------------------------------------------------- 1009 { 1010 // copie de optimizedBorder_Rosenfeld 1011 uint32 a, b, c, x; 1012 1013 x = E[i][j]; 1014 1015 if (x) { 1016 b = E[i - 1][j]; 1017 if (b) { 1018 vuse2_Parallel_Features_Rosenfeld_Dist(b, x, T, D, alpha, F); // dist, local 1019 } 1020 else { 1021 c = E[i - 1][j + 1]; 1022 if (c) { 1023 a = E[i - 1][j - 1]; 1024 if (a) { 1025 vuse3_Parallel_Features_Rosenfeld_Dist(a, c, x, T, D, alpha, F); // dist, local 1026 } 1027 else { 1028 vuse2_Parallel_Features_Rosenfeld_Dist(c, x, T, D, alpha, F); // dist, local 1029 } 1030 } 1031 else { 1032 a = E[i - 1][j - 1]; 1033 if (a) { 1034 vuse2_Parallel_Features_Rosenfeld_Dist(a, x, T, D, alpha, F); // dist, local 1035 } 1036 } 1037 } 1038 } 1039 } 1040 #endif // FAST && FEATURES && PARMERGE 1041 1042 1043 #if FAST && FEATURES && PARMERGE 1044 // --------------------------------------------------------------------------------------------------------------------------------------- 1045 void optimizedBorderLeft_Parallel_Features_Rosenfeld_Dist(uint32 ** E, int i, int j, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 1046 // --------------------------------------------------------------------------------------------------------------------------------------- 1047 { 1048 uint32 x = E[i][j]; 1049 1050 if (x) { 1051 uint32 b = E[i - 1][j]; 1052 if (b) { 1053 vuse2_Parallel_Features_Rosenfeld_Dist(b, x, T, D, alpha, F); // dist, local 1054 } 1055 else { 1056 uint32 c = E[i - 1][j + 1]; 1057 if (c) { 1058 vuse2_Parallel_Features_Rosenfeld_Dist(c, x, T, D, alpha, F); // dist, local 1059 } 1060 } 1061 } 1062 } 1063 #endif // FAST && FEATURES && PARMERGE 1064 1065 1066 #if FAST && FEATURES && PARMERGE 1067 // ---------------------------------------------------------------------------------------------------------------------------------------- 1068 void optimizedBorderRight_Parallel_Features_Rosenfeld_Dist(uint32 ** E, int i, int j, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 1069 // ---------------------------------------------------------------------------------------------------------------------------------------- 1070 { 1071 // copie de optimizedBorder_Rosenfeld 1072 // test d'existance de ex en local local 1073 1074 uint32 x = E[i][j]; 1075 1076 if (x) { 1077 uint32 b = E[i - 1][j]; 1078 if (b) { 1079 vuse2_Parallel_Features_Rosenfeld_Dist(b, x, T, D, alpha, F); // dist, local 1080 } 1081 else { 1082 uint32 a = E[i - 1][j - 1]; 1083 if (a) { 1084 vuse2_Parallel_Features_Rosenfeld_Dist(a, x, T, D, alpha, F); // dist, local 1085 } 1086 } 1087 } 1088 } 1089 #endif // FAST && FEATURES && PARMERGE 1090 1091 1092 #if FAST && FEATURES 1093 // --------------------------------------------------------------------------------------------------------------------------------------------- 1094 void borderMerging_Fast_Features_Rosenfeld_Dist(uint8 ** X, int i, int width, uint32 ** E, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 1095 // --------------------------------------------------------------------------------------------------------------------------------------------- 1096 { 1097 MCA_VERBOSE2(printf("[%s]", __func__)); 1098 1099 #if PARMERGE 1100 optimizedBorderLeft_Parallel_Features_Rosenfeld_Dist(E, i, 0, T, D, alpha, F); 1101 #else 1102 optimizedBorderLeft_Features_Rosenfeld_Dist(E, i, 0, T, D, alpha, F); 1103 #endif 1104 1105 for (int j = 1; j < width - 1; j++) { 1106 #if PARMERGE 1107 optimizedBorder_Parallel_Features_Rosenfeld_Dist(E, i, j, T, D, alpha, F); 1108 #else 1109 optimizedBorder_Features_Rosenfeld_Dist(E, i, j, T, D, alpha, F); 1110 #endif 1111 } 1112 1113 #if PARMERGE 1114 optimizedBorderRight_Parallel_Features_Rosenfeld_Dist(E, i, width - 1, T, D, alpha, F); 1115 #else 1116 optimizedBorderRight_Features_Rosenfeld_Dist(E, i, width - 1, T, D, alpha, F); 1117 #endif 1118 } 1119 #endif // FAST && FEATURES 1120 1121 1122 #if !FEATURES 1123 // -------------------------------------------------------------------------------------------------------------------- 1124 static void borderMerging_Rosenfeld_Dist(uint8 ** X, int i, int width, uint32 ** E, uint32 * T, uint32 ** D, int alpha) 1125 // -------------------------------------------------------------------------------------------------------------------- 1126 { 930 SetRoot_Rosenfeld(D, r1, eps, alpha, F); 931 MCA_VERBOSE3(printf("D[%5d] <- %d\n", r1, eps)); 932 } 933 //if (r2 > 0) { 934 // r2 = FindRoot_Dist(D, r2, alpha); 935 //} 936 if (r2 > eps && r2 != r1) { 937 //if (r2 > eps) { 938 SetRoot_Rosenfeld(D, r2, eps, alpha, F); 939 MCA_VERBOSE3(printf("D[%5d] <- %d\n", r2, eps)); 940 } 941 //rx = FindRoot_Dist(D, rx, alpha); 942 if (rx > eps && rx != r2 && rx != r1) { 943 //if (rx > eps) { 944 SetRoot_Rosenfeld(D, rx, eps, alpha, F); 945 MCA_VERBOSE3(printf("D[%5d] <- %d\n", rx, eps)); 946 } 947 MCA_VERBOSE3(printf("---------------------------\n")); 948 } 949 } 950 } 951 #endif // SLOW 952 953 954 955 // -------------------------------------------------------------------------------------------------------------------------------------- 956 static void borderMerging_Rosenfeld_Dist(uint8 ** X, int i, int width, uint32 ** E, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 957 // -------------------------------------------------------------------------------------------------------------------------------------- 958 { 959 #if FAST 960 borderMerging_Fast_Rosenfeld_Dist(X, i, width, E, T, D, alpha, F); 961 #endif // FAST 1127 962 #if SLOW 1128 borderMerging_Slow_Rosenfeld_Dist(X, i, width, E, T, D, alpha); 1129 #elif FAST 1130 borderMerging_Fast_Rosenfeld_Dist(X, i, width, E, T, D, alpha); 1131 #else 1132 #error "Please define SLOW or FAST for the Rosenfeld version" 1133 #endif 1134 } 1135 #endif // !FEATURES 1136 1137 1138 #if FEATURES 1139 // ----------------------------------------------------------------------------------------------------------------------------------------------- 1140 static void borderMerging_Features_Rosenfeld_Dist(uint8 ** X, int i, int width, uint32 ** E, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 1141 // ----------------------------------------------------------------------------------------------------------------------------------------------- 1142 { 1143 #if SLOW 1144 borderMerging_Slow_Features_Rosenfeld_Dist(X, i, width, E, T, D, alpha, F); 1145 #elif FAST 1146 borderMerging_Fast_Features_Rosenfeld_Dist(X, i, width, E, T, D, alpha, F); 1147 #else 1148 #error "Please define SLOW or FAST for the Rosenfeld version" 1149 #endif 1150 } 1151 #endif // FEATURES 963 borderMerging_Slow_Rosenfeld_Dist(X, i, width, E, T, D, alpha, F); 964 #endif // SLOW 965 } 1152 966 1153 967 … … 1383 1197 return ne; 1384 1198 } 1385 #endif // FAST 1386 1387 1388 #if FAST 1199 1200 // FAST 1201 1389 1202 // ---------------------------------------------------------------------------------------------- 1390 1203 static uint32 optimizedAccessRight_DT_Rosenfeld(uint32 ** E, int i, int j, uint32 * T, uint32 ne) … … 1416 1229 return ne; 1417 1230 } 1418 #endif // FAST 1419 1420 1421 #if FAST 1231 1232 // FAST 1233 1422 1234 // ----------------------------------------------------------------------------------------- 1423 1235 static uint32 optimizedAccess_DT_Rosenfeld(uint32 ** E, int i, int j, uint32 * T, uint32 ne) … … 1467 1279 return ne; 1468 1280 } 1469 #endif // FAST 1470 1471 1472 1473 #if FAST 1281 1282 // FAST 1283 1474 1284 // -------------------------------------------------------------------------------------------------------- 1475 1285 static uint32 lineLabeling_Fast_Rosenfeld(uint8 ** X, int i, int width, uint32 ** E, uint32 * T, uint32 ne) … … 1517 1327 #elif FAST 1518 1328 return lineLabeling_Fast_Rosenfeld(X, i, width, E, T, ne); 1519 #else1520 #error "Please define SLOW or FAST for the Rosenfeld version"1521 1329 #endif 1522 1330 } … … 1539 1347 1540 1348 1541 #if !FEATURES 1542 // --------------------------------------------------------------------- 1543 static void solveTable_Range_Rosenfeld(uint32 * T, uint32 e0, uint32 e1) 1544 // --------------------------------------------------------------------- 1545 { 1546 uint32 e, r; 1547 1548 for (e = e0; e <= e1; e++) { 1549 r = T[T[e]]; 1550 if (r < e) { 1551 T[e] = r; // racine de la classe d'equivalence 1552 } 1553 } 1554 } 1555 #endif // !FEATURES 1556 1557 1558 #if FEATURES 1559 // ---------------------------------------------------------------------------------------------------------- 1560 static void solveTable_solveFeatures_Range_Rosenfeld(uint32 * T, uint32 e0, uint32 e1, RegionStats * Stats) 1561 // ---------------------------------------------------------------------------------------------------------- 1349 // ------------------------------------------------------------------------------------------ 1350 static void solveTable_Range_Rosenfeld(uint32 * T, uint32 e0, uint32 e1, RegionStats * Stats) 1351 // ------------------------------------------------------------------------------------------ 1562 1352 { 1563 1353 uint32 e, r; … … 1568 1358 if (r < e) { 1569 1359 T[e] = r; // racine de la classe d'equivalence 1360 #if FEATURES 1570 1361 RegionStats_Accumulate_Stats1_From_Index(Stats, r, e); 1571 } 1572 } 1573 } 1574 #endif // FEATURES 1575 1576 1577 #if !FEATURES 1578 // ------------------------------------- 1579 void MCA_Label_Rosenfeld_PAR1(MCA * mca) 1580 // ------------------------------------- 1362 #endif 1363 } 1364 } 1365 } 1366 1367 1368 // -------------------------------------------- 1369 static void MCA_Label_Rosenfeld_PAR1(MCA * mca) 1370 // -------------------------------------------- 1581 1371 { 1582 1372 if (mca->p == 0) { 1583 printf("*** %s ***\n", __func__); 1584 } 1585 1586 CLOCK_THREAD_START_STEP(mca->p, 0); 1373 MCA_VERBOSE2(printf("*** %s ***\n", __func__)); 1374 } 1375 1587 1376 1588 1377 int i0 = mca->i0; 1589 1378 int i1 = mca->i1; 1590 int width = mca->width; 1379 int width = mca->width; 1380 1591 1381 uint32 e0 = mca->e0; 1592 1382 uint32 e1 = mca->e1; … … 1598 1388 uint32 ** E = mca->E; 1599 1389 uint32 * T = mca->T; 1600 1390 RegionStats * stats = mca->stats; 1391 1392 // reset sous optimal (pour le moment = voir region32) 1601 1393 if (mca->p == 0) { 1602 1394 set_ui32vector_j(T, e0 - 1, e1); // car e0 = 1, on a besoin que T[0] = 0 pour FindRoot 1395 #if FEATURES 1396 zero_RegionStatsVector(stats, e0 - 1, e1); 1397 #endif 1603 1398 } 1604 1399 else { 1605 1400 set_ui32vector_j(T, e0, e1); 1606 } 1607 1608 MCA_VERBOSE2(display_ui8matrix_positive(X, i0, i1, 0, width - 1, 5, "Xp"); printf("\n")); 1401 #if FEATURES 1402 zero_RegionStatsVector(stats, e0, e1); 1403 #endif 1404 } 1405 1406 if (mca->p == 0) { 1407 MCA_VERBOSE3(display_ui8matrix_positive(X, i0, i1, 0, width - 1, 5, "Xp"); printf("\n")); 1408 } 1409 1410 // ---------------------------- // 1411 // -- Etiquetage d'une bande -- // 1412 // ---------------------------- // 1413 1414 CLOCK_THREAD_START_STEP(mca->p, 0); 1609 1415 1610 1416 ne = line0Labeling_Rosenfeld(X, i0, width, E, T, ne); 1417 #if FEATURES 1418 lineFeaturesComputation(E, i0, width, stats); 1419 #endif 1420 1611 1421 for (int i = i0 + 1; i <= i1; i++) { 1612 ne = lineLabeling_Rosenfeld(X, i, width, E, T, ne); 1613 } 1614 1615 MCA_VERBOSE2(display_ui32matrix_positive(E, i0, i1, 0, width - 1, 5, "Ep"); printf("\n")); 1422 ne = lineLabeling_Rosenfeld(X, i, width, E, T, ne); // Slow or Fast 1423 #if FEATURES 1424 lineFeaturesComputation(E, i, width, stats); 1425 #endif 1426 } 1427 mca->ne = ne; //plus grande etiquette de l'intervalle [e0..e1] 1428 1616 1429 if (mca->p == 0) { 1617 MCA_VERBOSE2(display_ui32vector_number(T, e0, ne, "%5d", "Tp_avant")); 1618 } 1619 1620 // fermeture transitive sans pack 1621 solveTable_Range_Rosenfeld(T, e0, ne); 1622 mca->ne = ne; // Plus grande etiquette de l'intervalle [e0..e1] 1623 1624 MCA_VERBOSE2(nr = countTable_Range_Rosenfeld(T, e0, ne)); 1625 MCA_VERBOSE2(printf("p = %d : e = [%d..%d] -> ne = %d -> nr = %d\n", mca->p, e0, ne, (ne - e0 + 1), nr)); 1430 MCA_VERBOSE3(printf("ne = %d\n", ne)); 1431 MCA_VERBOSE3(display_ui32matrix_positive(E, i0, i1, 0, width - 1, 5, "Ep"); printf("\n")); 1432 MCA_VERBOSE3(display_ui32vector_number(T, e0, ne, "%5d", "Tp_avant")); 1433 } 1434 1435 // ------------------------------------------------------ // 1436 // -- Fermeture transitive sans pack de chaque table T -- // 1437 // ------------------------------------------------------ // 1438 1439 solveTable_Range_Rosenfeld(T, e0, ne, stats); 1440 1626 1441 if (mca->p == 0) { 1627 MCA_VERBOSE2(display_ui32vector_number(T, e0, ne, "%5d", "Tp_apres")); 1628 } 1629 1442 MCA_VERBOSE3(nr = countTable_Range_Rosenfeld(T, e0, ne); 1443 printf("p = %d : e = [%d..%d] -> ne = %d -> nr = %d\n", mca->p, e0, ne, (ne - e0 + 1), nr)); 1444 MCA_VERBOSE3(display_ui32vector_number(T, e0, ne, "%5d", "Tp_apres")); 1445 } 1630 1446 CLOCK_THREAD_END_STEP(mca->p, 0); 1631 1447 } 1632 #endif // !FEATURES 1633 1634 1635 #if !FEATURES 1636 // ------------------------------------- 1637 void MCA_Label_Rosenfeld_PYR2(MCA * mca) 1638 // ------------------------------------- 1639 { 1640 // input 1448 1449 1450 1451 #if PARMERGE 1452 // ----------------------------------------------------- 1453 static void MCA_Label_Rosenfeld_PAR2(MCA * mca) 1454 // ----------------------------------------------------- 1455 { 1641 1456 int p = mca->p; 1642 1457 int nb_level = mca->nb_level; 1643 1458 1644 1459 if (mca->p == 0) { 1645 printf("*** %s ***\n", __func__);1460 MCA_VERBOSE2(printf("*** %s ***\n", __func__)); 1646 1461 } 1647 1462 1648 1463 // ------------------------------ 1649 // -- p yramidal border merging --1464 // -- parallel border merging -- 1650 1465 // ------------------------------ 1651 1466 … … 1662 1477 uint32 * T = mca->T; 1663 1478 uint32 ** D = mca->D; 1664 1665 CLOCK_THREAD_START_STEP(p, 1);1666 #if PYR_BARRIERS1667 // Version optimisée qui fait faire un break aux processeurs qui n'ont plus1668 // à faire de merge.1669 // Implique de pré-calculer le nombre de threads à chaque barriÚre1670 if (p != 0) { // thread 0 never has any merge to do1671 int been_active = 0;1672 for (int level = 0; level < nb_level; level++) {1673 if ((p + (1 << level)) % (1 << (level + 1)) == 0) {1674 borderMerging_Rosenfeld_Dist(X, i, width, E, T, D, alpha); // en (i) et (i-1)1675 been_active = 1;1676 }1677 else if (been_active) {1678 break;1679 }1680 pthread_barrier_wait(&mca->barriers[level]);1681 }1682 }1683 pthread_barrier_wait(&main_barrier);1684 #else1685 for (int level = 1; level <= nb_level; level++) {1686 if ((p + (1 << (level - 1))) % (1 << level) == 0) {1687 // thread actif1688 borderMerging_Rosenfeld_Dist(X, i, width, E, T, D, alpha); // en (i) et (i-1)1689 }1690 pthread_barrier_wait(&main_barrier);1691 }1692 #endif1693 CLOCK_THREAD_END_STEP(p, 1);1694 1695 1696 // ---------------------------------1697 // -- parallel transitive closure --1698 // ---------------------------------1699 1700 CLOCK_THREAD_START_STEP(p, 2);1701 for (uint32 e = e0; e <= e1; e++) {1702 uint32 r = T[e]; // acces local1703 if (r < e) {1704 r = FindRoot_Dist(D, e, alpha); // acces distant1705 T[e] = r; // @QM était en dehors du "if" (je pense que déjà demandé)1706 }1707 MCA_VERBOSE2(printf("p%d : T[%d] <- %d\n", p, e, r));1708 }1709 CLOCK_THREAD_END_STEP(p, 2);1710 }1711 #endif // !FEATURES1712 1713 1714 // -------------------------------------1715 void MCA_Label_Rosenfeld_PAR3(MCA * mca)1716 // -------------------------------------1717 {1718 // input1719 if (mca->p == 0) {1720 printf("*** %s ***\n", __func__);1721 }1722 1723 int i0 = mca->i0;1724 int i1 = mca->i1;1725 int j0 = 0;1726 int j1 = mca->width - 1;1727 1728 uint32 ** E = mca->E;1729 uint32 * T = mca->T;1730 1731 CLOCK_THREAD_START_STEP(mca->p, 3);1732 for (int i = i0; i <= i1; i++) {1733 for (int j = j0; j <= j1; j++) {1734 uint32 e = E[i][j];1735 if (e != 0) {1736 E[i][j] = T[e];1737 }1738 }1739 }1740 CLOCK_THREAD_END_STEP(mca->p, 3);1741 }1742 1743 1744 #if FEATURES1745 // -----------------------------------------------------1746 static void MCA_Label_Features_Rosenfeld_PAR1(MCA * mca)1747 // -----------------------------------------------------1748 {1749 if (mca->p == 0) {1750 printf("*** %s ***\n", __func__);1751 }1752 1753 CLOCK_THREAD_START_STEP(mca->p, 0);1754 1755 int i0 = mca->i0;1756 int i1 = mca->i1;1757 int width = mca->width;1758 1759 uint32 e0 = mca->e0;1760 uint32 e1 = mca->e1;1761 uint32 ne = e0 - 1;1762 uint32 nr = 0;1763 1764 // local memory zones1765 uint8 ** X = mca->X;1766 uint32 ** E = mca->E;1767 uint32 * T = mca->T;1768 1769 RegionStats * stats = mca->stats;1770 1771 // reset sous optimal (pour le moment = voir region32)1772 if (mca->p == 0) {1773 set_ui32vector_j(T, e0 - 1, e1); // car e0 = 1, on a besoin que T[0] = 0 pour FindRoot1774 zero_RegionStatsVector(stats, e0 - 1, e1);1775 }1776 else {1777 set_ui32vector_j(T, e0, e1);1778 zero_RegionStatsVector(stats, e0, e1);1779 }1780 1781 if (mca->p == 0) {1782 MCA_DISPLAY2(display_ui8matrix_positive(X, i0, i1, 0, width - 1, 5, "Xp"); printf("\n"));1783 }1784 1785 // ---------------------------- //1786 // -- Etiquetage d'une bande -- //1787 // ---------------------------- //1788 1789 ne = line0Labeling_Rosenfeld(X, i0, width, E, T, ne);1790 lineFeaturesComputation(E, i0, width, stats);1791 1792 for (int i = i0 + 1; i <= i1; i++) {1793 ne = lineLabeling_Rosenfeld(X, i, width, E, T, ne); // Slow or Fast1794 lineFeaturesComputation(E, i, width, stats);1795 }1796 mca->ne = ne; //plus grande etiquette de l'intervalle [e0..e1]1797 1798 if (mca->p == 0) {1799 MCA_VERBOSE2(printf("ne = %d\n", ne));1800 MCA_DISPLAY2(display_ui32matrix_positive(E, i0, i1, 0, width - 1, 5, "Ep"); printf("\n"));1801 MCA_DISPLAY2(display_ui32vector_number(T, e0, ne, "%5d", "Tp_avant"));1802 }1803 1804 // ------------------------------------------------------ //1805 // -- Fermeture transitive sans pack de chaque table T -- //1806 // ------------------------------------------------------ //1807 1808 solveTable_solveFeatures_Range_Rosenfeld(T, e0, ne, stats);1809 1810 if (mca->p == 0) {1811 MCA_VERBOSE2(nr = countTable_Range_Rosenfeld(T, e0, ne);1812 printf("p = %d : e = [%d..%d] -> ne = %d -> nr = %d\n", mca->p, e0, ne, (ne - e0 + 1), nr));1813 MCA_DISPLAY2(display_ui32vector_number(T, e0, ne, "%5d", "Tp_apres"));1814 }1815 CLOCK_THREAD_END_STEP(mca->p, 0);1816 }1817 #endif // FEATURES1818 1819 1820 #if FEATURES && !PARMERGE1821 // -----------------------------------------------------1822 static void MCA_Label_Features_Rosenfeld_PYR2(MCA * mca)1823 // -----------------------------------------------------1824 {1825 int p = mca->p;1826 int nb_level = mca->nb_level;1827 1828 if (mca->p == 0) {1829 printf("*** %s ***\n", __func__);1830 }1831 1832 // ------------------------------1833 // -- pyramidal border merging --1834 // ------------------------------1835 1836 // local variables1837 int i = mca->i0;1838 int width = mca->width;1839 int alpha = mca->alpha;1840 uint32 e0 = mca->e0;1841 uint32 e1 = mca->ne;1842 1843 // local memory zones1844 uint8 ** X = mca->X;1845 uint32 ** E = mca->E;1846 uint32 * T = mca->T;1847 uint32 ** D = mca->D;1848 RegionStats ** F = mca->F;1849 1850 CLOCK_THREAD_START_STEP(p, 1);1851 #if PYR_BARRIERS1852 // Version optimisée qui fait faire un break aux processeurs qui n'ont plus1853 // à faire de merge.1854 // Implique de pré-calculer le nombre de threads à chaque barriÚre1855 if (p != 0) { // thread 0 never has any merge to do1856 int been_active = 0;1857 for (int level = 0; level < nb_level; level++) {1858 if ((p + (1 << level)) % (1 << (level + 1)) == 0) {1859 borderMerging_Features_Rosenfeld_Dist(X, i, width, E, T, D, alpha, F); // (i) et (i-1)1860 been_active = 1;1861 }1862 else if (been_active) {1863 break;1864 }1865 pthread_barrier_wait(&mca->barriers[level]);1866 }1867 }1868 pthread_barrier_wait(&main_barrier);1869 #else1870 for (int level = 1; level <= nb_level; level++) {1871 if ((p + (1 << (level - 1))) % (1 << level) == 0) {1872 // thread actif1873 borderMerging_Features_Rosenfeld_Dist(X, i, width, E, T, D, alpha, F); // (i) et (i-1)1874 }1875 pthread_barrier_wait(&main_barrier);1876 }1877 #endif1878 CLOCK_THREAD_END_STEP(p, 1);1879 1880 1881 /**1882 * To remove?1883 // -- Affichage de debug1884 if (mca->p == 0) {1885 MCA_VERBOSE1(puts("-----------------------------"));1886 MCA_VERBOSE1(puts("[PYR2]: avant pack sequentiel"));1887 MCA_VERBOSE1(puts("-----------------------------"));1888 1889 for (int p = 0; p < mca->np; p++) {1890 1891 MCA* mca_par = mcas[p];1892 uint32 e0 = mca_par->e0;1893 uint32 e1 = mca_par->ne;1894 1895 uint32* T = mca_par->T;1896 RegionStats* Stats = mca_par->Stats;1897 1898 RegionStats_DisplayStats_Sparse(T, e0, e1, Stats, NULL);1899 puts("");1900 }1901 }1902 */1903 1904 // ---------------------------------1905 // -- parallel transitive closure --1906 // ---------------------------------1907 // identique a la version sans Features1908 1909 CLOCK_THREAD_START_STEP(p, 2);1910 for (uint32 e = e0; e <= e1; e++) {1911 uint32 r = T[e]; // acces local1912 if (r < e) {1913 r = FindRoot_Dist(D, e, alpha); // acces distant1914 T[e] = r;1915 }1916 MCA_VERBOSE2(printf("p%d : T[%d] <- %d\n", p, e, r));1917 }1918 CLOCK_THREAD_END_STEP(p, 2);1919 1920 // To avoid uninitialized accesses1921 CLOCK_THREAD_START_STEP(p, 3);1922 CLOCK_THREAD_END_STEP(p, 3);1923 }1924 #endif // FEATURES && !PARMERGE1925 1926 1927 #if FEATURES && PARMERGE1928 // -----------------------------------------------------1929 static void MCA_Label_Features_Rosenfeld_PAR2(MCA * mca)1930 // -----------------------------------------------------1931 {1932 int p = mca->p;1933 int nb_level = mca->nb_level;1934 1935 if (mca->p == 0) {1936 printf("*** %s ***\n", __func__);1937 }1938 1939 // ------------------------------1940 // -- parallel border merging --1941 // ------------------------------1942 1943 // local variables1944 int i = mca->i0;1945 int width = mca->width;1946 int alpha = mca->alpha;1947 uint32 e0 = mca->e0;1948 uint32 e1 = mca->ne;1949 1950 // local memory zones1951 uint8 ** X = mca->X;1952 uint32 ** E = mca->E;1953 uint32 * T = mca->T;1954 uint32 ** D = mca->D;1955 1479 RegionStats ** F = mca->F; 1956 1480 1957 1481 CLOCK_THREAD_START_STEP(p, 1); 1958 1482 if (p != 0) { // thread 0 never has any merge to do 1959 borderMerging_ Features_Rosenfeld_Dist(X, i, width, E, T, D, alpha, F); // (i) et (i-1)1483 borderMerging_Rosenfeld_Dist(X, i, width, E, T, D, alpha, F); // (i) et (i-1) 1960 1484 } 1961 1485 pthread_barrier_wait(&main_barrier); … … 1975 1499 T[e] = r; 1976 1500 } 1977 MCA_VERBOSE 2(printf("p%d : T[%d] <- %d\n", p, e, r));1501 MCA_VERBOSE3(printf("p%d : T[%d] <- %d\n", p, e, r)); 1978 1502 } 1979 1503 CLOCK_THREAD_END_STEP(p, 2); … … 1983 1507 CLOCK_THREAD_END_STEP(p, 3); 1984 1508 } 1985 #endif // FEATURES 1986 1987 1988 1989 1990 #if !FEATURES 1991 // ============================================================= 1992 #if TARGET_OS == GIETVM 1993 __attribute__((constructor)) void MCA_Label_Rosenfeld(MCA * mca) 1509 #endif // PARMERGE 1510 1511 1512 #if !PARMERGE 1513 // -------------------------------------------- 1514 static void MCA_Label_Rosenfeld_PYR2(MCA * mca) 1515 // -------------------------------------------- 1516 { 1517 // input 1518 int p = mca->p; 1519 int nb_level = mca->nb_level; 1520 1521 if (mca->p == 0) { 1522 MCA_VERBOSE2(printf("*** %s ***\n", __func__)); 1523 } 1524 1525 // ------------------------------ 1526 // -- pyramidal border merging -- 1527 // ------------------------------ 1528 1529 // local variables 1530 int i = mca->i0; 1531 int width = mca->width; 1532 int alpha = mca->alpha; 1533 uint32 e0 = mca->e0; 1534 uint32 e1 = mca->ne; 1535 1536 // local memory zones 1537 uint8 ** X = mca->X; 1538 uint32 ** E = mca->E; 1539 uint32 * T = mca->T; 1540 uint32 ** D = mca->D; 1541 RegionStats ** F = mca->F; 1542 1543 CLOCK_THREAD_START_STEP(p, 1); 1544 #if PYR_BARRIERS 1545 // Version optimisée qui fait faire un break aux processeurs qui n'ont plus 1546 // à faire de merge. 1547 // Implique de pré-calculer le nombre de threads à chaque barriÚre 1548 if (p != 0) { // thread 0 never has any merge to do 1549 int been_active = 0; 1550 for (int level = 0; level < nb_level; level++) { 1551 if ((p + (1 << level)) % (1 << (level + 1)) == 0) { 1552 borderMerging_Rosenfeld_Dist(X, i, width, E, T, D, alpha, F); // (i) et (i-1) 1553 been_active = 1; 1554 } 1555 else if (been_active) { 1556 break; 1557 } 1558 pthread_barrier_wait(&mca->barriers[level]); 1559 } 1560 } 1561 pthread_barrier_wait(&main_barrier); 1994 1562 #else 1995 void MCA_Label_Rosenfeld(MCA * mca) 1563 for (int level = 1; level <= nb_level; level++) { 1564 if ((p + (1 << (level - 1))) % (1 << level) == 0) { 1565 // thread actif 1566 borderMerging_Rosenfeld_Dist(X, i, width, E, T, D, alpha, F); // (i) et (i-1) 1567 } 1568 pthread_barrier_wait(&main_barrier); 1569 } 1996 1570 #endif 1997 // ============================================================= 1998 { 1999 #if TARGET_OS == GIETVM 2000 unsigned int x, y, lpid; 2001 giet_proc_xyp(&x, &y, &lpid); 2002 // Mettre à jour mca->p en fonction de x, y, lpid 2003 // pour que les allocations faites par le main soient locales, 2004 // i.e. 2005 mca->p = (x * Y_SIZE + y) * NB_PROCS_MAX + lpid; 2006 // We have : 2007 // mca->p = 4 pour (x = 0, y = 1, lpid = 0) 2008 // mca->p = 5 pour (x = 0, y = 1, lpid = 1) 2009 MCA_VERBOSE2(printf("mca->p = %d pour (x = %d, y = %d, lpid = %d)\n", mca->p, x, y, lpid)); 2010 #endif 2011 2012 CLOCK_THREAD_START(mca->p); 2013 CLOCK_THREAD_COMPUTE_START(mca->p); 2014 2015 MCA_Scatter_ImageX(mca); 2016 pthread_barrier_wait(&main_barrier); 2017 2018 MCA_Label_Rosenfeld_PAR1(mca); 2019 pthread_barrier_wait(&main_barrier); 2020 2021 MCA_Label_Rosenfeld_PYR2(mca); 2022 pthread_barrier_wait(&main_barrier); 2023 2024 MCA_Label_Rosenfeld_PAR3(mca); 2025 pthread_barrier_wait(&main_barrier); 2026 2027 MCA_Gather_ImageL(mca); 2028 pthread_barrier_wait(&main_barrier); 2029 2030 CLOCK_THREAD_COMPUTE_END(mca->p); 2031 CLOCK_THREAD_END(mca->p); 2032 2033 #if TARGET_OS == GIETVM 2034 if (mca->p != 0) { 2035 exit(0); 2036 } 2037 #endif 1571 CLOCK_THREAD_END_STEP(p, 1); 1572 1573 1574 // --------------------------------- 1575 // -- parallel transitive closure -- 1576 // --------------------------------- 1577 1578 CLOCK_THREAD_START_STEP(p, 2); 1579 for (uint32 e = e0; e <= e1; e++) { 1580 uint32 r = T[e]; // acces local 1581 if (r < e) { 1582 r = FindRoot_Dist(D, e, alpha); // acces distant 1583 T[e] = r; 1584 } 1585 MCA_VERBOSE3(printf("p%d : T[%d] <- %d\n", p, e, r)); 1586 } 1587 CLOCK_THREAD_END_STEP(p, 2); 2038 1588 } 2039 1589 #endif // !FEATURES 2040 1590 2041 1591 2042 #if FEATURES 1592 // ------------------------------------- 1593 void MCA_Label_Rosenfeld_PAR3(MCA * mca) 1594 // ------------------------------------- 1595 { 1596 // input 1597 if (mca->p == 0) { 1598 MCA_VERBOSE2(printf("*** %s ***\n", __func__)); 1599 } 1600 1601 int i0 = mca->i0; 1602 int i1 = mca->i1; 1603 int j0 = 0; 1604 int j1 = mca->width - 1; 1605 1606 uint32 ** E = mca->E; 1607 uint32 * T = mca->T; 1608 1609 CLOCK_THREAD_START_STEP(mca->p, 3); 1610 for (int i = i0; i <= i1; i++) { 1611 for (int j = j0; j <= j1; j++) { 1612 uint32 e = E[i][j]; 1613 if (e != 0) { 1614 E[i][j] = T[e]; 1615 } 1616 } 1617 } 1618 CLOCK_THREAD_END_STEP(mca->p, 3); 1619 } 1620 1621 1622 2043 1623 // ====================================================================== 2044 1624 #if TARGET_OS == GIETVM 2045 __attribute__((constructor)) void * MCA_Label_ Features_Rosenfeld(void * arg)1625 __attribute__((constructor)) void * MCA_Label_Rosenfeld(void * arg) 2046 1626 #else 2047 void * MCA_Label_ Features_Rosenfeld(void * arg)1627 void * MCA_Label_Rosenfeld(void * arg) 2048 1628 #endif 2049 1629 // ====================================================================== … … 2060 1640 // mca->p = 4 pour (x = 0, y = 1, lpid = 0) 2061 1641 // mca->p = 5 pour (x = 0, y = 1, lpid = 1) 2062 MCA_VERBOSE 2(printf("mca->p = %d pour (x = %d, y = %d, lpid = %d)\n", mca->p, x, y, lpid));1642 MCA_VERBOSE3(printf("mca->p = %d pour (x = %d, y = %d, lpid = %d)\n", mca->p, x, y, lpid)); 2063 1643 #endif 2064 1644 … … 2069 1649 pthread_barrier_wait(&main_barrier); 2070 1650 2071 MCA_Label_ Features_Rosenfeld_PAR1(mca);1651 MCA_Label_Rosenfeld_PAR1(mca); 2072 1652 pthread_barrier_wait(&main_barrier); 2073 1653 2074 1654 #if PARMERGE 2075 MCA_Label_ Features_Rosenfeld_PAR2(mca);1655 MCA_Label_Rosenfeld_PAR2(mca); 2076 1656 #else 2077 MCA_Label_ Features_Rosenfeld_PYR2(mca);1657 MCA_Label_Rosenfeld_PYR2(mca); 2078 1658 #endif 2079 1659 pthread_barrier_wait(&main_barrier); … … 2087 1667 CLOCK_THREAD_COMPUTE_END(mca->p); 2088 1668 1669 #if FEATURES 2089 1670 if (display_features) { 2090 1671 if (mca->p == 0) { 2091 1672 int i = 1; 2092 printf("[STATS]\n");1673 MCA_VERBOSE1(printf("[STATS]\n")); 2093 1674 for (int p = 0; p < mca->np; p++) { 2094 1675 MCA * mca_par = mca->mca->mcas[p]; … … 2097 1678 uint32 * T = mca_par->T; 2098 1679 RegionStats * stats = mca_par->stats; 2099 RegionStats_DisplayStats_Sparse(T, e0, e0 + ne, stats, NULL, &i); 2100 } 2101 printf("[/STATS]\n"); 2102 } 2103 } 1680 MCA_VERBOSE1(RegionStats_DisplayStats_Sparse(T, e0, e0 + ne, stats, NULL, &i)); 1681 } 1682 MCA_VERBOSE1(printf("[/STATS]\n")); 1683 } 1684 } 1685 #endif 2104 1686 2105 1687 CLOCK_THREAD_END(mca->p); … … 2113 1695 return NULL; 2114 1696 } 2115 #endif // FEATURES2116 1697 2117 1698 -
soft/giet_vm/applications/rosenfeld/src/ecc_features.c
r821 r822 35 35 36 36 37 // ----------------------------------------------------- 38 void RegionStats_Init(RegionStats * Stats, uint32 nemax) 39 // ----------------------------------------------------- 40 { 41 for (int i = 0; i < (int) nemax; i++) { 42 #if PARMERGE 43 pthread_spin_init(&Stats[i].lock, PTHREAD_PROCESS_PRIVATE); 44 #endif 45 } 46 } 47 48 37 49 // ------------------------------------------------------------- 38 50 void RegionStats_Constructor(RegionStats ** Stats, uint32 nemax) … … 54 66 } 55 67 56 RegionStats_ Clear(Stats, nemax);68 RegionStats_Init(Stats, nemax); 57 69 58 70 return Stats; … … 72 84 // ------------------------------------------------------------ 73 85 { 74 RegionStats_Clear(Stats, nemax);86 //RegionStats_Clear(Stats, nemax); 75 87 free(Stats); 76 88 } 77 78 89 79 90 // ------------------------------------------------------ … … 82 93 { 83 94 for (int i = 0; i < (int) nemax; i++) { 95 #if FEATURES 84 96 Stats[i].xmin = 65535; 85 97 Stats[i].xmax = 0; … … 91 103 Stats[i].Sx = 0; 92 104 Stats[i].Sy = 0; 93 #if PARMERGE94 pthread_spin_init(&Stats[i].lock, PTHREAD_PROCESS_PRIVATE);95 105 #endif 96 106 } 97 107 } 98 108 99 109 #if FEATURES 100 110 // ----------------------------------------- 101 111 void RegionStats_Clear1(RegionStats * stats) … … 396 406 dst->Sy = src->Sy; 397 407 } 398 408 #endif 399 409 400 410 // =============================== … … 414 424 return NULL; 415 425 } 416 RegionStats_ Clear(v, i1 - i0 + 1 + NR_END);426 RegionStats_Init(v, i1 - i0 + 1 + NR_END); 417 427 return v - i0 + NR_END; 418 428 } … … 432 442 return NULL; 433 443 } 434 RegionStats_ Clear(v, i1 - i0 + 1 + NR_END);444 RegionStats_Init(v, i1 - i0 + 1 + NR_END); 435 445 return v - i0 + NR_END; 436 446 } … … 542 552 543 553 554 #if FEATURES 544 555 // ----------------------------------- 545 556 void zero_RegionStats(RegionStats * x) … … 1420 1431 return n1 - s; 1421 1432 } 1433 #endif // FEATURES 1422 1434 1423 1435 // Local Variables: -
soft/giet_vm/applications/rosenfeld/src/ecc_generation.c
r791 r822 23 23 24 24 25 // ------------------------------------------------------------------------------------------------------------------------- 26 void generate_granularity_density_float(uint8 ** X, int i0, int i1, int j0, int j1, int granularity, float density, int seed)27 // ------------------------------------------------------------------------------------------------------------------------- 25 // -------------------------------------------------------------------------------------------------------------------------- 26 void generate_granularity_density_float(uint8 ** X, int i0, int i1, int j0, int j1, int granularity, float density, int seed) 27 // -------------------------------------------------------------------------------------------------------------------------- 28 28 { 29 29 uint8 x; 30 int i, j;31 int di, dj;32 33 30 double r; 34 31 … … 36 33 init_genrand(seed); 37 34 38 for (i=i0; i<=i1; i+=granularity) {39 for (j=j0; j<=j1; j+=granularity) {35 for (int i = i0; i <= i1; i += granularity) { 36 for (int j = j0; j <= j1; j += granularity) { 40 37 41 38 //r = 100.0*(double)rand() / rmax; 42 39 //r = 100.0*(double)rand() / rmax; 43 r = 100.0*(double)genrand_real2(); 44 if(r <= density) x = 1; else x = 0; 45 46 for(di=0; di<granularity; di++) { 47 for(dj=0; dj<granularity; dj++) { 48 if ((i+di<=i1) && (j+dj<=j1)) X[i+di][j+dj] = x; 40 r = 100.0 * (double) genrand_real2(); 41 if (r <= density) { 42 x = 1; 43 } 44 else { 45 x = 0; 46 } 47 48 for (int di = 0; di < granularity; di++) { 49 for (int dj = 0; dj < granularity; dj++) { 50 if ((i + di <= i1) && (j + dj <= j1)) { 51 X[i + di][j + dj] = x; 52 } 49 53 } // dj 50 54 } // di 51 52 } //j 55 } // j 53 56 } // i 54 57 } 55 // --------------------------------------------------------------------------------------------------------------------- 56 void generate_granularity_density_int(uint8 **X, int i0, int i1, int j0, int j1, int granularity, int density, int seed) 57 // --------------------------------------------------------------------------------------------------------------------- 58 59 // ---------------------------------------------------------------------------------------------------------------------- 60 void generate_granularity_density_int(uint8 ** X, int i0, int i1, int j0, int j1, int granularity, int density, int seed) 61 // ---------------------------------------------------------------------------------------------------------------------- 58 62 { 59 63 generate_granularity_density_float(X, i0, i1, j0, j1, granularity, (float) density, seed); 60 64 } 61 // --------------------------------------------------------------------------------------------------------- 62 void generate_granularity_density_name(char *name, int granularity, int density, char *filename, int maxlen) 63 // --------------------------------------------------------------------------------------------------------- 65 66 // ----------------------------------------------------------------------------------------------------------- 67 void generate_granularity_density_name(char * name, int granularity, int density, char * filename, int maxlen) 68 // ----------------------------------------------------------------------------------------------------------- 64 69 { 65 70 snprintf(filename, maxlen, "%s_%02d_%03d.pgm", name, granularity, density); 66 71 } 67 // ------------------------------------------------------------------------------------------------------------------------------ 68 void generate_granularity_density_ext_name(char *name, int granularity, int density, char *extension, char *filename, int maxlen) 69 // ------------------------------------------------------------------------------------------------------------------------------ 72 73 // --------------------------------------------------------------------------------------------------------------------------------- 74 void generate_granularity_density_ext_name(char * name, int granularity, int density, char * extension, char * filename, int maxlen) 75 // --------------------------------------------------------------------------------------------------------------------------------- 70 76 { 71 77 snprintf(filename, maxlen, "%s_%02d_%03d.%s", name, granularity, density, extension); 72 78 } 73 // ------------------------------------------------------------------------------------------------------------------------ 74 void generate_size_granularity_density_name(char * name, int size, int granularity, int density, char *filename, int maxlen)75 // ------------------------------------------------------------------------------------------------------------------------ 79 // -------------------------------------------------------------------------------------------------------------------------- 80 void generate_size_granularity_density_name(char * name, int size, int granularity, int density, char * filename, int maxlen) 81 // -------------------------------------------------------------------------------------------------------------------------- 76 82 { 77 83 snprintf(filename, maxlen, "%s_%d_%02d_%03d.pgm", name, size, granularity, density); 78 84 } 79 // --------------------------------------------------------------------------------------------------------------------------------------------- 80 void generate_size_granularity_density_ext_name(char * name, int size, int granularity, int density, char *extension, char *filename, int maxlen)81 // --------------------------------------------------------------------------------------------------------------------------------------------- 85 // ----------------------------------------------------------------------------------------------------------------------------------------------- 86 void generate_size_granularity_density_ext_name(char * name, int size, int granularity, int density, char *extension, char * filename, int maxlen) 87 // ----------------------------------------------------------------------------------------------------------------------------------------------- 82 88 { 83 89 snprintf(filename, maxlen, "%s_%d_%02d_%03d.%s", name, size, granularity, density, extension); 84 90 } 85 // --------------------------------------------------------------------------------------------------- 86 void generate_size_granularity_name(char * name, int size, int granularity, char *filename, int maxlen)87 // --------------------------------------------------------------------------------------------------- 91 // ----------------------------------------------------------------------------------------------------- 92 void generate_size_granularity_name(char * name, int size, int granularity, char * filename, int maxlen) 93 // ----------------------------------------------------------------------------------------------------- 88 94 { 89 95 snprintf(filename, maxlen, "%s_%d_%02d.pgm", name, size, granularity); 90 }// ----------------------------------------------------------------------------------------- 91 void generate_name100(char * name, int granularity, float density, char *filename, int maxlen)92 // ------------------------------------------------------------------------------------------ 96 }// ------------------------------------------------------------------------------------------ 97 void generate_name100(char * name, int granularity, float density, char *filename, int maxlen) 98 // ------------------------------------------------------------------------------------------- 93 99 { 94 100 // density en pourcentage: 0:100 … … 98 104 } 99 105 // ---------------------------------------- 100 int test_generation(int argc, char * argv[])106 int test_generation(int argc, char * argv[]) 101 107 // ---------------------------------------- 102 108 { 103 uint8 ** X;104 uint8 ** X255;109 uint8 ** X; 110 uint8 ** X255; 105 111 char filename[32]; 106 112 … … 123 129 n = 4096; 124 130 125 X = ui8matrix(0 -border, n-1+border, 0-border, n-1+border);126 X255 = ui8matrix(0 -border, n-1+border, 0-border, n-1+border);127 128 for (g=gmin; g<=gmax; g*=2) {129 for (d=dmin; d<=dmax; d+=dstep) {130 generate_granularity_density_int(X, 0, n -1, 0, n-1, g, d, seed);131 X = ui8matrix(0 - border, n - 1 + border, 0 - border, n - 1 + border); 132 X255 = ui8matrix(0 - border, n - 1 + border, 0 - border, n - 1 + border); 133 134 for (g = gmin; g <= gmax; g *= 2) { 135 for (d = dmin; d <= dmax; d += dstep) { 136 generate_granularity_density_int(X, 0, n - 1, 0, n - 1, g, d, seed); 131 137 generate_granularity_density_name("I", g, d, filename, 32); 132 138 printf(filename); 133 bin2gray_ui8matrix(X, 0, n -1, 0, n-1, X255);134 SavePGM_ui8matrix(X255, 0, n -1, 0, n-1, filename);135 } 136 } 137 free_ui8matrix(X, 0 -border, n-1+border, 0-border, n-1+border);138 free_ui8matrix(X255, 0 -border, n-1+border, 0-border, n-1+border);139 bin2gray_ui8matrix(X, 0, n - 1, 0, n - 1, X255); 140 SavePGM_ui8matrix(X255, 0, n - 1, 0, n - 1, filename); 141 } 142 } 143 free_ui8matrix(X, 0 - border, n - 1 + border, 0 - border, n - 1 + border); 144 free_ui8matrix(X255, 0 - border, n - 1 + border, 0 - border, n - 1 + border); 139 145 140 146 return 0; 141 147 } 142 // ----------------------------------------- 143 void hline(uint8 **X, int i, int j0, int j1) 144 // ----------------------------------------- 145 { 146 int j; 147 for(j=j0; j<=j1; j++) X[i][j] = 1; 148 } 149 // ----------------------------------------- 150 void vline(uint8 **X, int i0, int i1, int j) 151 // ----------------------------------------- 152 { 153 int i; 154 for(i=i0; i<=i1; i++) X[i][j] = 1; 155 } 156 // ----------------------------------------------------------- 157 void draw_rectangle(uint8 **X, int i0, int i1, int j0, int j1) 158 // ----------------------------------------------------------- 148 149 // ------------------------------------------ 150 void hline(uint8 ** X, int i, int j0, int j1) 151 // ------------------------------------------ 152 { 153 for (int j = j0; j <= j1; j++) { 154 X[i][j] = 1; 155 } 156 } 157 // ------------------------------------------ 158 void vline(uint8 ** X, int i0, int i1, int j) 159 // ------------------------------------------ 160 { 161 for (int i = i0; i <= i1; i++) { 162 X[i][j] = 1; 163 } 164 } 165 166 // ------------------------------------------------------------ 167 void draw_rectangle(uint8 ** X, int i0, int i1, int j0, int j1) 168 // ------------------------------------------------------------ 159 169 { 160 170 hline(X, i0, j0, j1); … … 163 173 hline(X, i1, j0, j1); 164 174 } 165 // -------------------------------------------------- 166 void spirale_simple(uint8 **X, int height, int width) 167 // -------------------------------------------------- 175 176 // --------------------------------------------------- 177 void spirale_simple(uint8 ** X, int height, int width) 178 // --------------------------------------------------- 168 179 { 169 180 int i0, j0; // point de depart haut … … 172 183 int n; //min(height, width) 173 184 174 zero_ui8matrix(X, 0, height -1, 0, width-1);175 176 if (height<width) {185 zero_ui8matrix(X, 0, height - 1, 0, width - 1); 186 187 if (height < width) { 177 188 n = height; 178 } else { 189 } 190 else { 179 191 n = width; 180 192 } … … 184 196 185 197 // avec correction 186 i0 = 0; i1 = 2*(n/2)-1; 187 j0 = 0; j1 = 2*(n/2)-1; 198 i0 = 0; 199 i1 = 2 * (n / 2) - 1; 200 j0 = 0; 201 j1 = 2 * (n / 2) - 1; 188 202 189 203 nc = n / 4; 190 204 191 for (c=0; c<nc; c++) {192 draw_rectangle(X, i0 +2*c, i1-2*c, j0+2*c, j1-2*c);193 X[1 +2*c ][0+2*c] = 0;194 X[1 +2*c+1][0+2*c+1] = 1;205 for (c = 0; c < nc; c++) { 206 draw_rectangle(X, i0 + 2 * c, i1 - 2 * c, j0 + 2 * c, j1 - 2 * c); 207 X[1 + 2 * c ][0 + 2 * c ] = 0; 208 X[1 + 2 * c + 1][0 + 2 * c + 1] = 1; 195 209 } 196 210 197 211 // centre 198 212 //X[n/2][n/2] = 1; 199 for(c=i0+2*nc; c<=i1-2*nc; c++) { 200 hline(X, c, j0+2*nc, j1-2*nc); 201 } 202 } 213 for (c = i0 + 2 * nc; c <= i1 - 2 * nc; c++) { 214 hline(X, c, j0 + 2 * nc, j1 - 2 * nc); 215 } 216 } 217 203 218 // -------------------------------------------------- 204 219 void spirale_double(uint8 **X, int height, int width) … … 212 227 zero_ui8matrix(X, 0, height-1, 0, width-1); 213 228 214 if (height<width) {229 if (height < width) { 215 230 n = height; 216 } else { 231 } 232 else { 217 233 n = width; 218 234 } … … 221 237 //n = ((n-1) & (~0x3))+1; 222 238 223 i0 = 0; i1 = 2*(n/2)-1; 224 j0 = 0; j1 = 2*(n/2)-1; 239 i0 = 0; 240 i1 = 2 * (n / 2) - 1; 241 j0 = 0; 242 j1 = 2 * (n / 2) - 1; 225 243 226 244 nc = n / 4; 227 245 228 for (c=0; c<nc; c++) {229 draw_rectangle(X, i0 +2*c, i1-2*c, j0+2*c, j1-2*c);230 } 231 for (c=0; c<nc; c++) {232 X[(i0 +1)+(2*c )][(j0)+(2*c)] = 0;233 X[(i0 +1)+(2*c+1)][(j0)+(2*c+1)] = 1;246 for (c = 0; c < nc; c++) { 247 draw_rectangle(X, i0 + 2 * c, i1 - 2 * c, j0 + 2 * c, j1 - 2 * c); 248 } 249 for (c = 0; c < nc; c++) { 250 X[(i0 + 1) + (2 * c )][(j0) + (2 * c )] = 0; 251 X[(i0 + 1) + (2 * c + 1)][(j0) + (2 * c + 1)] = 1; 234 252 235 X[(i1 -1)-(2*c )][(j1)-(2*c)] = 0;236 X[(i1 -1)-(2*c+1)][(j1)-(2*c+1)] = 1;253 X[(i1 - 1) - (2 * c )][(j1) - (2 * c )] = 0; 254 X[(i1 - 1) - (2 * c + 1)][(j1) - (2 * c + 1)] = 1; 237 255 } 238 256 // centre 239 257 //X[n/2][n/2] = 1; 240 for (c=i0+2*nc; c<=i1-2*nc; c++) {241 hline(X, c, j0 +2*nc, j1-2*nc);258 for (c = i0 + 2 * nc; c <= i1 - 2 * nc; c++) { 259 hline(X, c, j0 + 2 * nc, j1 - 2 * nc); 242 260 } 243 261 } … … 246 264 // ------------------------ 247 265 { 248 uint8 ** X;249 uint8 ** X255;266 uint8 ** X; 267 uint8 ** X255; 250 268 char filename[128]; 251 269 //char *ptr = (char*) filename; … … 254 272 h = w = n; 255 273 256 X = ui8matrix(0, h -1, 0, w-1);257 X255 = ui8matrix(0, h -1, 0, w-1);274 X = ui8matrix(0, h - 1, 0, w - 1); 275 X255 = ui8matrix(0, h - 1, 0, w - 1); 258 276 259 277 snprintf(filename, 128, "spirale_simple_%d.pgm", n); 260 278 spirale_simple(X, h, w); 261 bin2gray_ui8matrix(X, 0, h -1, 0, w-1, X255);262 SavePGM_ui8matrix(X255, 0, h -1, 0, w-1, filename);279 bin2gray_ui8matrix(X, 0, h - 1, 0, w - 1, X255); 280 SavePGM_ui8matrix(X255, 0, h - 1, 0, w - 1, filename); 263 281 264 282 snprintf(filename, 128, "spirale_double_%d.pgm", n); 265 283 spirale_double(X, h, w); 266 bin2gray_ui8matrix(X, 0, h-1, 0, w-1, X255); 267 SavePGM_ui8matrix(X255, 0, h-1, 0, w-1, filename);/**/ 268 269 free_ui8matrix(X, 0, h-1, 0, w-1); 270 free_ui8matrix(X255, 0, h-1, 0, w-1); 271 } 272 // -------------------------------------- 273 void test_spirale(int argc, char* argv[]) 274 // -------------------------------------- 284 bin2gray_ui8matrix(X, 0, h - 1, 0, w - 1, X255); 285 SavePGM_ui8matrix(X255, 0, h - 1, 0, w - 1, filename);/**/ 286 287 free_ui8matrix(X, 0, h - 1, 0, w - 1); 288 free_ui8matrix(X255, 0, h - 1, 0, w - 1); 289 } 290 291 // --------------------------------------- 292 void test_spirale(int argc, char * argv[]) 293 // --------------------------------------- 275 294 { 276 295 routine_spirale(128); … … 283 302 routine_spirale(1024); 284 303 } 285 // -------------------------------------------- 286 int test_generation_HGH(int argc, char* argv[]) 287 // -------------------------------------------- 288 { 289 uint8 **X; 290 uint8 **X255; 304 305 // --------------------------------------------- 306 int test_generation_HGH(int argc, char * argv[]) 307 // --------------------------------------------- 308 { 309 uint8 ** X; 310 uint8 ** X255; 291 311 char filename[32]; 292 312 293 313 int h = 1280; 294 int w = 90 *1024;314 int w = 90 * 1024; 295 315 296 316 int border = 2; … … 303 323 //w = h; 304 324 305 X = ui8matrix(0 -border, h-1+border, 0-border, w-1+border);306 X255 = ui8matrix(0 -border, h-1+border, 0-border, w-1+border);307 308 generate_granularity_density_float(X, 0, h -1, 0, w-1, g, d, seed);325 X = ui8matrix(0 - border, h - 1 + border, 0 - border, w - 1 + border); 326 X255 = ui8matrix(0 - border, h - 1 + border, 0 - border, w - 1 + border); 327 328 generate_granularity_density_float(X, 0, h - 1, 0, w - 1, g, d, seed); 309 329 generate_granularity_density_name("HGH", g, d, filename, 32); 310 330 printf(filename); 311 bin2gray_ui8matrix(X, 0, h -1, 0, w-1, X255);312 SavePGM_ui8matrix(X255, 0, h -1, 0, w-1, filename);313 314 free_ui8matrix(X, 0 -border, h-1+border, 0-border, w-1+border);315 free_ui8matrix(X255, 0 -border, h-1+border, 0-border, w-1+border);331 bin2gray_ui8matrix(X, 0, h - 1, 0, w - 1, X255); 332 SavePGM_ui8matrix(X255, 0, h - 1, 0, w - 1, filename); 333 334 free_ui8matrix(X, 0 - border, h - 1 + border, 0 - border, w - 1 + border); 335 free_ui8matrix(X255, 0 - border, h - 1 + border, 0 - border, w - 1 + border); 316 336 317 337 return 0; 318 338 } 319 // -------------------------------------------- 320 int image_analysis_2014(int argc, char* argv[]) 321 // -------------------------------------------- 339 340 // --------------------------------------------- 341 int image_analysis_2014(int argc, char * argv[]) 342 // --------------------------------------------- 322 343 { 323 344 // uint8 **X; … … 466 487 // -------------------------- 467 488 { 468 int i,n = 32;489 int n = 32; 469 490 470 491 printf("---------------------------"); … … 474 495 475 496 init_genrand(0); 476 for (i=0; i<n; i++) {497 for (int i = 0; i < n; i++) { 477 498 printf("%10lu ", genrand_int32()); 478 if (i%8==7) printf("\n"); 499 if (i % 8 == 7) { 500 printf("\n"); 501 } 479 502 } 480 503 printf("\n---"); 481 504 482 505 init_genrand(1); 483 for (i=0; i<n; i++) {506 for (int i = 0; i < n; i++) { 484 507 printf("%10lu ", genrand_int32()); 485 if (i%8==7) printf("\n"); 508 if (i % 8== 7) { 509 printf("\n"); 510 } 486 511 } 487 512 printf("\n---"); 488 513 489 514 init_genrand(0); 490 for (i=0; i<n; i++) {515 for (int i = 0; i < n; i++) { 491 516 printf("%10lu ", genrand_int32()); 492 if (i%8==7) printf("\n"); 517 if (i % 8== 7) { 518 printf("\n"); 519 } 493 520 } 494 521 printf("\n---"); 495 522 496 523 init_genrand(1); 497 for (i=0; i<n; i++) {524 for (int i = 0; i < n; i++) { 498 525 printf("%10lu ", genrand_int32()); 499 if (i%8==7) printf("\n"); 500 } 501 } 502 // ------------------------------------- 503 void image_zoom2(int argc, char *argv[]) 504 // ------------------------------------- 505 { 506 uint8 x, **X, **Y; 507 int i, j, i0, i1, j0, j1; 526 if (i % 8 == 7) { 527 printf("\n"); 528 } 529 } 530 } 531 532 // -------------------------------------- 533 void image_zoom2(int argc, char * argv[]) 534 // -------------------------------------- 535 { 536 uint8 x, ** X, ** Y; 537 int i0, i1, j0, j1; 508 538 int height, width; 509 char *src_filename; 510 char *dst_filename; 511 512 if(argc<3) { 513 printf("too few arguments"); 514 printf("%s src.pgm dst.pgm\n", argv[0]); 515 return; 516 } 517 518 src_filename = argv[1]; 519 dst_filename = argv[2]; 520 521 X = LoadPGM_ui8matrix(src_filename, &i0, &i1, &j0, &j1); 522 523 height = i1-i0+1; 524 width = j1-j0+1; 525 526 printf("width = %d height = %d\n", width, height); 527 528 Y = ui8matrix(0, 2*height-1, 0, 2*width-1); 529 530 for(i=0; i<=height-1; i++) { 531 for(j=0; j<=width-1; j++) { 532 x = X[i][j]; 533 Y[2*i+0][2*j+0] = x; Y[2*i+0][2*j+1] = x; 534 Y[2*i+1][2*j+0] = x; Y[2*i+1][2*j+1] = x; 535 } 536 } 537 SavePGM_ui8matrix(Y, 0, 2*height-1, 0, 2*width-1, dst_filename); 538 539 free_ui8matrix(X, 0, height-1, 0, width-1); 540 free_ui8matrix(Y, 0, 2*height-1, 0, 2*width-1); 541 } 542 // -------------------------------------------- 543 void image_duplication2(int argc, char *argv[]) 544 // -------------------------------------------- 545 { 546 uint8 x, **X, **Y; 547 int i, j, i0, i1, j0, j1; 548 int height, width; 549 char *src_filename; 550 char *dst_filename; 539 char * src_filename; 540 char * dst_filename; 551 541 552 542 if (argc < 3) { … … 561 551 X = LoadPGM_ui8matrix(src_filename, &i0, &i1, &j0, &j1); 562 552 563 height = i1 -i0+1;564 width = j1 -j0+1;553 height = i1 - i0 + 1; 554 width = j1 - j0 + 1; 565 555 566 556 printf("width = %d height = %d\n", width, height); 567 557 568 Y = ui8matrix(0, 2*height-1, 0, 2*width-1); 558 Y = ui8matrix(0, 2 * height - 1, 0, 2 * width - 1); 559 560 for (int i = 0; i <= height - 1; i++) { 561 for (int j = 0; j <= width - 1; j++) { 562 x = X[i][j]; 563 Y[2 * i + 0][2 * j + 0] = x; 564 Y[2 * i + 0][2 * j + 1] = x; 565 Y[2 * i + 1][2 * j + 0] = x; 566 Y[2 * i + 1][2 * j + 1] = x; 567 } 568 } 569 SavePGM_ui8matrix(Y, 0, 2 * height - 1, 0, 2 * width - 1, dst_filename); 570 571 free_ui8matrix(X, 0, height - 1, 0, width - 1); 572 free_ui8matrix(Y, 0, 2 * height - 1, 0, 2 * width - 1); 573 } 574 575 576 // --------------------------------------------- 577 void image_duplication2(int argc, char * argv[]) 578 // --------------------------------------------- 579 { 580 uint8 x, ** X, ** Y; 581 int i0, i1, j0, j1; 582 int height, width; 583 char * src_filename; 584 char * dst_filename; 585 586 if (argc < 3) { 587 printf("too few arguments"); 588 printf("%s src.pgm dst.pgm\n", argv[0]); 589 return; 590 } 591 592 src_filename = argv[1]; 593 dst_filename = argv[2]; 594 595 X = LoadPGM_ui8matrix(src_filename, &i0, &i1, &j0, &j1); 596 597 height = i1 - i0 + 1; 598 width = j1 - j0 + 1; 599 600 printf("width = %d height = %d\n", width, height); 601 602 Y = ui8matrix(0, 2 * height - 1, 0, 2 * width - 1); 569 603 570 604 // horizontal duplication 571 for (i=0; i<=height-1; i++) {572 for (j=0; j<=width-1; j++) {605 for (int i = 0; i <= height - 1; i++) { 606 for (int j = 0; j <= width - 1; j++) { 573 607 x = X[i][j]; 574 Y[i][width +j] = x;608 Y[i][width + j] = x; 575 609 } 576 610 } 577 611 578 612 // vertical duplication 579 for (i=0; i<=height-1; i++) {580 for (j=0; j<=2*width-1; j++) {613 for (int i = 0; i <= height - 1; i++) { 614 for (int j = 0; j <= 2 * width - 1; j++) { 581 615 x = X[i][j]; 582 Y[height+i][j] = x; 583 } 584 } 585 SavePGM_ui8matrix(Y, 0, 2*height-1, 0, 2*width-1, dst_filename); 586 587 free_ui8matrix(X, 0, height-1, 0, width-1); 588 free_ui8matrix(Y, 0, 2*height-1, 0, 2*width-1); 589 } 616 Y[height + i][j] = x; 617 } 618 } 619 SavePGM_ui8matrix(Y, 0, 2 * height - 1, 0, 2 * width - 1, dst_filename); 620 621 free_ui8matrix(X, 0, height - 1, 0, width - 1); 622 free_ui8matrix(Y, 0, 2 * height - 1, 0, 2 * width - 1); 623 } 624 625 626 627
Note: See TracChangeset
for help on using the changeset viewer.