Changeset 821 for soft/giet_vm/applications/rosenfeld/nrc2
- Timestamp:
- May 6, 2016, 3:06:29 PM (9 years ago)
- Location:
- soft/giet_vm/applications/rosenfeld/nrc2
- Files:
-
- 1 deleted
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/rosenfeld/nrc2/Makefile
r798 r821 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, nr kernel.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.c9 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 10 10 11 11 12 TARGET ?= linux 12 13 13 14 # -- Paths ---------- … … 15 16 OBJ_PATH = obj 16 17 INC_PATH = include 18 19 ifeq ($(TARGET),giet-vm) 20 21 CC = mipsel-unknown-elf-gcc 22 AR = mipsel-unknown-elf-ar 23 RANLIB = mipsel-unknown-elf-ranlib 24 AS = mipsel-unknown-elf-as 25 OD = mipsel-unknown-elf-objdump 26 OCPY = mipsel-unknown-elf-objcopy 27 LD = mipsel-unknown-elf-ld 28 NM = mipsel-unknown-elf-nm 17 29 18 30 … … 22 34 C_CONFIG_FLAGS = -DCLI 23 35 C_INC_FLAGS = -I$(INC_PATH) -I../../.. -I../../../giet_libs 36 CFLAGSCPU := -mips32 -EL -G0 -mhard-float 37 38 endif 39 40 ifeq ($(TARGET),linux) 41 42 CC = gcc 43 LD = gcc 44 AR = ar 45 RANLIB = ranlib 46 47 C_DEBUG_FLAGS = -O0 48 C_OPTIMISATION_FLAGS = -std=c99 -O2 -fstrict-aliasing 49 C_OS_FLAGS = -DGTODay -DTARGET_OS=LINUX 50 C_CONFIG_FLAGS = -DCLI 51 C_INC_FLAGS = -I$(INC_PATH) 52 53 endif 54 24 55 25 56 # -- Flags ---------- … … 30 61 # CC tools and parameters 31 62 #------------------------------------------------------------------------------ 32 CC = mipsel-unknown-elf-gcc33 AR = mipsel-unknown-elf-ar -cr34 RANLIB = mipsel-unknown-elf-ranlib35 AS = mipsel-unknown-elf-as36 OD = mipsel-unknown-elf-objdump37 OCPY = mipsel-unknown-elf-objcopy38 LD = mipsel-unknown-elf-ld39 NM = mipsel-unknown-elf-nm40 63 41 64 CFLAGSW := -Wredundant-decls -Wdisabled-optimization -Winline -Wpointer-arith -Wsign-compare -Wendif-labels 42 CFLAGSCPU := -mips32 -EL -G0 -mhard-float43 65 CFLAGS := $(CFLAGS) -g -Wall -fomit-frame-pointer $(CFLAGSW) $(CFLAGSCPU) -fno-builtin -ffreestanding 44 66 … … 55 77 56 78 $(PRODUCT): $(OBJS) 57 $(AR) $@ $^79 $(AR) -cr $@ $^ 58 80 $(RANLIB) $@ 59 81 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nralloc.h
r772 r821 11 11 #define __NRALLOC_H__ 12 12 13 #ifdef __cplusplus14 #pragma message ("C++")15 extern "C" {16 #endif17 18 #ifdef VERBOSE_PRAGMA19 //#pragma message ("- *** include nralloc.h ***")20 #endif21 13 22 14 #include "nralloc1.h" … … 24 16 #include "nralloc3.h" 25 17 26 #ifdef __cplusplus 27 } 28 #endif 18 #endif /* __NRALLOC_H__ */ 29 19 30 #endif /* __NRALLOC_H__ */ -
soft/giet_vm/applications/rosenfeld/nrc2/include/nralloc1.h
r772 r821 11 11 #define __NRALLOC1_H__ 12 12 13 #ifdef __cplusplus 14 #pragma message ("C++") 15 extern "C" { 16 #endif 17 18 #ifdef VERBOSE_PRAGMA 19 //#pragma message ("- *** include nralloc1.h ***") 20 #endif 13 #include <stdint.h> 21 14 22 23 //NR_END est maintenant defini dans nrutil.h 24 25 #define NR_END 0 26 #define FREE_ARG char* 27 28 //long nr_end = NR_END; 29 30 //void nrerror(char error_text[]); 31 //void nrerror(char *format, ...); 32 //void Error (char *format, ...); 33 //void Warning(char *format, ...); 15 #include "nrc_os_config.h" 16 #include "nrtype.h" 34 17 35 18 /* … … 39 22 */ 40 23 41 // do: allocate a float vector with subscript range v[nl..nh] 24 #define type_vector(t) \ 25 t * short_name(t,,vector)(int32_t nl, int32_t nh) 42 26 43 //IMAGE_EXPORT(byte*) bvector(long nl, long nh); 44 IMAGE_EXPORT(sint8*) si8vector(long nl, long nh); 45 IMAGE_EXPORT(uint8*) ui8vector(long nl, long nh); 46 IMAGE_EXPORT(sint16*) si16vector(long nl, long nh); 47 IMAGE_EXPORT(uint16*) ui16vector(long nl, long nh); 48 IMAGE_EXPORT(sint32*) si32vector(long nl, long nh); 49 IMAGE_EXPORT(uint32*) ui32vector(long nl, long nh); 50 IMAGE_EXPORT(sint64*) si64vector(long nl, long nh); 51 IMAGE_EXPORT(uint64*) ui64vector(long nl, long nh); 27 type_vector(int8_t); 28 type_vector(uint8_t); 29 type_vector(int16_t); 30 type_vector(uint16_t); 31 type_vector(int32_t); 32 type_vector(uint32_t); 33 type_vector(int64_t); 34 type_vector(uint64_t); 35 type_vector(float); 36 type_vector(double); 37 type_vector(rgb8); 38 type_vector(rgbx8); 39 type_vector(rgb32); 40 type_vector(void_p); 52 41 53 IMAGE_EXPORT(float32*) f32vector(long nl, long nh);54 IMAGE_EXPORT(float64*) f64vector(long nl, long nh);55 42 56 IMAGE_EXPORT(rgb8*) rgb8vector(long nl, long nh);57 IMAGE_EXPORT(rgbx8*) rgbx8vector(long nl, long nh);58 IMAGE_EXPORT(rgb32*) rgb32vector(long nl, long nh);59 43 60 IMAGE_EXPORT(void**) vvector(long nl, long nh); 44 #if TARGET_OS == GIETVM 45 #define remote_type_vector(t) \ 46 t * short_name(t,remote_,vector)(int32_t nl, int32_t nh, int32_t x, int32_t y) 47 48 remote_type_vector(int8_t); 49 remote_type_vector(uint8_t); 50 remote_type_vector(int16_t); 51 remote_type_vector(uint16_t); 52 remote_type_vector(int32_t); 53 remote_type_vector(uint32_t); 54 remote_type_vector(int64_t); 55 remote_type_vector(uint64_t); 56 remote_type_vector(float); 57 remote_type_vector(double); 58 remote_type_vector(rgb8); 59 remote_type_vector(rgbx8); 60 remote_type_vector(rgb32); 61 remote_type_vector(void_p); 62 63 //void ** remote_vvector(long nl, long nh, int x, int y); 64 #endif 65 66 #define type_vector0(t) \ 67 t * short_name(t,,vector0)(int32_t nl, int32_t nh) 68 69 type_vector0(int8_t); 70 type_vector0(uint8_t); 71 type_vector0(int16_t); 72 type_vector0(uint16_t); 73 type_vector0(int32_t); 74 type_vector0(uint32_t); 75 type_vector0(int64_t); 76 type_vector0(uint64_t); 77 type_vector0(float); 78 type_vector0(double); 79 type_vector0(rgb8); 80 type_vector0(rgbx8); 81 type_vector0(rgb32); 82 type_vector0(void_p); 83 84 #define realloc_type_vector(t) \ 85 t * short_name(t,realloc_,vector)(t * v, int32_t nl, int32_t nh) 86 87 realloc_type_vector(int8_t); 88 realloc_type_vector(uint8_t); 89 realloc_type_vector(int16_t); 90 realloc_type_vector(uint16_t); 91 realloc_type_vector(int32_t); 92 realloc_type_vector(uint32_t); 93 realloc_type_vector(int64_t); 94 realloc_type_vector(uint64_t); 95 realloc_type_vector(float); 96 realloc_type_vector(double); 97 realloc_type_vector(rgb8); 98 realloc_type_vector(rgbx8); 99 realloc_type_vector(rgb32); 100 realloc_type_vector(void_p); 101 102 103 #define free_type_vector(t) \ 104 void short_name(t,free_,vector)(t * v, long nl, long nh) 105 106 free_type_vector(int8_t); 107 free_type_vector(uint8_t); 108 free_type_vector(int16_t); 109 free_type_vector(uint16_t); 110 free_type_vector(int32_t); 111 free_type_vector(uint32_t); 112 free_type_vector(int64_t); 113 free_type_vector(uint64_t); 114 free_type_vector(float); 115 free_type_vector(double); 116 free_type_vector(rgb8); 117 free_type_vector(rgbx8); 118 free_type_vector(rgb32); 119 free_type_vector(void_p); 120 121 61 122 62 123 /* 63 * --------------- 64 * --- vector0 --- 65 * --------------- 66 */ 67 68 // do: allocate a vector and set it to 0 69 70 //IMAGE_EXPORT(byte*) bvector0(long nl, long nh); 71 IMAGE_EXPORT(sint8*) si8vector0(long nl, long nh); 72 IMAGE_EXPORT(uint8*) ui8vector0(long nl, long nh); 73 IMAGE_EXPORT(sint16*) si16vector0(long nl, long nh); 74 IMAGE_EXPORT(uint16*) ui16vector0(long nl, long nh); 75 IMAGE_EXPORT(sint32*) si32vector0(long nl, long nh); 76 IMAGE_EXPORT(uint32*) ui32vector0(long nl, long nh); 77 78 IMAGE_EXPORT(float32*) f32vector0(long nl, long nh); 79 IMAGE_EXPORT(float64*) f64vector0(long nl, long nh); 80 81 IMAGE_EXPORT(rgb8*) rgb8vector0(long nl, long nh); 82 IMAGE_EXPORT(rgbx8*) rgbx8vector0(long nl, long nh); 83 IMAGE_EXPORT(rgb32*) rgb32vector0(long nl, long nh); 84 85 IMAGE_EXPORT(void**) vvector0(long nl, long nh); 86 /* 87 * ---------------------- 88 * --- realloc_vector --- 89 * ---------------------- 90 */ 91 92 // realloc a vector to [nl..nh] 93 IMAGE_EXPORT(void**) realloc_vvector(void **v, long nl, long nh); 94 95 /* 96 * ------------------- 97 * --- free_vector --- 98 * ------------------- 99 */ 100 101 //IMAGE_EXPORT(void) free_bvector (byte *v, long nl, long nh); 102 IMAGE_EXPORT(void) free_si8vector (sint8 *v, long nl, long nh); 103 IMAGE_EXPORT(void) free_ui8vector (uint8 *v, long nl, long nh); 104 IMAGE_EXPORT(void) free_si16vector (sint16 *v, long nl, long nh); 105 IMAGE_EXPORT(void) free_ui16vector (uint16 *v, long nl, long nh); 106 IMAGE_EXPORT(void) free_si32vector (sint32 *v, long nl, long nh); 107 IMAGE_EXPORT(void) free_ui32vector (uint32 *v, long nl, long nh); 108 IMAGE_EXPORT(void) free_si64vector (sint64 *v, long nl, long nh); 109 IMAGE_EXPORT(void) free_ui64vector (uint64 *v, long nl, long nh); 110 111 IMAGE_EXPORT(void) free_f32vector (float32 *v, long nl, long nh); 112 IMAGE_EXPORT(void) free_f64vector (float64 *v, long nl, long nh); 113 114 IMAGE_EXPORT(void) free_rgb8vector (rgb8 *v, long nl, long nh); 115 IMAGE_EXPORT(void) free_rgbx8vector(rgbx8 *v, long nl, long nh); 116 IMAGE_EXPORT(void) free_rgb32vector(rgb32 *v, long nl, long nh); 117 118 IMAGE_EXPORT(void) free_vvector (void **v, long nl, long nh); 119 120 #ifdef __cplusplus 121 } 122 #endif 124 void ** vvector(long nl, long nh); 125 void ** vvector0(long nl, long nh); 126 void ** realloc_vvector(void ** v, long nl, long nh); 127 void free_vvector(void ** v, long nl, long nh); 128 */ 123 129 124 130 #endif /* __NRALLOC1_H__ */ 131 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nralloc2.h
r772 r821 16 16 #define __NRALLOC2_H__ 17 17 18 #ifdef __cplusplus 19 #pragma message ("C++") 20 extern "C" { 21 #endif 22 23 #ifdef VERBOSE_PRAGMA 24 //#pragma message ("- *** include nralloc2.h ***") 25 #endif 18 #include "nrc_os_config.h" 26 19 27 20 /* … … 31 24 */ 32 25 33 IMAGE_EXPORT(sint8**) si8matrix(long nrl, long nrh, long ncl, long nch);34 IMAGE_EXPORT(uint8**) ui8matrix(long nrl, long nrh, long ncl, long nch);35 IMAGE_EXPORT(sint16**) si16matrix(long nrl, long nrh, long ncl, long nch);36 IMAGE_EXPORT(uint16**) ui16matrix(long nrl, long nrh, long ncl, long nch);37 IMAGE_EXPORT(sint32**) si32matrix(long nrl, long nrh, long ncl, long nch);38 IMAGE_EXPORT(uint32**) ui32matrix(long nrl, long nrh, long ncl, long nch);39 IMAGE_EXPORT(sint64**) si64matrix(long nrl, long nrh, long ncl, long nch);40 IMAGE_EXPORT(uint64**) ui64matrix(long nrl, long nrh, long ncl, long nch);41 26 42 IMAGE_EXPORT(float32**) f32matrix(long nrl, long nrh, long ncl, long nch); 43 IMAGE_EXPORT(float64**) f64matrix(long nrl, long nrh, long ncl, long nch); 27 #undef type_matrix 28 #define type_matrix(t) \ 29 t ** short_name(t,,matrix)(int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) 44 30 45 IMAGE_EXPORT(complex32**) c32matrix(long nrl, long nrh, long ncl, long nch);46 IMAGE_EXPORT(complex64**) c64matrix(long nrl, long nrh, long ncl, long nch);47 31 48 IMAGE_EXPORT(rgb8**) rgb8matrix(long nrl, long nrh, long ncl, long nch); 49 IMAGE_EXPORT(rgbx8**) rgbx8matrix(long nrl, long nrh, long ncl, long nch); 50 //IMAGE_EXPORT(rgb32**) rgb32matrix(long nrl, long nrh, long ncl, long nch); 51 //IMAGE_EXPORT(rgbx32**) rgbx32matrix(long nrl, long nrh, long ncl, long nch); 32 type_matrix(int8_t); 33 type_matrix(uint8_t); 34 type_matrix(int16_t); 35 type_matrix(uint16_t); 36 type_matrix(int32_t); 37 type_matrix(uint32_t); 38 type_matrix(int64_t); 39 type_matrix(uint64_t); 40 type_matrix(float); 41 type_matrix(double); 42 type_matrix(void_p); 43 type_matrix(rgb8); 44 type_matrix(rgbx8); 45 type_matrix(rgb32); 46 type_matrix(rgbx32); 47 type_matrix(complex32); 48 type_matrix(complex64); 52 49 53 /*54 * ---------------55 * --- matrix0 ---56 * ---------------57 */58 50 59 IMAGE_EXPORT(sint8**) si8matrix0(long nrl, long nrh, long ncl, long nch); 60 IMAGE_EXPORT(uint8**) ui8matrix0(long nrl, long nrh, long ncl, long nch); 61 IMAGE_EXPORT(sint16**) si16matrix0(long nrl, long nrh, long ncl, long nch); 62 IMAGE_EXPORT(uint16**) ui16matrix0(long nrl, long nrh, long ncl, long nch); 63 IMAGE_EXPORT(sint32**) i32matrix0(long nrl, long nrh, long ncl, long nch); 64 IMAGE_EXPORT(uint32**) ui32matrix0(long nrl, long nrh, long ncl, long nch); 65 IMAGE_EXPORT(sint64**) si64matrix0(long nrl, long nrh, long ncl, long nch); 66 IMAGE_EXPORT(uint64**) ui64matrix0(long nrl, long nrh, long ncl, long nch); 67 IMAGE_EXPORT(rgb8**) rgb8matrix0(long nrl, long nrh, long ncl, long nch); 68 IMAGE_EXPORT(rgbx8**) rgbx8matrix0(long nrl, long nrh, long ncl, long nch); 69 IMAGE_EXPORT(rgb32**) rgb32matrix0(long nrl, long nrh, long ncl, long nch); 70 IMAGE_EXPORT(rgbx32**) rgbx32matrix0(long nrl, long nrh, long ncl, long nch); 51 #undef type_matrix0 52 #define type_matrix0(t) \ 53 t ** short_name(t,,matrix0)(int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) 71 54 72 IMAGE_EXPORT(float32**) f32matrix0(long nrl, long nrh, long ncl, long nch);73 IMAGE_EXPORT(float64**) f64matrix0(long nrl, long nrh, long ncl, long nch);74 55 75 /* 76 * ------------------- 77 * --- free_matrix --- 78 * ------------------- 79 */ 56 type_matrix0(int8_t); 57 type_matrix0(uint8_t); 58 type_matrix0(int16_t); 59 type_matrix0(uint16_t); 60 type_matrix0(int32_t); 61 type_matrix0(uint32_t); 62 type_matrix0(int64_t); 63 type_matrix0(uint64_t); 64 type_matrix0(float); 65 type_matrix0(double); 66 type_matrix0(void_p); 67 type_matrix0(rgb8); 68 type_matrix0(rgbx8); 69 type_matrix0(rgb32); 70 type_matrix0(rgbx32); 71 type_matrix0(complex32); 72 type_matrix0(complex64); 80 73 81 IMAGE_EXPORT(void) free_si8matrix (sint8 **m, long nrl, long nrh, long ncl, long nch);82 IMAGE_EXPORT(void) free_ui8matrix (uint8 **m, long nrl, long nrh, long ncl, long nch);83 IMAGE_EXPORT(void) free_si16matrix (sint16 **m, long nrl, long nrh, long ncl, long nch);84 IMAGE_EXPORT(void) free_ui16matrix (uint16 **m, long nrl, long nrh, long ncl, long nch);85 IMAGE_EXPORT(void) free_si32matrix (sint32 **m, long nrl, long nrh, long ncl, long nch);86 IMAGE_EXPORT(void) free_ui32matrix (uint32 **m, long nrl, long nrh, long ncl, long nch);87 IMAGE_EXPORT(void) free_si64matrix (sint64 **m, long nrl, long nrh, long ncl, long nch);88 IMAGE_EXPORT(void) free_ui64matrix (uint64 **m, long nrl, long nrh, long ncl, long nch);89 74 90 IMAGE_EXPORT(void) free_f32matrix (float32 **m, long nrl, long nrh, long ncl, long nch); 91 IMAGE_EXPORT(void) free_f64matrix (float64 **m, long nrl, long nrh, long ncl, long nch); 92 IMAGE_EXPORT(void) free_c32matrix (complex32 **m, long nrl, long nrh, long ncl, long nch); 93 IMAGE_EXPORT(void) free_c64matrix (complex64 **m, long nrl, long nrh, long ncl, long nch); 75 #if TARGET_OS == GIETVM 94 76 95 IMAGE_EXPORT(void) free_rgb8matrix (rgb8 **m, long nrl, long nrh, long ncl, long nch); 96 IMAGE_EXPORT(void) free_rgbx8matrix (rgbx8 **m, long nrl, long nrh, long ncl, long nch); 97 IMAGE_EXPORT(void) free_rgb32matrix (rgb32 **m, long nrl, long nrh, long ncl, long nch); 98 IMAGE_EXPORT(void) free_rgbx32matrix(rgbx32 **m, long nrl, long nrh, long ncl, long nch); 77 #undef remote_type_matrix 78 #define remote_type_matrix(t) \ 79 t ** short_name(t,remote_,matrix)(int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) 99 80 100 #ifdef __cplusplus 101 } 81 remote_type_matrix(int8_t); 82 remote_type_matrix(uint8_t); 83 remote_type_matrix(int16_t); 84 remote_type_matrix(uint16_t); 85 remote_type_matrix(int32_t); 86 remote_type_matrix(uint32_t); 87 remote_type_matrix(int64_t); 88 remote_type_matrix(uint64_t); 89 remote_type_matrix(float); 90 remote_type_matrix(double); 91 remote_type_matrix(void_p); 92 remote_type_matrix(rgb8); 93 remote_type_matrix(rgbx8); 94 remote_type_matrix(rgb32); 95 remote_type_matrix(rgbx32); 96 remote_type_matrix(complex32); 97 remote_type_matrix(complex64); 98 102 99 #endif 103 100 101 102 #undef free_type_matrix 103 #define free_type_matrix(t) \ 104 void short_name(t,free_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) 105 106 free_type_matrix(int8_t); 107 free_type_matrix(uint8_t); 108 free_type_matrix(int16_t); 109 free_type_matrix(uint16_t); 110 free_type_matrix(int32_t); 111 free_type_matrix(uint32_t); 112 free_type_matrix(int64_t); 113 free_type_matrix(uint64_t); 114 free_type_matrix(float); 115 free_type_matrix(double); 116 free_type_matrix(void_p); 117 free_type_matrix(rgb8); 118 free_type_matrix(rgbx8); 119 free_type_matrix(rgb32); 120 free_type_matrix(rgbx32); 121 free_type_matrix(complex32); 122 free_type_matrix(complex64); 123 124 104 125 #endif /* __NRALLOC2_H__ */ 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 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 134 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nralloc2x.h
r772 r821 16 16 #define __NRALLOC2X_H__ 17 17 18 #ifdef __cplusplus19 #pragma message ("C++")20 extern "C" {21 #endif22 23 #ifdef VERBOSE_PRAGMA24 //#pragma message ("- *** include nralloc2x.h ***")25 #endif26 18 19 #include "nrc_os_config.h" 27 20 #include "nrtype.h" 28 21 #include "nrtypex.h" 29 22 30 /* ---------------------------------- */31 /* --- composite user type matrix --- */32 /* ---------------------------------- */33 34 IMAGE_EXPORT(si16Point**) si16Pmatrix(long nrl, long nrh, long ncl, long nch);35 IMAGE_EXPORT(ui16Point**) ui16Pmatrix(long nrl, long nrh, long ncl, long nch);36 IMAGE_EXPORT(si32Point**) si32Pmatrix(long nrl, long nrh, long ncl, long nch);37 IMAGE_EXPORT(ui32Point**) ui32Pmatrix(long nrl, long nrh, long ncl, long nch);38 IMAGE_EXPORT(f32Point**) f32Pmatrix(long nrl, long nrh, long ncl, long nch);39 40 IMAGE_EXPORT(si16Triplet**) si16Tmatrix(long nrl, long nrh, long ncl, long nch);41 IMAGE_EXPORT(ui16Triplet**) ui16Tmatrix(long nrl, long nrh, long ncl, long nch);42 IMAGE_EXPORT(si32Triplet**) si32Tmatrix(long nrl, long nrh, long ncl, long nch);43 IMAGE_EXPORT(ui32Triplet**) ui32Tmatrix(long nrl, long nrh, long ncl, long nch);44 IMAGE_EXPORT(f32Triplet**) f32Tmatrix(long nrl, long nrh, long ncl, long nch);45 46 IMAGE_EXPORT(void) free_si16Pmatrix(si16Point **m, long nrl, long nrh, long ncl, long nch);47 IMAGE_EXPORT(void) free_ui16Pmatrix(ui16Point **m, long nrl, long nrh, long ncl, long nch);48 IMAGE_EXPORT(void) free_si32Pmatrix(si32Point **m, long nrl, long nrh, long ncl, long nch);49 IMAGE_EXPORT(void) free_ui32Pmatrix(ui32Point **m, long nrl, long nrh, long ncl, long nch);50 IMAGE_EXPORT(void) free_f32Pmatrix(f32Point **m, long nrl, long nrh, long ncl, long nch);51 52 IMAGE_EXPORT(void) free_si16Tmatrix(si16Triplet **m, long nrl, long nrh, long ncl, long nch);53 IMAGE_EXPORT(void) free_ui16Tmatrix(ui16Triplet **m, long nrl, long nrh, long ncl, long nch);54 IMAGE_EXPORT(void) free_si32Tmatrix(si32Triplet **m, long nrl, long nrh, long ncl, long nch);55 IMAGE_EXPORT(void) free_ui32Tmatrix(ui32Triplet **m, long nrl, long nrh, long ncl, long nch);56 IMAGE_EXPORT(void) free_f32Tmatrix ( f32Triplet **m, long nrl, long nrh, long ncl, long nch);57 23 58 24 /* ----------------- */ … … 60 26 /* ----------------- */ 61 27 62 IMAGE_EXPORT(byte**) btrimatrix(long nrl, long nrh, long ncl, long nch, long step); 63 IMAGE_EXPORT(sint16**) si16trimatrix(long nrl, long nrh, long ncl, long nch, long step); 64 IMAGE_EXPORT(uint16**) ui16trimatrix(long nrl, long nrh, long ncl, long nch, long step); 65 IMAGE_EXPORT(sint32**) si32trimatrix(long nrl, long nrh, long ncl, long nch, long step); 66 IMAGE_EXPORT(uint32**) ui32trimatrix(long nrl, long nrh, long ncl, long nch, long step); 67 IMAGE_EXPORT(float32**) f32trimatrix(long nrl, long nrh, long ncl, long nch, long step); 68 IMAGE_EXPORT(float64**) f64trimatrix(long nrl, long nrh, long ncl, long nch, long step); 28 #define type_trimatrix(t) \ 29 t ** short_name(t,,trimatrix)(int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, int32_t step) 69 30 70 #ifdef __cplusplus 71 } 72 #endif 31 type_trimatrix(int8_t); 32 type_trimatrix(uint8_t); 33 type_trimatrix(int16_t); 34 type_trimatrix(uint16_t); 35 type_trimatrix(int32_t); 36 type_trimatrix(uint32_t); 37 type_trimatrix(float); 38 type_trimatrix(double); 39 73 40 74 41 #endif /* __NRALLOC2X_H__ */ 42 43 // Local Variables: 44 // tab-width: 4 45 // c-basic-offset: 4 46 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 47 // indent-tabs-mode: nil 48 // End: 49 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 50 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nralloc3.h
r772 r821 13 13 #define __NRALLOC3_H__ 14 14 15 #ifdef __cplusplus 16 #pragma message ("C++") 17 extern "C" { 18 #endif 19 20 #ifdef VERBOSE_PRAGMA 21 //#pragma message ("- *** include nralloc3.h ***") 22 #endif 15 #include "nrc_os_config.h" 23 16 24 double*** d3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh); 25 void free_d3tensor(double ***t,long nrl,long nrh,long ncl,long nch,long ndl,long ndh); 17 //double*** d3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh); 18 //void free_d3tensor(double ***t,long nrl,long nrh,long ncl,long nch,long ndl,long ndh); 19 20 #define type_cube(t) \ 21 t *** short_name(t,,cube)(int32_t ndl, int32_t ndh, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ 26 22 27 23 24 type_cube(int8_t); 25 type_cube(uint8_t); 26 type_cube(int16_t); 27 type_cube(uint16_t); 28 type_cube(int32_t); 29 type_cube(uint32_t); 30 type_cube(int64_t); 31 type_cube(uint64_t); 32 type_cube(float); 33 type_cube(double); 34 type_cube(rgb8); 35 type_cube(rgbx8); 28 36 29 IMAGE_EXPORT(sint8***) si8cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch); 30 IMAGE_EXPORT(uint8***) ui8cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch); 31 IMAGE_EXPORT(sint16***) si16cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch); 32 IMAGE_EXPORT(uint16***) ui16cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch); 33 IMAGE_EXPORT(sint32***) si32cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch); 34 IMAGE_EXPORT(uint32***) ui32cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch); 35 IMAGE_EXPORT(float32***) f32cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch); 36 IMAGE_EXPORT(float64***) f64cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch); 37 IMAGE_EXPORT(rgb8***) rgb8cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch); 38 IMAGE_EXPORT(rgbx8***) rgbx8cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch); 37 #define free_type_cube(t) \ 38 void short_name(t,free_,cube)(t *** c, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, int32_t ndl, int32_t ndh) \ 39 39 40 IMAGE_EXPORT(void) free_si8cube (sint8 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh); 41 IMAGE_EXPORT(void) free_ui8cube (uint8 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh); 42 IMAGE_EXPORT(void) free_si16cube (sint16 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh); 43 IMAGE_EXPORT(void) free_ui16cube (uint16 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh); 44 IMAGE_EXPORT(void) free_si32cube (sint32 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh); 45 IMAGE_EXPORT(void) free_ui32cube (uint32 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh); 46 IMAGE_EXPORT(void) free_f32cube (float32 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh); 47 IMAGE_EXPORT(void) free_f64cube (float64 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh); 48 IMAGE_EXPORT(void) free_rgb8cube (rgb8 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh); 49 IMAGE_EXPORT(void) free_rgbx8cube(rgbx8 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh); 40 free_type_cube(int8_t); 41 free_type_cube(uint8_t); 42 free_type_cube(int16_t); 43 free_type_cube(uint16_t); 44 free_type_cube(int32_t); 45 free_type_cube(uint32_t); 46 free_type_cube(int64_t); 47 free_type_cube(uint64_t); 48 free_type_cube(float); 49 free_type_cube(double); 50 free_type_cube(rgb8); 51 free_type_cube(rgbx8); 50 52 51 #ifdef __cplusplus52 }53 #endif54 53 55 54 #endif /* __NRALLOC3_H__ */ 55 56 // Local Variables: 57 // tab-width: 4 58 // c-basic-offset: 4 59 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 60 // indent-tabs-mode: nil 61 // End: 62 63 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 64 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrarith0.h
r772 r821 11 11 #define __NRARITH0_H__ 12 12 13 #ifdef __cplusplus14 #pragma message ("C++")15 extern "C" {16 #endif17 18 #ifdef VERBOSE_PRAGMA19 //#pragma message(" -include nrarith0.h")20 #endif21 22 13 /* ---------- */ 23 14 /* -- Swap -- */ 24 15 /* ---------- */ 25 16 26 ROUTINE(void) i8swap(int8 *a, int8 *b); 27 ROUTINE(void) i16swap(int16 *a, int16 *b); 28 ROUTINE(void) i32swap(int32 *a, int32 *b); 29 ROUTINE(void) i64swap(int64 *a, int64 *b); 30 ROUTINE(void) f32swap(float32 *a, float32 *b); 31 ROUTINE(void) f64swap(float64 *a, float64 *b); 32 ROUTINE(void) rgb8swap(rgb8 *a, rgb8 *b); 33 ROUTINE(void) rgbx8swap(rgbx8 *a, rgbx8 *b); 17 #define type_swap(t) \ 18 void short_name(t,,swap)(t * a, t * b) 19 20 type_swap(int8_t); 21 type_swap(int16_t); 22 type_swap(int32_t); 23 type_swap(int64_t); 24 type_swap(float); 25 type_swap(double); 26 type_swap(rgb8); 27 type_swap(rgbx8); 28 34 29 35 30 /* --------- */ … … 37 32 /* --------- */ 38 33 39 ROUTINE(float32) f32min (float32 x1, float32 x2); 40 ROUTINE(float32) f32min2(float32 x1, float32 x2); 41 ROUTINE(float32) f32min3(float32 x1, float32 x2, float32 x3); 42 ROUTINE(float32) f32min4(float32 x1, float32 x2, float32 x3, float32 x4); 43 ROUTINE(float32) f32min5(float32 x1, float32 x2, float32 x3, float32 x4, float32 x5); 34 #define type_min(t) \ 35 t short_name(t,,min)(t x1, t x2); \ 36 t short_name(t,,min2)(t x1, t x2); \ 37 t short_name(t,,min3)(t x1, t x2, t x3); \ 38 t short_name(t,,min4)(t x1, t x2, t x3, t x4); \ 39 t short_name(t,,min5)(t x1, t x2, t x3, t x4, t x5) \ 44 40 45 ROUTINE(float64) f64min (float64 x1, float64 x2); 46 ROUTINE(float64) f64min2(float64 x1, float64 x2); 47 ROUTINE(float64) f64min3(float64 x1, float64 x2, float64 x3); 48 ROUTINE(float64) f64min4(float64 x1, float64 x2, float64 x3, float64 x4); 49 ROUTINE(float64) f64min5(float64 x1, float64 x2, float64 x3, float64 x4, float64 x5); 41 type_min(float); 42 type_min(double); 43 type_min(int8_t); 44 type_min(uint8_t); 45 type_min(int16_t); 46 type_min(uint16_t); 47 type_min(int32_t); 48 type_min(uint32_t); 49 type_min(rgb8); 50 50 51 ROUTINE(byte) bmin (byte x1, byte x2);52 ROUTINE(byte) bmin2(byte x1, byte x2);53 ROUTINE(byte) bmin3(byte x1, byte x2, byte x3);54 ROUTINE(byte) bmin4(byte x1, byte x2, byte x3, byte x4);55 ROUTINE(byte) bmin5(byte x1, byte x2, byte x3, byte x4, byte x5);56 57 ROUTINE(uint16) ui16min (uint16 x1, uint16 x2);58 ROUTINE(uint16) ui16min2(uint16 x1, uint16 x2);59 ROUTINE(uint16) ui16min3(uint16 x1, uint16 x2, uint16 x3);60 ROUTINE(uint16) ui16min4(uint16 x1, uint16 x2, uint16 x3, uint16 x4);61 ROUTINE(uint16) ui16min5(uint16 x1, uint16 x2, uint16 x3, uint16 x4, uint16 x5);62 63 ROUTINE(int32) i32min (int32 x1, int32 x2);64 ROUTINE(int32) i32min2(int32 x1, int32 x2);65 ROUTINE(int32) i32min3(int32 x1, int32 x2, int32 x3);66 ROUTINE(int32) i32min4(int32 x1, int32 x2, int32 x3, int32 x4);67 ROUTINE(int32) i32min5(int32 x1, int32 x2, int32 x3, int32 x4, int32 x5);68 69 ROUTINE(rgb8) rgb8min (rgb8 x1, rgb8 x2);70 ROUTINE(rgb8) rgb8min2(rgb8 x1, rgb8 x2);71 ROUTINE(rgb8) rgb8min3(rgb8 x1, rgb8 x2, rgb8 x3);72 ROUTINE(rgb8) rgb8min4(rgb8 x1, rgb8 x2, rgb8 x3, rgb8 x4);73 ROUTINE(rgb8) rgb8min5(rgb8 x1, rgb8 x2, rgb8 x3, rgb8 x4, rgb8 x5);74 51 75 52 /* --------- */ 76 53 /* -- Max -- */ 77 54 /* --------- */ 78 ROUTINE(float32) f32max (float32 x1, float32 x2);79 ROUTINE(float32) f32max2(float32 x1, float32 x2);80 ROUTINE(float32) f32max3(float32 x1, float32 x2, float32 x3);81 ROUTINE(float32) f32max4(float32 x1, float32 x2, float32 x3, float32 x4);82 ROUTINE(float32) f32max5(float32 x1, float32 x2, float32 x3, float32 x4, float32 x5);83 55 84 ROUTINE(float64) f64max (float64 x1, float64 x2); 85 ROUTINE(float64) f64max2(float64 x1, float64 x2); 86 ROUTINE(float64) f64max3(float64 x1, float64 x2, float64 x3); 87 ROUTINE(float64) f64max4(float64 x1, float64 x2, float64 x3, float64 x4); 88 ROUTINE(float64) f64max5(float64 x1, float64 x2, float64 x3, float64 x4, float64 x5); 56 #define type_max(t) \ 57 t short_name(t,,max)(t x1, t x2); \ 58 t short_name(t,,max2)(t x1, t x2); \ 59 t short_name(t,,max3)(t x1, t x2, t x3); \ 60 t short_name(t,,max4)(t x1, t x2, t x3, t x4); \ 61 t short_name(t,,max5)(t x1, t x2, t x3, t x4, t x5) \ 89 62 90 ROUTINE(byte) bmax (byte x1, byte x2); 91 ROUTINE(byte) bmax2(byte x1, byte x2); 92 ROUTINE(byte) bmax3(byte x1, byte x2, byte x3); 93 ROUTINE(byte) bmax4(byte x1, byte x2, byte x3, byte x4); 94 ROUTINE(byte) bmax5(byte x1, byte x2, byte x3, byte x4, byte x5); 63 type_max(float); 64 type_max(double); 65 type_max(int8_t); 66 type_max(uint8_t); 67 type_max(int16_t); 68 type_max(uint16_t); 69 type_max(int32_t); 70 type_max(uint32_t); 71 type_max(rgb8); 95 72 96 ROUTINE(uint16) ui16max (uint16 x1, uint16 x2);97 ROUTINE(uint16) ui16max2(uint16 x1, uint16 x2);98 ROUTINE(uint16) ui16max3(uint16 x1, uint16 x2, uint16 x3);99 ROUTINE(uint16) ui16max4(uint16 x1, uint16 x2, uint16 x3, uint16 x4);100 ROUTINE(uint16) ui16max5(uint16 x1, uint16 x2, uint16 x3, uint16 x4, uint16 x5);101 102 ROUTINE(int32) i32max (int32 x1, int32 x2);103 ROUTINE(int32) i32max2(int32 x1, int32 x2);104 ROUTINE(int32) i32max3(int32 x1, int32 x2, int32 x3);105 ROUTINE(int32) i32max4(int32 x1, int32 x2, int32 x3, int32 x4);106 ROUTINE(int32) i32max5(int32 x1, int32 x2, int32 x3, int32 x4, int32 x5);107 108 ROUTINE(rgb8) rgb8max (rgb8 x1, rgb8 x2);109 ROUTINE(rgb8) rgb8max2(rgb8 x1, rgb8 x2);110 ROUTINE(rgb8) rgb8max3(rgb8 x1, rgb8 x2, rgb8 x3);111 ROUTINE(rgb8) rgb8max4(rgb8 x1, rgb8 x2, rgb8 x3, rgb8 x4);112 ROUTINE(rgb8) rgb8max5(rgb8 x1, rgb8 x2, rgb8 x3, rgb8 x4, rgb8 x5);113 73 114 74 /* ----------- */ … … 116 76 /* ----------- */ 117 77 118 ROUTINE(byte) ibit(int32 x, int n);119 ROUTINE(int32) sym_int32(int32x);120 ROUTINE(int) myLog2(int x);121 ROUTINE(int) next_power2(int x);122 ROUTINE(int) myGCD(int u, int v);123 ROUTINE(int) myLCM(int u, int v);78 int32_t i32bit(int32_t x, int32_t n); 79 int32_t sym_int32(int32_t x); 80 int32_t myLog2(int32_t x); 81 int32_t next_power2(int32_t x); 82 int32_t myGCD(int32_t u, int32_t v); 83 int32_t myLCM(int32_t u, int32_t v); 124 84 125 #ifdef __cplusplus126 }127 85 #endif 128 86 129 #else 130 //#pragma message(" Warning : attempt to re-include nrarith0.h") 131 #endif 87 // Local Variables: 88 // tab-width: 4 89 // c-basic-offset: 4 90 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 91 // indent-tabs-mode: nil 92 // End: 132 93 94 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 95 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrarith1.h
r772 r821 11 11 #define _NRARITH1_H_ 12 12 13 #ifdef __cplusplus 14 #ifdef PRAGMA_VERBOSE 15 #pragma message ("C++") 16 #endif 17 extern "C" { 18 #endif 19 20 #ifdef PRAGMA_VERBOSE 21 //#pragma message("- include nrarith1.h") 22 #endif 23 24 /* ======================================================================== */ 25 /* === Beta reduction ===================================================== */ 26 /* ======================================================================== */ 27 28 IMAGE_EXPORT(int32) sum_bvector (byte *v, long nl, long nh); 29 IMAGE_EXPORT(int32) sum_si16vector (sint16 *v, long nl, long nh); 30 IMAGE_EXPORT(int32) sum_si32vector (sint32 *v, long nl, long nh); 31 IMAGE_EXPORT(float) sum_f32vector (float32 *v, long nl, long nh); 32 33 // ================== 34 // === min_vector === 35 // ================== 36 37 IMAGE_EXPORT(sint8) min_si8vector (sint8 *v, long nl, long nh); 38 IMAGE_EXPORT(uint8) min_ui8vector (uint8 *v, long nl, long nh); 39 IMAGE_EXPORT(sint16) min_si16vector (sint16 *v, long nl, long nh); 40 IMAGE_EXPORT(uint16) min_ui16vector (uint16 *v, long nl, long nh); 41 IMAGE_EXPORT(sint32) min_si32vector (sint32 *v, long nl, long nh); 42 IMAGE_EXPORT(uint32) min_ui32vector (uint32 *v, long nl, long nh); 43 IMAGE_EXPORT(float32) min_f32vector (float32 *v, long nl, long nh); 44 IMAGE_EXPORT(float64) min_f64vector (float64 *v, long nl, long nh); 45 46 // ================== 47 // === max_vector === 48 // ================== 49 50 IMAGE_EXPORT(sint8) max_si8vector (sint8 *v, long nl, long nh); 51 IMAGE_EXPORT(uint8) max_ui8vector (uint8 *v, long nl, long nh); 52 IMAGE_EXPORT(sint16) max_si16vector (sint16 *v, long nl, long nh); 53 IMAGE_EXPORT(uint16) max_ui16vector (uint16 *v, long nl, long nh); 54 IMAGE_EXPORT(sint32) max_si32vector (sint32 *v, long nl, long nh); 55 IMAGE_EXPORT(uint32) max_ui32vector (uint32 *v, long nl, long nh); 56 57 IMAGE_EXPORT(float32) max_f32vector (float32 *v, long nl, long nh); 58 IMAGE_EXPORT(float64) max_f64vector (float64 *v, long nl, long nh); 59 60 // ====================== 61 // === min_vector_pos === 62 // ====================== 63 64 IMAGE_EXPORT(sint8) min_si8vector_pos (sint8 *v, long nl, long nh, int *pos); 65 IMAGE_EXPORT(uint8) min_ui8vector_pos (uint8 *v, long nl, long nh, int *pos); 66 IMAGE_EXPORT(sint16) min_si16vector_pos (sint16 *v, long nl, long nh, int *pos); 67 IMAGE_EXPORT(uint16) min_ui16vector_pos (uint16 *v, long nl, long nh, int *pos); 68 IMAGE_EXPORT(sint32) min_si32vector_pos (sint32 *v, long nl, long nh, int *pos); 69 IMAGE_EXPORT(uint32) min_ui32vector_pos (uint32 *v, long nl, long nh, int *pos); 70 71 IMAGE_EXPORT(float32)min_f32vector_pos (float32 *v, long nl, long nh, int *pos); 72 IMAGE_EXPORT(float64)min_f64vector_pos (float64 *v, long nl, long nh, int *pos); 73 74 // ====================== 75 // === max_vector_pos === 76 // ====================== 77 78 IMAGE_EXPORT(sint8) max_si8vector_pos (sint8 *v, long nl, long nh, int *pos); 79 IMAGE_EXPORT(uint8) max_ui8vector_pos (uint8 *v, long nl, long nh, int *pos); 80 IMAGE_EXPORT(sint16) max_si16vector_pos (sint16 *v, long nl, long nh, int *pos); 81 IMAGE_EXPORT(uint16) max_ui16vector_pos (uint16 *v, long nl, long nh, int *pos); 82 IMAGE_EXPORT(sint32) max_si32vector_pos (sint32 *v, long nl, long nh, int *pos); 83 IMAGE_EXPORT(uint32) max_ui32vector_pos (uint32 *v, long nl, long nh, int *pos); 84 85 IMAGE_EXPORT(float32)max_f32vector_pos (float32 *v, long nl, long nh, int *pos); 86 IMAGE_EXPORT(float64)max_f64vector_pos (float64 *v, long nl, long nh, int *pos); 13 /* 14 * ------------------ 15 * --- sum_vector --- 16 * ------------------ 17 */ 18 19 #define sum_type_vector(t,r) \ 20 r short_name(t,sum_,vector)(t * v, int32_t nl, int32_t nh) 21 22 sum_type_vector(int8_t, int32_t); 23 sum_type_vector(uint8_t, uint32_t); 24 sum_type_vector(int16_t, int32_t); 25 sum_type_vector(uint16_t, uint32_t); 26 sum_type_vector(int32_t, int32_t); 27 sum_type_vector(uint32_t, uint32_t); 28 sum_type_vector(float, float); 29 sum_type_vector(double, double); 30 31 /* 32 * ------------------ 33 * --- min_vector --- 34 * ------------------ 35 */ 36 37 #define min_type_vector(t) \ 38 t short_name(t,min_,vector)(t * v, int32_t nl, int32_t nh) 39 40 min_type_vector(int8_t); 41 min_type_vector(uint8_t); 42 min_type_vector(int16_t); 43 min_type_vector(uint16_t); 44 min_type_vector(int32_t); 45 min_type_vector(uint32_t); 46 min_type_vector(float); 47 min_type_vector(double); 48 49 50 /* 51 * ------------------ 52 * --- max_vector --- 53 * ------------------ 54 */ 55 56 #define max_type_vector(t) \ 57 t short_name(t,max_,vector)(t * v, int32_t nl, int32_t nh) 58 59 max_type_vector(int8_t); 60 max_type_vector(uint8_t); 61 max_type_vector(int16_t); 62 max_type_vector(uint16_t); 63 max_type_vector(int32_t); 64 max_type_vector(uint32_t); 65 max_type_vector(float); 66 max_type_vector(double); 67 68 69 /* 70 * ---------------------- 71 * --- min_vector_pos --- 72 * ---------------------- 73 */ 74 75 76 #define min_type_vector_pos(t) \ 77 t short_name(t,min_,vector_pos)(t * v, int32_t nl, int32_t nh, int32_t * pos) 78 79 min_type_vector_pos(int8_t); 80 min_type_vector_pos(uint8_t); 81 min_type_vector_pos(int16_t); 82 min_type_vector_pos(uint16_t); 83 min_type_vector_pos(int32_t); 84 min_type_vector_pos(uint32_t); 85 min_type_vector_pos(float); 86 min_type_vector_pos(double); 87 88 89 /* 90 * ---------------------- 91 * --- max_vector_pos --- 92 * ---------------------- 93 */ 94 95 #define max_type_vector_pos(t) \ 96 t short_name(t,max_,vector_pos)(t * v, int32_t nl, int32_t nh, int32_t * pos) 97 98 max_type_vector_pos(int8_t); 99 max_type_vector_pos(uint8_t); 100 max_type_vector_pos(int16_t); 101 max_type_vector_pos(uint16_t); 102 max_type_vector_pos(int32_t); 103 max_type_vector_pos(uint32_t); 104 max_type_vector_pos(float); 105 max_type_vector_pos(double); 106 87 107 88 108 // ============= … … 90 110 // ============= 91 111 92 IMAGE_EXPORT(void) beta_sum_rgb32vector (rgb32 *S,long nl,long nh, rgb32 *D); 93 IMAGE_EXPORT(void) beta_average_rgb32vector(rgb32 *S,long nl,long nh, rgb32 *D); 94 95 IMAGE_EXPORT(void) add_i32vector(int32 *S1, long nl,long nh, int32 *S2, int32 *D); 96 IMAGE_EXPORT(void) sub_i32vector(int32 *S1, long nl,long nh, int32 *S2, int32 *D); 97 98 IMAGE_EXPORT(void) cumulleft_i32vector (int32 *S, long nl, long nh, int32 *D); 99 IMAGE_EXPORT(void) cumulleft_rgb32vector(rgb32 *S, long nl, long nh, rgb32 *D); 100 101 IMAGE_EXPORT(void) cumulright_i32vector (int32 *S, long nl, long nh, int32 *D); 102 IMAGE_EXPORT(void) cumulright_rgb32vector(rgb32 *S, long nl, long nh, rgb32 *D); 103 104 IMAGE_EXPORT(void) mulc_i32vector (int32 *S, long nl, long nh, int32 c, int32 *D); 105 IMAGE_EXPORT(void) mulc_rgb32vector (rgb32 *S, long nl, long nh, int32 c, rgb32 *D); 106 IMAGE_EXPORT(void) divc_i32vector (int32 *S, long nl, long nh, int32 c, int32 *D); 107 IMAGE_EXPORT(void) divc_rgb32vector (rgb32 *S, long nl, long nh, int32 c, rgb32 *D); 108 109 IMAGE_EXPORT(void) mulfrac_i32vector (int32 *S, long nl, long nh, int32 a, int32 b, int32 *D); 110 IMAGE_EXPORT(void) mulfrac_rgb32vector(rgb32 *S, long nl, long nh, int32 a, int32 b, rgb32 *D); 111 112 #ifdef __cplusplus 113 } 114 #endif 112 #define add_type_vector(t) \ 113 void short_name(t,add_,vector)(t * S1, int32_t nl, int32_t nh, t * S2, t * D) 114 115 add_type_vector(int8_t); 116 add_type_vector(uint8_t); 117 add_type_vector(int16_t); 118 add_type_vector(uint16_t); 119 add_type_vector(int32_t); 120 add_type_vector(uint32_t); 121 add_type_vector(float); 122 add_type_vector(double); 123 124 #define sub_type_vector(t) \ 125 void short_name(t,sub_,vector)(t * S1, int32_t nl, int32_t nh, t * S2, t * D) 126 127 sub_type_vector(int8_t); 128 sub_type_vector(uint8_t); 129 sub_type_vector(int16_t); 130 sub_type_vector(uint16_t); 131 sub_type_vector(int32_t); 132 sub_type_vector(uint32_t); 133 sub_type_vector(float); 134 sub_type_vector(double); 135 136 #define mulc_type_vector(t) \ 137 void short_name(t,mulc_,vector)(t * S, int32_t nl, int32_t nh, int32_t c, t * D) 138 139 mulc_type_vector(int8_t); 140 mulc_type_vector(uint8_t); 141 mulc_type_vector(int16_t); 142 mulc_type_vector(uint16_t); 143 mulc_type_vector(int32_t); 144 mulc_type_vector(uint32_t); 145 mulc_type_vector(float); 146 mulc_type_vector(double); 147 148 #define divc_type_vector(t) \ 149 void short_name(t,divc_,vector)(t * S, int32_t nl, int32_t nh, int32_t c, t * D) 150 151 divc_type_vector(int8_t); 152 divc_type_vector(uint8_t); 153 divc_type_vector(int16_t); 154 divc_type_vector(uint16_t); 155 divc_type_vector(int32_t); 156 divc_type_vector(uint32_t); 157 divc_type_vector(float); 158 divc_type_vector(double); 159 160 161 #define cumulleft_type_vector(t) \ 162 void short_name(t,cumulleft_,vector)(t * S, int32_t nl, int32_t nh, int32_t * D) 163 164 cumulleft_type_vector(int8_t); 165 cumulleft_type_vector(uint8_t); 166 cumulleft_type_vector(int16_t); 167 cumulleft_type_vector(uint16_t); 168 cumulleft_type_vector(int32_t); 169 cumulleft_type_vector(uint32_t); 170 cumulleft_type_vector(float); 171 cumulleft_type_vector(double); 172 173 #define cumulright_type_vector(t) \ 174 void short_name(t,cumulright_,vector)(t * S, int32_t nl, int32_t nh, int32_t * D) 175 176 cumulright_type_vector(int8_t); 177 cumulright_type_vector(uint8_t); 178 cumulright_type_vector(int16_t); 179 cumulright_type_vector(uint16_t); 180 cumulright_type_vector(int32_t); 181 cumulright_type_vector(uint32_t); 182 cumulright_type_vector(float); 183 cumulright_type_vector(double); 184 185 186 #define mulfrac_type_vector(t) \ 187 void short_name(t,mulfrac_,vector)(t * S, int32_t nl, int32_t nh, int32_t a, int32_t b, t * D) 188 189 mulfrac_type_vector(int8_t); 190 mulfrac_type_vector(uint8_t); 191 mulfrac_type_vector(int16_t); 192 mulfrac_type_vector(uint16_t); 193 mulfrac_type_vector(int32_t); 194 mulfrac_type_vector(uint32_t); 195 mulfrac_type_vector(float); 196 mulfrac_type_vector(double); 197 198 199 200 void beta_sum_rgb32vector (rgb32 * S, int32_t nl, int32_t nh, rgb32 * D); 201 void beta_average_rgb32vector(rgb32 * S, int32_t nl, int32_t nh, rgb32 * D); 202 void cumulleft_rgb32vector (rgb32 * S, int32_t nl, int32_t nh, rgb32 * D); 203 void cumulright_rgb32vector (rgb32 * S, int32_t nl, int32_t nh, rgb32 * D); 204 void mulc_rgb32vector (rgb32 * S, int32_t nl, int32_t nh, int32 c, rgb32 * D); 205 void divc_rgb32vector (rgb32 * S, int32_t nl, int32_t nh, int32 c, rgb32 * D); 206 void mulfrac_rgb32vector (rgb32 * S, int32_t nl, int32_t nh, int32 a, int32 b, rgb32 * D); 207 115 208 116 209 #endif /* _NRARITH1_H_ */ 210 211 // Local Variables: 212 // tab-width: 4 213 // c-basic-offset: 4 214 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 215 // indent-tabs-mode: nil 216 // End: 217 218 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 219 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrarith2.h
r772 r821 11 11 #define _NRARITH2_H_ 12 12 13 #ifdef __cplusplus 14 #ifdef PRAGMA_VERBOSE 15 #pragma message ("C++") 16 #endif 17 extern "C" { 18 #endif 19 20 #ifdef PRAGMA_VERBOSE 21 //#pragma message("- include nrarith.h") 22 #endif 13 #include "nrc_os_config.h" 23 14 24 15 /* ------------------ */ … … 26 17 /* ------------------ */ 27 18 28 IMAGE_EXPORT(sint8) min_si8matrix (sint8 **m, long nrl,long nrh,long ncl, long nch); 29 IMAGE_EXPORT(uint8) min_ui8matrix (uint8 **m, long nrl,long nrh,long ncl, long nch); 30 IMAGE_EXPORT(sint16) min_si16matrix (sint16 **m, long nrl,long nrh,long ncl, long nch); 31 IMAGE_EXPORT(uint16) min_ui16matrix (uint16 **m, long nrl,long nrh,long ncl, long nch); 32 IMAGE_EXPORT(sint32) min_si32matrix (sint32 **m, long nrl,long nrh,long ncl, long nch); 33 IMAGE_EXPORT(uint32) min_ui32matrix (uint32 **m, long nrl,long nrh,long ncl, long nch); 34 IMAGE_EXPORT(sint64) min_si64matrix (sint64 **m, long nrl,long nrh,long ncl, long nch); 35 IMAGE_EXPORT(uint64) min_ui64matrix (uint64 **m, long nrl,long nrh,long ncl, long nch); 36 IMAGE_EXPORT(float32) min_f32matrix (float32 **m, long nrl,long nrh,long ncl, long nch); 37 IMAGE_EXPORT(float64) min_f64matrix (float64 **m, long nrl,long nrh,long ncl, long nch); 19 #define min_type_matrix(t) \ 20 t short_name(t,min_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) 21 22 min_type_matrix(int8_t); 23 min_type_matrix(uint8_t); 24 min_type_matrix(int16_t); 25 min_type_matrix(uint16_t); 26 min_type_matrix(int32_t); 27 min_type_matrix(uint32_t); 28 min_type_matrix(int64_t); 29 min_type_matrix(uint64_t); 30 min_type_matrix(float); 31 min_type_matrix(double); 32 38 33 39 34 /* ------------------ */ … … 41 36 /* ------------------ */ 42 37 43 IMAGE_EXPORT(sint8) max_si8matrix (sint8 **m, long nrl,long nrh,long ncl, long nch); 44 IMAGE_EXPORT(uint8) max_ui8matrix (uint8 **m, long nrl,long nrh,long ncl, long nch); 45 IMAGE_EXPORT(sint16) max_si16matrix (sint16 **m, long nrl,long nrh,long ncl, long nch); 46 IMAGE_EXPORT(uint16) max_ui16matrix (uint16 **m, long nrl,long nrh,long ncl, long nch); 47 IMAGE_EXPORT(sint32) max_si32matrix (sint32 **m, long nrl,long nrh,long ncl, long nch); 48 IMAGE_EXPORT(uint32) max_ui32matrix (uint32 **m, long nrl,long nrh,long ncl, long nch); 49 IMAGE_EXPORT(sint64) max_si64matrix (sint64 **m, long nrl,long nrh,long ncl, long nch); 50 IMAGE_EXPORT(uint64) max_ui64matrix (uint64 **m, long nrl,long nrh,long ncl, long nch); 51 IMAGE_EXPORT(float32) max_f32matrix (float32 **m, long nrl,long nrh,long ncl, long nch); 52 IMAGE_EXPORT(float64) max_f64matrix (float64 **m, long nrl,long nrh,long ncl, long nch); 38 #define max_type_matrix(t) \ 39 t short_name(t,max_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) 40 41 max_type_matrix(int8_t); 42 max_type_matrix(uint8_t); 43 max_type_matrix(int16_t); 44 max_type_matrix(uint16_t); 45 max_type_matrix(int32_t); 46 max_type_matrix(uint32_t); 47 max_type_matrix(int64_t); 48 max_type_matrix(uint64_t); 49 max_type_matrix(float); 50 max_type_matrix(double); 51 53 52 54 53 /* ------------------ */ … … 56 55 /* ------------------ */ 57 56 58 IMAGE_EXPORT(void) add_si8matrix (sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 **Y, sint8 **Z); 59 IMAGE_EXPORT(void) add_ui8matrix (uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 **Y, uint8 **Z); 60 IMAGE_EXPORT(void) add_si16matrix (sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y, sint16 **Z); 61 IMAGE_EXPORT(void) add_ui16matrix (uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 **Y, uint16 **Z); 62 IMAGE_EXPORT(void) add_si32matrix (sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 **Y, sint32 **Z); 63 IMAGE_EXPORT(void) add_ui32matrix (uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 **Y, uint32 **Z); 64 IMAGE_EXPORT(void) add_si64matrix (sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 **Y, sint64 **Z); 65 IMAGE_EXPORT(void) add_ui64matrix (uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 **Y, uint64 **Z); 66 67 IMAGE_EXPORT(void) add_f32matrix (float32 **X, long nrl,long nrh,long ncl, long nch, float32 **Y, float32 **Z); 68 IMAGE_EXPORT(void) add_f64matrix (float64 **X, long nrl,long nrh,long ncl, long nch, float64 **Y, float64 **Z); 69 70 IMAGE_EXPORT(void) add_rgb8matrix (rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y, rgb8 **Z); 71 IMAGE_EXPORT(void) add_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y, rgbx8 **Z); 57 #define add_type_matrix(t) \ 58 void short_name(t,add_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z) 59 60 add_type_matrix(int8_t); 61 add_type_matrix(uint8_t); 62 add_type_matrix(int16_t); 63 add_type_matrix(uint16_t); 64 add_type_matrix(int32_t); 65 add_type_matrix(uint32_t); 66 add_type_matrix(int64_t); 67 add_type_matrix(uint64_t); 68 add_type_matrix(float); 69 add_type_matrix(double); 70 71 void add_rgb8matrix (rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb8 ** Y, rgb8 ** Z); 72 void add_rgbx8matrix(rgbx8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx8 ** Y, rgbx8 ** Z); 73 72 74 73 75 /* -------------------- */ … … 75 77 /* -------------------- */ 76 78 77 IMAGE_EXPORT(void) addc_si8matrix (sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 y, sint8 **Z); 78 IMAGE_EXPORT(void) addc_ui8matrix (uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 y, uint8 **Z); 79 IMAGE_EXPORT(void) addc_si16matrix (sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 y, sint16 **Z); 80 IMAGE_EXPORT(void) addc_ui16matrix (uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 y, uint16 **Z); 81 IMAGE_EXPORT(void) addc_si32matrix (sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 y, sint32 **Z); 82 IMAGE_EXPORT(void) addc_ui32matrix (uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 y, uint32 **Z); 83 IMAGE_EXPORT(void) addc_si64matrix (sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 y, sint64 **Z); 84 IMAGE_EXPORT(void) addc_ui64matrix (uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 y, uint64 **Z); 85 86 IMAGE_EXPORT(void) addc_f32matrix (float32 **X, long nrl,long nrh,long ncl, long nch, float32 y, float32 **Z); 87 IMAGE_EXPORT(void) addc_f64matrix (float64 **X, long nrl,long nrh,long ncl, long nch, float64 y, float64 **Z); 88 89 IMAGE_EXPORT(void) addc_rgb8matrix (rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 y, rgb8 **Z); 90 IMAGE_EXPORT(void) addc_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 y, rgbx8 **Z); 79 #define addc_type_matrix(t) \ 80 void short_name(t,addc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) 81 82 addc_type_matrix(int8_t); 83 addc_type_matrix(uint8_t); 84 addc_type_matrix(int16_t); 85 addc_type_matrix(uint16_t); 86 addc_type_matrix(int32_t); 87 addc_type_matrix(uint32_t); 88 addc_type_matrix(int64_t); 89 addc_type_matrix(uint64_t); 90 addc_type_matrix(float); 91 addc_type_matrix(double); 92 93 void addc_rgb8matrix (rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb8 y, rgb8 ** Z); 94 void addc_rgbx8matrix(rgbx8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 ** Z); 95 91 96 92 97 /* ----------- */ … … 94 99 /* ----------- */ 95 100 96 IMAGE_EXPORT(void) sub_si8matrix (sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 **Y, sint8 **Z); 97 IMAGE_EXPORT(void) sub_ui8matrix (uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 **Y, uint8 **Z); 98 IMAGE_EXPORT(void) sub_si16matrix (sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y, sint16 **Z); 99 IMAGE_EXPORT(void) sub_ui16matrix (uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 **Y, uint16 **Z); 100 IMAGE_EXPORT(void) sub_si32matrix (sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 **Y, sint32 **Z); 101 IMAGE_EXPORT(void) sub_ui32matrix (uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 **Y, uint32 **Z); 102 IMAGE_EXPORT(void) sub_si64matrix (sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 **Y, sint64 **Z); 103 IMAGE_EXPORT(void) sub_ui64matrix (uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 **Y, uint64 **Z); 104 105 IMAGE_EXPORT(void) sub_f32matrix (float32 **X, long nrl,long nrh,long ncl, long nch, float32 **Y, float32 **Z); 106 IMAGE_EXPORT(void) sub_f64matrix (float64 **X, long nrl,long nrh,long ncl, long nch, float64 **Y, float64 **Z); 107 108 IMAGE_EXPORT(void) sub_rgb8matrix (rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y, rgb8 **Z); 109 IMAGE_EXPORT(void) sub_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y, rgbx8 **Z); 101 #define sub_type_matrix(t) \ 102 void short_name(t,sub_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z) 103 104 sub_type_matrix(int8_t); 105 sub_type_matrix(uint8_t); 106 sub_type_matrix(int16_t); 107 sub_type_matrix(uint16_t); 108 sub_type_matrix(int32_t); 109 sub_type_matrix(uint32_t); 110 sub_type_matrix(int64_t); 111 sub_type_matrix(uint64_t); 112 sub_type_matrix(float); 113 sub_type_matrix(double); 114 115 void sub_rgb8matrix (rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb8 ** Y, rgb8 ** Z); 116 void sub_rgbx8matrix(rgbx8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx8 ** Y, rgbx8 ** Z); 117 110 118 111 119 /* --------------------- */ … … 113 121 /* --------------------- */ 114 122 115 IMAGE_EXPORT(void) subc_si8matrix (sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 y, sint8 **Z); 116 IMAGE_EXPORT(void) subc_ui8matrix (uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 y, uint8 **Z); 117 IMAGE_EXPORT(void) subc_si16matrix (sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 y, sint16 **Z); 118 IMAGE_EXPORT(void) subc_ui16matrix (uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 y, uint16 **Z); 119 IMAGE_EXPORT(void) subc_si32matrix (sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 y, sint32 **Z); 120 IMAGE_EXPORT(void) subc_ui32matrix (uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 y, uint32 **Z); 121 IMAGE_EXPORT(void) subc_si64matrix (sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 y, sint64 **Z); 122 IMAGE_EXPORT(void) subc_ui64matrix (uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 y, uint64 **Z); 123 124 IMAGE_EXPORT(void) subc_f32matrix (float32 **X, long nrl,long nrh,long ncl, long nch, float32 y, float32 **Z); 125 IMAGE_EXPORT(void) subc_f64matrix (float64 **X, long nrl,long nrh,long ncl, long nch, float64 y, float64 **Z); 126 127 IMAGE_EXPORT(void) subc_rgb8matrix (rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 y, rgb8 **Z); 128 IMAGE_EXPORT(void) subc_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 y, rgbx8 **Z); 129 130 /* --------------------- */ 131 /* --- Sub constante --- */ 123 #define subc_type_matrix(t) \ 124 void short_name(t,subc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) 125 126 subc_type_matrix(int8_t); 127 subc_type_matrix(uint8_t); 128 subc_type_matrix(int16_t); 129 subc_type_matrix(uint16_t); 130 subc_type_matrix(int32_t); 131 subc_type_matrix(uint32_t); 132 subc_type_matrix(int64_t); 133 subc_type_matrix(uint64_t); 134 subc_type_matrix(float); 135 subc_type_matrix(double); 136 137 void subc_rgb8matrix (rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb8 y, rgb8 ** Z); 138 void subc_rgbx8matrix(rgbx8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 ** Z); 139 140 /* --------------------- */ 141 /* --- Mul constante --- */ 132 142 /* --------------------- */ 133 143 134 144 // Z = X * y 135 IMAGE_EXPORT(void) mulc_si8matrix (sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 y, sint8 **Z); 136 IMAGE_EXPORT(void) mulc_ui8matrix (uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 y, uint8 **Z); 137 IMAGE_EXPORT(void) mulc_si16matrix (sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 y, sint16 **Z); 138 IMAGE_EXPORT(void) mulc_ui16matrix (uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 y, uint16 **Z); 139 IMAGE_EXPORT(void) mulc_si32matrix (sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 y, sint32 **Z); 140 IMAGE_EXPORT(void) mulc_ui32matrix (uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 y, uint32 **Z); 141 IMAGE_EXPORT(void) mulc_si64matrix (sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 y, sint64 **Z); 142 IMAGE_EXPORT(void) mulc_ui64matrix (uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 y, uint64 **Z); 143 144 IMAGE_EXPORT(void) mulc_f32matrix (float32 **X, long nrl,long nrh,long ncl, long nch, float32 y, float32 **Z); 145 IMAGE_EXPORT(void) mulc_f64matrix (float64 **X, long nrl,long nrh,long ncl, long nch, float64 y, float64 **Z); 146 147 IMAGE_EXPORT(void) mulc_rgb8matrix (rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 y, rgb8 **Z); 148 IMAGE_EXPORT(void) mulc_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 y, rgbx8 **Z); 145 146 #define mulc_type_matrix(t) \ 147 void short_name(t,mulc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) 148 149 mulc_type_matrix(int8_t); 150 mulc_type_matrix(uint8_t); 151 mulc_type_matrix(int16_t); 152 mulc_type_matrix(uint16_t); 153 mulc_type_matrix(int32_t); 154 mulc_type_matrix(uint32_t); 155 mulc_type_matrix(int64_t); 156 mulc_type_matrix(uint64_t); 157 mulc_type_matrix(float); 158 mulc_type_matrix(double); 159 160 void mulc_rgb8matrix (rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb8 y, rgb8 ** Z); 161 void mulc_rgbx8matrix(rgbx8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 ** Z); 162 149 163 150 164 /* --------------- */ 151 165 /* --- MulFrac --- */ 152 166 /* --------------- */ 153 // m2 = (a*m1)/b 154 IMAGE_EXPORT(void) mulfrac_bmatrix (byte **m1, long nrl,long nrh,long ncl, long nch, int32 a, int32 b, byte **m2); 155 IMAGE_EXPORT(void) mulfrac_si16matrix (sint16 **m1, long nrl,long nrh,long ncl, long nch, int32 a, int32 b, sint16 **m2); 156 IMAGE_EXPORT(void) mulfrac_ui16matrix (uint16 **m1, long nrl,long nrh,long ncl, long nch, int32 a, int32 b, uint16 **m2); 157 IMAGE_EXPORT(void) mulfrac_si32matrix (sint32 **m1, long nrl,long nrh,long ncl, long nch, int32 a, int32 b, sint32 **m2); 158 IMAGE_EXPORT(void) mulfrac_ui32matrix (uint32 **m1, long nrl,long nrh,long ncl, long nch, int32 a, int32 b, uint32 **m2); 159 IMAGE_EXPORT(void) mulfrac_rgb8matrix (rgb8 **m1, long nrl,long nrh,long ncl, long nch, rgb32 a, rgb32 b, rgb8 **m2); 160 IMAGE_EXPORT(void) mulfrac_rgbx8matrix(rgbx8 **m1, long nrl,long nrh,long ncl, long nch, rgbx32 a, rgbx32 b, rgbx8 **m2); 161 162 IMAGE_EXPORT(void) mulfrack_rgb8matrix (rgb8 **m1, long nrl,long nrh,long ncl, long nch, int32 a, int32 b, rgb8 **m2); 163 IMAGE_EXPORT(void) mulfrack_rgbx8matrix(rgbx8 **m1, long nrl,long nrh,long ncl, long nch, int32 a, int32 b, rgbx8 **m2); 167 168 // m2 = (a * m1) / b 169 170 #define mulfrac_type_matrix(t) \ 171 void short_name(t,mulfrac_,matrix)(t ** X, int32_t nrl, int32_t nrh, \ 172 int32_t ncl, int32_t nch, int32_t a, int32_t b, t ** Y) 173 174 mulfrac_type_matrix(int8_t); 175 mulfrac_type_matrix(uint8_t); 176 mulfrac_type_matrix(int16_t); 177 mulfrac_type_matrix(uint16_t); 178 mulfrac_type_matrix(int32_t); 179 mulfrac_type_matrix(uint32_t); 180 mulfrac_type_matrix(int64_t); 181 mulfrac_type_matrix(uint64_t); 182 mulfrac_type_matrix(float); 183 mulfrac_type_matrix(double); 184 185 void mulfrack_rgb8matrix (rgb8 ** m1, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, int32 a, int32 b, rgb8 ** m2); 186 void mulfrack_rgbx8matrix(rgbx8 ** m1, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, int32 a, int32 b, rgbx8 ** m2); 187 164 188 165 189 /* ---------------- */ 166 190 /* --- MulShift --- */ 167 191 /* ---------------- */ 168 // m3 = (a*m1)>>s 169 IMAGE_EXPORT(void) mulshift_bmatrix (byte **m1, long nrl,long nrh,long ncl, long nch, int32 a, int32 s, byte **m2); 170 IMAGE_EXPORT(void) mulshift_i16matrix (int16 **m1, long nrl,long nrh,long ncl, long nch, int32 a, int32 s, int16 **m2); 171 IMAGE_EXPORT(void) mulshift_ui16matrix (uint16 **m1, long nrl,long nrh,long ncl, long nch, int32 a, int32 s, uint16 **m2); 172 IMAGE_EXPORT(void) mulshift_i32matrix (int32 **m1, long nrl,long nrh,long ncl, long nch, int32 a, int32 s, int32 **m2); 173 IMAGE_EXPORT(void) mulshift_ui32matrix (uint32 **m1, long nrl,long nrh,long ncl, long nch, int32 a, int32 s, uint32 **m2); 174 IMAGE_EXPORT(void) mulshift_rgb8matrix (rgb8 **m1, long nrl,long nrh,long ncl, long nch, rgb32 a, rgb32 s, rgb8 **m2); 175 IMAGE_EXPORT(void) mulshift_rgbx8matrix(rgbx8 **m1, long nrl,long nrh,long ncl, long nch, rgbx32 a, rgbx32 s, rgbx8 **m2); 176 177 IMAGE_EXPORT(void) mulshiftk_rgb8matrix (rgb8 **m1, long nrl,long nrh,long ncl, long nch, int32 a, int32 s, rgb8 **m2); 178 IMAGE_EXPORT(void) mulshiftk_rgbx8matrix(rgbx8 **m1, long nrl,long nrh,long ncl, long nch, int32 a, int32 s, rgbx8 **m2); 179 180 IMAGE_EXPORT(void) quadratic_error_si16matrix(sint16 **m1,long nrl,long nrh,long ncl, long nch, sint16 **m2, sint16 **m3); 181 182 183 #ifdef __cplusplus 184 } 185 #endif 192 // m3 = (a * m1) >> s 193 194 #define mulshift_type_matrix(t) \ 195 void short_name(t,mulshift_,matrix)(t ** X, int32_t nrl, int32_t nrh, \ 196 int32_t ncl, int32_t nch, int32_t a, int32_t s, t ** Y) 197 198 mulshift_type_matrix(int8_t); 199 mulshift_type_matrix(uint8_t); 200 mulshift_type_matrix(int16_t); 201 mulshift_type_matrix(uint16_t); 202 mulshift_type_matrix(int32_t); 203 mulshift_type_matrix(uint32_t); 204 mulshift_type_matrix(int64_t); 205 mulshift_type_matrix(uint64_t); 206 mulshift_type_matrix(float); 207 mulshift_type_matrix(double); 208 209 void mulshift_rgb8matrix (rgb8 **m1, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb32 a, rgb32 s, rgb8 ** m2); 210 void mulshift_rgbx8matrix(rgbx8 **m1, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx32 a, rgbx32 s, rgbx8 ** m2); 211 212 void mulshiftk_rgb8matrix (rgb8 ** m1, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, int32 a, int32 s, rgb8 ** m2); 213 void mulshiftk_rgbx8matrix(rgbx8 ** m1, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, int32 a, int32 s, rgbx8 ** m2); 214 215 void quadratic_error_si16matrix(sint16 ** m1, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, sint16 ** m2, sint16 ** m3); 216 186 217 187 218 #endif /* _NRARITH2_H_ */ 219 220 // Local Variables: 221 // tab-width: 4 222 // c-basic-offset: 4 223 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 224 // indent-tabs-mode: nil 225 // End: 226 227 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 228 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrarith2x.h
r772 r821 11 11 #define _NRARITH2X_H_ 12 12 13 #ifdef __cplusplus 14 #ifdef PRAGMA_VERBOSE 15 #pragma message ("C++") 16 #endif 17 extern "C" { 18 #endif 13 // Add conditionnel 19 14 20 #ifdef PRAGMA_VERBOSE 21 #pragma message("- include nrarith2x.h") 22 #endif 15 #define addcnz_type_matrix(t) \ 16 void short_name(t,addcnz_,matrix)(t ** src, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t cte, t ** dst) 17 18 addcnz_type_matrix(int8_t); 19 addcnz_type_matrix(uint8_t); 20 addcnz_type_matrix(int16_t); 21 addcnz_type_matrix(uint16_t); 22 addcnz_type_matrix(int32_t); 23 addcnz_type_matrix(uint32_t); 24 addcnz_type_matrix(int64_t); 25 addcnz_type_matrix(uint64_t); 26 addcnz_type_matrix(float); 27 addcnz_type_matrix(double); 23 28 24 29 25 // Add conditionnel 26 IMAGE_EXPORT(void) addc_bmatrix (byte **src,long nrl,long nrh,long ncl, long nch, byte cte, byte **dst); 27 IMAGE_EXPORT(void) addc_smatrix (sint16 **src,long nrl,long nrh,long ncl, long nch, short cte, sint16 **dst); 28 IMAGE_EXPORT(void) addc_usmatrix(uint16 **src,long nrl,long nrh,long ncl, long nch, short cte, uint16 **dst); 30 #define addandc_type_matrix(t) \ 31 void short_name(t,addandc_,matrix)(t ** src, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t cte, t ** dst) 29 32 30 IMAGE_EXPORT(void) addandc_bmatrix (byte **src,long nrl,long nrh,long ncl, long nch, byte cte, byte **dst); 31 IMAGE_EXPORT(void) addandc_si16matrix (sint16 **src,long nrl,long nrh,long ncl, long nch, short cte, sint16 **dst); 32 IMAGE_EXPORT(void) addandc_ui16matrix (uint16 **src,long nrl,long nrh,long ncl, long nch, short cte, uint16 **dst); 33 addandc_type_matrix(int8_t); 34 addandc_type_matrix(uint8_t); 35 addandc_type_matrix(int16_t); 36 addandc_type_matrix(uint16_t); 37 addandc_type_matrix(int32_t); 38 addandc_type_matrix(uint32_t); 39 addandc_type_matrix(int64_t); 40 addandc_type_matrix(uint64_t); 41 addandc_type_matrix(float); 42 addandc_type_matrix(double); 33 43 34 IMAGE_EXPORT(void) addcnz_bmatrix(byte **src,long nrl,long nrh,long ncl, long nch, byte cte, byte **dst);35 44 36 IMAGE_EXPORT(int) count_bmatrix(byte **m, long nrl,long nrh,long ncl, long nch); 37 /* 38 * renvoie la somme des points de la matrice 39 */ 45 /* renvoie la somme des points de la matrice */ 40 46 41 #ifdef __cplusplus 42 } 43 #endif 47 #define sum_type_matrix(t,rt) \ 48 rt short_name(t,sum_,matrix)(t ** m, int32_t nrl, int32_t nrh,int32_t ncl, int32_t nch) 49 50 sum_type_matrix(int8_t, int32_t); 51 sum_type_matrix(uint8_t, uint32_t); 52 sum_type_matrix(int16_t, int32_t); 53 sum_type_matrix(uint16_t, uint32_t); 54 sum_type_matrix(int32_t, int64_t); 55 sum_type_matrix(uint32_t, uint64_t); 56 sum_type_matrix(int64_t, int64_t); 57 sum_type_matrix(uint64_t, uint64_t); 58 sum_type_matrix(float, float); 59 sum_type_matrix(double, double); 60 61 44 62 45 63 #endif /* _NRUTIL_H_ */ 64 65 // Local Variables: 66 // tab-width: 4 67 // c-basic-offset: 4 68 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 69 // indent-tabs-mode: nil 70 // End: 71 72 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 73 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrc_os_config.h
r798 r821 7 7 #define printf(...) giet_tty_printf(__VA_ARGS__) 8 8 9 #define open(x, y) giet_fat_open(x, y) 10 #define close(x) giet_fat_close(x) 11 #define read(x, y, z) giet_fat_read(x, y, z) 12 #define write(x, y, z) giet_fat_write(x, y, z) 13 #define fprintf(x, ...) giet_fat_fprintf(x, __VA_ARGS__) 14 #define fscanf(x, ...) ; 15 #define exit(x) giet_pthread_exit(NULL) 16 #else 9 #define open(x, y) giet_fat_open(x, y) 10 #define close(x) giet_fat_close(x) 11 #define read(x, y, z) giet_fat_read(x, y, z) 12 #define write(x, y, z) giet_fat_write(x, y, z) 13 #define fprintf(x, ...) giet_fat_fprintf(x, __VA_ARGS__) 14 //#define fscanf(x, ...) ; 15 #define exit(x) giet_pthread_exit(NULL) 16 17 #define pthread_barrier_t giet_barrier_t 18 #define pthread_spinlock_t user_lock_t 19 #define pthread_spin_lock(x) lock_acquire(x) 20 #define pthread_spin_unlock(x) lock_release(x) 21 #define pthread_spin_init(x, y) lock_init(x) 22 #define pthread_mutexlock_t user_lock_t 23 #define pthread_mutex_lock(x) lock_acquire(x) 24 #define pthread_mutex_unlock(x) lock_release(x) 25 #define pthread_mutex_init(x, y) lock_init(x) 26 #define pthread_barrier_init(x,y,z) barrier_init(x, z) 27 #define pthread_barrier_wait(x) barrier_wait(x) 28 #define pthread_barrier_destroy(x) 29 #define pthread_create(x,y,z,t) giet_pthread_create(x,y,z,t) 30 #define pthread_join(x,y) giet_pthread_join(x,y) 17 31 #endif 18 32 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrkernel.h
r772 r821 11 11 #define __NRKERNEL_H__ 12 12 13 #ifdef __cplusplus 14 #pragma message ("C++") 15 extern "C" { 16 #endif 17 18 #ifdef VERBOSE_PRAGMA 19 //#pragma message ("- *** include nrkernel.h ***") 13 14 #if TARGET_OS == GIETVM 15 #define nrerror(...) ({ \ 16 printf("*** NRC Runtime Error:\n "); \ 17 printf(__VA_ARGS__); \ 18 exit(1); \ 19 }) 20 #else 21 #define nrerror(...) ({ \ 22 fprintf(stderr, "*** NRC Runtime Error:\n "); \ 23 fprintf(stderr, __VA_ARGS__); \ 24 exit(1); \ 25 }) 20 26 #endif 21 27 22 void nrerror(char error_text[]);23 void nrerror0(char error_text[]);24 void nrerror1(char *format, ...);25 26 void Error (char *format, ...);27 void Warning(char *format, ...);28 28 29 29 30 #ifdef __cplusplus31 }32 #endif33 30 34 31 #endif // __NRKERNEL_H__ -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrtype.h
r772 r821 16 16 #define _NRTYPE_H_ 17 17 18 #ifdef __cplusplus 19 #pragma message ("C++") 20 extern "C" { 21 #endif 22 23 #define VERBOSE_PRAGMA 24 25 #ifdef VERBOSE_PRAGMA 26 //#pragma message ("- include nrtype.h") 27 #endif 18 #include <stdint.h> 28 19 29 20 // ---------------------------------- // … … 31 22 // ---------------------------------- // 32 23 24 33 25 #include "mypredef.h" 34 26 35 typedef unsigned char BOOLEAN;36 typedef unsigned char boolean;37 typedef int BOOL;38 #ifdef VERBOSE_PRAGMA39 //#pragma message("boolean")40 #endif41 27 42 #ifndef TRUE 43 #define TRUE 1 44 #else 45 #pragma message(" ATTENTION : TRUE already defined") 46 #endif 28 // Short names 47 29 48 #ifndef FALSE 49 #define FALSE 0 50 #else 51 #pragma message(" ATTENTION : FALSE already defined") 52 #endif 30 #define sn_int8_t(p,s) p##i8##s 31 #define sn_int16_t(p,s) p##i16##s 32 #define sn_int32_t(p,s) p##i32##s 33 #define sn_int64_t(p,s) p##i64##s 34 #define sn_uint8_t(p,s) p##ui8##s 35 #define sn_uint16_t(p,s) p##ui16##s 36 #define sn_uint32_t(p,s) p##ui32##s 37 #define sn_uint64_t(p,s) p##ui64##s 38 #define sn_float(p,s) p##f32##s 39 #define sn_double(p,s) p##f64##s 40 #define sn_void_p(p,s) p##v##s 41 #define sn_rgb8(p,s) p##rgb8##s 42 #define sn_rgbx8(p,s) p##rgbx8##s 43 #define sn_rgb32(p,s) p##rgb32##s 44 #define sn_rgbx32(p,s) p##rgbx32##s 45 #define sn_complex32(p,s) p##c32##s 46 #define sn_complex64(p,s) p##c64##s 47 #define sn_si16Point(p,s) p##si16P##s 48 #define sn_ui16Point(p,s) p##ui16P##s 49 #define sn_si32Point(p,s) p##si32P##s 50 #define sn_ui32Point(p,s) p##ui32P##s 51 #define sn_f32Point(p,s) p##f32P##s 52 #define sn_si16Triplet(p,s) p##si16T##s 53 #define sn_ui16Triplet(p,s) p##ui16T##s 54 #define sn_si32Triplet(p,s) p##si32T##s 55 #define sn_ui32Triplet(p,s) p##ui32T##s 56 #define sn_f32Triplet(p,s) p##f32T##s 57 58 #define short_name(t,p,s) sn_##t(p,s) 59 60 #define NR_END 0 61 #define FREE_ARG char* 62 63 64 53 65 54 66 /* ------------------------------- */ 55 67 /* --- 8, 16, 32, 64 bit types --- */ 56 68 /* ------------------------------- */ 57 // old types to be removed58 //typedef sint16 usint16 ;59 //typedef int uint;60 69 61 // half-typed types 70 typedef void * void_p; 71 typedef char byte; 62 72 63 typedef char byte; 64 //typedef char usint16 ; 65 //typedef char uint; 66 67 typedef char int8; 68 typedef short int16; 69 typedef int int32; 70 typedef long long int64; 73 typedef int8_t int8; 74 typedef int16_t int16; 75 typedef int32_t int32; 76 typedef int64_t int64; 71 77 72 #ifdef LIBCOMP73 #if defined(myCompiler_ICC) || defined (myCompiler_MSC)74 typedef __int64 int64;75 #else76 typedef long long int64;77 #endif78 #endif79 78 80 79 // full-typed types 81 typedef signed charsint8;82 typedef u nsigned charuint8;80 typedef int8_t sint8; 81 typedef uint8_t uint8; 83 82 84 typedef signed short sint16;85 typedef u nsigned shortuint16;83 typedef int16_t sint16; 84 typedef uint16_t uint16; 86 85 87 typedef signed intsint32;88 typedef u nsigned int uint32;86 typedef int32_t sint32; 87 typedef uint32_t uint32; 89 88 90 #if defined(myCompiler_ICC) || defined (myCompiler_MSC) 91 typedef __int64 int64; 92 typedef signed __int64 sint64; 93 typedef unsigned __int64 uint64; 94 #else 95 typedef signed long long sint64; 96 typedef unsigned long long uint64; 97 #endif 89 typedef int64_t sint64; 90 typedef uint64_t uint64; 98 91 99 typedef float float32; 100 typedef double float64; 92 typedef float float32; 93 typedef double float64; 94 101 95 102 96 /* -------------------- */ 103 97 /* --- complex type --- */ 104 98 /* -------------------- */ 99 105 100 typedef struct { float32 x; float32 y;} complex32; 106 101 typedef struct { float64 x; float64 y;} complex64; … … 199 194 } bitfield8; 200 195 201 #ifdef __cplusplus202 }203 #endif204 196 205 197 #endif // _NR_TYPE_H_ 198 -
soft/giet_vm/applications/rosenfeld/nrc2/src/nralloc1.c
r772 r821 29 29 #include <stdlib.h> 30 30 #include <malloc.h> 31 #include < math.h> // fabs31 #include <stdint.h> 32 32 33 #include "nrc_os_config.h" 33 34 #include "mypredef.h" 34 35 #include "nrtype.h" … … 38 39 39 40 #include "nralloc1.h" 40 #include "nrset1.h" // set 141 41 42 42 43 long nr_end = NR_END;44 43 45 // ------------------------------------------------------------------ 46 // -- deprecated type (original NRC type, not enough typed vector) -- 47 // ------------------------------------------------------------------ 48 49 /* ---------------------------------------- */ 50 NRC_EXPORT(sint8*) si8vector(long nl, long nh) 51 /* ---------------------------------------- */ 52 { 53 sint8 *v; 54 55 v=(sint8 *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(sint8))); 56 if (!v) nrerror("allocation failure in si8vector()"); 57 return v-nl+NR_END; 58 } 59 /* ---------------------------------------- */ 60 NRC_EXPORT(uint8*) ui8vector(long nl, long nh) 61 /* ---------------------------------------- */ 62 { 63 uint8 *v; 64 65 v=(uint8 *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(uint8))); 66 if (!v) nrerror("allocation failure in ui8vector()"); 67 return v-nl+NR_END; 68 } 69 /* -------------------------------------------- */ 70 NRC_EXPORT(sint16*) si16vector(long nl, long nh) 71 /* -------------------------------------------- */ 72 { 73 sint16 *v; 74 75 v=(sint16 *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(sint16))); 76 if (!v) nrerror("allocation failure in si16vector()"); 77 return v-nl+NR_END; 78 } 79 /* -------------------------------------------- */ 80 NRC_EXPORT(uint16*) ui16vector(long nl, long nh) 81 /* -------------------------------------------- */ 82 { 83 uint16 *v; 84 85 v=(uint16 *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(uint16))); 86 if (!v) nrerror("allocation failure in ui16vector()"); 87 return v-nl+NR_END; 88 } 89 /* -------------------------------------------- */ 90 IMAGE_EXPORT(sint32*) si32vector(long nl, long nh) 91 /* -------------------------------------------- */ 92 { 93 sint32 *v; 94 95 v=(sint32 *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(sint32))); 96 if (!v) nrerror("allocation failure in si32vector()"); 97 if(!v) return NULL; 98 return v-nl+NR_END; 99 } 100 /* -------------------------------------------- */ 101 IMAGE_EXPORT(uint32*) ui32vector(long nl, long nh) 102 /* -------------------------------------------- */ 103 { 104 uint32 *v; 105 106 v=(uint32 *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(uint32))); 107 if (!v) nrerror("allocation failure in ui32vector()"); 108 if(!v) return NULL; 109 return v-nl+NR_END; 110 } 111 /* -------------------------------------------- */ 112 IMAGE_EXPORT(sint64*) si64vector(long nl, long nh) 113 /* -------------------------------------------- */ 114 { 115 sint64 *v; 116 117 v=(sint64 *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(sint64))); 118 if (!v) nrerror("allocation failure in si64vector()"); 119 return v-nl+NR_END; 120 } 121 /* -------------------------------------------- */ 122 IMAGE_EXPORT(uint64*) ui64vector(long nl, long nh) 123 /* -------------------------------------------- */ 124 { 125 uint64 *v; 126 127 v=(uint64 *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(uint64))); 128 if (!v) nrerror("allocation failure in ui64vector()"); 129 return v-nl+NR_END; 130 } 131 /* ------------------------------------------ */ 132 NRC_EXPORT(float32*) f32vector(long nl, long nh) 133 /* ------------------------------------------ */ 134 { 135 float32 *v; 136 137 v=(float32 *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(float32))); 138 if (!v) nrerror("allocation failure in f32vector()"); 139 if(!v) return NULL; 140 return v-nl+NR_END; 141 } 142 /* ------------------------------------------ */ 143 NRC_EXPORT(float64*) f64vector(long nl, long nh) 144 /* ------------------------------------------ */ 145 { 146 float64 *v; 147 148 v=(float64 *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(float64))); 149 if (!v) nrerror("allocation failure in f64vector()"); 150 if(!v) return NULL; 151 return v-nl+NR_END; 152 } 153 /* ------------------------------------------ */ 154 IMAGE_EXPORT(rgb8*) rgb8vector(long nl, long nh) 155 /* ------------------------------------------ */ 156 { 157 rgb8 *v; 158 159 v=(rgb8 *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(rgb8))); 160 if (!v) nrerror("allocation failure in rgb8vector()"); 161 return v-nl+NR_END; 162 } 163 /* -------------------------------------------- */ 164 IMAGE_EXPORT(rgbx8*) rgbx8vector(long nl, long nh) 165 /* -------------------------------------------- */ 166 { 167 rgbx8 *v; 168 169 v=(rgbx8 *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(rgbx8))); 170 if (!v) nrerror("allocation failure in rgbx8vector()"); 171 return v-nl+NR_END; 172 } 173 /* -------------------------------------------- */ 174 IMAGE_EXPORT(rgb32*) rgb32vector(long nl, long nh) 175 /* -------------------------------------------- */ 176 { 177 rgb32 *v; 178 179 v=(rgb32 *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(rgb32))); 180 if (!v) nrerror("allocation failure in rgb32vector()"); 181 return v-nl+NR_END; 44 #undef type_vector 45 #define type_vector(t) \ 46 t * short_name(t,,vector)(int32_t nl, int32_t nh) \ 47 { \ 48 t * v; \ 49 v = malloc((nh - nl + 1 + NR_END) * sizeof(t)); \ 50 if (v == NULL) { \ 51 nrerror("*** Error: allocation failure in %s\n", __func__); \ 52 } \ 53 return v - nl + NR_END; \ 182 54 } 183 55 184 /* ---------------------------------------- */ 185 IMAGE_EXPORT(void**) vvector(long nl, long nh) 186 /* ---------------------------------------- */ 187 { 188 void **v; 189 190 v=(void**)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(void*))); 191 if (!v) nrerror("allocation failure in vvector()"); 192 return v-nl+NR_END; 56 type_vector(int8_t); 57 type_vector(uint8_t); 58 type_vector(int16_t); 59 type_vector(uint16_t); 60 type_vector(int32_t); 61 type_vector(uint32_t); 62 type_vector(int64_t); 63 type_vector(uint64_t); 64 type_vector(float); 65 type_vector(double); 66 type_vector(void_p); 67 type_vector(rgb8); 68 type_vector(rgbx8); 69 type_vector(rgb32); 70 71 72 73 #undef type_vector0 74 #define type_vector0(t) \ 75 t * short_name(t,,vector0)(int32_t nl, int32_t nh) \ 76 { \ 77 t * v; \ 78 v = calloc((nh - nl + 1 + NR_END), sizeof(t)); \ 79 if (v == NULL) { \ 80 nrerror("*** Error: allocation failure in %s\n", __func__); \ 81 } \ 82 return v - nl + NR_END; \ 193 83 } 194 /*195 * ---------------196 * --- vector0 ---197 * ---------------198 */199 84 200 // do: allocate a vector and set it to 0 85 type_vector0(int8_t); 86 type_vector0(uint8_t); 87 type_vector0(int16_t); 88 type_vector0(uint16_t); 89 type_vector0(int32_t); 90 type_vector0(uint32_t); 91 type_vector0(int64_t); 92 type_vector0(uint64_t); 93 type_vector0(float); 94 type_vector0(double); 95 type_vector0(void_p); 96 type_vector0(rgb8); 97 type_vector0(rgbx8); 98 type_vector0(rgb32); 201 99 202 // ---------------------- 203 // --- not deprecated --- 204 // ---------------------- 205 /* ------------------------------------------- */ 206 IMAGE_EXPORT(sint8*) si8vector0(long nl, long nh) 207 /* ------------------------------------------- */ 208 { 209 sint8 *v;210 211 v=(sint8 *)calloc((size_t) ((nh-nl+1+NR_END)), sizeof(sint8));212 if (!v) nrerror("allocation failure in si8vector0()");213 return v -nl+NR_END;100 101 #undef realloc_type_vector 102 #define realloc_type_vector(t) \ 103 t * short_name(t,realloc_,vector)(t * v, int32_t nl, int32_t nh) \ 104 { \ 105 v += nl; \ 106 v -= NR_END; \ 107 v = realloc(v, (nh - nl + 1 + NR_END) * sizeof(t)); \ 108 if (v == NULL) { \ 109 nrerror("*** Error: allocation failure in %s\n", __func__); \ 110 } \ 111 return v - nl + NR_END; \ 214 112 } 215 /* ------------------------------------------- */ 216 IMAGE_EXPORT(uint8*) ui8vector0(long nl, long nh) 217 /* ------------------------------------------- */ 218 { 219 uint8 *v; 220 221 v=(uint8 *)calloc((size_t) ((nh-nl+1+NR_END)), sizeof(uint8)); 222 if (!v) nrerror("allocation failure in ui8vector0()"); 223 return v-nl+NR_END; 113 114 115 realloc_type_vector(int8_t); 116 realloc_type_vector(uint8_t); 117 realloc_type_vector(int16_t); 118 realloc_type_vector(uint16_t); 119 realloc_type_vector(int32_t); 120 realloc_type_vector(uint32_t); 121 realloc_type_vector(int64_t); 122 realloc_type_vector(uint64_t); 123 realloc_type_vector(float); 124 realloc_type_vector(double); 125 realloc_type_vector(void_p); 126 realloc_type_vector(rgb8); 127 realloc_type_vector(rgbx8); 128 realloc_type_vector(rgb32); 129 130 131 #undef free_type_vector 132 #define free_type_vector(t) \ 133 void short_name(t,free_,vector)(t * v, long nl, long nh) \ 134 { \ 135 free((FREE_ARG) (v + nl - NR_END)); \ 224 136 } 225 /* -------------------------------------------- */ 226 IMAGE_EXPORT(int16*) si16vector0(long nl, long nh) 227 /* -------------------------------------------- */ 228 { 229 sint16 *v; 230 231 v=(sint16 *)calloc((size_t) ((nh-nl+1+NR_END)), sizeof(sint16)); 232 if (!v) nrerror("allocation failure in si16vector0()"); 233 return v-nl+NR_END; 137 138 free_type_vector(int8_t); 139 free_type_vector(uint8_t); 140 free_type_vector(int16_t); 141 free_type_vector(uint16_t); 142 free_type_vector(int32_t); 143 free_type_vector(uint32_t); 144 free_type_vector(int64_t); 145 free_type_vector(uint64_t); 146 free_type_vector(float); 147 free_type_vector(double); 148 free_type_vector(void_p); 149 free_type_vector(rgb8); 150 free_type_vector(rgbx8); 151 free_type_vector(rgb32); 152 153 154 155 156 #if TARGET_OS == GIETVM 157 #undef remote_type_vector 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) \ 160 { \ 161 t * v; \ 162 v = remote_malloc((nh - nl + 1 + NR_END) * sizeof(t), x, y); \ 163 if (v == NULL) { \ 164 nrerror("*** Error: allocation failure in %s\n", __func__); \ 165 } \ 166 return v - nl + NR_END; \ 234 167 } 235 /* --------------------------------------------- */236 IMAGE_EXPORT(uint16*) ui16vector0(long nl, long nh)237 /* --------------------------------------------- */238 {239 uint16 *v;240 241 v=(uint16 *)calloc((size_t) ((nh-nl+1+NR_END)), sizeof(uint16));242 if (!v) nrerror("allocation failure in ui16vector0()");243 return v-nl+NR_END;244 }245 /* --------------------------------------------- */246 IMAGE_EXPORT(sint32*) si32vector0(long nl, long nh)247 /* --------------------------------------------- */248 /* allocate a sint32 vector with subscript range v[nl..nh] */249 {250 sint32 *v;251 252 v=(sint32 *) calloc((size_t) (nh-nl+1+NR_END),sizeof(sint32));253 if (!v) nrerror("allocation failure in si32vector0()");254 return v-nl+NR_END;255 }256 /* --------------------------------------------- */257 IMAGE_EXPORT(uint32*) ui32vector0(long nl, long nh)258 /* --------------------------------------------- */259 /* allocate a uint32 vector with subscript range v[nl..nh] */260 {261 uint32 *v;262 263 v=(uint32 *) calloc((size_t) (nh-nl+1+NR_END),sizeof(uint32));264 if (!v) nrerror("allocation failure in ui32vector0()");265 return v-nl+NR_END;266 }267 /* --------------------------------------------- */268 IMAGE_EXPORT(float32*) f32vector0(long nl, long nh)269 /* --------------------------------------------- */270 /* allocate a float32 vector with subscript range v[nl..nh] */271 {272 float32 *v;273 274 v=(float32 *) calloc ( (size_t) (nh-nl+1+NR_END), sizeof(float32) );275 if (!v) nrerror("allocation failure in f32vector0()");276 if(!v) return NULL;277 return v-nl+NR_END;278 }279 /* --------------------------------------------- */280 IMAGE_EXPORT(float64*) f64vector0(long nl, long nh)281 /* --------------------------------------------- */282 /* allocate a float vector with subscript range v[nl..nh] */283 {284 float64 *v;285 286 v=(float64 *) calloc ( (size_t) (nh-nl+1+NR_END), sizeof(float64) );287 if (!v) nrerror("allocation failure in f64vector0()");288 if(!v) return NULL;289 return v-nl+NR_END;290 }291 /* ------------------------------------------- */292 IMAGE_EXPORT(rgb8*) rgb8vector0(long nl, long nh)293 /* ------------------------------------------- */294 {295 rgb8 *v;296 297 v=(rgb8 *)calloc((size_t) ((nh-nl+1+NR_END)), sizeof(rgb8));298 if (!v) nrerror("allocation failure in rgb8vector0()");299 return v-nl+NR_END;300 }301 /* --------------------------------------------- */302 IMAGE_EXPORT(rgbx8*) rgbx8vector0(long nl, long nh)303 /* --------------------------------------------- */304 {305 rgbx8 *v;306 307 v=(rgbx8 *)calloc((size_t) ((nh-nl+1+NR_END)), sizeof(rgbx8));308 if (!v) nrerror("allocation failure in rgbx8vector0()");309 return v-nl+NR_END;310 }311 /* --------------------------------------------- */312 IMAGE_EXPORT(rgb32*) rgb32vector0(long nl, long nh)313 /* --------------------------------------------- */314 {315 rgb32 *v;316 317 v=(rgb32 *)calloc((size_t) ((nh-nl+1+NR_END)), sizeof(rgb32));318 if (!v) nrerror("allocation failure in rgb32vector0()");319 return v-nl+NR_END;320 }321 /*322 * ----------------------323 * --- realloc_vector ---324 * ----------------------325 */326 168 327 /* ------------------------------------------------------------ */ 328 IMAGE_EXPORT(sint8*) realloc_si8vector(sint8 *v, long nl, long nh) 329 /* ------------------------------------------------------------ */ 330 { 331 v += nl; 332 v -= NR_END; 333 v=(sint8 *)realloc(v, (size_t) ((nh-nl+1+NR_END)*sizeof(sint8))); 334 if (!v) nrerror("allocation failure in realloc_si8vector()"); 335 336 return v-nl+NR_END; 337 } 338 /* ------------------------------------------------------------ */ 339 IMAGE_EXPORT(uint8*) realloc_ui8vector(uint8 *v, long nl, long nh) 340 /* ------------------------------------------------------------ */ 341 { 342 v += nl; 343 v -= NR_END; 344 v=(uint8 *)realloc(v, (size_t) ((nh-nl+1+NR_END)*sizeof(uint8))); 345 if (!v) nrerror("allocation failure in realloc_ui8vector()"); 346 347 return v-nl+NR_END; 348 } 349 /* --------------------------------------------------------------- */ 350 IMAGE_EXPORT(sint16*) realloc_si16vector(sint16 *v, long nl, long nh) 351 /* --------------------------------------------------------------- */ 352 { 353 v += nl; 354 v -= NR_END; 355 v=(sint16 *)realloc(v, (size_t) ((nh-nl+1+NR_END)*sizeof(sint16))); 356 if (!v) nrerror("allocation failure in realloc_si16vector()"); 357 358 return v-nl+NR_END; 359 } 360 /* --------------------------------------------------------------- */ 361 IMAGE_EXPORT(uint16*) realloc_ui16vector(uint16 *v, long nl, long nh) 362 /* --------------------------------------------------------------- */ 363 { 364 v += nl; 365 v -= NR_END; 366 v=(uint16 *)realloc(v, (size_t) ((nh-nl+1+NR_END)*sizeof(uint16))); 367 if (!v) nrerror("allocation failure in realloc_ui16vector()"); 368 369 return v-nl+NR_END; 370 } 371 /* --------------------------------------------------------------- */ 372 IMAGE_EXPORT(sint32*) realloc_si32vector(sint32 *v, long nl, long nh) 373 /* --------------------------------------------------------------- */ 374 { 375 v += nl; 376 v -= NR_END; 377 v=(sint32 *)realloc(v, (size_t) ((nh-nl+1+NR_END)*sizeof(sint32))); 378 if (!v) nrerror("allocation failure in realloc_si32vector()"); 379 380 return v-nl+NR_END; 381 } 382 /* --------------------------------------------------------------- */ 383 IMAGE_EXPORT(uint32*) realloc_ui32vector(uint32 *v, long nl, long nh) 384 /* --------------------------------------------------------------- */ 385 { 386 v += nl; 387 v -= NR_END; 388 v=(uint32 *)realloc(v, (size_t) ((nh-nl+1+NR_END)*sizeof(uint32))); 389 if (!v) nrerror("allocation failure in realloc_ui32vector()"); 390 391 return v-nl+NR_END; 392 } 393 /* --------------------------------------------------------------- */ 394 IMAGE_EXPORT(sint64*) realloc_si64vector(sint64 *v, long nl, long nh) 395 /* --------------------------------------------------------------- */ 396 { 397 v += nl; 398 v -= NR_END; 399 v=(sint64 *)realloc(v, (size_t) ((nh-nl+1+NR_END)*sizeof(sint64))); 400 if (!v) nrerror("allocation failure in realloc_si64vector()"); 401 402 return v-nl+NR_END; 403 } 404 /* --------------------------------------------------------------- */ 405 IMAGE_EXPORT(uint64*) realloc_ui64vector(uint64 *v, long nl, long nh) 406 /* --------------------------------------------------------------- */ 407 { 408 v += nl; 409 v -= NR_END; 410 v=(uint64 *)realloc(v, (size_t) ((nh-nl+1+NR_END)*sizeof(uint64))); 411 if (!v) nrerror("allocation failure in realloc_ui64vector()"); 412 413 return v-nl+NR_END; 414 } 415 /* ---------------------------------------------------------- */ 416 IMAGE_EXPORT(rgb8*) realloc_rgb8vector(rgb8 *v, long nl, long nh) 417 /* ---------------------------------------------------------- */ 418 { 419 v += nl; 420 v -= NR_END; 421 v=(rgb8 *)realloc(v, (size_t) ((nh-nl+1+NR_END)*sizeof(rgb8))); 422 if (!v) nrerror("allocation failure in realloc_rgb8vector()"); 423 424 return v-nl+NR_END; 425 } 426 /* -------------------------------------------------------------- */ 427 IMAGE_EXPORT(rgbx8*) realloc_rgbx8vector(rgbx8 *v, long nl, long nh) 428 /* -------------------------------------------------------------- */ 429 { 430 v += nl; 431 v -= NR_END; 432 v=(rgbx8 *)realloc(v, (size_t) ((nh-nl+1+NR_END)*sizeof(rgbx8))); 433 if (!v) nrerror("allocation failure in realloc_rgbx8vector()"); 434 435 return v-nl+NR_END; 436 } 437 /* -------------------------------------------------------------- */ 438 IMAGE_EXPORT(rgb32*) realloc_rgb32vector(rgb32 *v, long nl, long nh) 439 /* -------------------------------------------------------------- */ 440 { 441 v += nl; 442 v -= NR_END; 443 v=(rgb32 *)realloc(v, (size_t) ((nh-nl+1+NR_END)*sizeof(rgb32))); 444 if (!v) nrerror("allocation failure in realloc_rgb32vector()"); 445 446 return v-nl+NR_END; 447 } 448 /* ---------------------------------------------------------- */ 449 IMAGE_EXPORT(void**) realloc_vvector(void **v, long nl, long nh) 450 /* ---------------------------------------------------------- */ 451 /* 452 * add n item to an void* vector with subscript range 453 * fromv[nl..nh] to [nl..nh+n] */ 454 { 455 v += nl; 456 v -= NR_END; 457 v=(void**)realloc(v, (size_t) ((nh-nl+1+NR_END)*sizeof(void*))); 458 if (!v) nrerror("allocation failure in realloc vvector()"); 459 460 return v-nl+NR_END; 461 } 462 /* 463 * ------------------- 464 * --- free_vector --- 465 * ------------------- 466 */ 169 remote_type_vector(int8_t); 170 remote_type_vector(uint8_t); 171 remote_type_vector(int16_t); 172 remote_type_vector(uint16_t); 173 remote_type_vector(int32_t); 174 remote_type_vector(uint32_t); 175 remote_type_vector(int64_t); 176 remote_type_vector(uint64_t); 177 remote_type_vector(float); 178 remote_type_vector(double); 179 remote_type_vector(void_p); 180 remote_type_vector(rgb8); 181 remote_type_vector(rgbx8); 182 remote_type_vector(rgb32); 467 183 468 /* free a byte vector allocated with bvector() */ 184 #endif 469 185 470 /* ------------------------------------------------------- */ 471 IMAGE_EXPORT(void) free_si8vector(sint8 *v, long nl, long nh) 472 /* ------------------------------------------------------- */ 473 { 474 free((FREE_ARG) (v+nl-NR_END)); 475 } 476 /* ------------------------------------------------------- */ 477 IMAGE_EXPORT(void) free_ui8vector(uint8 *v, long nl, long nh) 478 /* ------------------------------------------------------- */ 479 { 480 free((FREE_ARG) (v+nl-NR_END)); 481 } 482 /* --------------------------------------------------------- */ 483 IMAGE_EXPORT(void) free_si16vector(sint16 *v, long nl, long nh) 484 /* --------------------------------------------------------- */ 485 { 486 free((FREE_ARG) (v+nl-NR_END)); 487 } 488 /* ------------------------------------------------------- */ 489 IMAGE_EXPORT(void) free_ui16vector(uint16 *v, long nl, long nh) 490 /* ------------------------------------------------------- */ 491 { 492 free((FREE_ARG) (v+nl-NR_END)); 493 } 494 /* --------------------------------------------------------- */ 495 IMAGE_EXPORT(void) free_si32vector(sint32 *v, long nl, long nh) 496 /* --------------------------------------------------------- */ 497 { 498 free((FREE_ARG) (v+nl-NR_END)); 499 } 500 /* --------------------------------------------------------- */ 501 IMAGE_EXPORT(void) free_ui32vector(uint32 *v, long nl, long nh) 502 /* --------------------------------------------------------- */ 503 { 504 free((FREE_ARG) (v+nl-NR_END)); 505 } 506 /* --------------------------------------------------------- */ 507 IMAGE_EXPORT(void) free_si64vector(sint64 *v, long nl, long nh) 508 /* --------------------------------------------------------- */ 509 { 510 free((FREE_ARG) (v+nl-NR_END)); 511 } 512 /* --------------------------------------------------------- */ 513 IMAGE_EXPORT(void) free_ui64vector(uint64 *v, long nl, long nh) 514 /* --------------------------------------------------------- */ 515 { 516 free((FREE_ARG) (v+nl-NR_END)); 517 } 518 /* ---------------------------------------------------- */ 519 IMAGE_EXPORT(void) free_f32vector(float32 *v, long nl, long nh) 520 /* ---------------------------------------------------- */ 521 { 522 free((FREE_ARG) (v+nl-NR_END)); 523 } 524 /* ---------------------------------------------------- */ 525 IMAGE_EXPORT(void) free_f64vector(float64 *v, long nl, long nh) 526 /* ---------------------------------------------------- */ 527 { 528 free((FREE_ARG) (v+nl-NR_END)); 529 } 530 /* -------------------------------------------------------- */ 531 IMAGE_EXPORT(void) free_rgb8vector(rgb8 *v, long nl, long nh) 532 /* -------------------------------------------------------- */ 533 { 534 free((FREE_ARG) (v+nl-NR_END)); 535 } 536 /* --------------------------------------------------------- */ 537 IMAGE_EXPORT(void) free_rgbx8vector(rgbx8 *v, long nl, long nh) 538 /* --------------------------------------------------------- */ 539 { 540 free((FREE_ARG) (v+nl-NR_END)); 541 } 542 /* ------------------------------------------------------- */ 543 IMAGE_EXPORT(void) free_rgb32vector(rgb32 *v, long nl, long nh) 544 /* ------------------------------------------------------- */ 545 { 546 free((FREE_ARG) (v+nl-NR_END)); 547 } 548 /* ----------------------------------------------------- */ 549 IMAGE_EXPORT(void) free_vvector(void **v, long nl, long nh) 550 /* ----------------------------------------------------- */ 551 { 552 free((FREE_ARG) (v+nl-NR_END)); 553 } 186 // Local Variables: 187 // tab-width: 4 188 // c-basic-offset: 4 189 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 190 // indent-tabs-mode: nil 191 // End: 192 193 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 194 -
soft/giet_vm/applications/rosenfeld/nrc2/src/nralloc2.c
r772 r821 30 30 #include <malloc.h> 31 31 #include <math.h> // fabs 32 // #include <memory.h> // memcpy 33 32 33 #include "nrc_os_config.h" 34 34 #include "mypredef.h" 35 35 #include "nrtype.h" 36 #include "nrtypex.h" 36 37 #include "nrdef.h" 37 38 #include "nrmacro.h" 38 39 #include "nrkernel.h" 39 40 40 #include "nralloc1.h"41 41 #include "nralloc2.h" 42 //#include "nrarith.h"43 42 44 43 /* … … 47 46 * -------------- 48 47 */ 49 /* ------------------------------------------------ */ 50 float** matrix(long nrl, long nrh, long ncl, long nch) 51 /* ------------------------------------------------ */ 52 { 53 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 54 float **m; 55 56 /* allocate pointers to rows */ 57 m=(float **) malloc((size_t)((nrow+NR_END)*sizeof(float*))); 58 if (!m) nrerror("allocation failure 1 in matrix()"); 59 m += NR_END; 60 m -= nrl; 61 62 63 /* allocate rows and set pointers to them */ 64 m[nrl]=(float *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(float))); 65 if (!m[nrl]) nrerror("allocation failure 2 in matrix()"); 66 m[nrl] += NR_END; 67 m[nrl] -= ncl; 68 69 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 70 71 /* return pointer to array of pointers to rows */ 72 return m; 73 } 74 /* -------------------------------------------------------------- */ 75 IMAGE_EXPORT(byte**) bmatrix(long nrl, long nrh, long ncl, long nch) 76 /* -------------------------------------------------------------- */ 77 { 78 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 79 byte **m; 80 81 /* allocate pointers to rows */ 82 m=(byte **) malloc((size_t)((nrow+NR_END)*sizeof(byte*))); 83 if (!m) nrerror("allocation failure 1 in bmatrix()"); 84 m += NR_END; 85 m -= nrl; 86 87 88 /* allocate rows and set pointers to them */ 89 m[nrl]=(byte *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(byte))); 90 if (!m[nrl]) nrerror("allocation failure 2 in bmatrix()"); 91 m[nrl] += NR_END; 92 m[nrl] -= ncl; 93 94 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 95 96 /* return pointer to array of pointers to rows */ 97 return m; 98 }/* ---------------------------------------------------------------- */ 99 IMAGE_EXPORT(sint8**) si8matrix(long nrl, long nrh, long ncl, long nch) 100 /* ----------------------------------------------------------------- */ 101 { 102 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 103 sint8 **m; 104 105 /* allocate pointers to rows */ 106 m=(sint8 **) malloc((size_t)((nrow+NR_END)*sizeof(sint8*))); 107 if (!m) nrerror("allocation failure 1 in i8matrix()"); 108 m += NR_END; 109 m -= nrl; 110 111 /* allocate rows and set pointers to them */ 112 m[nrl]=(sint8 *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(sint8))); 113 if (!m[nrl]) nrerror("allocation failure 2 in i8matrix()"); 114 m[nrl] += NR_END; 115 m[nrl] -= ncl; 116 117 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 118 119 /* return pointer to array of pointers to rows */ 120 return m; 121 } 122 /* ----------------------------------------------------------------- */ 123 IMAGE_EXPORT(uint8**) ui8matrix(long nrl, long nrh, long ncl, long nch) 124 /* ----------------------------------------------------------------- */ 125 { 126 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 127 uint8 **m; 128 129 /* allocate pointers to rows */ 130 m=(uint8 **) malloc((size_t)((nrow+NR_END)*sizeof(uint8*))); 131 if (!m) nrerror("allocation failure 1 in ui8matrix()"); 132 m += NR_END; 133 m -= nrl; 134 135 /* allocate rows and set pointers to them */ 136 m[nrl]=(uint8 *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(uint8))); 137 if (!m[nrl]) nrerror("allocation failure 2 in ui8matrix()"); 138 m[nrl] += NR_END; 139 m[nrl] -= ncl; 140 141 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 142 143 /* return pointer to array of pointers to rows */ 144 return m; 145 } 146 /* ------------------------------------------------------------------- */ 147 IMAGE_EXPORT(sint16**) si16matrix(long nrl, long nrh, long ncl, long nch) 148 /* ------------------------------------------------------------------- */ 149 { 150 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 151 sint16 **m; 152 153 /* allocate pointers to rows */ 154 m=(sint16 **) malloc((size_t)((nrow+NR_END)*sizeof(sint16*))); 155 if (!m) nrerror("allocation failure 1 in si16matrix()"); 156 m += NR_END; 157 m -= nrl; 158 159 /* allocate rows and set pointers to them */ 160 m[nrl]=(sint16 *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(sint16))); 161 if (!m[nrl]) nrerror("allocation failure 2 in si16matrix()"); 162 m[nrl] += NR_END; 163 m[nrl] -= ncl; 164 165 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 166 167 /* return pointer to array of pointers to rows */ 168 return m; 169 } 170 /* ------------------------------------------------------------------- */ 171 IMAGE_EXPORT(uint16**) ui16matrix(long nrl, long nrh, long ncl, long nch) 172 /* ------------------------------------------------------------------- */ 173 { 174 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 175 uint16 **m; 176 177 /* allocate pointers to rows */ 178 m=(uint16 **) malloc((size_t)((nrow+NR_END)*sizeof(uint16*))); 179 if (!m) nrerror("allocation failure 1 in ui16matrix()"); 180 m += NR_END; 181 m -= nrl; 182 183 /* allocate rows and set pointers to them */ 184 m[nrl]=(uint16 *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(uint16))); 185 if (!m[nrl]) nrerror("allocation failure 2 in ui16matrix()"); 186 m[nrl] += NR_END; 187 m[nrl] -= ncl; 188 189 for(i=nrl+1;i<=nrh;i++) 190 m[i]=m[i-1]+ncol; 191 192 /* return pointer to array of pointers to rows */ 193 return m; 194 } 195 /* ------------------------------------------------------------------- */ 196 IMAGE_EXPORT(sint32**) si32matrix(long nrl, long nrh, long ncl, long nch) 197 /* ------------------------------------------------------------------- */ 198 /* allocate a int32 matrix with subscript range m[nrl..nrh][ncl..nch] */ 199 { 200 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 201 sint32 **m; 202 203 /* allocate pointers to rows */ 204 m=(sint32 **) malloc((size_t)((nrow+NR_END)*sizeof(sint32*))); 205 if (!m) nrerror("allocation failure 1 in si32matrix()"); 206 m += NR_END; 207 m -= nrl; 208 209 /* allocate rows and set pointers to them */ 210 m[nrl]=(sint32 *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(sint32))); 211 if (!m[nrl]) nrerror("allocation failure 2 in si32matrix()"); 212 m[nrl] += NR_END; 213 m[nrl] -= ncl; 214 215 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 216 217 /* return pointer to array of pointers to rows */ 218 return m; 219 } 220 /* ------------------------------------------------------------------- */ 221 IMAGE_EXPORT(uint32**) ui32matrix(long nrl, long nrh, long ncl, long nch) 222 /* ------------------------------------------------------------------- */ 223 /* allocate a uint32 matrix with subscript range m[nrl..nrh][ncl..nch] */ 224 { 225 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 226 uint32 **m; 227 228 /* allocate pointers to rows */ 229 m=(uint32 **) malloc((size_t)((nrow+NR_END)*sizeof(uint32*))); 230 if (!m) nrerror("allocation failure 1 in ui32matrix()"); 231 m += NR_END; 232 m -= nrl; 233 234 /* allocate rows and set pointers to them */ 235 m[nrl]=(uint32 *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(uint32))); 236 if (!m[nrl]) nrerror("allocation failure 2 in ui32matrix()"); 237 m[nrl] += NR_END; 238 m[nrl] -= ncl; 239 240 for(i=nrl+1;i<=nrh;i++) 241 m[i]=m[i-1]+ncol; 242 243 /* return pointer to array of pointers to rows */ 244 return m; 245 } 246 /* ------------------------------------------------------------------- */ 247 IMAGE_EXPORT(sint64**) si64matrix(long nrl, long nrh, long ncl, long nch) 248 /* ------------------------------------------------------------------- */ 249 /* allocate a int64 matrix with subscript range m[nrl..nrh][ncl..nch] */ 250 { 251 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 252 sint64 **m; 253 254 /* allocate pointers to rows */ 255 m=(sint64 **) malloc((size_t)((nrow+NR_END)*sizeof(sint64*))); 256 if (!m) nrerror("allocation failure 1 in si64matrix()"); 257 m += NR_END; 258 m -= nrl; 259 260 /* allocate rows and set pointers to them */ 261 m[nrl]=(sint64 *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(sint64))); 262 if (!m[nrl]) nrerror("allocation failure 2 in si64matrix()"); 263 m[nrl] += NR_END; 264 m[nrl] -= ncl; 265 266 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 267 268 /* return pointer to array of pointers to rows */ 269 return m; 270 } 271 /* ------------------------------------------------------------------- */ 272 IMAGE_EXPORT(uint64**) ui64matrix(long nrl, long nrh, long ncl, long nch) 273 /* ------------------------------------------------------------------- */ 274 /* allocate a int64 matrix with subscript range m[nrl..nrh][ncl..nch] */ 275 { 276 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 277 uint64 **m; 278 279 /* allocate pointers to rows */ 280 m=(uint64 **) malloc((size_t)((nrow+NR_END)*sizeof(uint64*))); 281 if (!m) nrerror("allocation failure 1 in ui64matrix()"); 282 m += NR_END; 283 m -= nrl; 284 285 /* allocate rows and set pointers to them */ 286 m[nrl]=(uint64 *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(uint64))); 287 if (!m[nrl]) nrerror("allocation failure 2 in ui64matrix()"); 288 m[nrl] += NR_END; 289 m[nrl] -= ncl; 290 291 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 292 293 /* return pointer to array of pointers to rows */ 294 return m; 295 } 296 /* ------------------------------------------------------------------- */ 297 IMAGE_EXPORT(float32**) f32matrix(long nrl, long nrh, long ncl, long nch) 298 /* ------------------------------------------------------------------- */ 299 /* allocate a float matrix with subscript range m[nrl..nrh][ncl..nch] */ 300 { 301 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 302 float32 **m; 303 304 /* allocate pointers to rows */ 305 m=(float32 **) malloc((size_t)((nrow+NR_END)*sizeof(float32*))); 306 if (!m) nrerror("allocation failure 1 in f32matrix()"); 307 m += NR_END; 308 m -= nrl; 309 310 /* allocate rows and set pointers to them */ 311 m[nrl]=(float32 *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(float32))); 312 if (!m[nrl]) nrerror("allocation failure 2 in f32matrix()"); 313 m[nrl] += NR_END; 314 m[nrl] -= ncl; 315 316 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 317 318 /* return pointer to array of pointers to rows */ 319 return m; 320 }/* ------------------------------------------------------------------- */ 321 IMAGE_EXPORT(float64**) f64matrix(long nrl, long nrh, long ncl, long nch) 322 /* ------------------------------------------------------------------- */ 323 324 /* allocate a float matrix with subscript range m[nrl..nrh][ncl..nch] */ 325 { 326 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 327 float64 **m; 328 329 /* allocate pointers to rows */ 330 m=(float64 **) malloc((size_t)((nrow+NR_END)*sizeof(float64*))); 331 if (!m) nrerror("allocation failure 1 in f64matrix()"); 332 m += NR_END; 333 m -= nrl; 334 335 /* allocate rows and set pointers to them */ 336 m[nrl]=(float64 *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(float64))); 337 if (!m[nrl]) nrerror("allocation failure 2 in f64matrix()"); 338 m[nrl] += NR_END; 339 m[nrl] -= ncl; 340 341 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 342 /* return pointer to array of pointers to rows */ 343 return m; 344 } 345 /* --------------------------------------------------------------------- */ 346 IMAGE_EXPORT(complex32**) c32matrix(long nrl, long nrh, long ncl, long nch) 347 /* --------------------------------------------------------------------- */ 348 /* allocate a complex32 matrix with subscript range m[nrl..nrh][ncl..nch] */ 349 { 350 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 351 complex32 **m; 352 353 /* allocate pointers to rows */ 354 m=(complex32 **) malloc((size_t)((nrow+NR_END)*sizeof(complex32*))); 355 if (!m) nrerror("allocation failure 1 in c32matrix()"); 356 m += NR_END; 357 m -= nrl; 358 359 /* allocate rows and set pointers to them */ 360 m[nrl]=(complex32 *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(complex32))); 361 if (!m[nrl]) nrerror("allocation failure 2 in c32matrix()"); 362 m[nrl] += NR_END; 363 m[nrl] -= ncl; 364 365 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 366 367 /* return pointer to array of pointers to rows */ 368 return m; 369 } 370 /* --------------------------------------------------------------------- */ 371 IMAGE_EXPORT(complex64**) c64matrix(long nrl, long nrh, long ncl, long nch) 372 /* --------------------------------------------------------------------- */ 373 /* allocate a complex32 matrix with subscript range m[nrl..nrh][ncl..nch] */ 374 { 375 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 376 complex64 **m; 377 378 /* allocate pointers to rows */ 379 m=(complex64 **) malloc((size_t)((nrow+NR_END)*sizeof(complex64*))); 380 if (!m) nrerror("allocation failure 1 in c64matrix()"); 381 m += NR_END; 382 m -= nrl; 383 384 /* allocate rows and set pointers to them */ 385 m[nrl]=(complex64 *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(complex64))); 386 if (!m[nrl]) nrerror("allocation failure 2 in c64matrix()"); 387 m[nrl] += NR_END; 388 m[nrl] -= ncl; 389 390 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 391 392 /* return pointer to array of pointers to rows */ 393 return m; 394 } 395 /* ----------------------------------------------------------------- */ 396 IMAGE_EXPORT(rgb8**) rgb8matrix(long nrl, long nrh, long ncl, long nch) 397 /* ----------------------------------------------------------------- */ 398 /* allocate a sint16 matrix with subscript range m[nrl..nrh][ncl..nch] */ 399 { 400 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 401 rgb8 **m; 402 403 /* allocate pointers to rows */ 404 m=(rgb8**) malloc((size_t)((nrow+NR_END)*sizeof(rgb8*))); 405 if (!m) nrerror("allocation failure 1 in rgb8matrix()"); 406 m += NR_END; 407 m -= nrl; 408 409 /* allocate rows and set pointers to them */ 410 m[nrl]=(rgb8*) malloc((size_t)((nrow*ncol+NR_END)*sizeof(rgb8))); 411 if (!m[nrl]) nrerror("allocation failure 2 in rgb8matrix()"); 412 m[nrl] += NR_END; 413 m[nrl] -= ncl; 414 415 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 416 417 /* return pointer to array of pointers to rows */ 418 return m; 419 } 420 /* ------------------------------------------------------------------- */ 421 IMAGE_EXPORT(rgbx8**) rgbx8matrix(long nrl, long nrh, long ncl, long nch) 422 /* ------------------------------------------------------------------- */ 423 /* allocate a sint16 matrix with subscript range m[nrl..nrh][ncl..nch] */ 424 { 425 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 426 rgbx8 **m; 427 428 /* allocate pointers to rows */ 429 m=(rgbx8**) malloc((size_t)((nrow+NR_END)*sizeof(rgbx8*))); 430 if (!m) nrerror("allocation failure 1 in rgbx8matrix()"); 431 m += NR_END; 432 m -= nrl; 433 434 /* allocate rows and set pointers to them */ 435 m[nrl]=(rgbx8*) malloc((size_t)((nrow*ncol+NR_END)*sizeof(rgbx8))); 436 if (!m[nrl]) nrerror("allocation failure 2 in rgbx8matrix()"); 437 m[nrl] += NR_END; 438 m[nrl] -= ncl; 439 440 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 441 442 /* return pointer to array of pointers to rows */ 443 return m; 444 } 445 /* ------------------------------------------------------------------- */ 446 IMAGE_EXPORT(rgb32**) rgb32matrix(long nrl, long nrh, long ncl, long nch) 447 /* ------------------------------------------------------------------- */ 448 /* allocate a sint16 matrix with subscript range m[nrl..nrh][ncl..nch] */ 449 { 450 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 451 rgb32 **m; 452 453 /* allocate pointers to rows */ 454 m=(rgb32**) malloc((size_t)((nrow+NR_END)*sizeof(rgb32*))); 455 if (!m) nrerror("allocation failure 1 in rgb32matrix()"); 456 m += NR_END; 457 m -= nrl; 458 459 /* allocate rows and set pointers to them */ 460 m[nrl]=(rgb32*) malloc((size_t)((nrow*ncol+NR_END)*sizeof(rgb32))); 461 if (!m[nrl]) nrerror("allocation failure 2 in rgb32matrix()"); 462 m[nrl] += NR_END; 463 m[nrl] -= ncl; 464 465 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 466 467 /* return pointer to array of pointers to rows */ 468 return m; 469 } 470 /* --------------------------------------------------------------------- */ 471 IMAGE_EXPORT(rgbx32**) rgbx32matrix(long nrl, long nrh, long ncl, long nch) 472 /* --------------------------------------------------------------------- */ 473 /* allocate a sint16 matrix with subscript range m[nrl..nrh][ncl..nch] */ 474 { 475 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 476 rgbx32 **m; 477 478 /* allocate pointers to rows */ 479 m=(rgbx32**) malloc((size_t)((nrow+NR_END)*sizeof(rgbx32*))); 480 if (!m) nrerror("allocation failure 1 in rgbx32matrix()"); 481 m += NR_END; 482 m -= nrl; 483 484 /* allocate rows and set pointers to them */ 485 m[nrl]=(rgbx32*) malloc((size_t)((nrow*ncol+NR_END)*sizeof(rgbx32))); 486 if (!m[nrl]) nrerror("allocation failure 2 in rgbx32matrix()"); 487 m[nrl] += NR_END; 488 m[nrl] -= ncl; 489 490 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 491 492 /* return pointer to array of pointers to rows */ 493 return m; 494 } 495 496 /* 497 * --------------- 498 * --- matrix0 --- 499 * --------------- 500 */ 501 502 /* --------------------------------------------------------------- */ 503 IMAGE_EXPORT(byte**) bmatrix0(long nrl, long nrh, long ncl, long nch) 504 /* --------------------------------------------------------------- */ 505 /* allocate a byte matrix with subscript range m[nrl..nrh][ncl..nch] */ 506 { 507 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 508 byte **m; 509 510 /* allocate pointers to rows */ 511 m=(byte **) malloc((size_t)((nrow+NR_END)*sizeof(byte*))); 512 if (!m) nrerror("allocation failure 1 in bmatrix0()"); 513 m += NR_END; 514 m -= nrl; 515 516 /* allocate rows and set pointers to them */ 517 m[nrl]=(byte *) calloc((size_t)(nrow*ncol+NR_END),sizeof(byte)); 518 if (!m[nrl]) nrerror("allocation failure 2 in bmatrix0()"); 519 m[nrl] += NR_END; 520 m[nrl] -= ncl; 521 522 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 523 524 /* return pointer to array of pointers to rows */ 525 return m; 526 } 527 /* ------------------------------------------------------------------ */ 528 IMAGE_EXPORT(sint8**) si8matrix0(long nrl, long nrh, long ncl, long nch) 529 /* ------------------------------------------------------------------ */ 530 { 531 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 532 sint8 **m; 533 534 /* allocate pointers to rows */ 535 m=(sint8 **) malloc((size_t)((nrow+NR_END)*sizeof(sint8*))); 536 if (!m) nrerror("allocation failure 1 in i8matrix0()"); 537 m += NR_END; 538 m -= nrl; 539 540 /* allocate rows and set pointers to them */ 541 m[nrl]=(sint8 *) calloc((size_t)(nrow*ncol+NR_END),sizeof(sint8)); 542 if (!m[nrl]) nrerror("allocation failure 2 in imatrix0()"); 543 m[nrl] += NR_END; 544 m[nrl] -= ncl; 545 546 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 547 548 /* return pointer to array of pointers to rows */ 549 return m; 550 } 551 /* ------------------------------------------------------------------ */ 552 IMAGE_EXPORT(uint8**) ui8matrix0(long nrl, long nrh, long ncl, long nch) 553 /* ------------------------------------------------------------------ */ 554 { 555 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 556 uint8 **m; 557 558 /* allocate pointers to rows */ 559 m=(uint8 **) malloc((size_t)((nrow+NR_END)*sizeof(uint8*))); 560 if (!m) nrerror("allocation failure 1 in ui8matrix0()"); 561 m += NR_END; 562 m -= nrl; 563 564 /* allocate rows and set pointers to them */ 565 m[nrl]=(uint8 *) calloc((size_t)(nrow*ncol+NR_END),sizeof(uint8)); 566 if (!m[nrl]) nrerror("allocation failure 2 in ui8matrix0()"); 567 m[nrl] += NR_END; 568 m[nrl] -= ncl; 569 570 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 571 572 /* return pointer to array of pointers to rows */ 573 return m; 574 } 575 /* -------------------------------------------------------------------- */ 576 IMAGE_EXPORT(sint16**) si16matrix0(long nrl, long nrh, long ncl, long nch) 577 /* -------------------------------------------------------------------- */ 578 /* allocate a sint16 matrix with subscript range m[nrl..nrh][ncl..nch] */ 579 { 580 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 581 sint16 **m; 582 583 /* allocate pointers to rows */ 584 m=(sint16 **) malloc((size_t)((nrow+NR_END)*sizeof(sint16*))); 585 if (!m) nrerror("allocation failure 1 in si16matrix0()"); 586 m += NR_END; 587 m -= nrl; 588 589 /* allocate rows and set pointers to them */ 590 m[nrl]=(sint16 *) calloc(nrow*ncol, sizeof(int16)); 591 if (!m[nrl]) nrerror("allocation failure 2 in si16matrix0()"); 592 m[nrl] += NR_END; 593 m[nrl] -= ncl; 594 595 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 596 597 /* return pointer to array of pointers to rows */ 598 return m; 599 } 600 /* -------------------------------------------------------------------- */ 601 IMAGE_EXPORT(uint16**) ui16matrix0(long nrl, long nrh, long ncl, long nch) 602 /* -------------------------------------------------------------------- */ 603 /* allocate a sint16 matrix with subscript range m[nrl..nrh][ncl..nch] */ 604 { 605 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 606 uint16 **m; 607 608 /* allocate pointers to rows */ 609 m=(uint16 **) malloc((size_t)((nrow+NR_END)*sizeof(uint16*))); 610 if (!m) nrerror("allocation failure 1 in ui16matrix0()"); 611 m += NR_END; 612 m -= nrl; 613 614 /* allocate rows and set pointers to them */ 615 m[nrl]=(uint16 *) calloc(nrow*ncol, sizeof(uint16)); 616 if (!m[nrl]) nrerror("allocation failure 2 in ui16matrix0()"); 617 m[nrl] += NR_END; 618 m[nrl] -= ncl; 619 620 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 621 622 /* return pointer to array of pointers to rows */ 623 return m; 624 } 625 /* -------------------------------------------------------------------- */ 626 IMAGE_EXPORT(sint32**) si32matrix0(long nrl, long nrh, long ncl, long nch) 627 /* -------------------------------------------------------------------- */ 628 /* allocate a int32 matrix with subscript range m[nrl..nrh][ncl..nch] */ 629 { 630 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 631 sint32 **m; 632 633 /* allocate pointers to rows */ 634 m=(sint32 **) malloc((size_t)((nrow+NR_END)*sizeof(sint32*))); 635 if (!m) nrerror("allocation failure 1 in si32matrix0()"); 636 m += NR_END; 637 m -= nrl; 638 639 /* allocate rows and set pointers to them */ 640 m[nrl]=(sint32 *) calloc((size_t)(nrow*ncol+NR_END),sizeof(sint32)); 641 if (!m[nrl]) nrerror("allocation failure 2 in si32matrix0()"); 642 m[nrl] += NR_END; 643 m[nrl] -= ncl; 644 645 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 646 647 /* return pointer to array of pointers to rows */ 648 return m; 649 } 650 /* -------------------------------------------------------------------- */ 651 IMAGE_EXPORT(uint32**) ui32matrix0(long nrl, long nrh, long ncl, long nch) 652 /* -------------------------------------------------------------------- */ 653 /* allocate a sint16 matrix with subscript range m[nrl..nrh][ncl..nch] */ 654 { 655 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 656 uint32 **m; 657 /* allocate pointers to rows */ 658 m=(uint32 **) malloc((size_t)((nrow+NR_END)*sizeof(uint32*))); 659 if (!m) nrerror("allocation failure 1 in ui32matrix0()"); 660 m += NR_END; 661 m -= nrl; 662 663 /* allocate rows and set pointers to them */ 664 m[nrl]=(uint32 *) calloc((size_t)(nrow*ncol+NR_END), sizeof(uint32)); 665 if (!m[nrl]) nrerror("allocation failure 2 in ui32matrix0()"); 666 m[nrl] += NR_END; 667 m[nrl] -= ncl; 668 669 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 670 /* return pointer to array of pointers to rows */ 671 return m; 672 } 673 /* -------------------------------------------------------------------- */ 674 IMAGE_EXPORT(sint64**) si64matrix0(long nrl, long nrh, long ncl, long nch) 675 /* -------------------------------------------------------------------- */ 676 { 677 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 678 sint64 **m; 679 680 /* allocate pointers to rows */ 681 m=(sint64 **) malloc((size_t)((nrow+NR_END)*sizeof(sint64*))); 682 if (!m) nrerror("allocation failure 1 in si64matrix0()"); 683 m += NR_END; 684 m -= nrl; 685 686 /* allocate rows and set pointers to them */ 687 m[nrl]=(sint64 *) calloc((size_t)(nrow*ncol+NR_END),sizeof(sint64)); 688 if (!m[nrl]) nrerror("allocation failure 2 in si64matrix0()"); 689 m[nrl] += NR_END; 690 m[nrl] -= ncl; 691 692 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 693 694 /* return pointer to array of pointers to rows */ 695 return m; 696 } 697 /* -------------------------------------------------------------------- */ 698 IMAGE_EXPORT(uint64**) ui64matrix0(long nrl, long nrh, long ncl, long nch) 699 /* -------------------------------------------------------------------- */ 700 { 701 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 702 uint64 **m; 703 704 /* allocate pointers to rows */ 705 m=(uint64 **) malloc((size_t)((nrow+NR_END)*sizeof(uint64*))); 706 if (!m) nrerror("allocation failure 1 in i64matrix0()"); 707 m += NR_END; 708 m -= nrl; 709 710 /* allocate rows and set pointers to them */ 711 m[nrl]=(uint64 *) calloc((size_t)(nrow*ncol+NR_END),sizeof(uint64)); 712 if (!m[nrl]) nrerror("allocation failure 2 in i64matrix0()"); 713 m[nrl] += NR_END; 714 m[nrl] -= ncl; 715 716 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 717 718 /* return pointer to array of pointers to rows */ 719 return m; 720 } 721 /* -------------------------------------------------------------------- */ 722 IMAGE_EXPORT(float32**) f32matrix0(long nrl, long nrh, long ncl, long nch) 723 /* -------------------------------------------------------------------- */ 724 { 725 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 726 float32 **m; 727 728 /* allocate pointers to rows */ 729 m=(float32 **) malloc((size_t)((nrow+NR_END)*sizeof(float32*))); 730 if (!m) nrerror("allocation failure 1 in f32matrix0()"); 731 m += NR_END; 732 m -= nrl; 733 734 /* allocate rows and set pointers to them */ 735 m[nrl]=(float32 *) calloc((size_t)(nrow*ncol+NR_END),sizeof(float32)); 736 if (!m[nrl]) nrerror("allocation failure 2 in f32matrix0()"); 737 m[nrl] += NR_END; 738 m[nrl] -= ncl; 739 740 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 741 742 /* return pointer to array of pointers to rows */ 743 return m; 744 } 745 /* -------------------------------------------------------------------- */ 746 IMAGE_EXPORT(float64**) f64matrix0(long nrl, long nrh, long ncl, long nch) 747 /* -------------------------------------------------------------------- */ 748 { 749 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 750 float64 **m; 751 752 /* allocate pointers to rows */ 753 m=(float64 **) malloc((size_t)((nrow+NR_END)*sizeof(float64*))); 754 if (!m) nrerror("allocation failure 1 in f64matrix0()"); 755 m += NR_END; 756 m -= nrl; 757 758 /* allocate rows and set pointers to them */ 759 m[nrl]=(float64 *) calloc((size_t)(nrow*ncol+NR_END),sizeof(float64)); 760 if (!m[nrl]) nrerror("allocation failure 2 in f64matrix0()"); 761 m[nrl] += NR_END; 762 m[nrl] -= ncl; 763 764 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 765 /* return pointer to array of pointers to rows */ 766 return m; 767 } 768 /* ---------------------------------------------------------------------- */ 769 IMAGE_EXPORT(complex32**) c32matrix0(long nrl, long nrh, long ncl, long nch) 770 /* ---------------------------------------------------------------------- */ 771 { 772 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 773 complex32 **m; 774 775 /* allocate pointers to rows */ 776 m=(complex32 **) malloc((size_t)((nrow+NR_END)*sizeof(complex32*))); 777 if (!m) nrerror("allocation failure 1 in c32matrix0()"); 778 m += NR_END; 779 m -= nrl; 780 781 /* allocate rows and set pointers to them */ 782 m[nrl]=(complex32 *) calloc((size_t)(nrow*ncol+NR_END),sizeof(complex32)); 783 if (!m[nrl]) nrerror("allocation failure 2 in c32matrix0()"); 784 m[nrl] += NR_END; 785 m[nrl] -= ncl; 786 787 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 788 789 /* return pointer to array of pointers to rows */ 790 return m; 791 } 792 /* ---------------------------------------------------------------------- */ 793 IMAGE_EXPORT(complex64**) c64matrix0(long nrl, long nrh, long ncl, long nch) 794 /* ---------------------------------------------------------------------- */ 795 { 796 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 797 complex64 **m; 798 799 /* allocate pointers to rows */ 800 m=(complex64 **) malloc((size_t)((nrow+NR_END)*sizeof(complex64*))); 801 if (!m) nrerror("allocation failure 1 in c64matrix0()"); 802 m += NR_END; 803 m -= nrl; 804 805 /* allocate rows and set pointers to them */ 806 m[nrl]=(complex64 *) calloc((size_t)(nrow*ncol+NR_END),sizeof(complex64)); 807 if (!m[nrl]) nrerror("allocation failure 2 in c64matrix0()"); 808 m[nrl] += NR_END; 809 m[nrl] -= ncl; 810 811 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 812 813 /* return pointer to array of pointers to rows */ 814 return m; 815 } 816 /* ------------------------------------------------------------------ */ 817 IMAGE_EXPORT(rgb8**) rgb8matrix0(long nrl, long nrh, long ncl, long nch) 818 /* ------------------------------------------------------------------ */ 819 /* allocate a sint16 matrix with subscript range m[nrl..nrh][ncl..nch] */ 820 { 821 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 822 rgb8 **m; 823 824 /* allocate pointers to rows */ 825 m=(rgb8**) malloc((size_t)((nrow+NR_END)*sizeof(rgb8*))); 826 if (!m) nrerror("allocation failure 1 in rgb8matrix0()"); 827 m += NR_END; 828 m -= nrl; 829 830 /* allocate rows and set pointers to them */ 831 m[nrl]=(rgb8*) calloc((size_t)(nrow*ncol+NR_END), sizeof(rgb8)); 832 if (!m[nrl]) nrerror("allocation failure 2 in rgb8matrix0()"); 833 m[nrl] += NR_END; 834 m[nrl] -= ncl; 835 836 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 837 838 /* return pointer to array of pointers to rows */ 839 return m; 840 } 841 /* -------------------------------------------------------------------- */ 842 IMAGE_EXPORT(rgbx8**) rgbx8matrix0(long nrl, long nrh, long ncl, long nch) 843 /* -------------------------------------------------------------------- */ 844 /* allocate a sint16 matrix with subscript range m[nrl..nrh][ncl..nch] */ 845 { 846 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 847 rgbx8 **m; 848 849 /* allocate pointers to rows */ 850 m=(rgbx8**) malloc((size_t)((nrow+NR_END)*sizeof(rgbx8*))); 851 if (!m) nrerror("allocation failure 1 in rgbx8matrix()"); 852 m += NR_END; 853 m -= nrl; 854 855 /* allocate rows and set pointers to them */ 856 m[nrl]=(rgbx8*) calloc((size_t)(nrow*ncol+NR_END), sizeof(rgbx8)); 857 if (!m[nrl]) nrerror("allocation failure 2 in rgbx8matrix()"); 858 m[nrl] += NR_END; 859 m[nrl] -= ncl; 860 861 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 862 863 /* return pointer to array of pointers to rows */ 864 return m; 865 } 866 /* -------------------------------------------------------------------- */ 867 IMAGE_EXPORT(rgb32**) rgb32matrix0(long nrl, long nrh, long ncl, long nch) 868 /* -------------------------------------------------------------------- */ 869 /* allocate a rgb32 matrix with subscript range m[nrl..nrh][ncl..nch] */ 870 { 871 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 872 rgb32 **m; 873 874 /* allocate pointers to rows */ 875 m=(rgb32**) malloc((size_t)((nrow+NR_END)*sizeof(rgb32*))); 876 if (!m) nrerror("allocation failure 1 in rgb32matrix0()"); 877 m += NR_END; 878 m -= nrl; 879 880 /* allocate rows and set pointers to them */ 881 m[nrl]=(rgb32*) calloc((nrow*ncol+NR_END), sizeof(rgb32)); 882 if (!m[nrl]) nrerror("allocation failure 2 in rgb32matrix0()"); 883 m[nrl] += NR_END; 884 m[nrl] -= ncl; 885 886 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 887 888 /* return pointer to array of pointers to rows */ 889 return m; 890 } 891 /* ---------------------------------------------------------------------- */ 892 IMAGE_EXPORT(rgbx32**) rgbx32matrix0(long nrl, long nrh, long ncl, long nch) 893 /* ---------------------------------------------------------------------- */ 894 /* allocate a rgb32 matrix with subscript range m[nrl..nrh][ncl..nch] */ 895 { 896 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1; 897 rgbx32 **m; 898 899 /* allocate pointers to rows */ 900 m=(rgbx32**) malloc((size_t)((nrow+NR_END)*sizeof(rgbx32*))); 901 if (!m) nrerror("allocation failure 1 in rgbx32matrix()"); 902 m += NR_END; 903 m -= nrl; 904 905 /* allocate rows and set pointers to them */ 906 m[nrl]=(rgbx32*) calloc((size_t)(nrow*ncol+NR_END), sizeof(rgbx32)); 907 if (!m[nrl]) nrerror("allocation failure 2 in rgbx32matrix()"); 908 m[nrl] += NR_END; 909 m[nrl] -= ncl; 910 911 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; 912 913 /* return pointer to array of pointers to rows */ 914 return m; 915 } 916 /* 917 * ------------------- 918 * --- free_matrix --- 919 * ------------------- 920 */ 921 922 /* ------------------------------------------------------------- */ 923 void free_matrix(float **m, long nrl, long nrh, long ncl, long nch) 924 /* ------------------------------------------------------------- */ 925 /* free a float matrix allocated by matrix() */ 926 { 927 free((FREE_ARG) (m[nrl]+ncl-NR_END)); 928 free((FREE_ARG) (m+nrl-NR_END)); 929 } 930 /* --------------------------------------------------------------------------- */ 931 IMAGE_EXPORT(void) free_bmatrix(byte **m, long nrl, long nrh, long ncl, long nch) 932 /* --------------------------------------------------------------------------- */ 933 { 934 free((FREE_ARG) (m[nrl]+ncl-NR_END)); 935 free((FREE_ARG) (m+nrl-NR_END)); 936 } 937 /* ------------------------------------------------------------------------------ */ 938 IMAGE_EXPORT(void) free_si8matrix(sint8 **m, long nrl, long nrh, long ncl, long nch) 939 /* ------------------------------------------------------------------------------ */ 940 { 941 free((FREE_ARG) (m[nrl]+ncl-NR_END)); 942 free((FREE_ARG) (m+nrl-NR_END)); 943 } 944 /* ------------------------------------------------------------------------------ */ 945 IMAGE_EXPORT(void) free_ui8matrix(uint8 **m, long nrl, long nrh, long ncl, long nch) 946 /* ------------------------------------------------------------------------------ */ 947 { 948 free((FREE_ARG) (m[nrl]+ncl-NR_END)); 949 free((FREE_ARG) (m+nrl-NR_END)); 950 }/* -------------------------------------------------------------------------------- */ 951 IMAGE_EXPORT(void) free_si16matrix(sint16 **m, long nrl, long nrh, long ncl, long nch) 952 /* -------------------------------------------------------------------------------- */ 953 { 954 free((FREE_ARG) (m[nrl]+ncl-NR_END)); 955 free((FREE_ARG) (m+nrl-NR_END)); 956 } 957 /* -------------------------------------------------------------------------------- */ 958 IMAGE_EXPORT(void) free_ui16matrix(uint16 **m, long nrl, long nrh, long ncl, long nch) 959 /* -------------------------------------------------------------------------------- */ 960 { 961 free((FREE_ARG) (m[nrl]+ncl-NR_END)); 962 free((FREE_ARG) (m+nrl-NR_END)); 963 } 964 /* -------------------------------------------------------------------------------- */ 965 IMAGE_EXPORT(void) free_si32matrix(sint32 **m, long nrl, long nrh, long ncl, long nch) 966 /* -------------------------------------------------------------------------------- */ 967 { 968 free((FREE_ARG) (m[nrl]+ncl-NR_END)); 969 free((FREE_ARG) (m+nrl-NR_END)); 970 } 971 /* -------------------------------------------------------------------------------- */ 972 IMAGE_EXPORT(void) free_ui32matrix(uint32 **m, long nrl, long nrh, long ncl, long nch) 973 /* -------------------------------------------------------------------------------- */ 974 { 975 free((FREE_ARG) (m[nrl]+ncl-NR_END)); 976 free((FREE_ARG) (m+nrl-NR_END)); 977 } 978 /* -------------------------------------------------------------------------------- */ 979 IMAGE_EXPORT(void) free_si64matrix(sint64 **m, long nrl, long nrh, long ncl, long nch) 980 /* -------------------------------------------------------------------------------- */ 981 { 982 free((FREE_ARG) (m[nrl]+ncl-NR_END)); 983 free((FREE_ARG) (m+nrl-NR_END)); 984 } 985 /* -------------------------------------------------------------------------------- */ 986 IMAGE_EXPORT(void) free_ui64matrix(uint64 **m, long nrl, long nrh, long ncl, long nch) 987 /* -------------------------------------------------------------------------------- */ 988 { 989 free((FREE_ARG) (m[nrl]+ncl-NR_END)); 990 free((FREE_ARG) (m+nrl-NR_END)); 991 } 992 /* -------------------------------------------------------------------------------- */ 993 IMAGE_EXPORT(void) free_f32matrix(float32 **m, long nrl, long nrh, long ncl, long nch) 994 /* -------------------------------------------------------------------------------- */ 995 { 996 free((FREE_ARG) (m[nrl]+ncl-NR_END)); 997 free((FREE_ARG) (m+nrl-NR_END)); 998 } 999 /* -------------------------------------------------------------------------------- */ 1000 IMAGE_EXPORT(void) free_f64matrix(float64 **m, long nrl, long nrh, long ncl, long nch) 1001 /* -------------------------------------------------------------------------------- */ 1002 { 1003 free((FREE_ARG) (m[nrl]+ncl-NR_END)); 1004 free((FREE_ARG) (m+nrl-NR_END)); 1005 } 1006 /* ---------------------------------------------------------------------------------- */ 1007 IMAGE_EXPORT(void) free_c32matrix(complex32 **m, long nrl, long nrh, long ncl, long nch) 1008 /* ---------------------------------------------------------------------------------- */ 1009 { 1010 free((FREE_ARG) (m[nrl]+ncl-NR_END)); 1011 free((FREE_ARG) (m+nrl-NR_END)); 1012 } 1013 /* ---------------------------------------------------------------------------------- */ 1014 IMAGE_EXPORT(void) free_c64matrix(complex64 **m, long nrl, long nrh, long ncl, long nch) 1015 /* ---------------------------------------------------------------------------------- */ 1016 { 1017 free((FREE_ARG) (m[nrl]+ncl-NR_END)); 1018 free((FREE_ARG) (m+nrl-NR_END)); 1019 } 1020 /* ------------------------------------------------------------------------------ */ 1021 IMAGE_EXPORT(void) free_rgb8matrix(rgb8 **m, long nrl, long nrh, long ncl, long nch) 1022 /* ------------------------------------------------------------------------------ */ 1023 { 1024 free((FREE_ARG) (m[nrl]+ncl-NR_END)); 1025 free((FREE_ARG) (m+nrl-NR_END)); 1026 } 1027 /* -------------------------------------------------------------------------------- */ 1028 IMAGE_EXPORT(void) free_rgbx8matrix(rgbx8 **m, long nrl, long nrh, long ncl, long nch) 1029 /* -------------------------------------------------------------------------------- */ 1030 { 1031 free((FREE_ARG) (m[nrl]+ncl-NR_END)); 1032 free((FREE_ARG) (m+nrl-NR_END)); 1033 } 1034 /* ------------------------------------------------------------------------------ */ 1035 IMAGE_EXPORT(void) free_rgb32matrix(rgb32 **m, long nrl, long nrh, long ncl, long nch) 1036 /* ------------------------------------------------------------------------------ */ 1037 { 1038 free((FREE_ARG) (m[nrl]+ncl-NR_END)); 1039 free((FREE_ARG) (m+nrl-NR_END)); 1040 } 1041 /* ---------------------------------------------------------------------------------- */ 1042 IMAGE_EXPORT(void) free_rgbx32matrix(rgbx32 **m, long nrl, long nrh, long ncl, long nch) 1043 /* ---------------------------------------------------------------------------------- */ 1044 { 1045 free((FREE_ARG) (m[nrl]+ncl-NR_END)); 1046 free((FREE_ARG) (m+nrl-NR_END)); 1047 } 48 49 50 #undef type_matrix 51 #define type_matrix(t) \ 52 t ** short_name(t,,matrix)(int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ 53 { \ 54 int32_t nrow = nrh - nrl + 1; \ 55 int32_t ncol = nch - ncl + 1; \ 56 t ** m; \ 57 /* allocate pointers to row */ \ 58 m = malloc((nrow + NR_END) * sizeof(t *)); \ 59 if (m == NULL) { \ 60 nrerror("*** Error: allocation failure in %s\n", __func__); \ 61 } \ 62 m += NR_END; \ 63 m -= nrl; \ 64 /* allocate rows and set pointers to them */ \ 65 m[nrl] = malloc((nrow * ncol + NR_END) * sizeof(t)); \ 66 if (m[nrl] == NULL) { \ 67 nrerror("*** Error: allocation failure in %s\n", __func__); \ 68 } \ 69 m[nrl] += NR_END; \ 70 m[nrl] -= ncl; \ 71 for (int32_t i = nrl + 1; i <= nrh; i++) { \ 72 m[i] = m[i - 1] + ncol; \ 73 } \ 74 /* return pointer to array of pointers to rows */ \ 75 return m; \ 76 } 77 78 79 type_matrix(int8_t); 80 type_matrix(uint8_t); 81 type_matrix(int16_t); 82 type_matrix(uint16_t); 83 type_matrix(int32_t); 84 type_matrix(uint32_t); 85 type_matrix(int64_t); 86 type_matrix(uint64_t); 87 type_matrix(float); 88 type_matrix(double); 89 type_matrix(void_p); 90 type_matrix(rgb8); 91 type_matrix(rgbx8); 92 type_matrix(rgb32); 93 type_matrix(rgbx32); 94 type_matrix(complex32); 95 type_matrix(complex64); 96 type_matrix(si16Point); 97 type_matrix(ui16Point); 98 type_matrix(si32Point); 99 type_matrix(ui32Point); 100 type_matrix(f32Point); 101 type_matrix(si16Triplet); 102 type_matrix(ui16Triplet); 103 type_matrix(si32Triplet); 104 type_matrix(ui32Triplet); 105 type_matrix(f32Triplet); 106 107 108 109 110 #undef type_matrix0 111 #define type_matrix0(t) \ 112 t ** short_name(t,,matrix0)(int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ 113 { \ 114 int32_t nrow = nrh - nrl + 1; \ 115 int32_t ncol = nch - ncl + 1; \ 116 t ** m; \ 117 /* allocate pointers to row */ \ 118 m = malloc((nrow + NR_END) * sizeof(t *)); \ 119 if (m == NULL) { \ 120 nrerror("*** Error: allocation failure in %s\n", __func__); \ 121 } \ 122 m += NR_END; \ 123 m -= nrl; \ 124 /* allocate rows and set pointers to them */ \ 125 m[nrl] = calloc((nrow * ncol + NR_END), sizeof(t)); \ 126 if (m[nrl] == NULL) { \ 127 nrerror("*** Error: allocation failure in %s\n", __func__); \ 128 } \ 129 m[nrl] += NR_END; \ 130 m[nrl] -= ncl; \ 131 for (int32_t i = nrl + 1; i <= nrh; i++) { \ 132 m[i] = m[i - 1] + ncol; \ 133 } \ 134 /* return pointer to array of pointers to rows */ \ 135 return m; \ 136 } 137 138 139 type_matrix0(int8_t); 140 type_matrix0(uint8_t); 141 type_matrix0(int16_t); 142 type_matrix0(uint16_t); 143 type_matrix0(int32_t); 144 type_matrix0(uint32_t); 145 type_matrix0(int64_t); 146 type_matrix0(uint64_t); 147 type_matrix0(float); 148 type_matrix0(double); 149 type_matrix0(void_p); 150 type_matrix0(rgb8); 151 type_matrix0(rgbx8); 152 type_matrix0(rgb32); 153 type_matrix0(rgbx32); 154 type_matrix0(complex32); 155 type_matrix0(complex64); 156 157 158 #if TARGET_OS == GIETVM 159 160 #undef remote_type_matrix 161 #define remote_type_matrix(t) \ 162 t ** short_name(t,remote_,matrix)(int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ 163 { \ 164 int32_t nrow = nrh - nrl + 1; \ 165 int32_t ncol = nch - ncl + 1; \ 166 t ** m; \ 167 /* allocate pointers to row */ \ 168 m = malloc((nrow + NR_END) * sizeof(t *)); \ 169 if (m == NULL) { \ 170 nrerror("*** Error: allocation failure in %s\n", __func__); \ 171 } \ 172 m += NR_END; \ 173 m -= nrl; \ 174 /* allocate rows and set pointers to them */ \ 175 m[nrl] = malloc((nrow * ncol + NR_END) * sizeof(t)); \ 176 if (m[nrl] == NULL) { \ 177 nrerror("*** Error: allocation failure in %s\n", __func__); \ 178 } \ 179 m[nrl] += NR_END; \ 180 m[nrl] -= ncl; \ 181 for (int32_t i = nrl + 1; i <= nrh; i++) { \ 182 m[i] = m[i - 1] + ncol; \ 183 } \ 184 /* return pointer to array of pointers to rows */ \ 185 return m; \ 186 } 187 188 189 remote_type_matrix(int8_t); 190 remote_type_matrix(uint8_t); 191 remote_type_matrix(int16_t); 192 remote_type_matrix(uint16_t); 193 remote_type_matrix(int32_t); 194 remote_type_matrix(uint32_t); 195 remote_type_matrix(int64_t); 196 remote_type_matrix(uint64_t); 197 remote_type_matrix(float); 198 remote_type_matrix(double); 199 remote_type_matrix(void_p); 200 remote_type_matrix(rgb8); 201 remote_type_matrix(rgbx8); 202 remote_type_matrix(rgb32); 203 remote_type_matrix(rgbx32); 204 remote_type_matrix(complex32); 205 remote_type_matrix(complex64); 206 207 #endif 208 209 210 #undef free_type_matrix 211 #define free_type_matrix(t) \ 212 void short_name(t,free_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ 213 { \ 214 free((FREE_ARG) (m[nrl] + ncl - NR_END)); \ 215 free((FREE_ARG) (m + nrl - NR_END)); \ 216 } 217 218 free_type_matrix(int8_t); 219 free_type_matrix(uint8_t); 220 free_type_matrix(int16_t); 221 free_type_matrix(uint16_t); 222 free_type_matrix(int32_t); 223 free_type_matrix(uint32_t); 224 free_type_matrix(int64_t); 225 free_type_matrix(uint64_t); 226 free_type_matrix(float); 227 free_type_matrix(double); 228 free_type_matrix(void_p); 229 free_type_matrix(rgb8); 230 free_type_matrix(rgbx8); 231 free_type_matrix(rgb32); 232 free_type_matrix(rgbx32); 233 free_type_matrix(complex32); 234 free_type_matrix(complex64); 235 free_type_matrix(si16Point); 236 free_type_matrix(ui16Point); 237 free_type_matrix(si32Point); 238 free_type_matrix(ui32Point); 239 free_type_matrix(f32Point); 240 free_type_matrix(si16Triplet); 241 free_type_matrix(ui16Triplet); 242 free_type_matrix(si32Triplet); 243 free_type_matrix(ui32Triplet); 244 free_type_matrix(f32Triplet); 245 246 247 248 // Local Variables: 249 // tab-width: 4 250 // c-basic-offset: 4 251 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 252 // indent-tabs-mode: nil 253 // End: 254 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 255 -
soft/giet_vm/applications/rosenfeld/nrc2/src/nralloc2x.c
r772 r821 17 17 #include <malloc.h> 18 18 #include <math.h> // fabs 19 // #include <memory.h> // memcpy20 19 20 #include "nrc_os_config.h" 21 21 #include "mypredef.h" 22 22 #include "nrtype.h" … … 25 25 #include "nrkernel.h" 26 26 27 #include "nralloc1.h"28 #include "nralloc2.h"29 27 #include "nralloc2x.h" 30 //#include "nrarith.h"31 28 32 /* ----------------------------------------------------------------------- */33 IMAGE_EXPORT(si16Point**) si16Pmatrix(long nrl, long nrh, long ncl, long nch)34 /* ----------------------------------------------------------------------- */35 {36 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;37 si16Point **m;38 39 /* allocate pointers to rows */40 m=(si16Point **) malloc((size_t)((nrow+NR_END)*sizeof(si16Point*)));41 if (!m) nrerror("allocation failure 1 in si16Pmatrix()");42 m += NR_END;43 m -= nrl;44 45 /* allocate rows and set pointers to them */46 m[nrl]=(si16Point *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(si16Point)));47 if (!m[nrl]) nrerror("allocation failure 2 in si16Pmatrix()");48 m[nrl] += NR_END;49 m[nrl] -= ncl;50 51 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;52 53 /* return pointer to array of pointers to rows */54 return m;55 }56 /* ----------------------------------------------------------------------- */57 IMAGE_EXPORT(ui16Point**) ui16Pmatrix(long nrl, long nrh, long ncl, long nch)58 /* ----------------------------------------------------------------------- */59 {60 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;61 ui16Point **m;62 63 /* allocate pointers to rows */64 m=(ui16Point **) malloc((size_t)((nrow+NR_END)*sizeof(ui16Point*)));65 if (!m) nrerror("allocation failure 1 in ui16Pmatrix()");66 m += NR_END;67 m -= nrl;68 69 /* allocate rows and set pointers to them */70 m[nrl]=(ui16Point *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(ui16Point)));71 if (!m[nrl]) nrerror("allocation failure 2 in ui16Pmatrix()");72 m[nrl] += NR_END;73 m[nrl] -= ncl;74 75 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;76 77 /* return pointer to array of pointers to rows */78 return m;79 }80 /* ----------------------------------------------------------------------- */81 IMAGE_EXPORT(si32Point**) si32Pmatrix(long nrl, long nrh, long ncl, long nch)82 /* ----------------------------------------------------------------------- */83 {84 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;85 si32Point **m;86 87 /* allocate pointers to rows */88 m=(si32Point **) malloc((size_t)((nrow+NR_END)*sizeof(si32Point*)));89 if (!m) nrerror("allocation failure 1 in si32Pmatrix()");90 m += NR_END;91 m -= nrl;92 93 /* allocate rows and set pointers to them */94 m[nrl]=(si32Point *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(si32Point)));95 if (!m[nrl]) nrerror("allocation failure 2 in si32Pmatrix()");96 m[nrl] += NR_END;97 m[nrl] -= ncl;98 99 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;100 101 /* return pointer to array of pointers to rows */102 return m;103 }104 /* ----------------------------------------------------------------------- */105 IMAGE_EXPORT(ui32Point**) ui32Pmatrix(long nrl, long nrh, long ncl, long nch)106 /* ----------------------------------------------------------------------- */107 {108 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;109 ui32Point **m;110 111 /* allocate pointers to rows */112 m=(ui32Point **) malloc((size_t)((nrow+NR_END)*sizeof(ui32Point*)));113 if (!m) nrerror("allocation failure 1 in ui32Pmatrix()");114 m += NR_END;115 m -= nrl;116 117 /* allocate rows and set pointers to them */118 m[nrl]=(ui32Point *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(ui32Point)));119 if (!m[nrl]) nrerror("allocation failure 2 in ui32Pmatrix()");120 m[nrl] += NR_END;121 m[nrl] -= ncl;122 123 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;124 125 /* return pointer to array of pointers to rows */126 return m;127 }128 /* ---------------------------------------------------------------------- */129 IMAGE_EXPORT(f32Point**) f32Pmatrix(long nrl, long nrh, long ncl, long nch)130 /* --------------------------------------------------------------------- */131 {132 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;133 f32Point **m;134 135 /* allocate pointers to rows */136 m=(f32Point **) malloc((size_t)((nrow+NR_END)*sizeof(f32Point*)));137 if (!m) nrerror("allocation failure 1 in f32Pmatrix()");138 m += NR_END;139 m -= nrl;140 141 /* allocate rows and set pointers to them */142 m[nrl]=(f32Point *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(f32Point)));143 if (!m[nrl]) nrerror("allocation failure 2 in f32Pmatrix()");144 m[nrl] += NR_END;145 m[nrl] -= ncl;146 147 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;148 149 /* return pointer to array of pointers to rows */150 return m;151 }152 /* ------------------------------------------------------------------------- */153 IMAGE_EXPORT(si16Triplet**) si16Tmatrix(long nrl, long nrh, long ncl, long nch)154 /* ------------------------------------------------------------------------- */155 {156 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;157 si16Triplet **m;158 159 /* allocate pointers to rows */160 m=(si16Triplet **) malloc((size_t)((nrow+NR_END)*sizeof(si16Triplet*)));161 if (!m) nrerror("allocation failure 1 in si16Tmatrix()");162 m += NR_END;163 m -= nrl;164 165 /* allocate rows and set pointers to them */166 m[nrl]=(si16Triplet *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(si16Triplet)));167 if (!m[nrl]) nrerror("allocation failure 2 in si16Tmatrix()");168 m[nrl] += NR_END;169 m[nrl] -= ncl;170 171 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;172 173 /* return pointer to array of pointers to rows */174 return m;175 }176 /* ----------------------------------------------------------------------- */177 IMAGE_EXPORT(ui16Triplet**) ui16Tmatrix(long nrl, long nrh, long ncl, long nch)178 /* ----------------------------------------------------------------------- */179 {180 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;181 ui16Triplet **m;182 183 /* allocate pointers to rows */184 m=(ui16Triplet **) malloc((size_t)((nrow+NR_END)*sizeof(ui16Triplet*)));185 if (!m) nrerror("allocation failure 1 in ui16Tmatrix()");186 m += NR_END;187 m -= nrl;188 189 /* allocate rows and set pointers to them */190 m[nrl]=(ui16Triplet *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(ui16Triplet)));191 if (!m[nrl]) nrerror("allocation failure 2 in ui16Tmatrix()");192 m[nrl] += NR_END;193 m[nrl] -= ncl;194 195 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;196 197 /* return pointer to array of pointers to rows */198 return m;199 }200 /* ----------------------------------------------------------------------- */201 IMAGE_EXPORT(si32Triplet**) si32Tmatrix(long nrl, long nrh, long ncl, long nch)202 /* ----------------------------------------------------------------------- */203 {204 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;205 si32Triplet **m;206 207 /* allocate pointers to rows */208 m=(si32Triplet**) malloc((size_t)((nrow+NR_END)*sizeof(si32Triplet*)));209 if (!m) nrerror("allocation failure 1 in si32Tmatrix()");210 m += NR_END;211 m -= nrl;212 213 /* allocate rows and set pointers to them */214 m[nrl]=(si32Triplet*) malloc((size_t)((nrow*ncol+NR_END)*sizeof(si32Triplet)));215 if (!m[nrl]) nrerror("allocation failure 2 in si32Tmatrix()");216 m[nrl] += NR_END;217 m[nrl] -= ncl;218 219 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;220 221 /* return pointer to array of pointers to rows */222 return m;223 }224 /* ----------------------------------------------------------------------- */225 IMAGE_EXPORT(ui32Triplet**) ui32Tmatrix(long nrl, long nrh, long ncl, long nch)226 /* ----------------------------------------------------------------------- */227 {228 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;229 ui32Triplet **m;230 231 /* allocate pointers to rows */232 m=(ui32Triplet **) malloc((size_t)((nrow+NR_END)*sizeof(ui32Triplet*)));233 if (!m) nrerror("allocation failure 1 in ui32Tmatrix()");234 m += NR_END;235 m -= nrl;236 237 /* allocate rows and set pointers to them */238 m[nrl]=(ui32Triplet *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(ui32Triplet)));239 if (!m[nrl]) nrerror("allocation failure 2 in ui32Tmatrix()");240 m[nrl] += NR_END;241 m[nrl] -= ncl;242 243 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;244 245 /* return pointer to array of pointers to rows */246 return m;247 }248 /* ---------------------------------------------------------------------- */249 IMAGE_EXPORT(f32Triplet**) f32Tmatrix(long nrl, long nrh, long ncl, long nch)250 /* --------------------------------------------------------------------- */251 {252 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;253 f32Triplet **m;254 255 /* allocate pointers to rows */256 m=(f32Triplet **) malloc((size_t)((nrow+NR_END)*sizeof(f32Triplet*)));257 if (!m) nrerror("allocation failure 1 in f32Tmatrix()");258 m += NR_END;259 m -= nrl;260 261 /* allocate rows and set pointers to them */262 m[nrl]=(f32Triplet *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(f32Triplet)));263 if (!m[nrl]) nrerror("allocation failure 2 in f32Tmatrix()");264 m[nrl] += NR_END;265 m[nrl] -= ncl;266 267 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;268 269 /* return pointer to array of pointers to rows */270 return m;271 }272 /* ---------------------------------------------------------------------------------- */273 IMAGE_EXPORT(void) free_si16Pmatrix(si16Point **m, long nrl, long nrh, long ncl, long nch)274 /* ---------------------------------------------------------------------------------- */275 /* free an si16Point matrix allocated by si16Pmatrix() */276 {277 free((FREE_ARG) (m[nrl]+ncl-NR_END));278 free((FREE_ARG) (m+nrl-NR_END));279 }280 /* ---------------------------------------------------------------------------------- */281 IMAGE_EXPORT(void) free_ui16Pmatrix(ui16Point **m, long nrl, long nrh, long ncl, long nch)282 /* ---------------------------------------------------------------------------------- */283 /* free an ui16Point matrix allocated by ui16Pmatrix() */284 {285 free((FREE_ARG) (m[nrl]+ncl-NR_END));286 free((FREE_ARG) (m+nrl-NR_END));287 }288 /* ------------------------------------------------------------------------------------ */289 IMAGE_EXPORT(void) free_si32Pmatrix(si32Point **m, long nrl, long nrh, long ncl, long nch)290 /* ------------------------------------------------------------------------------------ */291 {292 free((FREE_ARG) (m[nrl]+ncl-NR_END));293 free((FREE_ARG) (m+nrl-NR_END));294 }295 /* ------------------------------------------------------------------------------------ */296 IMAGE_EXPORT(void) free_ui32Pmatrix(ui32Point **m, long nrl, long nrh, long ncl, long nch)297 /* ------------------------------------------------------------------------------------ */298 {299 free((FREE_ARG) (m[nrl]+ncl-NR_END));300 free((FREE_ARG) (m+nrl-NR_END));301 }302 /* ---------------------------------------------------------------------------------- */303 IMAGE_EXPORT(void) free_f32Pmatrix(f32Point **m, long nrl, long nrh, long ncl, long nch)304 /* ---------------------------------------------------------------------------------- */305 /* free an f32Point matrix allocated by f32Pmatrix() */306 {307 free((FREE_ARG) (m[nrl]+ncl-NR_END));308 free((FREE_ARG) (m+nrl-NR_END));309 }310 /* -------------------------------------------------------------------------------------- */311 IMAGE_EXPORT(void) free_si16Tmatrix(si16Triplet **m, long nrl, long nrh, long ncl, long nch)312 /* -------------------------------------------------------------------------------------- */313 /* free an si16Point matrix allocated by si16Pmatrix() */314 {315 free((FREE_ARG) (m[nrl]+ncl-NR_END));316 free((FREE_ARG) (m+nrl-NR_END));317 }318 /* ---------------------------------------------------------------------------------- */319 IMAGE_EXPORT(void) free_ui16Tmatrix(ui16Triplet **m, long nrl, long nrh, long ncl, long nch)320 /* ---------------------------------------------------------------------------------- */321 /* free an ui16Point matrix allocated by ui16Pmatrix() */322 {323 free((FREE_ARG) (m[nrl]+ncl-NR_END));324 free((FREE_ARG) (m+nrl-NR_END));325 }326 /* ------------------------------------------------------------------------------------ */327 IMAGE_EXPORT(void) free_si32Tmatrix(si32Triplet **m, long nrl, long nrh, long ncl, long nch)328 /* ------------------------------------------------------------------------------------ */329 {330 free((FREE_ARG) (m[nrl]+ncl-NR_END));331 free((FREE_ARG) (m+nrl-NR_END));332 }333 /* -------------------------------------------------------------------------------------- */334 IMAGE_EXPORT(void) free_ui32Tmatrix(ui32Triplet **m, long nrl, long nrh, long ncl, long nch)335 /* -------------------------------------------------------------------------------------- */336 {337 free((FREE_ARG) (m[nrl]+ncl-NR_END));338 free((FREE_ARG) (m+nrl-NR_END));339 }340 /* ------------------------------------------------------------------------------------ */341 IMAGE_EXPORT(void) free_f32Tmatrix(f32Triplet **m, long nrl, long nrh, long ncl, long nch)342 /* ------------------------------------------------------------------------------------ */343 /* free an f32Point matrix allocated by f32Pmatrix() */344 {345 free((FREE_ARG) (m[nrl]+ncl-NR_END));346 free((FREE_ARG) (m+nrl-NR_END));347 }348 29 349 30 /* ----------------- */ 350 31 /* --- trimatrix --- */ 351 32 /* ----------------- */ 352 /* ---------------------------------------------------------------------------- */ 353 IMAGE_EXPORT(byte**) btrimatrix(long nrl, long nrh, long ncl, long nch, long step) 354 /* ---------------------------------------------------------------------------- */ 355 /* allocate an byte triangle-matrix with subscript range m[nrl..nrh][ncl..nch] */ 356 { 357 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1, n = nrow * ncol + (nrow * (nrow-1) * step) / 2; 358 // Attention, factorisation of n IS NOT PERMITTED : (nrow-1)step/2 is not even!!! 359 byte **m; 360 361 /* allocate pointers to rows */ 362 m=(byte **) malloc((size_t)((nrow+NR_END)*sizeof(byte*))); 363 if (!m) nrerror("allocation failure 1 in btrimatrix()"); 364 m += NR_END; 365 m -= nrl; 366 367 368 /* allocate rows and set pointers to them */ 369 m[nrl]=(byte *) malloc((size_t)((n+NR_END)*sizeof(byte))); 370 if (!m[nrl]) nrerror("allocation failure 2 in btrimatrix()"); 371 m[nrl] += NR_END; 372 m[nrl] -= ncl; 373 374 for(i=nrl+1;i<=nrh;i++) { m[i]=m[i-1]+ncol; ncol += step; } 375 376 /* return pointer to array of pointers to rows */ 377 return m; 33 34 35 #undef type_trimatrix 36 #define type_trimatrix(t) \ 37 t ** short_name(t,,trimatrix)(int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, int32_t step) \ 38 /* allocate an byte triangle-matrix with subscript range m[nrl..nrh][ncl..nch] */ \ 39 { \ 40 int32_t nrow = nrh - nrl + 1; \ 41 int32_t ncol = nch - ncl + 1; \ 42 int n = nrow * ncol + (nrow * (nrow - 1) * step) / 2; \ 43 /* Attention, factorisation of n IS NOT PERMITTED : (nrow - 1) step / 2 is not even!!! */ \ 44 t ** m; \ 45 /* allocate pointers to rows */ \ 46 m = malloc((nrow + NR_END) * sizeof(t *)); \ 47 if (m == NULL) { \ 48 nrerror("*** Error: allocation failure in %s\n", __func__); \ 49 } \ 50 m += NR_END; \ 51 m -= nrl; \ 52 /* allocate rows and set pointers to them */ \ 53 m[nrl] = malloc(((n + NR_END) * sizeof(t))); \ 54 if (m[nrl] == NULL) { \ 55 nrerror("*** Error: allocation failure in %s\n", __func__); \ 56 } \ 57 m[nrl] += NR_END; \ 58 m[nrl] -= ncl; \ 59 for (int32_t i = nrl + 1; i <= nrh;i++) { \ 60 m[i] = m[i - 1] + ncol; \ 61 ncol += step; \ 62 } \ 63 /* return pointer to array of pointers to rows */ \ 64 return m; \ 378 65 } 379 /* --------------------------------------------------------------------------------- */ 380 IMAGE_EXPORT(sint16**) si16trimatrix(long nrl, long nrh, long ncl, long nch, long step) 381 /* --------------------------------------------------------------------------------- */ 382 /* allocate an i16 triangle-matrix with subscript range m[nrl..nrh][ncl..nch] */ 383 { 384 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1, n = nrow * ncol + (nrow * (nrow-1) * step) / 2; 385 // Attention, factorisation of n IS NOT PERMITTED : (nrow-1)step/2 is not even!!! 386 sint16 **m; 387 388 /* allocate pointers to rows */ 389 m=(sint16 **) malloc((size_t)((nrow+NR_END)*sizeof(sint16*))); 390 if (!m) nrerror("allocation failure 1 in i16trimatrix()"); 391 m += NR_END; 392 m -= nrl; 393 394 395 /* allocate rows and set pointers to them */ 396 m[nrl]=(int16*) malloc((size_t)((n+NR_END)*sizeof(int16))); 397 if (!m[nrl]) nrerror("allocation failure 2 in i16trimatrix()"); 398 m[nrl] += NR_END; 399 m[nrl] -= ncl; 400 401 for(i=nrl+1;i<=nrh;i++) { m[i]=m[i-1]+ncol; ncol += step; } 402 403 /* return pointer to array of pointers to rows */ 404 return m; 405 } 406 /* --------------------------------------------------------------------------------- */ 407 IMAGE_EXPORT(uint16**) ui16trimatrix(long nrl, long nrh, long ncl, long nch, long step) 408 /* --------------------------------------------------------------------------------- */ 409 /* allocate an i16 triangle-matrix with subscript range m[nrl..nrh][ncl..nch] */ 410 { 411 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1, n = nrow * ncol + (nrow * (nrow-1) * step) / 2; 412 // Attention, factorisation of n IS NOT PERMITTED : (nrow-1)step/2 is not even!!! 413 uint16 **m; 414 415 /* allocate pointers to rows */ 416 m=(uint16 **) malloc((size_t)((nrow+NR_END)*sizeof(uint16*))); 417 if (!m) nrerror("allocation failure 1 in ui16trimatrix()"); 418 m += NR_END; 419 m -= nrl; 420 421 422 /* allocate rows and set pointers to them */ 423 m[nrl]=(uint16*) malloc((size_t)((n+NR_END)*sizeof(uint16))); 424 if (!m[nrl]) nrerror("allocation failure 2 in i16trimatrix()"); 425 m[nrl] += NR_END; 426 m[nrl] -= ncl; 427 428 for(i=nrl+1;i<=nrh;i++) { m[i]=m[i-1]+ncol; ncol += step; } 429 430 /* return pointer to array of pointers to rows */ 431 return m; 432 } 433 /* --------------------------------------------------------------------------------- */ 434 IMAGE_EXPORT(sint32**) si32trimatrix(long nrl, long nrh, long ncl, long nch, long step) 435 /* --------------------------------------------------------------------------------- */ 436 /* allocate an i32 triangle-matrix with subscript range m[nrl..nrh][ncl..nch] */ 437 { 438 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1, n = nrow * ncol + (nrow * (nrow-1) * step) / 2; 439 // Attention, factorisation of n IS NOT PERMITTED : (nrow-1)step/2 is not even!!! 440 sint32 **m; 441 442 /* allocate pointers to rows */ 443 m=(sint32 **) malloc((size_t)((nrow+NR_END)*sizeof(sint32*))); 444 if (!m) nrerror("allocation failure 1 in si32trimatrix()"); 445 m += NR_END; 446 m -= nrl; 447 448 449 /* allocate rows and set pointers to them */ 450 m[nrl]=(sint32*) malloc((size_t)((n+NR_END)*sizeof(sint32))); 451 if (!m[nrl]) nrerror("allocation failure 2 in si32trimatrix()"); 452 m[nrl] += NR_END; 453 m[nrl] -= ncl; 454 455 for(i=nrl+1;i<=nrh;i++) { m[i]=m[i-1]+ncol; ncol += step; } 456 457 /* return pointer to array of pointers to rows */ 458 return m; 459 } 460 /* -------------------------------------------------------------------------------- */ 461 IMAGE_EXPORT(uint32**) i32trimatrix(long nrl, long nrh, long ncl, long nch, long step) 462 /* -------------------------------------------------------------------------------- */ 463 /* allocate an i32 triangle-matrix with subscript range m[nrl..nrh][ncl..nch] */ 464 { 465 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1, n = nrow * ncol + (nrow * (nrow-1) * step) / 2; 466 // Attention, factorisation of n IS NOT PERMITTED : (nrow-1)step/2 is not even!!! 467 uint32 **m; 468 469 /* allocate pointers to rows */ 470 m=(uint32 **) malloc((size_t)((nrow+NR_END)*sizeof(uint32*))); 471 if (!m) nrerror("allocation failure 1 in ui32trimatrix()"); 472 m += NR_END; 473 m -= nrl; 474 475 476 /* allocate rows and set pointers to them */ 477 m[nrl]=(uint32*) malloc((size_t)((n+NR_END)*sizeof(uint32))); 478 if (!m[nrl]) nrerror("allocation failure 2 in i32trimatrix()"); 479 m[nrl] += NR_END; 480 m[nrl] -= ncl; 481 482 for(i=nrl+1;i<=nrh;i++) { m[i]=m[i-1]+ncol; ncol += step; } 483 484 /* return pointer to array of pointers to rows */ 485 return m; 486 } 487 /* --------------------------------------------------------------------------------- */ 488 IMAGE_EXPORT(float32**) f32trimatrix(long nrl, long nrh, long ncl, long nch, long step) 489 /* --------------------------------------------------------------------------------- */ 490 /* allocate an f32 triangle-matrix with subscript range m[nrl..nrh][ncl..nch] */ 491 { 492 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1, n = nrow * ncol + (nrow * (nrow-1) * step) / 2; 493 // Attention, factorisation of n IS NOT PERMITTED : (nrow-1)step/2 is not even!!! 494 float32 **m; 495 496 /* allocate pointers to rows */ 497 m=(float32 **) malloc((size_t)((nrow+NR_END)*sizeof(float32*))); 498 if (!m) nrerror("allocation failure 1 in f32trimatrix()"); 499 m += NR_END; 500 m -= nrl; 501 502 503 /* allocate rows and set pointers to them */ 504 m[nrl]=(float32*) malloc((size_t)((n+NR_END)*sizeof(float32))); 505 if (!m[nrl]) nrerror("allocation failure 2 in f32trimatrix()"); 506 m[nrl] += NR_END; 507 m[nrl] -= ncl; 508 509 for(i=nrl+1;i<=nrh;i++) { m[i]=m[i-1]+ncol; ncol += step; } 510 511 /* return pointer to array of pointers to rows */ 512 return m; 513 } 514 /* --------------------------------------------------------------------------------- */ 515 IMAGE_EXPORT(float64**) f64trimatrix(long nrl, long nrh, long ncl, long nch, long step) 516 /* --------------------------------------------------------------------------------- */ 517 /* allocate an f64 triangle-matrix with subscript range m[nrl..nrh][ncl..nch] */ 518 { 519 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1, n = nrow * ncol + (nrow * (nrow-1) * step) / 2; 520 // Attention, factorisation of n IS NOT PERMITTED : (nrow-1)step/2 is not even!!! 521 float64 **m; 522 523 /* allocate pointers to rows */ 524 m=(float64 **) malloc((size_t)((nrow+NR_END)*sizeof(float64*))); 525 if (!m) nrerror("allocation failure 1 in f64trimatrix()"); 526 m += NR_END; 527 m -= nrl; 528 529 530 /* allocate rows and set pointers to them */ 531 m[nrl]=(float64*) malloc((size_t)((n+NR_END)*sizeof(float64))); 532 if (!m[nrl]) nrerror("allocation failure 2 in f64trimatrix()"); 533 m[nrl] += NR_END; 534 m[nrl] -= ncl; 535 536 for(i=nrl+1;i<=nrh;i++) { m[i]=m[i-1]+ncol; ncol += step; } 537 538 /* return pointer to array of pointers to rows */ 539 return m; 540 } 66 67 68 type_trimatrix(int8_t); 69 type_trimatrix(uint8_t); 70 type_trimatrix(int16_t); 71 type_trimatrix(uint16_t); 72 type_trimatrix(int32_t); 73 type_trimatrix(uint32_t); 74 type_trimatrix(float); 75 type_trimatrix(double); 76 77 // Local Variables: 78 // tab-width: 4 79 // c-basic-offset: 4 80 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 81 // indent-tabs-mode: nil 82 // End: 83 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 84 -
soft/giet_vm/applications/rosenfeld/nrc2/src/nralloc3.c
r772 r821 31 31 #include <string.h> // memcpy 32 32 #include <math.h> // fabs 33 // #include <memory.h> // memcpy34 33 34 35 #include "nrc_os_config.h" 35 36 #include "mypredef.h" 36 37 #include "nrtype.h" … … 39 40 #include "nrkernel.h" 40 41 41 #include "nralloc1.h"42 42 #include "nralloc3.h" 43 43 44 45 #undef type_cube 46 #define type_cube(t) \ 47 t *** short_name(t,,cube)(int32_t ndl, int32_t ndh, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ 48 { \ 49 int32_t ndep = ndh - ndl + 1; \ 50 int32_t nrow = nrh - nrl + 1; \ 51 int32_t nrol = nch - ncl + 1; \ 52 t *** c; \ 53 /* allocate pointers to pointers to rows */ \ 54 c = malloc((ndep + NR_END) * sizeof(t **)); \ 55 if (c == NULL) { \ 56 nrerror("*** Error: allocation failure in %s\n", __func__); \ 57 } \ 58 c += NR_END; \ 59 c -= ndl; \ 60 /* allocate pointers to rows anc set pointers to them */ \ 61 c[ndl] = malloc((ndep * nrow + NR_END) * sizeof(t *)); \ 62 if (c[ndl] == NULL) { \ 63 nrerror("*** Error: allocation failure in %s\n", __func__); \ 64 } \ 65 c[ndl] += NR_END; \ 66 c[ndl] -= nrl; \ 67 /* allocate rows anc set pointers to them */ \ 68 c[ndl][nrl] = malloc((ndep * nrow * nrol + NR_END) * sizeof(t)); \ 69 if (c[ndl][nrl]) { \ 70 nrerror("*** Error: allocation failure in %s\n", __func__); \ 71 } \ 72 c[ndl][nrl] += NR_END; \ 73 c[ndl][nrl] -= ncl; \ 74 \ 75 for(int32_t j = nrl + 1; j <= nrh; j++) { \ 76 c[ndl][j] = c[ndl][j - 1] + nrol; \ 77 } \ 78 for(int32_t i = ndl + 1; i <= ndh; i++) { \ 79 c[i] = c[i - 1] + nrow; \ 80 c[i][nrl] = c[i - 1][nrl] + nrow * nrol; \ 81 for (int32_t j = nrl + 1; j <= nrh; j++) { \ 82 c[i][j] = c[i][j - 1] + nrol; \ 83 } \ 84 } \ 85 /* return pointer to array of pointers to rows */ \ 86 return t; \ 87 } 88 89 90 type_cube(int8_t); 91 type_cube(uint8_t); 92 type_cube(int16_t); 93 type_cube(uint16_t); 94 type_cube(int32_t); 95 type_cube(uint32_t); 96 type_cube(int64_t); 97 type_cube(uint64_t); 98 type_cube(float); 99 type_cube(double); 100 type_cube(rgb8); 101 type_cube(rgbx8); 102 103 #undef free_type_cube 104 #define free_type_cube(t) \ 105 void short_name(t,free_,cube)(t *** c, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, int32_t ndl, int32_t ndh) \ 106 { \ 107 free((FREE_ARG) (c[nrl][ncl] + ndl - NR_END)); \ 108 free((FREE_ARG) (c[nrl] + ncl - NR_END)); \ 109 free((FREE_ARG) (c + nrl - NR_END)); \ 110 } 111 112 free_type_cube(int8_t); 113 free_type_cube(uint8_t); 114 free_type_cube(int16_t); 115 free_type_cube(uint16_t); 116 free_type_cube(int32_t); 117 free_type_cube(uint32_t); 118 free_type_cube(int64_t); 119 free_type_cube(uint64_t); 120 free_type_cube(float); 121 free_type_cube(double); 122 free_type_cube(rgb8); 123 free_type_cube(rgbx8); 124 125 126 #if 0 44 127 /* ----------------------------------------------------------------------- */ 45 128 double*** d3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh) … … 78 161 return t; 79 162 } 163 164 80 165 /* ------------------------------------------------------------------------------ */ 81 166 void free_d3tensor(double ***t,long nrl,long nrh,long ncl,long nch,long ndl,long ndh) … … 87 172 free((FREE_ARG) (t+nrl-NR_END)); 88 173 } 174 #endif 89 175 90 /* ------------------------------------------------------------------------------------ */ 91 IMAGE_EXPORT(sint8***) si8cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch) 92 /* ------------------------------------------------------------------------------------ */ 93 { 94 long i,j,ndep=ndh-ndl+1,nrow=nrh-nrl+1,nrol=nch-ncl+1; 95 sint8 ***t; 96 97 /* allocate pointers to pointers to rows */ 98 t=(sint8***) malloc((size_t)((ndep+NR_END)*sizeof(sint8**))); 99 if (!t) nrerror("allocation failure 1 in si8cube()"); 100 t += NR_END; 101 t -= ndl; 102 103 /* allocate pointers to rows anc set pointers to them */ 104 t[ndl]=(sint8**) malloc((size_t)((ndep*nrow+NR_END)*sizeof(sint8*))); 105 if (!t[ndl]) nrerror("allocation failure 2 in si8cube()"); 106 t[ndl] += NR_END; 107 t[ndl] -= nrl; 108 109 /* allocate rows anc set pointers to them */ 110 t[ndl][nrl]=(sint8*) malloc((size_t)((ndep*nrow*nrol+NR_END)*sizeof(sint8))); 111 if (!t[ndl][nrl]) nrerror("allocation failure 3 in si8cube()"); 112 t[ndl][nrl] += NR_END; 113 t[ndl][nrl] -= ncl; 114 115 for(j=nrl+1;j<=nrh;j++) t[ndl][j]=t[ndl][j-1]+nrol; 116 for(i=ndl+1;i<=ndh;i++) { 117 t[i]=t[i-1]+nrow; 118 t[i][nrl]=t[i-1][nrl]+nrow*nrol; 119 for(j=nrl+1;j<=nrh;j++) t[i][j]=t[i][j-1]+nrol; 120 } 121 /* return pointer to array of pointers to rows */ 122 return t; 123 } 124 /* ------------------------------------------------------------------------------------ */ 125 IMAGE_EXPORT(uint8***) ui8cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch) 126 /* ------------------------------------------------------------------------------------ */ 127 { 128 long i,j,ndep=ndh-ndl+1,nrow=nrh-nrl+1,nrol=nch-ncl+1; 129 uint8 ***t; 130 131 /* allocate pointers to pointers to rows */ 132 t=(uint8***) malloc((size_t)((ndep+NR_END)*sizeof(uint8**))); 133 if (!t) nrerror("allocation failure 1 in ui8cube()"); 134 t += NR_END; 135 t -= ndl; 136 137 /* allocate pointers to rows anc set pointers to them */ 138 t[ndl]=(uint8**) malloc((size_t)((ndep*nrow+NR_END)*sizeof(uint8*))); 139 if (!t[ndl]) nrerror("allocation failure 2 in ui8cube()"); 140 t[ndl] += NR_END; 141 t[ndl] -= nrl; 142 143 /* allocate rows anc set pointers to them */ 144 t[ndl][nrl]=(uint8*) malloc((size_t)((ndep*nrow*nrol+NR_END)*sizeof(uint8))); 145 if (!t[ndl][nrl]) nrerror("allocation failure 3 in ui8cube()"); 146 t[ndl][nrl] += NR_END; 147 t[ndl][nrl] -= ncl; 148 149 for(j=nrl+1;j<=nrh;j++) t[ndl][j]=t[ndl][j-1]+nrol; 150 for(i=ndl+1;i<=ndh;i++) { 151 t[i]=t[i-1]+nrow; 152 t[i][nrl]=t[i-1][nrl]+nrow*nrol; 153 for(j=nrl+1;j<=nrh;j++) t[i][j]=t[i][j-1]+nrol; 154 } 155 /* return pointer to array of pointers to rows */ 156 return t; 157 } 158 /* -------------------------------------------------------------------------------------- */ 159 IMAGE_EXPORT(sint16***) si16cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch) 160 /* -------------------------------------------------------------------------------------- */ 161 { 162 long i,j,ndep=ndh-ndl+1,nrow=nrh-nrl+1,nrol=nch-ncl+1; 163 sint16 ***t; 164 165 /* allocate pointers to pointers to rows */ 166 t=(sint16 ***) malloc((size_t)((ndep+NR_END)*sizeof(sint16**))); 167 if (!t) nrerror("allocation failure 1 in si16cube()"); 168 t += NR_END; 169 t -= ndl; 170 171 /* allocate pointers to rows anc set pointers to them */ 172 t[ndl]=(sint16 **) malloc((size_t)((ndep*nrow+NR_END)*sizeof(sint16*))); 173 if (!t[ndl]) nrerror("allocation failure 2 in si16cube()"); 174 t[ndl] += NR_END; 175 t[ndl] -= nrl; 176 177 /* allocate rows anc set pointers to them */ 178 t[ndl][nrl]=(sint16 *) malloc((size_t)((ndep*nrow*nrol+NR_END)*sizeof(sint16))); 179 if (!t[ndl][nrl]) nrerror("allocation failure 3 in si16cube()"); 180 t[ndl][nrl] += NR_END; 181 t[ndl][nrl] -= ncl; 182 183 for(j=nrl+1;j<=nrh;j++) t[ndl][j]=t[ndl][j-1]+nrol; 184 for(i=ndl+1;i<=ndh;i++) { 185 t[i]=t[i-1]+nrow; 186 t[i][nrl]=t[i-1][nrl]+nrow*nrol; 187 for(j=nrl+1;j<=nrh;j++) t[i][j]=t[i][j-1]+nrol; 188 } 189 /* return pointer to array of pointers to rows */ 190 return t; 191 } 192 /* -------------------------------------------------------------------------------------- */ 193 IMAGE_EXPORT(uint16***) ui16cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch) 194 /* -------------------------------------------------------------------------------------- */ 195 { 196 long i,j,ndep=ndh-ndl+1,nrow=nrh-nrl+1,nrol=nch-ncl+1; 197 uint16 ***t; 198 199 /* allocate pointers to pointers to rows */ 200 t=(uint16***) malloc((size_t)((ndep+NR_END)*sizeof(uint16**))); 201 if (!t) nrerror("allocation failure 1 in ui16cube()"); 202 t += NR_END; 203 t -= ndl; 204 205 /* allocate pointers to rows anc set pointers to them */ 206 t[ndl]=(uint16**) malloc((size_t)((ndep*nrow+NR_END)*sizeof(uint16*))); 207 if (!t[ndl]) nrerror("allocation failure 2 in ui16cube()"); 208 t[ndl] += NR_END; 209 t[ndl] -= nrl; 210 211 /* allocate rows anc set pointers to them */ 212 t[ndl][nrl]=(uint16*) malloc((size_t)((ndep*nrow*nrol+NR_END)*sizeof(uint16))); 213 if (!t[ndl][nrl]) nrerror("allocation failure 3 in ui16cube()"); 214 t[ndl][nrl] += NR_END; 215 t[ndl][nrl] -= ncl; 216 217 for(j=nrl+1;j<=nrh;j++) t[ndl][j]=t[ndl][j-1]+nrol; 218 for(i=ndl+1;i<=ndh;i++) { 219 t[i]=t[i-1]+nrow; 220 t[i][nrl]=t[i-1][nrl]+nrow*nrol; 221 for(j=nrl+1;j<=nrh;j++) t[i][j]=t[i][j-1]+nrol; 222 } 223 /* return pointer to array of pointers to rows */ 224 return t; 225 } 226 /* ------------------------------------------------------------------------------------ */ 227 IMAGE_EXPORT(sint32***) si32cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch) 228 /* ------------------------------------------------------------------------------------ */ 229 { 230 long i,j,ndep=ndh-ndl+1,nrow=nrh-nrl+1,nrol=nch-ncl+1; 231 sint32 ***t; 232 233 /* allocate pointers to pointers to rows */ 234 t=(sint32***) malloc((size_t)((ndep+NR_END)*sizeof(sint32**))); 235 if (!t) nrerror("allocation failure 1 in si32cube()"); 236 t += NR_END; 237 t -= ndl; 238 239 /* allocate pointers to rows anc set pointers to them */ 240 t[ndl]=(sint32**) malloc((size_t)((ndep*nrow+NR_END)*sizeof(sint32*))); 241 if (!t[ndl]) nrerror("allocation failure 2 in si32cube()"); 242 t[ndl] += NR_END; 243 t[ndl] -= nrl; 244 245 /* allocate rows anc set pointers to them */ 246 t[ndl][nrl]=(sint32*) malloc((size_t)((ndep*nrow*nrol+NR_END)*sizeof(sint32))); 247 if (!t[ndl][nrl]) nrerror("allocation failure 3 in si32cube()"); 248 t[ndl][nrl] += NR_END; 249 t[ndl][nrl] -= ncl; 250 251 for(j=nrl+1;j<=nrh;j++) t[ndl][j]=t[ndl][j-1]+nrol; 252 for(i=ndl+1;i<=ndh;i++) { 253 t[i]=t[i-1]+nrow; 254 t[i][nrl]=t[i-1][nrl]+nrow*nrol; 255 for(j=nrl+1;j<=nrh;j++) t[i][j]=t[i][j-1]+nrol; 256 } 257 /* return pointer to array of pointers to rows */ 258 return t; 259 } 260 /* -------------------------------------------------------------------------------------- */ 261 IMAGE_EXPORT(uint32***) ui32cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch) 262 /* -------------------------------------------------------------------------------------- */ 263 { 264 long i,j,ndep=ndh-ndl+1,nrow=nrh-nrl+1,nrol=nch-ncl+1; 265 uint32 ***t; 266 267 /* allocate pointers to pointers to rows */ 268 t=(uint32***) malloc((size_t)((ndep+NR_END)*sizeof(uint32**))); 269 if (!t) nrerror("allocation failure 1 in ui32cube()"); 270 t += NR_END; 271 t -= ndl; 272 273 /* allocate pointers to rows anc set pointers to them */ 274 t[ndl]=(uint32**) malloc((size_t)((ndep*nrow+NR_END)*sizeof(uint32*))); 275 if (!t[ndl]) nrerror("allocation failure 2 in ui32cube()"); 276 t[ndl] += NR_END; 277 t[ndl] -= nrl; 278 279 /* allocate rows anc set pointers to them */ 280 t[ndl][nrl]=(uint32*) malloc((size_t)((ndep*nrow*nrol+NR_END)*sizeof(uint32))); 281 if (!t[ndl][nrl]) nrerror("allocation failure 3 in ui32cube()"); 282 t[ndl][nrl] += NR_END; 283 t[ndl][nrl] -= ncl; 284 285 for(j=nrl+1;j<=nrh;j++) t[ndl][j]=t[ndl][j-1]+nrol; 286 for(i=ndl+1;i<=ndh;i++) { 287 t[i]=t[i-1]+nrow; 288 t[i][nrl]=t[i-1][nrl]+nrow*nrol; 289 for(j=nrl+1;j<=nrh;j++) t[i][j]=t[i][j-1]+nrol; 290 } 291 /* return pointer to array of pointers to rows */ 292 return t; 293 } 294 /* -------------------------------------------------------------------------------------- */ 295 IMAGE_EXPORT(float32***) f32cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch) 296 /* -------------------------------------------------------------------------------------- */ 297 { 298 long i,j,ndep=ndh-ndl+1,nrow=nrh-nrl+1,nrol=nch-ncl+1; 299 float32 ***t; 300 301 /* allocate pointers to pointers to rows */ 302 t=(float32***) malloc((size_t)((ndep+NR_END)*sizeof(float32**))); 303 if (!t) nrerror("allocation failure 1 in f32cube()"); 304 t += NR_END; 305 t -= ndl; 306 307 /* allocate pointers to rows anc set pointers to them */ 308 t[ndl]=(float32**) malloc((size_t)((ndep*nrow+NR_END)*sizeof(float32*))); 309 if (!t[ndl]) nrerror("allocation failure 2 in f32cube()"); 310 t[ndl] += NR_END; 311 t[ndl] -= nrl; 312 313 /* allocate rows anc set pointers to them */ 314 t[ndl][nrl]=(float32*) malloc((size_t)((ndep*nrow*nrol+NR_END)*sizeof(float32))); 315 if (!t[ndl][nrl]) nrerror("allocation failure 3 in f32cube()"); 316 t[ndl][nrl] += NR_END; 317 t[ndl][nrl] -= ncl; 318 319 for(j=nrl+1;j<=nrh;j++) t[ndl][j]=t[ndl][j-1]+nrol; 320 for(i=ndl+1;i<=ndh;i++) { 321 t[i]=t[i-1]+nrow; 322 t[i][nrl]=t[i-1][nrl]+nrow*nrol; 323 for(j=nrl+1;j<=nrh;j++) t[i][j]=t[i][j-1]+nrol; 324 } 325 /* return pointer to array of pointers to rows */ 326 return t; 327 } 328 /* -------------------------------------------------------------------------------------- */ 329 IMAGE_EXPORT(float64***) f64cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch) 330 /* -------------------------------------------------------------------------------------- */ 331 { 332 long i,j,ndep=ndh-ndl+1,nrow=nrh-nrl+1,nrol=nch-ncl+1; 333 float64 ***t; 334 335 /* allocate pointers to pointers to rows */ 336 t=(float64***) malloc((size_t)((ndep+NR_END)*sizeof(float64**))); 337 if (!t) nrerror("allocation failure 1 in f32cube()"); 338 t += NR_END; 339 t -= ndl; 340 341 /* allocate pointers to rows anc set pointers to them */ 342 t[ndl]=(float64**) malloc((size_t)((ndep*nrow+NR_END)*sizeof(float64*))); 343 if (!t[ndl]) nrerror("allocation failure 2 in f64cube()"); 344 t[ndl] += NR_END; 345 t[ndl] -= nrl; 346 347 /* allocate rows anc set pointers to them */ 348 t[ndl][nrl]=(float64*) malloc((size_t)((ndep*nrow*nrol+NR_END)*sizeof(float64))); 349 if (!t[ndl][nrl]) nrerror("allocation failure 3 in f64cube()"); 350 t[ndl][nrl] += NR_END; 351 t[ndl][nrl] -= ncl; 352 353 for(j=nrl+1;j<=nrh;j++) t[ndl][j]=t[ndl][j-1]+nrol; 354 for(i=ndl+1;i<=ndh;i++) { 355 t[i]=t[i-1]+nrow; 356 t[i][nrl]=t[i-1][nrl]+nrow*nrol; 357 for(j=nrl+1;j<=nrh;j++) t[i][j]=t[i][j-1]+nrol; 358 } 359 /* return pointer to array of pointers to rows */ 360 return t; 361 } 362 /* ------------------------------------------------------------------------------------ */ 363 IMAGE_EXPORT(rgb8***) rgb8cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch) 364 /* ------------------------------------------------------------------------------------ */ 365 /* allocate a rgb8 cube with range t[ndl..ndh][nrl..nrh][ncl..nch] */ 366 { 367 long i,j,ndep=ndh-ndl+1,nrow=nrh-nrl+1,nrol=nch-ncl+1; 368 rgb8 ***t; 369 370 /* allocate pointers to pointers to rows */ 371 t=(rgb8***) malloc((size_t)((ndep+NR_END)*sizeof(rgb8**))); 372 if (!t) nrerror("allocation failure 1 in rgb8cube()"); 373 t += NR_END; 374 t -= ndl; 375 376 /* allocate pointers to rows anc set pointers to them */ 377 t[ndl]=(rgb8**) malloc((size_t)((ndep*nrow+NR_END)*sizeof(rgb8*))); 378 if (!t[ndl]) nrerror("allocation failure 2 in rgb8cube()"); 379 t[ndl] += NR_END; 380 t[ndl] -= nrl; 381 382 /* allocate rows anc set pointers to them */ 383 t[ndl][nrl]=(rgb8*) malloc((size_t)((ndep*nrow*nrol+NR_END)*sizeof(rgb8))); 384 if (!t[ndl][nrl]) nrerror("allocation failure 3 in rgb8cube()"); 385 t[ndl][nrl] += NR_END; 386 t[ndl][nrl] -= ncl; 387 388 for(j=nrl+1;j<=nrh;j++) t[ndl][j]=t[ndl][j-1]+nrol; 389 for(i=ndl+1;i<=ndh;i++) { 390 t[i]=t[i-1]+nrow; 391 t[i][nrl]=t[i-1][nrl]+nrow*nrol; 392 for(j=nrl+1;j<=nrh;j++) t[i][j]=t[i][j-1]+nrol; 393 } 394 /* return pointer to array of pointers to rows */ 395 return t; 396 } 397 /* -------------------------------------------------------------------------------------- */ 398 IMAGE_EXPORT(rgbx8***) rgbx8cube(long ndl, long ndh, long nrl, long nrh, long ncl, long nch) 399 /* -------------------------------------------------------------------------------------- */ 400 /* allocate a rgb8 cube with range t[ndl..ndh][nrl..nrh][ncl..nch] */ 401 { 402 long i,j,ndep=ndh-ndl+1,nrow=nrh-nrl+1,nrol=nch-ncl+1; 403 rgbx8 ***t; 404 405 /* allocate pointers to pointers to rows */ 406 t=(rgbx8***) malloc((size_t)((ndep+NR_END)*sizeof(rgbx8**))); 407 if (!t) nrerror("allocation failure 1 in rgbx8cube()"); 408 t += NR_END; 409 t -= ndl; 410 411 /* allocate pointers to rows anc set pointers to them */ 412 t[ndl]=(rgbx8**) malloc((size_t)((ndep*nrow+NR_END)*sizeof(rgbx8*))); 413 if (!t[ndl]) nrerror("allocation failure 2 in rgbx8cube()"); 414 t[ndl] += NR_END; 415 t[ndl] -= nrl; 416 417 /* allocate rows anc set pointers to them */ 418 t[ndl][nrl]=(rgbx8*) malloc((size_t)((ndep*nrow*nrol+NR_END)*sizeof(rgbx8))); 419 if (!t[ndl][nrl]) nrerror("allocation failure 3 in rgbx8cube()"); 420 t[ndl][nrl] += NR_END; 421 t[ndl][nrl] -= ncl; 422 423 for(j=nrl+1;j<=nrh;j++) t[ndl][j]=t[ndl][j-1]+nrol; 424 for(i=ndl+1;i<=ndh;i++) { 425 t[i]=t[i-1]+nrow; 426 t[i][nrl]=t[i-1][nrl]+nrow*nrol; 427 for(j=nrl+1;j<=nrh;j++) t[i][j]=t[i][j-1]+nrol; 428 } 429 /* return pointer to array of pointers to rows */ 430 return t; 431 } 432 /* ------------------------------------------------------------------------------------------- */ 433 IMAGE_EXPORT(void) free_si8cube(sint8 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh) 434 /* ------------------------------------------------------------------------------------------- */ 435 { 436 free((FREE_ARG) (c[nrl][ncl]+ndl-NR_END)); 437 free((FREE_ARG) (c[nrl]+ncl-NR_END)); 438 free((FREE_ARG) (c+nrl-NR_END)); 439 } 440 /* ------------------------------------------------------------------------------------------- */ 441 IMAGE_EXPORT(void) free_ui8cube(uint8 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh) 442 /* ------------------------------------------------------------------------------------------- */ 443 { 444 free((FREE_ARG) (c[nrl][ncl]+ndl-NR_END)); 445 free((FREE_ARG) (c[nrl]+ncl-NR_END)); 446 free((FREE_ARG) (c+nrl-NR_END)); 447 } 448 /* --------------------------------------------------------------------------------------------- */ 449 IMAGE_EXPORT(void) free_si16cube(sint16 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh) 450 /* --------------------------------------------------------------------------------------------- */ 451 { 452 free((FREE_ARG) (c[nrl][ncl]+ndl-NR_END)); 453 free((FREE_ARG) (c[nrl]+ncl-NR_END)); 454 free((FREE_ARG) (c+nrl-NR_END)); 455 } 456 /* --------------------------------------------------------------------------------------------- */ 457 IMAGE_EXPORT(void) free_ui16cube(uint16 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh) 458 /* --------------------------------------------------------------------------------------------- */ 459 { 460 free((FREE_ARG) (c[nrl][ncl]+ndl-NR_END)); 461 free((FREE_ARG) (c[nrl]+ncl-NR_END)); 462 free((FREE_ARG) (c+nrl-NR_END)); 463 } 464 /* --------------------------------------------------------------------------------------------- */ 465 IMAGE_EXPORT(void) free_si32cube(sint32 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh) 466 /* --------------------------------------------------------------------------------------------- */ 467 { 468 free((FREE_ARG) (c[nrl][ncl]+ndl-NR_END)); 469 free((FREE_ARG) (c[nrl]+ncl-NR_END)); 470 free((FREE_ARG) (c+nrl-NR_END)); 471 } 472 /* --------------------------------------------------------------------------------------------- */ 473 IMAGE_EXPORT(void) free_ui32cube(uint32 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh) 474 /* --------------------------------------------------------------------------------------------- */ 475 { 476 free((FREE_ARG) (c[nrl][ncl]+ndl-NR_END)); 477 free((FREE_ARG) (c[nrl]+ncl-NR_END)); 478 free((FREE_ARG) (c+nrl-NR_END)); 479 } 480 /* --------------------------------------------------------------------------------------------- */ 481 IMAGE_EXPORT(void) free_f32cube(float32 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh) 482 /* --------------------------------------------------------------------------------------------- */ 483 { 484 free((FREE_ARG) (c[nrl][ncl]+ndl-NR_END)); 485 free((FREE_ARG) (c[nrl]+ncl-NR_END)); 486 free((FREE_ARG) (c+nrl-NR_END)); 487 } 488 /* --------------------------------------------------------------------------------------------- */ 489 IMAGE_EXPORT(void) free_f64cube(float64 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh) 490 /* --------------------------------------------------------------------------------------------- */ 491 { 492 free((FREE_ARG) (c[nrl][ncl]+ndl-NR_END)); 493 free((FREE_ARG) (c[nrl]+ncl-NR_END)); 494 free((FREE_ARG) (c+nrl-NR_END)); 495 } 496 /* ------------------------------------------------------------------------------------------- */ 497 IMAGE_EXPORT(void) free_rgb8cube(rgb8 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh) 498 /* ------------------------------------------------------------------------------------------- */ 499 { 500 free((FREE_ARG) (c[nrl][ncl]+ndl-NR_END)); 501 free((FREE_ARG) (c[nrl]+ncl-NR_END)); 502 free((FREE_ARG) (c+nrl-NR_END)); 503 } 504 /* --------------------------------------------------------------------------------------------- */ 505 IMAGE_EXPORT(void) free_rgbx8cube(rgbx8 ***c,long nrl,long nrh,long ncl,long nch,long ndl,long ndh) 506 /* --------------------------------------------------------------------------------------------- */ 507 { 508 free((FREE_ARG) (c[nrl][ncl]+ndl-NR_END)); 509 free((FREE_ARG) (c[nrl]+ncl-NR_END)); 510 free((FREE_ARG) (c+nrl-NR_END)); 511 } 176 // Local Variables: 177 // tab-width: 4 178 // c-basic-offset: 4 179 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 180 // indent-tabs-mode: nil 181 // End: 182 183 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 184 -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrarith0.c
r772 r821 22 22 #include <math.h> 23 23 24 #include "nrc_os_config.h" 24 25 #include "mypredef.h" 25 26 #include "nrtype.h" … … 30 31 #include "nrarith0.h" 31 32 32 ROUTINE(void) i8swap(int8 *a, int8 *b) { int8 *t; t=a; a=b; b=t;} 33 ROUTINE(void) i16swap(int16 *a, int16 *b) { int16 *t; t=a; a=b; b=t;} 34 ROUTINE(void) i32swap(int32 *a, int32 *b) { int32 *t; t=a; a=b; b=t;} 35 ROUTINE(void) i64swap(int64 *a, int64 *b) { int64 *t; t=a; a=b; b=t;} 36 ROUTINE(void) f32swap(float32 *a, float32 *b) { float32 *t; t=a; a=b; b=t;} 37 ROUTINE(void) f64swap(float64 *a, float64 *b) { float64 *t; t=a; a=b; b=t;} 38 ROUTINE(void) rgb8swap(rgb8 *a, rgb8 *b) { rgb8 *t; t=a; a=b; b=t;} 39 ROUTINE(void) rgbx8swap(rgbx8 *a, rgbx8 *b) { rgbx8 *t; t=a; a=b; b=t;} 33 #undef type_swap 34 #define type_swap(t) \ 35 void short_name(t,,swap)(t * a, t * b) \ 36 { \ 37 t c; \ 38 c = *a; \ 39 *a = *b; \ 40 *b = c; \ 41 } 42 43 type_swap(int8_t); 44 type_swap(int16_t); 45 type_swap(int32_t); 46 type_swap(int64_t); 47 type_swap(float); 48 type_swap(double); 49 type_swap(rgb8); 50 type_swap(rgbx8); 40 51 41 52 /* --------- */ … … 43 54 /* --------- */ 44 55 45 ROUTINE(float32) f32min (float32 x1, float32 x2) {if (x1<x2) return x1; else return x2;} 46 ROUTINE(float32) f32min2 (float32 x1, float32 x2) {if (x1<x2) return x1; else return x2;} 47 ROUTINE(float32) f32min3 (float32 x1, float32 x2, float32 x3) {return f32min2(f32min2(x1, x2), x3);} 48 ROUTINE(float32) f32min4 (float32 x1, float32 x2, float32 x3, float32 x4) {return f32min2(f32min2(x1, x2), f32min2(x3, x4));} 49 ROUTINE(float32) f32min5 (float32 x1, float32 x2, float32 x3, float32 x4, float32 x5) {return f32min3(f32min2(x1, x2), f32min2(x3, x4), x5);} 50 51 ROUTINE(float64) f64min (float64 x1, float64 x2) {if (x1<x2) return x1; else return x2;} 52 ROUTINE(float64) f64min2 (float64 x1, float64 x2) {if (x1<x2) return x1; else return x2;} 53 ROUTINE(float64) f64min3 (float64 x1, float64 x2, float64 x3) {return f64min2(f64min2(x1, x2), x3);} 54 ROUTINE(float64) f64min4 (float64 x1, float64 x2, float64 x3, float64 x4) {return f64min2(f64min2(x1, x2), f64min2(x3, x4));} 55 ROUTINE(float64) f64min5 (float64 x1, float64 x2, float64 x3, float64 x4, float64 x5) {return f64min3(f64min2(x1, x2), f64min2(x3, x4), x5);} 56 57 ROUTINE(uint8) ui8min (uint8 x1, uint8 x2) {if (x1<x2) return x1; else return x2;} 58 ROUTINE(uint8) ui8min2(uint8 x1, uint8 x2) {if (x1<x2) return x1; else return x2;} 59 ROUTINE(uint8) ui8min3(uint8 x1, uint8 x2, uint8 x3) {return ui8min2(ui8min2(x1, x2), x3);} 60 ROUTINE(uint8) ui8min4(uint8 x1, uint8 x2, uint8 x3, uint8 x4) {return ui8min2(ui8min2(x1, x2), ui8min2(x3, x4));} 61 ROUTINE(uint8) ui8min5(uint8 x1, uint8 x2, uint8 x3, uint8 x4, uint8 x5) {return ui8min3(ui8min2(x1, x2), ui8min2(x3, x4), x5);} 62 63 ROUTINE(uint16) ui16min (uint16 x1, uint16 x2) {if (x1<x2) return x1; else return x2;} 64 ROUTINE(uint16) ui16min2(uint16 x1, uint16 x2) {if (x1<x2) return x1; else return x2;} 65 ROUTINE(uint16) ui16min3(uint16 x1, uint16 x2, uint16 x3) {return ui16min2(ui16min2(x1, x2), x3);} 66 ROUTINE(uint16) ui16min4(uint16 x1, uint16 x2, uint16 x3, uint16 x4) {return ui16min2(ui16min2(x1, x2), ui16min2(x3, x4));} 67 ROUTINE(uint16) ui16min5(uint16 x1, uint16 x2, uint16 x3, uint16 x4, uint16 x5) {return ui16min3(ui16min2(x1, x2), ui16min2(x3, x4), x5);} 68 69 ROUTINE(int32) ui32min (uint32 x1, uint32 x2) {if (x1<x2) return x1; else return x2;} 70 ROUTINE(int32) ui32min2(uint32 x1, uint32 x2) {if (x1<x2) return x1; else return x2;} 71 ROUTINE(int32) ui32min3(uint32 x1, uint32 x2, uint32 x3) {return ui32min2(ui32min2(x1, x2), x3);} 72 ROUTINE(int32) ui32min4(uint32 x1, uint32 x2, uint32 x3, uint32 x4) {return ui32min2(ui32min2(x1, x2), ui32min2(x3, x4));} 73 ROUTINE(int32) ui32min5(uint32 x1, uint32 x2, uint32 x3, uint32 x4, uint32 x5) {return ui32min3(ui32min2(x1, x2), ui32min2(x3, x4), x5);} 74 75 ROUTINE(rgb8) rgb8min (rgb8 x1, rgb8 x2) {rgb8 y; y.r = ui8min2(x1.r,x2.r);y.g=ui8min2(x1.g,x2.g);y.b=ui8min2(x1.b,x2.b);return y;} 76 ROUTINE(rgb8) rgb8min2(rgb8 x1, rgb8 x2) {rgb8 y; y.r = ui8min2(x1.r,x2.r);y.g=ui8min2(x1.g,x2.g);y.b=ui8min2(x1.b,x2.b);return y;} 77 ROUTINE(rgb8) rgb8min3(rgb8 x1, rgb8 x2, rgb8 x3) {return rgb8min2(rgb8min2(x1, x2), x3);} 78 ROUTINE(rgb8) rgb8min4(rgb8 x1, rgb8 x2, rgb8 x3, rgb8 x4) {return rgb8min2(rgb8min2(x1, x2), rgb8min2(x3,x4));} 79 ROUTINE(rgb8) rgb8min5(rgb8 x1, rgb8 x2, rgb8 x3, rgb8 x4, rgb8 x5) {return rgb8min3(rgb8min2(x1, x2), rgb8min2(x3,x4), x5);} 56 #undef type_min 57 #define type_min(t) \ 58 t short_name(t,,min)(t x1, t x2) \ 59 { \ 60 return (x1 < x2) ? x1 : x2; \ 61 } \ 62 t short_name(t,,min2)(t x1, t x2) \ 63 { \ 64 return (x1 < x2) ? x1 : x2; \ 65 } \ 66 t short_name(t,,min3)(t x1, t x2, t x3) \ 67 { \ 68 return short_name(t,,min2)(short_name(t,,min2)(x1, x2), x3); \ 69 } \ 70 t short_name(t,,min4)(t x1, t x2, t x3, t x4) \ 71 { \ 72 return short_name(t,,min2)(short_name(t,,min2)(x1, x2), short_name(t,,min2)(x3, x4)); \ 73 } \ 74 t short_name(t,,min5)(t x1, t x2, t x3, t x4, t x5) \ 75 { \ 76 return short_name(t,,min3)(short_name(t,,min2)(x1, x2), short_name(t,,min2)(x3, x4), x5); \ 77 } 78 79 type_min(float); 80 type_min(double); 81 type_min(int8_t); 82 type_min(uint8_t); 83 type_min(int16_t); 84 type_min(uint16_t); 85 type_min(int32_t); 86 type_min(uint32_t); 87 88 rgb8 rgb8min (rgb8 x1, rgb8 x2) {rgb8 y; y.r = ui8min2(x1.r,x2.r);y.g=ui8min2(x1.g,x2.g);y.b=ui8min2(x1.b,x2.b);return y;} 89 rgb8 rgb8min2(rgb8 x1, rgb8 x2) {rgb8 y; y.r = ui8min2(x1.r,x2.r);y.g=ui8min2(x1.g,x2.g);y.b=ui8min2(x1.b,x2.b);return y;} 90 rgb8 rgb8min3(rgb8 x1, rgb8 x2, rgb8 x3) {return rgb8min2(rgb8min2(x1, x2), x3);} 91 rgb8 rgb8min4(rgb8 x1, rgb8 x2, rgb8 x3, rgb8 x4) {return rgb8min2(rgb8min2(x1, x2), rgb8min2(x3,x4));} 92 rgb8 rgb8min5(rgb8 x1, rgb8 x2, rgb8 x3, rgb8 x4, rgb8 x5) {return rgb8min3(rgb8min2(x1, x2), rgb8min2(x3,x4), x5);} 80 93 81 94 /* --------- */ … … 83 96 /* --------- */ 84 97 85 ROUTINE(float32) f32max (float32 x1, float32 x2) {if (x1>x2) return x1; else return x2;} 86 ROUTINE(float32) f32max2(float32 x1, float32 x2) {if (x1>x2) return x1; else return x2;} 87 ROUTINE(float32) f32max3(float32 x1, float32 x2, float32 x3) {return f32max2(f32max2(x1, x2), x3);} 88 ROUTINE(float32) f32max4(float32 x1, float32 x2, float32 x3, float32 x4) {return f32max2(f32max2(x1, x2), f32max2(x3, x4));} 89 ROUTINE(float32) f32max5(float32 x1, float32 x2, float32 x3, float32 x4, float32 x5) {return f32max3(f32max2(x1, x2), f32max2(x3, x4), x5);} 90 91 ROUTINE(float64) f64max (float64 x1, float64 x2) {if (x1>x2) return x1; else return x2;} 92 ROUTINE(float64) f64max2 (float64 x1, float64 x2) {if (x1>x2) return x1; else return x2;} 93 ROUTINE(float64) f64max3 (float64 x1, float64 x2, float64 x3) {return f64max2(f64max2(x1, x2), x3);} 94 ROUTINE(float64) f64max4 (float64 x1, float64 x2, float64 x3, float64 x4) {return f64max2(f64max2(x1, x2), f64max2(x3, x4));} 95 ROUTINE(float64) f64max5 (float64 x1, float64 x2, float64 x3, float64 x4, float64 x5) {return f64max3(f64max2(x1, x2), f64max2(x3, x4), x5);} 96 97 ROUTINE(uint8) ui8max (uint8 x1, uint8 x2) {if (x1>x2) return x1; else return x2;} 98 ROUTINE(uint8) ui8max2(uint8 x1, uint8 x2) {if (x1>x2) return x1; else return x2;} 99 ROUTINE(uint8) ui8max3(uint8 x1, uint8 x2, uint8 x3) {return ui8max2(ui8max2(x1, x2), x3);} 100 ROUTINE(uint8) ui8max4(uint8 x1, uint8 x2, uint8 x3, uint8 x4) {return ui8max2(ui8max2(x1, x2), ui8max2(x3, x4));} 101 ROUTINE(uint8) ui8max5(uint8 x1, uint8 x2, uint8 x3, uint8 x4, uint8 x5) {return ui8max3(ui8max2(x1, x2), ui8max2(x3, x4), x5);} 102 103 ROUTINE(uint16) ui16max (uint16 x1, uint16 x2) {if (x1>x2) return x1; else return x2;} 104 ROUTINE(uint16) ui16max2(uint16 x1, uint16 x2) {if (x1>x2) return x1; else return x2;} 105 ROUTINE(uint16) ui16max3(uint16 x1, uint16 x2, uint16 x3) {return ui16max2(ui16max2(x1, x2), x3);} 106 ROUTINE(uint16) ui16max4(uint16 x1, uint16 x2, uint16 x3, uint16 x4) {return ui16max2(ui16max2(x1, x2), ui16max2(x3, x4));} 107 ROUTINE(uint16) ui16max5(uint16 x1, uint16 x2, uint16 x3, uint16 x4, uint16 x5) {return ui16max3(ui16max2(x1, x2), ui16max2(x3, x4), x5);} 108 109 ROUTINE(int32) ui32max (uint32 x1, uint32 x2) {if (x1>x2) return x1; else return x2;} 110 ROUTINE(int32) ui32max2(uint32 x1, uint32 x2) {if (x1>x2) return x1; else return x2;} 111 ROUTINE(int32) ui32max3(uint32 x1, uint32 x2, uint32 x3) {return ui32max2(ui32max2(x1, x2), x3);} 112 ROUTINE(int32) ui32max4(uint32 x1, uint32 x2, uint32 x3, uint32 x4) {return ui32max2(ui32max2(x1, x2), ui32max2(x3, x4));} 113 ROUTINE(int32) ui32max5(uint32 x1, uint32 x2, uint32 x3, uint32 x4, int32 x5) {return ui32max3(ui32max2(x1, x2), ui32max2(x3, x4), x5);} 98 #undef type_max 99 #define type_max(t) \ 100 t short_name(t,,max)(t x1, t x2) \ 101 { \ 102 return (x1 > x2) ? x1 : x2; \ 103 } \ 104 t short_name(t,,max2)(t x1, t x2) \ 105 { \ 106 return (x1 > x2) ? x1 : x2; \ 107 } \ 108 t short_name(t,,max3)(t x1, t x2, t x3) \ 109 { \ 110 return short_name(t,,max2)(short_name(t,,max2)(x1, x2), x3); \ 111 } \ 112 t short_name(t,,max4)(t x1, t x2, t x3, t x4) \ 113 { \ 114 return short_name(t,,max2)(short_name(t,,max2)(x1, x2), short_name(t,,max2)(x3, x4)); \ 115 } \ 116 t short_name(t,,max5)(t x1, t x2, t x3, t x4, t x5) \ 117 { \ 118 return short_name(t,,max3)(short_name(t,,max2)(x1, x2), short_name(t,,max2)(x3, x4), x5); \ 119 } 120 121 type_max(float); 122 type_max(double); 123 type_max(int8_t); 124 type_max(uint8_t); 125 type_max(int16_t); 126 type_max(uint16_t); 127 type_max(int32_t); 128 type_max(uint32_t); 114 129 115 130 ROUTINE(rgb8) rgb8max (rgb8 x1, rgb8 x2) {rgb8 y; y.r = ui8max2(x1.r,x2.r);y.g=ui8max2(x1.g,x2.g);y.b=ui8max2(x1.b,x2.b);return y;} … … 124 139 125 140 /* ------------------------------- */ 126 ROUTINE(int32) i32bit(int32 x, int n)141 int32_t i32bit(int32_t x, int32_t n) 127 142 /* ------------------------------- */ 128 143 { 129 return ((x>>n)&1); 130 } 144 return ((x >> n) & 1); 145 } 146 131 147 /* --------------------------- */ 132 ROUTINE(int32) sym_int32(int32x)148 int32_t sym_int32(int32_t x) 133 149 /* --------------------------- */ 134 150 { 135 int i; 136 int32 y = 0; 137 for(i=0; i<31; i++) { 138 y = y | (x & 1); 139 x = x >> 1; 140 } 141 y = y | x; 142 return y; 151 int32_t y = 0; 152 for (int32_t i = 0; i < 31; i++) { 153 y = y | (x & 1); 154 x = x >> 1; 155 } 156 y = y | x; 157 return y; 143 158 } 144 159 145 160 146 161 /* ----------------------- */ 147 ROUTINE(int) ilog2(int x)162 int32_t ilog2(int32_t x) 148 163 /* ----------------------- */ 149 164 { 150 int s = 0; 151 while(x) { 152 x >>= 1; 153 s++; 154 } 155 return s - 1; 156 } 165 int32_t s = 0; 166 while (x) { 167 x >>= 1; 168 s++; 169 } 170 return s - 1; 171 } 172 157 173 /* ----------------------------- */ 158 ROUTINE(int) next_power2(int x)174 int32_t next_power2(int32_t x) 159 175 /* ----------------------------- */ 160 176 { 161 int s = ilog2(x); 162 int n = 1 << s; 163 164 if(x != n) 165 return n << 1; 166 else 167 return n; 168 } 169 /* ---------------------------- */ 170 ROUTINE(int) gcd(int u, int v) 171 /* ---------------------------- */ 172 { 173 int r; 174 while(v) { 175 r = u % v; 176 u = v; 177 v = r; 178 } 179 return u; 180 } 181 /* ---------------------------- */ 182 ROUTINE(int) lcm(int u, int v) 183 /* ---------------------------- */ 184 { 185 return (u*v)/gcd(u,v); 186 } 177 int32_t s = ilog2(x); 178 int32_t n = 1 << s; 179 180 if (x != n) { 181 return n << 1; 182 } 183 else { 184 return n; 185 } 186 } 187 188 /* ---------------------------- */ 189 int32_t myGCD(int32_t u, int32_t v) 190 /* ---------------------------- */ 191 { 192 int32_t r; 193 while (v != 0) { 194 r = u % v; 195 u = v; 196 v = r; 197 } 198 return u; 199 } 200 201 /* ---------------------------- */ 202 int32_t myLCM(int32_t u, int32_t v) 203 /* ---------------------------- */ 204 { 205 return (u * v) / myGCD(u, v); 206 } 207 208 209 // Local Variables: 210 // tab-width: 4 211 // c-basic-offset: 4 212 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 213 // indent-tabs-mode: nil 214 // End: 215 216 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 217 -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrarith1.c
r772 r821 20 20 #include <malloc.h> 21 21 #include <math.h> // fabs 22 // #include <memory.h> // memcpy 23 22 23 #include "nrc_os_config.h" 24 24 #include "mypredef.h" 25 25 #include "nrtype.h" … … 28 28 #include "nrkernel.h" 29 29 30 //#include "nralloc.h"31 30 #include "nrarith1.h" 32 31 … … 37 36 */ 38 37 39 /* -------------------------------------------------------- */ 40 IMAGE_EXPORT(sint32) sum_si8vector(sint8 *v, long nl, long nh) 41 /* -------------------------------------------------------- */ 42 { 43 int i; 44 sint32 s = 0; 45 for(i=nl; i<=nh; i++) { 46 s += v[i]; 47 } 48 return s; 49 } 50 /* -------------------------------------------------------- */ 51 IMAGE_EXPORT(uint32) sum_u8ivector(uint8 *v, long nl, long nh) 52 /* -------------------------------------------------------- */ 53 { 54 int i; 55 uint32 s = 0; 56 for(i=nl; i<=nh; i++) { 57 s += v[i]; 58 } 59 return s; 60 } 61 /* ---------------------------------------------------------- */ 62 IMAGE_EXPORT(sint32) sum_si16vector(sint16 *v, long nl, long nh) 63 /* ---------------------------------------------------------- */ 64 { 65 int i; 66 sint32 s = 0; 67 for(i=nl; i<=nh; i++) { 68 s += v[i]; 69 } 70 return s; 71 } 72 /* ---------------------------------------------------------- */ 73 IMAGE_EXPORT(uint32) sum_u16ivector(uint16 *v, long nl, long nh) 74 /* ---------------------------------------------------------- */ 75 { 76 int i; 77 uint32 s = 0; 78 for(i=nl; i<=nh; i++) { 79 s += v[i]; 80 } 81 return s; 82 } 83 /* ---------------------------------------------------------- */ 84 IMAGE_EXPORT(sint32) sum_si32vector(sint32 *v, long nl, long nh) 85 /* ---------------------------------------------------------- */ 86 { 87 int i; 88 sint32 s = 0; 89 for(i=nl; i<=nh; i++) { 90 s += v[i]; 91 } 92 return s; 93 } 94 /* ---------------------------------------------------------- */ 95 IMAGE_EXPORT(uint32) sum_u32ivector(uint32 *v, long nl, long nh) 96 /* ---------------------------------------------------------- */ 97 { 98 int i; 99 uint32 s = 0; 100 for(i=nl; i<=nh; i++) { 101 s += v[i]; 102 } 103 return s; 104 } 105 /* ----------------------------------------------------------- */ 106 IMAGE_EXPORT(float32) sum_f32vector(float32 *v, long nl, long nh) 107 /* ----------------------------------------------------------- */ 108 { 109 int i; 110 float32 s = 0.0f; 111 for(i=nl; i<=nh; i++) { 112 s += v[i]; 113 } 114 return s; 115 } 116 /* ----------------------------------------------------------- */ 117 IMAGE_EXPORT(float64) sum_f64vector(float64 *v, long nl, long nh) 118 /* ----------------------------------------------------------- */ 119 { 120 int i; 121 float64 s = 0.0; 122 for(i=nl; i<=nh; i++) { 123 s += v[i]; 124 } 125 return s; 126 } 38 #undef sum_type_vector 39 #define sum_type_vector(t,r) \ 40 r short_name(t,sum_,vector)(t * v, int32_t nl, int32_t nh) \ 41 { \ 42 r s = 0; \ 43 for (int32_t i = nl; i <= nh; i++) { \ 44 s += v[i]; \ 45 } \ 46 return s; \ 47 } 48 49 sum_type_vector(int8_t, int32_t); 50 sum_type_vector(uint8_t, uint32_t); 51 sum_type_vector(int16_t, int32_t); 52 sum_type_vector(uint16_t, uint32_t); 53 sum_type_vector(int32_t, int32_t); 54 sum_type_vector(uint32_t, uint32_t); 55 sum_type_vector(float, float); 56 sum_type_vector(double, double); 127 57 128 58 /* … … 132 62 */ 133 63 134 /* ------------------------------------------------------- */ 135 IMAGE_EXPORT(sint8) min_si8vector(sint8 *v, long nl, long nh) 136 /* ------------------------------------------------------- */ 137 { 138 int i; 139 uint8 m; 140 141 m = v[nl]; 142 for(i=nl+1; i<=nh; i++) { 143 if(v[i]<m) m = v[i]; 144 } 145 return m; 146 } 147 /* ------------------------------------------------------- */ 148 IMAGE_EXPORT(uint8) min_ui8vector(uint8 *v, long nl, long nh) 149 /* ------------------------------------------------------- */ 150 { 151 int i; 152 uint8 m; 153 154 m = v[nl]; 155 for(i=nl+1; i<=nh; i++) { 156 if(v[i]<m) m = v[i]; 157 } 158 return m; 159 } 160 /* ---------------------------------------------------------- */ 161 IMAGE_EXPORT(sint16) min_si16vector(sint16 *v, long nl, long nh) 162 /* ---------------------------------------------------------- */ 163 { 164 int i; 165 int16 m; 166 167 m = v[nl]; 168 for(i=nl+1; i<=nh; i++) { 169 if(v[i]<m) m = v[i]; 170 } 171 return m; 172 } 173 /* ---------------------------------------------------------- */ 174 IMAGE_EXPORT(uint16) min_ui16vector(uint16 *v, long nl, long nh) 175 /* ---------------------------------------------------------- */ 176 { 177 int i; 178 uint16 m; 179 180 m = v[nl]; 181 for(i=nl+1; i<=nh; i++) { 182 if(v[i]<m) m = v[i]; 183 } 184 return m; 185 } 186 /* ---------------------------------------------------------- */ 187 IMAGE_EXPORT(sint32) min_si32vector(sint32 *v, long nl, long nh) 188 /* ---------------------------------------------------------- */ 189 { 190 int i; 191 int16 m; 192 193 m = v[nl]; 194 for(i=nl+1; i<=nh; i++) { 195 if(v[i]<m) m = v[i]; 196 } 197 return m; 198 } 199 /* ---------------------------------------------------------- */ 200 IMAGE_EXPORT(uint32) min_ui32vector(uint32 *v, long nl, long nh) 201 /* ---------------------------------------------------------- */ 202 { 203 int i; 204 uint32 m; 205 206 m = v[nl]; 207 for(i=nl+1; i<=nh; i++) { 208 if(v[i]<m) m = v[i]; 209 } 210 return m; 211 } 212 /* ----------------------------------------------------------- */ 213 IMAGE_EXPORT(float32) min_f32vector(float32 *v, long nl, long nh) 214 /* ----------------------------------------------------------- */ 215 { 216 int i; 217 float32 m; 218 219 m = v[nl]; 220 for(i=nl+1; i<=nh; i++) { 221 if(v[i]<m) m = v[i]; 222 } 223 return m; 224 } 225 /* ----------------------------------------------------------- */ 226 IMAGE_EXPORT(float64) min_f64vector(float64 *v, long nl, long nh) 227 /* ----------------------------------------------------------- */ 228 { 229 int i; 230 float64 m; 231 232 m = v[nl]; 233 for(i=nl+1; i<=nh; i++) { 234 if(v[i]<m) m = v[i]; 235 } 236 return m; 237 } 64 #undef min_type_vector 65 #define min_type_vector(t) \ 66 t short_name(t,min_,vector)(t * v, int32_t nl, int32_t nh) \ 67 { \ 68 t m = v[nl]; \ 69 for (int32_t i = nl + 1; i <= nh; i++) { \ 70 if (v[i] < m) { \ 71 m = v[i]; \ 72 } \ 73 } \ 74 return m; \ 75 } 76 77 78 min_type_vector(int8_t); 79 min_type_vector(uint8_t); 80 min_type_vector(int16_t); 81 min_type_vector(uint16_t); 82 min_type_vector(int32_t); 83 min_type_vector(uint32_t); 84 min_type_vector(float); 85 min_type_vector(double); 86 238 87 239 88 /* … … 243 92 */ 244 93 245 /* ------------------------------------------------------- */ 246 IMAGE_EXPORT(sint8) max_si8vector(sint8 *v, long nl, long nh) 247 /* ------------------------------------------------------- */ 248 { 249 int i; 250 sint8 m; 251 252 m = v[nl]; 253 for(i=nl+1; i<=nh; i++) { 254 if(v[i]>m) m = v[i]; 255 } 256 return m; 257 } 258 /* ------------------------------------------------------- */ 259 IMAGE_EXPORT(uint8) max_ui8vector(uint8 *v, long nl, long nh) 260 /* ------------------------------------------------------- */ 261 { 262 int i; 263 uint8 m; 264 265 m = v[nl]; 266 for(i=nl+1; i<=nh; i++) { 267 if(v[i]>m) m = v[i]; 268 } 269 return m; 270 } 271 /* ---------------------------------------------------------- */ 272 IMAGE_EXPORT(sint16) max_si16vector(sint16 *v, long nl, long nh) 273 /* ---------------------------------------------------------- */ 274 { 275 int i; 276 sint16 m; 277 278 m = v[nl]; 279 for(i=nl+1; i<=nh; i++) { 280 if(v[i]>m) m = v[i]; 281 } 282 return m; 283 } 284 /* ---------------------------------------------------------- */ 285 IMAGE_EXPORT(uint16) max_ui16vector(uint16 *v, long nl, long nh) 286 /* ---------------------------------------------------------- */ 287 { 288 int i; 289 uint16 m; 290 291 m = v[nl]; 292 for(i=nl+1; i<=nh; i++) { 293 if(v[i]>m) m = v[i]; 294 } 295 return m; 296 } 297 /* ---------------------------------------------------------- */ 298 IMAGE_EXPORT(sint32) max_si32vector(sint32 *v, long nl, long nh) 299 /* ---------------------------------------------------------- */ 300 { 301 int i; 302 sint32 m; 303 304 m = v[nl]; 305 for(i=nl+1; i<=nh; i++) { 306 if(v[i]>m) m = v[i]; 307 } 308 return m; 309 } 310 /* ---------------------------------------------------------- */ 311 IMAGE_EXPORT(uint32) max_ui32vector(uint32 *v, long nl, long nh) 312 /* ---------------------------------------------------------- */ 313 { 314 int i; 315 uint32 m; 316 317 m = v[nl]; 318 for(i=nl+1; i<=nh; i++) { 319 if(v[i]>m) m = v[i]; 320 } 321 return m; 322 } 323 /* ----------------------------------------------------------- */ 324 IMAGE_EXPORT(float32) max_f32vector(float32 *v, long nl, long nh) 325 /* ----------------------------------------------------------- */ 326 { 327 int i; 328 float32 m; 329 330 m = v[nl]; 331 for(i=nl+1; i<=nh; i++) { 332 if(v[i]>m) m = v[i]; 333 } 334 return m; 335 } 336 /* ----------------------------------------------------------- */ 337 IMAGE_EXPORT(float64) max_f64vector(float64 *v, long nl, long nh) 338 /* ----------------------------------------------------------- */ 339 { 340 int i; 341 float64 m; 342 343 m = v[nl]; 344 for(i=nl+1; i<=nh; i++) { 345 if(v[i]>m) m = v[i]; 346 } 347 return m; 348 } 94 #undef max_type_vector 95 #define max_type_vector(t) \ 96 t short_name(t,max_,vector)(t * v, int32_t nl, int32_t nh) \ 97 { \ 98 t m = v[nl]; \ 99 for (int32_t i = nl + 1; i <= nh; i++) { \ 100 if (v[i] > m) { \ 101 m = v[i]; \ 102 } \ 103 } \ 104 return m; \ 105 } 106 107 108 max_type_vector(int8_t); 109 max_type_vector(uint8_t); 110 max_type_vector(int16_t); 111 max_type_vector(uint16_t); 112 max_type_vector(int32_t); 113 max_type_vector(uint32_t); 114 max_type_vector(float); 115 max_type_vector(double); 116 117 349 118 /* 350 119 * ---------------------- … … 353 122 */ 354 123 355 /* --------------------------------------------------------------------- */ 356 IMAGE_EXPORT(sint8) min_si8vector_pos(sint8 *v, long nl, long nh, int *pos) 357 /* --------------------------------------------------------------------- */ 358 { 359 int i; 360 sint8 m = v[nl]; 361 int p = nl; 362 363 for(i=nl+1; i<=nh; i++) { 364 if(v[i]>m) { m = v[i]; p = i;} 365 } 366 *pos = p; 367 return m; 368 } 369 /* --------------------------------------------------------------------- */ 370 IMAGE_EXPORT(uint8) min_ui8vector_pos(uint8 *v, long nl, long nh, int *pos) 371 /* --------------------------------------------------------------------- */ 372 { 373 int i; 374 uint8 m = v[nl]; 375 int p = nl; 376 377 for(i=nl+1; i<=nh; i++) { 378 if(v[i]>m) { m = v[i]; p = i;} 379 } 380 *pos = p; 381 return m; 382 } 383 /* ------------------------------------------------------------------------ */ 384 IMAGE_EXPORT(sint16) min_si16vector_pos(sint16 *v, long nl, long nh, int *pos) 385 /* ------------------------------------------------------------------------ */ 386 { 387 int i; 388 sint16 m = v[nl]; 389 int p = nl; 390 391 for(i=nl+1; i<=nh; i++) { 392 if(v[i]>m) { m = v[i]; p = i;} 393 } 394 *pos = p; 395 return m; 396 } 397 /* ------------------------------------------------------------------------ */ 398 IMAGE_EXPORT(uint16) min_ui16vector_pos(uint16 *v, long nl, long nh, int *pos) 399 /* ------------------------------------------------------------------------ */ 400 { 401 int i; 402 uint16 m = v[nl]; 403 int p = nl; 404 405 for(i=nl+1; i<=nh; i++) { 406 if(v[i]>m) { m = v[i]; p = i;} 407 } 408 *pos = p; 409 return m; 410 } 411 /* ------------------------------------------------------------------------ */ 412 IMAGE_EXPORT(sint32) min_si32vector_pos(sint32 *v, long nl, long nh, int *pos) 413 /* ------------------------------------------------------------------------ */ 414 { 415 int i; 416 sint32 m = v[nl]; 417 int p = nl; 418 419 for(i=nl+1; i<=nh; i++) { 420 if(v[i]>m) { m = v[i]; p = i;} 421 } 422 *pos = p; 423 return m; 424 } 425 /* ------------------------------------------------------------------------ */ 426 IMAGE_EXPORT(uint32) min_ui32vector_pos(uint32 *v, long nl, long nh, int *pos) 427 /* ------------------------------------------------------------------------ */ 428 { 429 int i; 430 uint32 m = v[nl]; 431 int p = nl; 432 433 for(i=nl+1; i<=nh; i++) { 434 if(v[i]>m) { m = v[i]; p = i;} 435 } 436 *pos = p; 437 return m; 438 } 439 /* ------------------------------------------------------------------------- */ 440 IMAGE_EXPORT(float32) min_f32vector_pos(float32 *v, long nl, long nh, int *pos) 441 /* ------------------------------------------------------------------------- */ 442 { 443 int i; 444 float32 m = v[nl]; 445 int p = nl; 446 447 for(i=nl+1; i<=nh; i++) { 448 if(v[i]>m) { m = v[i]; p = i;} 449 } 450 *pos = p; 451 return m; 452 } 453 /* ------------------------------------------------------------------------- */ 454 IMAGE_EXPORT(float64) min_f64vector_pos(float64 *v, long nl, long nh, int *pos) 455 /* ------------------------------------------------------------------------- */ 456 { 457 int i; 458 float64 m = v[nl]; 459 int p = nl; 460 461 for(i=nl+1; i<=nh; i++) { 462 if(v[i]>m) { m = v[i]; p = i;} 463 } 464 *pos = p; 465 return m; 466 } 124 125 #undef min_type_vector_pos 126 #define min_type_vector_pos(t) \ 127 t short_name(t,min_,vector_pos)(t * v, int32_t nl, int32_t nh, int32_t * pos) \ 128 { \ 129 t m = v[nl]; \ 130 int32_t p = nl; \ 131 for (int32_t i = nl + 1; i <= nh; i++) { \ 132 if (v[i] < m) { \ 133 m = v[i]; \ 134 p = i; \ 135 } \ 136 } \ 137 *pos = p; \ 138 return m; \ 139 } 140 141 142 min_type_vector_pos(int8_t); 143 min_type_vector_pos(uint8_t); 144 min_type_vector_pos(int16_t); 145 min_type_vector_pos(uint16_t); 146 min_type_vector_pos(int32_t); 147 min_type_vector_pos(uint32_t); 148 min_type_vector_pos(float); 149 min_type_vector_pos(double); 150 467 151 468 152 /* … … 472 156 */ 473 157 474 /* --------------------------------------------------------------------- */ 475 IMAGE_EXPORT(sint8) max_si8vector_pos(sint8 *v, long nl, long nh, int *pos) 476 /* --------------------------------------------------------------------- */ 477 { 478 int i; 479 sint8 m = v[nl]; 480 int p = nl; 481 482 for(i=nl+1; i<=nh; i++) { 483 if(v[i]>m) { m = v[i]; p = i;} 484 } 485 *pos = p; 486 487 return m; 488 } 489 /* --------------------------------------------------------------------- */ 490 IMAGE_EXPORT(uint8) max_ui8vector_pos(uint8 *v, long nl, long nh, int *pos) 491 /* --------------------------------------------------------------------- */ 492 { 493 int i; 494 uint8 m = v[nl]; 495 int p = nl; 496 497 for(i=nl+1; i<=nh; i++) { 498 if(v[i]>m) { m = v[i]; p = i;} 499 } 500 *pos = p; 501 502 return m; 503 } 158 159 #undef max_type_vector_pos 160 #define max_type_vector_pos(t) \ 161 t short_name(t,max_,vector_pos)(t * v, int32_t nl, int32_t nh, int32_t * pos) \ 162 { \ 163 t m = v[nl]; \ 164 int32_t p = nl; \ 165 for (int32_t i = nl + 1; i <= nh; i++) { \ 166 if (v[i] > m) { \ 167 m = v[i]; \ 168 p = i; \ 169 } \ 170 } \ 171 *pos = p; \ 172 return m; \ 173 } 174 175 176 max_type_vector_pos(int8_t); 177 max_type_vector_pos(uint8_t); 178 max_type_vector_pos(int16_t); 179 max_type_vector_pos(uint16_t); 180 max_type_vector_pos(int32_t); 181 max_type_vector_pos(uint32_t); 182 max_type_vector_pos(float); 183 max_type_vector_pos(double); 184 185 186 #undef add_type_vector 187 #define add_type_vector(t) \ 188 void short_name(t,add_,vector)(t * S1, int32_t nl, int32_t nh, t * S2, t * D) \ 189 { \ 190 for (int32_t i = nl; i <= nh; i++) { \ 191 D[i] = S1[i] + S2[i]; \ 192 } \ 193 } 194 195 add_type_vector(int8_t); 196 add_type_vector(uint8_t); 197 add_type_vector(int16_t); 198 add_type_vector(uint16_t); 199 add_type_vector(int32_t); 200 add_type_vector(uint32_t); 201 add_type_vector(float); 202 add_type_vector(double); 203 204 205 #undef sub_type_vector 206 #define sub_type_vector(t) \ 207 void short_name(t,sub_,vector)(t * S1, int32_t nl, int32_t nh, t * S2, t * D) \ 208 { \ 209 for (int32_t i = nl; i <= nh; i++) { \ 210 D[i] = S1[i] - S2[i]; \ 211 } \ 212 } 213 214 sub_type_vector(int8_t); 215 sub_type_vector(uint8_t); 216 sub_type_vector(int16_t); 217 sub_type_vector(uint16_t); 218 sub_type_vector(int32_t); 219 sub_type_vector(uint32_t); 220 sub_type_vector(float); 221 sub_type_vector(double); 222 223 224 #undef mulc_type_vector 225 #define mulc_type_vector(t) \ 226 void short_name(t,mulc_,vector)(t * S, int32_t nl, int32_t nh, int32_t c, t * D) \ 227 { \ 228 for (int32_t i = nl; i <= nh; i++) { \ 229 D[i] = S[i] * c; \ 230 } \ 231 } 232 233 mulc_type_vector(int8_t); 234 mulc_type_vector(uint8_t); 235 mulc_type_vector(int16_t); 236 mulc_type_vector(uint16_t); 237 mulc_type_vector(int32_t); 238 mulc_type_vector(uint32_t); 239 mulc_type_vector(float); 240 mulc_type_vector(double); 241 242 243 #undef divc_type_vector 244 #define divc_type_vector(t) \ 245 void short_name(t,divc_,vector)(t * S, int32_t nl, int32_t nh, int32_t c, t * D) \ 246 { \ 247 for (int32_t i = nl; i <= nh; i++) { \ 248 D[i] = S[i] / c; \ 249 } \ 250 } 251 252 divc_type_vector(int8_t); 253 divc_type_vector(uint8_t); 254 divc_type_vector(int16_t); 255 divc_type_vector(uint16_t); 256 divc_type_vector(int32_t); 257 divc_type_vector(uint32_t); 258 divc_type_vector(float); 259 divc_type_vector(double); 260 261 262 #undef cumulleft_type_vector 263 #define cumulleft_type_vector(t) \ 264 void short_name(t,cumulleft_,vector)(t * S, int32_t nl, int32_t nh, int32_t * D) \ 265 { \ 266 for (int32_t i = nh - 1; i >= nl; i--) { \ 267 D[i] += S[i + 1]; \ 268 } \ 269 } 270 271 cumulleft_type_vector(int8_t); 272 cumulleft_type_vector(uint8_t); 273 cumulleft_type_vector(int16_t); 274 cumulleft_type_vector(uint16_t); 275 cumulleft_type_vector(int32_t); 276 cumulleft_type_vector(uint32_t); 277 cumulleft_type_vector(float); 278 cumulleft_type_vector(double); 279 280 281 #undef cumulright_type_vector 282 #define cumulright_type_vector(t) \ 283 void short_name(t,cumulright_,vector)(t * S, int32_t nl, int32_t nh, int32_t * D) \ 284 { \ 285 for (int32_t i = nl + 1; i <= nh; i++) { \ 286 D[i] += S[i - 1]; \ 287 } \ 288 } 289 290 cumulright_type_vector(int8_t); 291 cumulright_type_vector(uint8_t); 292 cumulright_type_vector(int16_t); 293 cumulright_type_vector(uint16_t); 294 cumulright_type_vector(int32_t); 295 cumulright_type_vector(uint32_t); 296 cumulright_type_vector(float); 297 cumulright_type_vector(double); 298 299 300 #undef mulfrac_type_vector 301 #define mulfrac_type_vector(t) \ 302 void short_name(t,mulfrac_,vector)(t * S, int32_t nl, int32_t nh, int32_t a, int32_t b, t * D) \ 303 { \ 304 for (int32_t i = nl; i <= nh; i++) { \ 305 D[i] = (a * S[i]) / b; \ 306 } \ 307 } 308 309 310 mulfrac_type_vector(int8_t); 311 mulfrac_type_vector(uint8_t); 312 mulfrac_type_vector(int16_t); 313 mulfrac_type_vector(uint16_t); 314 mulfrac_type_vector(int32_t); 315 mulfrac_type_vector(uint32_t); 316 mulfrac_type_vector(float); 317 mulfrac_type_vector(double); 318 319 320 /* --------------------------------------------------------------------- */ 321 void beta_sum_rgb32vector(rgb32 * S, int32_t nl, int32_t nh, rgb32 * D) 322 /* --------------------------------------------------------------------- */ 323 { 324 int32_t r, g, b; 325 int32_t s; 326 for (int32_t i = nl; i <= nh; i++) { 327 r = S[i].r; 328 g = S[i].g; 329 b = S[i].b; 330 s = r + g + b; 331 D[i].r = s; 332 D[i].g = s; 333 D[i].b = s; 334 } 335 } 336 337 /* ----------------------------------------------------------------------- */ 338 void beta_average_rgb32vector(rgb32 * S, int32_t nl, int32_t nh, rgb32 * D) 339 /* ----------------------------------------------------------------------- */ 340 { 341 int32_t r, g, b; 342 int32_t s; 343 for (int32_t i = nl; i <= nh; i++) { 344 r = S[i].r; 345 g = S[i].g; 346 b = S[i].b; 347 s = (r + g + b) / 3; 348 D[i].r = s; 349 D[i].g = s; 350 D[i].b = s; 351 } 352 } 353 504 354 /* ------------------------------------------------------------------------ */ 505 IMAGE_EXPORT(sint16) max_si16vector_pos(sint16 *v, long nl, long nh, int *pos)355 void mulc_rgb32vector(rgb32 * S, int32_t nl, int32_t nh, int32_t c, rgb32 * D) 506 356 /* ------------------------------------------------------------------------ */ 507 357 { 508 int i; 509 int16 m = v[nl]; 510 int p = nl; 511 512 for(i=nl+1; i<=nh; i++) { 513 if(v[i]>m) { m = v[i]; p = i;} 514 } 515 *pos = p; 516 return m; 517 } 518 /* ----------------------------------------------------------------------- */ 519 IMAGE_EXPORT(uint16) max_ui16vector_pos(uint16 *v, long nl, long nh, int *pos) 520 /* ----------------------------------------------------------------------- */ 521 { 522 int i; 523 uint16 m = v[nl]; 524 int p = nl; 525 526 for(i=nl+1; i<=nh; i++) { 527 if(v[i]>m) { m = v[i]; p = i;} 528 } 529 *pos = p; 530 531 return m; 532 } 533 /* --------------------------------------------------------------------- */ 534 IMAGE_EXPORT(sint32) max_si32vector_pos(sint32 *v, long nl, long nh, int *pos) 535 /* --------------------------------------------------------------------- */ 536 { 537 int i; 538 sint32 m = v[nl]; 539 int p = nl; 540 541 for(i=nl+1; i<=nh; i++) { 542 if(v[i]>m) { m = v[i]; p = i;} 543 } 544 *pos = p; 545 546 return m; 547 } 548 /* ------------------------------------------------------------------------ */ 549 IMAGE_EXPORT(uint32) max_ui32vector_pos(uint32 *v, long nl, long nh, int *pos) 550 /* ------------------------------------------------------------------------ */ 551 { 552 int i; 553 uint32 m = v[nl]; 554 int p = nl; 555 556 for(i=nl+1; i<=nh; i++) { 557 if(v[i]>m) { m = v[i]; p = i;} 558 } 559 *pos = p; 560 561 return m; 562 } 563 /* ----------------------------------------------------------------------- */ 564 IMAGE_EXPORT(float32) max_f32vector_pos(float32 *v, long nl, long nh, int *pos) 565 /* ----------------------------------------------------------------------- */ 566 { 567 int i; 568 float32 m = v[nl]; 569 int p = nl; 570 571 for(i=nl+1; i<=nh; i++) { 572 if(v[i]>m) { m = v[i]; p = i;} 573 } 574 *pos = p; 575 576 return m; 577 } 578 /* ------------------------------------------------------------------------- */ 579 IMAGE_EXPORT(float64) max_f64vector_pos(float64 *v, long nl, long nh, int *pos) 580 /* ------------------------------------------------------------------------- */ 581 { 582 int i; 583 float64 m = v[nl]; 584 int p = nl; 585 586 for(i=nl+1; i<=nh; i++) { 587 if(v[i]>m) { m = v[i]; p = i;} 588 } 589 *pos = p; 590 591 return m; 592 } 593 /* --------------------------------------------------------------------- */ 594 IMAGE_EXPORT(void) beta_sum_rgb32vector(rgb32 *S,long nl,long nh, rgb32 *D) 595 /* --------------------------------------------------------------------- */ 596 { 597 long i; 598 int32 r, g, b, s; 599 for(i=nl; i<=nh; i++){ 600 r = S[i].r; 601 g = S[i].g; 602 b = S[i].b; 603 s = r + g + b; 604 D[i].r = s; 605 D[i].g = s; 606 D[i].b = s; 607 } 608 } 609 /* ----------------------------------------------------------------------- */ 610 IMAGE_EXPORT(void) beta_average_rgb32vector(rgb32 *S,long nl,long nh, rgb32 *D) 611 /* ----------------------------------------------------------------------- */ 612 { 613 long i; 614 int32 r, g, b, s; 615 for(i=nl; i<=nh; i++){ 616 r = S[i].r; 617 g = S[i].g; 618 b = S[i].b; 619 s = (r + g + b) / 3; 620 D[i].r = s; 621 D[i].g = s; 622 D[i].b = s; 623 } 624 } 625 /* ------------------------------------------------------------------------ */ 626 IMAGE_EXPORT(void) add_i32vector(int32 *S1,long nl,long nh, int32 *S2, int32 *D) 627 /* ------------------------------------------------------------------------ */ 628 { 629 long i; 630 for(i=nl; i<=nh; i++) D[i] = S1[i] + S2[i]; 631 } 632 /* ------------------------------------------------------------------------ */ 633 IMAGE_EXPORT(void) sub_i32vector(int32 *S1,long nl,long nh, int32 *S2, int32 *D) 634 /* ------------------------------------------------------------------------ */ 635 { 636 long i; 637 for(i=nl; i<=nh; i++) D[i] = S1[i] - S2[i]; 638 } 639 /* ---------------------------------------------------------------------- */ 640 IMAGE_EXPORT(void) mulc_i32vector(int32 *S,long nl,long nh, int32 c, int32 *D) 641 /* ---------------------------------------------------------------------- */ 642 { 643 long i; 644 for(i=nl; i<=nh; i++) D[i] = c * S[i]; 645 } 646 /* ------------------------------------------------------------------------ */ 647 IMAGE_EXPORT(void) mulc_rgb32vector(rgb32 *S,long nl,long nh, int32 c, rgb32 *D) 648 /* ------------------------------------------------------------------------ */ 649 { 650 long i; 651 652 for(i=nl; i<=nh; i++) { 653 D[i].r = c * S[i].r; 654 D[i].g = c * S[i].g; 655 D[i].b = c * S[i].b; 656 } 657 } 658 /* ------------------------------------------------------------------------ */ 659 IMAGE_EXPORT(void) divc_i32vector(int32 *S,long nl,long nh, int32 c, int32 *D) 660 /* ------------------------------------------------------------------------ */ 661 { 662 long i; 663 for(i=nl; i<=nh; i++) D[i] = S[i] / c; 664 } 665 /* -------------------------------------------------------------------------- */ 666 IMAGE_EXPORT(void) divc_rgb32vector(rgb32 *S,long nl,long nh, int32 c, rgb32 *D) 667 /* -------------------------------------------------------------------------- */ 668 { 669 long i; 670 671 for(i=nl; i<=nh; i++) { 672 D[i].r = S[i].r / c; 673 D[i].g = S[i].g / c; 674 D[i].b = S[i].b / c; 675 } 676 } 677 /* -------------------------------------------------------------------- */ 678 IMAGE_EXPORT(void) cumulleft_i32vector(int32 *S, long nl,long nh, int32 *D) 679 /* -------------------------------------------------------------------- */ 680 { 681 // for histogram 682 long i; 683 684 for(i=nh-1; i>=nl; i--) { 685 D[i] += S[i+1]; 686 } 687 } 688 /* --------------------------------------------------------------------- */ 689 IMAGE_EXPORT(void) cumulleft_rgb32vector(rgb32 *S, long nl,long nh, rgb32 *D) 690 /* --------------------------------------------------------------------- */ 691 { 692 // for histogram 693 long i; 694 695 for(i=nh-1; i>=nl; i--) { 696 D[i].r += S[i+1].r; 697 D[i].g += S[i+1].g; 698 D[i].b += S[i+1].b; 699 } 700 } 701 /* -------------------------------------------------------------------- */ 702 IMAGE_EXPORT(void) cumulright_i32vector(int32 *S, long nl,long nh, int32 *D) 703 /* -------------------------------------------------------------------- */ 704 { 705 // for histogram 706 long i; 707 708 for(i=nl+1; i<=nh; i++) { 709 D[i] += S[i-1]; 710 } 711 } 712 /* ---------------------------------------------------------------------- */ 713 IMAGE_EXPORT(void) cumulright_rgb32vector(rgb32 *S, long nl,long nh, rgb32 *D) 714 /* ---------------------------------------------------------------------- */ 715 { 716 // for histogram 717 long i; 718 719 for(i=nl+1; i<=nh; i++) { 720 D[i].r += S[i-1].r; 721 D[i].g += S[i-1].g; 722 D[i].b += S[i-1].b; 723 } 724 } 725 /* ----------------------------------------------------------------------------------- */ 726 IMAGE_EXPORT(void) mulfrac_i32vector(int32 *S, long nl,long nh, int32 a, int32 b, int32 *D) 727 /* ----------------------------------------------------------------------------------- */ 728 { 729 long i; 730 731 for(i=nl; i<=nh; i++) { 732 //D[i] = (a * S[i] + b) / b; 733 D[i] = (a * S[i]) / b; 734 } 735 } 358 for (int32_t i = nl; i <= nh; i++) { 359 D[i].r = c * S[i].r; 360 D[i].g = c * S[i].g; 361 D[i].b = c * S[i].b; 362 } 363 } 364 365 /* --------------------------------------------------------------------- */ 366 void divc_rgb32vector(rgb32 * S, int32_t nl, int32_t nh, int32_t c, rgb32 * D) 367 /* --------------------------------------------------------------------- */ 368 { 369 for (int32_t i = nl; i <= nh; i++) { 370 D[i].r = S[i].r / c; 371 D[i].g = S[i].g / c; 372 D[i].b = S[i].b / c; 373 } 374 } 375 376 /* --------------------------------------------------------------------- */ 377 void cumulleft_rgb32vector(rgb32 * S, int32_t nl, int32_t nh, rgb32 * D) 378 /* --------------------------------------------------------------------- */ 379 { 380 // for histogram 381 for (int32_t i = nh - 1; i >= nl; i--) { 382 D[i].r += S[i + 1].r; 383 D[i].g += S[i + 1].g; 384 D[i].b += S[i + 1].b; 385 } 386 } 387 388 389 /* --------------------------------------------------------------------- */ 390 void cumulright_rgb32vector(rgb32 * S, int32_t nl, int32_t nh, rgb32 * D) 391 /* --------------------------------------------------------------------- */ 392 { 393 // for histogram 394 for (int32_t i = nl + 1; i <= nh; i++) { 395 D[i].r += S[i - 1].r; 396 D[i].g += S[i - 1].g; 397 D[i].b += S[i - 1].b; 398 } 399 } 400 401 736 402 /* ------------------------------------------------------------------------------------- */ 737 IMAGE_EXPORT(void) mulfrac_rgb32vector(rgb32 *S, long nl,long nh, int32 a, int32 b, rgb32 *D)403 void mulfrac_rgb32vector(rgb32 * S, int32_t nl, int32_t nh, int32_t a, int32_t b, rgb32 * D) 738 404 /* ------------------------------------------------------------------------------------- */ 739 405 { 740 long i; 741 742 for(i=nl; i<=nh; i++) { 743 //D[i].r = (a * S[i].r + b) / b; 744 //D[i].g = (a * S[i].g + b) / b; 745 //D[i].b = (a * S[i].b + b) / b; 746 D[i].r = (a * S[i].r) / b; 747 D[i].g = (a * S[i].g) / b; 748 D[i].b = (a * S[i].b) / b; 749 } 750 } 406 for (int32_t i = nl; i <= nh; i++) { 407 D[i].r = (a * S[i].r) / b; 408 D[i].g = (a * S[i].g) / b; 409 D[i].b = (a * S[i].b) / b; 410 } 411 } 412 413 // Local Variables: 414 // tab-width: 4 415 // c-basic-offset: 4 416 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 417 // indent-tabs-mode: nil 418 // End: 419 420 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 421 -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrarith2.c
r772 r821 17 17 #include <malloc.h> 18 18 #include <math.h> // fabs 19 // #include <memory.h> // memcpy 20 19 20 #include "nrc_os_config.h" 21 21 #include "mypredef.h" 22 22 #include "nrtype.h" … … 25 25 #include "nrkernel.h" 26 26 27 #include "nrarith1.h"28 27 #include "nrarith2.h" 29 28 … … 32 31 /* ------------------ */ 33 32 34 /* ----------------------------------------------------------------------------- */ 35 IMAGE_EXPORT(sint8) min_si8matrix(sint8 **m, long nrl, long nrh, long ncl, long nch) 36 /* ----------------------------------------------------------------------------- */ 37 { 38 int i, j; 39 sint8 minimum = m[nrl][ncl]; 40 41 for(i=nrl; i<=nrh; i++) { 42 for(j=ncl; j<=nch; j++) { 43 if(m[i][j]<minimum) minimum = m[i][j]; 44 } 45 } 46 return minimum; 47 } 48 /* ------------------------------------------------------------------------------ */ 49 IMAGE_EXPORT(uint8) min_ui8matrix(uint8 **m, long nrl, long nrh, long ncl, long nch) 50 /* ------------------------------------------------------------------------------ */ 51 { 52 int i, j; 53 uint8 minimum = m[nrl][ncl]; 54 55 for(i=nrl; i<=nrh; i++) { 56 for(j=ncl; j<=nch; j++) { 57 if(m[i][j]<minimum) minimum = m[i][j]; 58 } 59 } 60 return minimum; 61 } 62 /* --------------------------------------------------------------------------------- */ 63 IMAGE_EXPORT(sint16) min_si16matrix(sint16 **m, long nrl, long nrh, long ncl, long nch) 64 /* --------------------------------------------------------------------------------- */ 65 { 66 int i, j; 67 sint16 minimum = m[nrl][ncl]; 68 69 for(i=nrl; i<=nrh; i++) { 70 for(j=ncl; j<=nch; j++) { 71 if(m[i][j]<minimum) minimum = m[i][j]; 72 } 73 } 74 return minimum; 75 } 76 /* --------------------------------------------------------------------------------- */ 77 IMAGE_EXPORT(uint16) min_ui16matrix(uint16 **m, long nrl, long nrh, long ncl, long nch) 78 /* --------------------------------------------------------------------------------- */ 79 { 80 int i, j; 81 uint16 minimum = m[nrl][ncl]; 82 83 for(i=nrl; i<=nrh; i++) { 84 for(j=ncl; j<=nch; j++) { 85 if(m[i][j]<minimum) minimum = m[i][j]; 86 } 87 } 88 return minimum; 89 } 90 /* --------------------------------------------------------------------------------- */ 91 IMAGE_EXPORT(sint32) min_si32matrix(sint32 **m, long nrl, long nrh, long ncl, long nch) 92 /* --------------------------------------------------------------------------------- */ 93 { 94 int i, j; 95 sint32 minimum = m[nrl][ncl]; 96 97 for(i=nrl; i<=nrh; i++) { 98 for(j=ncl; j<=nch; j++) { 99 if(m[i][j]<minimum) minimum = m[i][j]; 100 } 101 } 102 return minimum; 103 } 104 /* --------------------------------------------------------------------------------- */ 105 IMAGE_EXPORT(uint32) min_ui32matrix(uint32 **m, long nrl, long nrh, long ncl, long nch) 106 /* --------------------------------------------------------------------------------- */ 107 { 108 int i, j; 109 uint32 minimum = m[nrl][ncl]; 110 111 for(i=nrl; i<=nrh; i++) { 112 for(j=ncl; j<=nch; j++) { 113 if(m[i][j]<minimum) minimum = m[i][j]; 114 } 115 } 116 return minimum; 117 } 118 /* --------------------------------------------------------------------------------- */ 119 IMAGE_EXPORT(sint64) min_si64matrix(sint64 **m, long nrl, long nrh, long ncl, long nch) 120 /* --------------------------------------------------------------------------------- */ 121 { 122 int i, j; 123 sint64 minimum = m[nrl][ncl]; 124 125 for(i=nrl; i<=nrh; i++) { 126 for(j=ncl; j<=nch; j++) { 127 if(m[i][j]<minimum) minimum = m[i][j]; 128 } 129 } 130 return minimum; 131 } 132 /* --------------------------------------------------------------------------------- */ 133 IMAGE_EXPORT(uint64) min_ui64matrix(uint64 **m, long nrl, long nrh, long ncl, long nch) 134 /* --------------------------------------------------------------------------------- */ 135 { 136 int i, j; 137 uint64 minimum = m[nrl][ncl]; 138 139 for(i=nrl; i<=nrh; i++) { 140 for(j=ncl; j<=nch; j++) { 141 if(m[i][j]<minimum) minimum = m[i][j]; 142 } 143 } 144 return minimum; 145 } 146 /* ---------------------------------------------------------------------------------- */ 147 IMAGE_EXPORT(float32) min_f32matrix(float32 **m, long nrl, long nrh, long ncl, long nch) 148 /* ---------------------------------------------------------------------------------- */ 149 { 150 int i, j; 151 float32 minimum = m[nrl][ncl]; 152 153 for(i=nrl; i<=nrh; i++) { 154 for(j=ncl; j<=nch; j++) { 155 if(m[i][j]<minimum) minimum = m[i][j]; 156 } 157 } 158 return minimum; 159 } 160 /* ---------------------------------------------------------------------------------- */ 161 IMAGE_EXPORT(float64) min_f64matrix(float64 **m, long nrl, long nrh, long ncl, long nch) 162 /* ---------------------------------------------------------------------------------- */ 163 { 164 int i, j; 165 float64 minimum = m[nrl][ncl]; 166 167 for(i=nrl; i<=nrh; i++) { 168 for(j=ncl; j<=nch; j++) { 169 if(m[i][j]<minimum) minimum = m[i][j]; 170 } 171 } 172 return minimum; 173 } 33 #undef min_type_matrix 34 #define min_type_matrix(t) \ 35 t short_name(t,min_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ 36 { \ 37 t minimum = m[nrl][nrh]; \ 38 for (int32_t i = nrl; i <= nrh; i++) { \ 39 for (int32_t j = ncl; j <= nch; j++) { \ 40 if (m[i][j] < minimum) { \ 41 minimum = m[i][j]; \ 42 } \ 43 } \ 44 } \ 45 return minimum; \ 46 } 47 48 min_type_matrix(int8_t); 49 min_type_matrix(uint8_t); 50 min_type_matrix(int16_t); 51 min_type_matrix(uint16_t); 52 min_type_matrix(int32_t); 53 min_type_matrix(uint32_t); 54 min_type_matrix(int64_t); 55 min_type_matrix(uint64_t); 56 min_type_matrix(float); 57 min_type_matrix(double); 58 174 59 175 60 /* ------------------ */ … … 177 62 /* ------------------ */ 178 63 179 /* ----------------------------------------------------------------------------- */ 180 IMAGE_EXPORT(sint8) max_si8matrix(sint8 **m, long nrl, long nrh, long ncl, long nch) 181 /* ----------------------------------------------------------------------------- */ 182 { 183 int i, j; 184 sint8 minimum = m[nrl][ncl]; 185 186 for(i=nrl; i<=nrh; i++) { 187 for(j=ncl; j<=nch; j++) { 188 if(m[i][j]>minimum) minimum = m[i][j]; 189 } 190 } 191 return minimum; 192 } 193 /* ------------------------------------------------------------------------------ */ 194 IMAGE_EXPORT(uint8) max_ui8matrix(uint8 **m, long nrl, long nrh, long ncl, long nch) 195 /* ------------------------------------------------------------------------------ */ 196 { 197 int i, j; 198 uint8 minimum = m[nrl][ncl]; 199 200 for(i=nrl; i<=nrh; i++) { 201 for(j=ncl; j<=nch; j++) { 202 if(m[i][j]>minimum) minimum = m[i][j]; 203 } 204 } 205 return minimum; 206 } 207 /* --------------------------------------------------------------------------------- */ 208 IMAGE_EXPORT(sint16) max_si16matrix(sint16 **m, long nrl, long nrh, long ncl, long nch) 209 /* --------------------------------------------------------------------------------- */ 210 { 211 int i, j; 212 sint16 minimum = m[nrl][ncl]; 213 214 for(i=nrl; i<=nrh; i++) { 215 for(j=ncl; j<=nch; j++) { 216 if(m[i][j]>minimum) minimum = m[i][j]; 217 } 218 } 219 return minimum; 220 } 221 /* --------------------------------------------------------------------------------- */ 222 IMAGE_EXPORT(uint16) max_ui16matrix(uint16 **m, long nrl, long nrh, long ncl, long nch) 223 /* --------------------------------------------------------------------------------- */ 224 { 225 int i, j; 226 uint16 minimum = m[nrl][ncl]; 227 228 for(i=nrl; i<=nrh; i++) { 229 for(j=ncl; j<=nch; j++) { 230 if(m[i][j]>minimum) minimum = m[i][j]; 231 } 232 } 233 return minimum; 234 } 235 /* --------------------------------------------------------------------------------- */ 236 IMAGE_EXPORT(sint32) max_si32matrix(sint32 **m, long nrl, long nrh, long ncl, long nch) 237 /* --------------------------------------------------------------------------------- */ 238 { 239 int i, j; 240 sint32 minimum = m[nrl][ncl]; 241 242 for(i=nrl; i<=nrh; i++) { 243 for(j=ncl; j<=nch; j++) { 244 if(m[i][j]>minimum) minimum = m[i][j]; 245 } 246 } 247 return minimum; 248 } 249 /* --------------------------------------------------------------------------------- */ 250 IMAGE_EXPORT(uint32) max_ui32matrix(uint32 **m, long nrl, long nrh, long ncl, long nch) 251 /* --------------------------------------------------------------------------------- */ 252 { 253 int i, j; 254 uint32 minimum = m[nrl][ncl]; 255 256 for(i=nrl; i<=nrh; i++) { 257 for(j=ncl; j<=nch; j++) { 258 if(m[i][j]>minimum) minimum = m[i][j]; 259 } 260 } 261 return minimum; 262 } 263 /* --------------------------------------------------------------------------------- */ 264 IMAGE_EXPORT(sint64) max_si64matrix(sint64 **m, long nrl, long nrh, long ncl, long nch) 265 /* --------------------------------------------------------------------------------- */ 266 { 267 int i, j; 268 sint64 minimum = m[nrl][ncl]; 269 270 for(i=nrl; i<=nrh; i++) { 271 for(j=ncl; j<=nch; j++) { 272 if(m[i][j]>minimum) minimum = m[i][j]; 273 } 274 } 275 return minimum; 276 } 277 /* --------------------------------------------------------------------------------- */ 278 IMAGE_EXPORT(uint64) max_ui64matrix(uint64 **m, long nrl, long nrh, long ncl, long nch) 279 /* --------------------------------------------------------------------------------- */ 280 { 281 int i, j; 282 uint64 minimum = m[nrl][ncl]; 283 284 for(i=nrl; i<=nrh; i++) { 285 for(j=ncl; j<=nch; j++) { 286 if(m[i][j]>minimum) minimum = m[i][j]; 287 } 288 } 289 return minimum; 290 } 291 /* ---------------------------------------------------------------------------------- */ 292 IMAGE_EXPORT(float32) max_f32matrix(float32 **m, long nrl, long nrh, long ncl, long nch) 293 /* ---------------------------------------------------------------------------------- */ 294 { 295 int i, j; 296 float32 minimum = m[nrl][ncl]; 297 298 for(i=nrl; i<=nrh; i++) { 299 for(j=ncl; j<=nch; j++) { 300 if(m[i][j]>minimum) minimum = m[i][j]; 301 } 302 } 303 return minimum; 304 } 305 /* ---------------------------------------------------------------------------------- */ 306 IMAGE_EXPORT(float64) max_f64matrix(float64 **m, long nrl, long nrh, long ncl, long nch) 307 /* ---------------------------------------------------------------------------------- */ 308 { 309 int i, j; 310 float64 minimum = m[nrl][ncl]; 311 312 for(i=nrl; i<=nrh; i++) { 313 for(j=ncl; j<=nch; j++) { 314 if(m[i][j]>minimum) minimum = m[i][j]; 315 } 316 } 317 return minimum; 318 } 319 320 /* -------------------------------------------------------------------------------------------------- */ 321 IMAGE_EXPORT(void) add_si8matrix(sint8 **X, long nrl,long nrh, long ncl, long nch, sint8 **Y, sint8 **Z) 322 /* -------------------------------------------------------------------------------------------------- */ 323 { 324 long i, j; 325 326 for(i=nrl; i<=nrh; i++) { 327 for(j=ncl; j<=nch; j++) { 328 Z[i][j] = X[i][j] + Y[i][j]; 329 } 330 } 331 } 64 #undef max_type_matrix 65 #define max_type_matrix(t) \ 66 t short_name(t,max_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ 67 { \ 68 t maximum = m[nrl][nrh]; \ 69 for (int32_t i = nrl; i <= nrh; i++) { \ 70 for (int32_t j = ncl; j <= nch; j++) { \ 71 if (m[i][j] > maximum) { \ 72 maximum = m[i][j]; \ 73 } \ 74 } \ 75 } \ 76 return maximum; \ 77 } 78 79 max_type_matrix(int8_t); 80 max_type_matrix(uint8_t); 81 max_type_matrix(int16_t); 82 max_type_matrix(uint16_t); 83 max_type_matrix(int32_t); 84 max_type_matrix(uint32_t); 85 max_type_matrix(int64_t); 86 max_type_matrix(uint64_t); 87 max_type_matrix(float); 88 max_type_matrix(double); 89 90 332 91 333 92 /* ------------------ */ … … 335 94 /* ------------------ */ 336 95 337 /* -------------------------------------------------------------------------------------------------- */ 338 IMAGE_EXPORT(void) add_ui8matrix(uint8 **X, long nrl,long nrh, long ncl, long nch, uint8 **Y, uint8 **Z) 339 /* -------------------------------------------------------------------------------------------------- */ 340 { 341 long i, j; 342 343 for(i=nrl; i<=nrh; i++) { 344 for(j=ncl; j<=nch; j++) { 345 Z[i][j] = X[i][j] + Y[i][j]; 346 } 347 } 348 } 349 /* ------------------------------------------------------------------------------------------------------ */ 350 IMAGE_EXPORT(void) add_si16matrix(sint16 **X, long nrl,long nrh, long ncl, long nch, sint16 **Y, sint16 **Z) 351 /* ------------------------------------------------------------------------------------------------------ */ 352 { 353 long i, j; 354 355 for(i=nrl; i<=nrh; i++) { 356 for(j=ncl; j<=nch; j++) { 357 Z[i][j] = X[i][j] + Y[i][j]; 358 } 359 } 360 } 361 /* ------------------------------------------------------------------------------------------------------ */ 362 IMAGE_EXPORT(void) add_ui16matrix(uint16 **X, long nrl,long nrh, long ncl, long nch, uint16 **Y, uint16 **Z) 363 /* ------------------------------------------------------------------------------------------------------ */ 364 { 365 long i, j; 366 367 for(i=nrl; i<=nrh; i++) { 368 for(j=ncl; j<=nch; j++) { 369 Z[i][j] = X[i][j] + Y[i][j]; 370 } 371 } 372 } 373 /* ------------------------------------------------------------------------------------------------------ */ 374 IMAGE_EXPORT(void) add_si32matrix(sint32 **X, long nrl,long nrh, long ncl, long nch, sint32 **Y, sint32 **Z) 375 /* ------------------------------------------------------------------------------------------------------ */ 376 { 377 long i, j; 378 379 for(i=nrl; i<=nrh; i++) { 380 for(j=ncl; j<=nch; j++) { 381 Z[i][j] = X[i][j] + Y[i][j]; 382 } 383 } 384 } 385 /* ------------------------------------------------------------------------------------------------------ */ 386 IMAGE_EXPORT(void) add_ui32matrix(uint32 **X, long nrl,long nrh, long ncl, long nch, uint32 **Y, uint32 **Z) 387 /* ------------------------------------------------------------------------------------------------------ */ 388 { 389 long i, j; 390 391 for(i=nrl; i<=nrh; i++) { 392 for(j=ncl; j<=nch; j++) { 393 Z[i][j] = X[i][j] + Y[i][j]; 394 } 395 } 396 } 397 /* ------------------------------------------------------------------------------------------------------ */ 398 IMAGE_EXPORT(void) add_si64matrix(sint64 **X, long nrl,long nrh, long ncl, long nch, sint64 **Y, sint64 **Z) 399 /* ------------------------------------------------------------------------------------------------------ */ 400 { 401 long i, j; 402 403 for(i=nrl; i<=nrh; i++) { 404 for(j=ncl; j<=nch; j++) { 405 Z[i][j] = X[i][j] + Y[i][j]; 406 } 407 } 408 } 409 /* ------------------------------------------------------------------------------------------------------ */ 410 IMAGE_EXPORT(void) add_ui64matrix(uint64 **X, long nrl,long nrh, long ncl, long nch, uint64 **Y, uint64 **Z) 411 /* ------------------------------------------------------------------------------------------------------ */ 412 { 413 long i, j; 414 415 for(i=nrl; i<=nrh; i++) { 416 for(j=ncl; j<=nch; j++) { 417 Z[i][j] = X[i][j] + Y[i][j]; 418 } 419 } 420 } 421 /* -------------------------------------------------------------------------------------------------------- */ 422 IMAGE_EXPORT(void) add_f32matrix(float32 **X, long nrl,long nrh, long ncl, long nch, float32 **Y, float32 **Z) 423 /* -------------------------------------------------------------------------------------------------------- */ 424 { 425 long i, j; 426 427 for(i=nrl; i<=nrh; i++) { 428 for(j=ncl; j<=nch; j++) { 429 Z[i][j] = X[i][j] + Y[i][j]; 430 } 431 } 432 } 433 /* -------------------------------------------------------------------------------------------------------- */ 434 IMAGE_EXPORT(void) add_f64matrix(float64 **X, long nrl,long nrh, long ncl, long nch, float64 **Y, float64 **Z) 435 /* -------------------------------------------------------------------------------------------------------- */ 436 { 437 long i, j; 438 439 for(i=nrl; i<=nrh; i++) { 440 for(j=ncl; j<=nch; j++) { 441 Z[i][j] = X[i][j] + Y[i][j]; 442 } 443 } 444 } 96 97 #undef add_type_matrix 98 #define add_type_matrix(t) \ 99 void short_name(t,add_,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 for (int32_t j = ncl; j <= nch; j++) { \ 103 Z[i][j] = X[i][j] + Y[i][j]; \ 104 } \ 105 } \ 106 } 107 108 add_type_matrix(int8_t); 109 add_type_matrix(uint8_t); 110 add_type_matrix(int16_t); 111 add_type_matrix(uint16_t); 112 add_type_matrix(int32_t); 113 add_type_matrix(uint32_t); 114 add_type_matrix(int64_t); 115 add_type_matrix(uint64_t); 116 add_type_matrix(float); 117 add_type_matrix(double); 118 119 445 120 /* ----------------------------------------------------------------------------------------------- */ 446 IMAGE_EXPORT(void) add_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y, rgb8 **Z)121 void add_rgb8matrix(rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb8 ** Y, rgb8 ** Z) 447 122 /* ----------------------------------------------------------------------------------------------- */ 448 123 { 449 long i, j; 450 rgb8 x, y, z; 451 452 for(i=nrl; i<=nrh; i++) { 453 for(j=ncl; j<=nch; j++) { 454 x = X[i][j]; 455 y = Y[i][j]; 456 //z = x + y; 457 RGB8_ADD(x,y,z); 458 Z[i][j] = z; 459 } 460 } 461 } 124 for (int32_t i = nrl; i <= nrh; i++) { 125 for (int32_t j = ncl; j <= nch; j++) { 126 //z = x + y; 127 RGB8_ADD(X[i][j], Y[i][j], Z[i][j]); 128 } 129 } 130 } 131 462 132 /* --------------------------------------------------------------------------------------------------- */ 463 IMAGE_EXPORT(void) add_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y, rgbx8 **Z)133 void add_rgbx8matrix(rgbx8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx8 ** Y, rgbx8 ** Z) 464 134 /* --------------------------------------------------------------------------------------------------- */ 465 135 { 466 long i, j; 467 rgbx8 x, y, z; 468 469 for(i=nrl; i<=nrh; i++) { 470 for(j=ncl; j<=nch; j++) { 471 x = X[i][j]; 472 y = Y[i][j]; 473 //z = x + y; 474 RGBX8_ADD(x,y,z); 475 Z[i][j] = z; 476 } 477 } 136 for (int32_t i = nrl; i <= nrh; i++) { 137 for (int32_t j = ncl; j <= nch; j++) { 138 //z = x + y; 139 RGBX8_ADD(X[i][j], Y[i][j], Z[i][j]); 140 } 141 } 478 142 } 479 143 … … 482 146 /* -------------------- */ 483 147 484 /* ------------------------------------------------------------------------------------------------ */ 485 IMAGE_EXPORT(void) addc_si8matrix(sint8 **X,long nrl,long nrh, long ncl, long nch, sint8 y, sint8 **Z) 486 /* ------------------------------------------------------------------------------------------------ */ 487 { 488 long i,j; 489 490 for(i=nrl; i<=nrh; i++) { 491 for(j=ncl; j<=nch; j++) { 492 Z[i][j] = X[i][j] + y; 493 } 494 } 495 } 496 /* ------------------------------------------------------------------------------------------------ */ 497 IMAGE_EXPORT(void) addc_ui8matrix(uint8 **X,long nrl,long nrh, long ncl, long nch, uint8 y, uint8 **Z) 498 /* ------------------------------------------------------------------------------------------------ */ 499 { 500 long i,j; 501 502 for(i=nrl; i<=nrh; i++) { 503 for(j=ncl; j<=nch; j++) { 504 Z[i][j] = X[i][j] + y; 505 } 506 } 507 } 508 /* ---------------------------------------------------------------------------------------------------- */ 509 IMAGE_EXPORT(void) addc_si16matrix(sint16 **X,long nrl,long nrh, long ncl, long nch, sint16 y, sint16 **Z) 510 /* ---------------------------------------------------------------------------------------------------- */ 511 { 512 long i,j; 513 514 for(i=nrl; i<=nrh; i++) { 515 for(j=ncl; j<=nch; j++) { 516 Z[i][j] = X[i][j] + y; 517 } 518 } 519 } 520 /* ---------------------------------------------------------------------------------------------------- */ 521 IMAGE_EXPORT(void) addc_ui16matrix(uint16 **X,long nrl,long nrh, long ncl, long nch, uint16 y, uint16 **Z) 522 /* ---------------------------------------------------------------------------------------------------- */ 523 { 524 long i,j; 525 526 for(i=nrl; i<=nrh; i++) { 527 for(j=ncl; j<=nch; j++) { 528 Z[i][j] = X[i][j] + y; 529 } 530 } 531 } 532 /* ---------------------------------------------------------------------------------------------------- */ 533 IMAGE_EXPORT(void) addc_si32matrix(sint32 **X,long nrl,long nrh, long ncl, long nch, sint32 y, sint32 **Z) 534 /* ---------------------------------------------------------------------------------------------------- */ 535 { 536 long i,j; 537 538 for(i=nrl; i<=nrh; i++) { 539 for(j=ncl; j<=nch; j++) { 540 Z[i][j] = X[i][j] + y; 541 } 542 } 543 } 544 /* ---------------------------------------------------------------------------------------------------- */ 545 IMAGE_EXPORT(void) addc_ui32matrix(uint32 **X,long nrl,long nrh, long ncl, long nch, uint32 y, uint32 **Z) 546 /* ---------------------------------------------------------------------------------------------------- */ 547 { 548 long i,j; 549 550 for(i=nrl; i<=nrh; i++) { 551 for(j=ncl; j<=nch; j++) { 552 Z[i][j] = X[i][j] + y; 553 } 554 } 555 } 556 /* ---------------------------------------------------------------------------------------------------- */ 557 IMAGE_EXPORT(void) addc_si64matrix(sint64 **X,long nrl,long nrh, long ncl, long nch, sint64 y, sint64 **Z) 558 /* ---------------------------------------------------------------------------------------------------- */ 559 { 560 long i,j; 561 562 for(i=nrl; i<=nrh; i++) { 563 for(j=ncl; j<=nch; j++) { 564 Z[i][j] = X[i][j] + y; 565 } 566 } 567 } 568 /* ---------------------------------------------------------------------------------------------------- */ 569 IMAGE_EXPORT(void) addc_ui64matrix(uint64 **X,long nrl,long nrh, long ncl, long nch, uint64 y, uint64 **Z) 570 /* ---------------------------------------------------------------------------------------------------- */ 571 { 572 long i,j; 573 574 for(i=nrl; i<=nrh; i++) { 575 for(j=ncl; j<=nch; j++) { 576 Z[i][j] = X[i][j] + y; 577 } 578 } 579 } 580 /* ------------------------------------------------------------------------------------------------------ */ 581 IMAGE_EXPORT(void) addc_f32matrix(float32 **X,long nrl,long nrh, long ncl, long nch, float32 y, float32 **Z) 582 /* ------------------------------------------------------------------------------------------------------ */ 583 { 584 long i,j; 585 586 for(i=nrl; i<=nrh; i++) { 587 for(j=ncl; j<=nch; j++) { 588 Z[i][j] = X[i][j] + y; 589 } 590 } 591 } 592 /* ------------------------------------------------------------------------------------------------------ */ 593 IMAGE_EXPORT(void) addc_f64matrix(float64 **X,long nrl,long nrh, long ncl, long nch, float64 y, float64 **Z) 594 /* ------------------------------------------------------------------------------------------------------ */ 595 { 596 long i,j; 597 598 for(i=nrl; i<=nrh; i++) { 599 for(j=ncl; j<=nch; j++) { 600 Z[i][j] = X[i][j] + y; 601 } 602 } 603 } 604 /* ---------------------------------------------------------------------------------------------- */ 605 IMAGE_EXPORT(void) addc_rgb8matrix(rgb8 **X,long nrl,long nrh, long ncl, long nch, rgb8 y, rgb8 **Z) 606 /* ---------------------------------------------------------------------------------------------- */ 607 { 608 long i,j; 609 rgb8 x, z; 610 611 for(i=nrl; i<=nrh; i++) { 612 for(j=ncl; j<=nch; j++) { 613 x = X[i][j]; 614 RGB8_ADD(x,y,z); 615 Z[i][j] = z; 616 } 617 } 618 } 619 /* -------------------------------------------------------------------------------------------------- */ 620 IMAGE_EXPORT(void) addc_rgbx8matrix(rgbx8 **X,long nrl,long nrh, long ncl, long nch, rgbx8 y, rgbx8 **Z) 621 /* -------------------------------------------------------------------------------------------------- */ 622 { 623 long i,j; 624 rgbx8 x, z; 625 626 for(i=nrl; i<=nrh; i++) { 627 for(j=ncl; j<=nch; j++) { 628 x = X[i][j]; 629 RGBX8_ADD(x,y,z); 630 Z[i][j] = z; 631 } 632 } 633 } 634 /* ------------------ */ 635 /* --- Add Matrix --- */ 636 /* ------------------ */ 637 638 /* -------------------------------------------------------------------------------------------------- */ 639 IMAGE_EXPORT(void) sub_ui8matrix(uint8 **X, long nrl,long nrh, long ncl, long nch, uint8 **Y, uint8 **Z) 640 /* -------------------------------------------------------------------------------------------------- */ 641 { 642 long i, j; 643 644 for(i=nrl; i<=nrh; i++) { 645 for(j=ncl; j<=nch; j++) { 646 Z[i][j] = X[i][j] - Y[i][j]; 647 } 648 } 649 } 650 /* ------------------------------------------------------------------------------------------------------ */ 651 IMAGE_EXPORT(void) sub_si16matrix(sint16 **X, long nrl,long nrh, long ncl, long nch, sint16 **Y, sint16 **Z) 652 /* ------------------------------------------------------------------------------------------------------ */ 653 { 654 long i, j; 655 656 for(i=nrl; i<=nrh; i++) { 657 for(j=ncl; j<=nch; j++) { 658 Z[i][j] = X[i][j] - Y[i][j]; 659 } 660 } 661 } 662 /* ------------------------------------------------------------------------------------------------------ */ 663 IMAGE_EXPORT(void) sub_ui16matrix(uint16 **X, long nrl,long nrh, long ncl, long nch, uint16 **Y, uint16 **Z) 664 /* ------------------------------------------------------------------------------------------------------ */ 665 { 666 long i, j; 667 668 for(i=nrl; i<=nrh; i++) { 669 for(j=ncl; j<=nch; j++) { 670 Z[i][j] = X[i][j] - Y[i][j]; 671 } 672 } 673 } 674 /* ------------------------------------------------------------------------------------------------------ */ 675 IMAGE_EXPORT(void) sub_si32matrix(sint32 **X, long nrl,long nrh, long ncl, long nch, sint32 **Y, sint32 **Z) 676 /* ------------------------------------------------------------------------------------------------------ */ 677 { 678 long i, j; 679 680 for(i=nrl; i<=nrh; i++) { 681 for(j=ncl; j<=nch; j++) { 682 Z[i][j] = X[i][j] - Y[i][j]; 683 } 684 } 685 } 686 /* ------------------------------------------------------------------------------------------------------ */ 687 IMAGE_EXPORT(void) sub_ui32matrix(uint32 **X, long nrl,long nrh, long ncl, long nch, uint32 **Y, uint32 **Z) 688 /* ------------------------------------------------------------------------------------------------------ */ 689 { 690 long i, j; 691 692 for(i=nrl; i<=nrh; i++) { 693 for(j=ncl; j<=nch; j++) { 694 Z[i][j] = X[i][j] - Y[i][j]; 695 } 696 } 697 } 698 /* ------------------------------------------------------------------------------------------------------ */ 699 IMAGE_EXPORT(void) sub_si64matrix(sint64 **X, long nrl,long nrh, long ncl, long nch, sint64 **Y, sint64 **Z) 700 /* ------------------------------------------------------------------------------------------------------ */ 701 { 702 long i, j; 703 704 for(i=nrl; i<=nrh; i++) { 705 for(j=ncl; j<=nch; j++) { 706 Z[i][j] = X[i][j] - Y[i][j]; 707 } 708 } 709 } 710 /* ------------------------------------------------------------------------------------------------------ */ 711 IMAGE_EXPORT(void) sub_ui64matrix(uint64 **X, long nrl,long nrh, long ncl, long nch, uint64 **Y, uint64 **Z) 712 /* ------------------------------------------------------------------------------------------------------ */ 713 { 714 long i, j; 715 716 for(i=nrl; i<=nrh; i++) { 717 for(j=ncl; j<=nch; j++) { 718 Z[i][j] = X[i][j] - Y[i][j]; 719 } 720 } 721 } 722 /* -------------------------------------------------------------------------------------------------------- */ 723 IMAGE_EXPORT(void) sub_f32matrix(float32 **X, long nrl,long nrh, long ncl, long nch, float32 **Y, float32 **Z) 724 /* -------------------------------------------------------------------------------------------------------- */ 725 { 726 long i, j; 727 728 for(i=nrl; i<=nrh; i++) { 729 for(j=ncl; j<=nch; j++) { 730 Z[i][j] = X[i][j] - Y[i][j]; 731 } 732 } 733 } 734 /* -------------------------------------------------------------------------------------------------------- */ 735 IMAGE_EXPORT(void) sub_f64matrix(float64 **X, long nrl,long nrh, long ncl, long nch, float64 **Y, float64 **Z) 736 /* -------------------------------------------------------------------------------------------------------- */ 737 { 738 long i, j; 739 740 for(i=nrl; i<=nrh; i++) { 741 for(j=ncl; j<=nch; j++) { 742 Z[i][j] = X[i][j] - Y[i][j]; 743 } 744 } 745 } 148 #undef addc_type_matrix 149 #define addc_type_matrix(t) \ 150 void short_name(t,addc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) \ 151 { \ 152 for (int32_t i = nrl; i <= nrh; i++) { \ 153 for (int32_t j = ncl; j <= nch; j++) { \ 154 Z[i][j] = X[i][j] + y; \ 155 } \ 156 } \ 157 } 158 159 addc_type_matrix(int8_t); 160 addc_type_matrix(uint8_t); 161 addc_type_matrix(int16_t); 162 addc_type_matrix(uint16_t); 163 addc_type_matrix(int32_t); 164 addc_type_matrix(uint32_t); 165 addc_type_matrix(int64_t); 166 addc_type_matrix(uint64_t); 167 addc_type_matrix(float); 168 addc_type_matrix(double); 169 170 171 172 /* ---------------------------------------------------------------------------------------------- */ 173 void addc_rgb8matrix(rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb8 y, rgb8 ** Z) 174 /* ---------------------------------------------------------------------------------------------- */ 175 { 176 for (int32_t i = nrl; i <= nrh; i++) { 177 for (int32_t j = ncl; j <= nch; j++) { 178 RGB8_ADD(X[i][j], y, Z[i][j]); 179 } 180 } 181 } 182 183 /* -------------------------------------------------------------------------------------------------- */ 184 void addc_rgbx8matrix(rgbx8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 ** Z) 185 /* -------------------------------------------------------------------------------------------------- */ 186 { 187 for (int32_t i = nrl; i <= nrh; i++) { 188 for (int32_t j = ncl; j <= nch; j++) { 189 RGBX8_ADD(X[i][j], y, Z[i][j]); 190 } 191 } 192 } 193 194 195 /* ------------------ */ 196 /* --- Sub Matrix --- */ 197 /* ------------------ */ 198 199 #undef sub_type_matrix 200 #define sub_type_matrix(t) \ 201 void short_name(t,sub_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z) \ 202 { \ 203 for (int32_t i = nrl; i <= nrh; i++) { \ 204 for (int32_t j = ncl; j <= nch; j++) { \ 205 Z[i][j] = X[i][j] - Y[i][j]; \ 206 } \ 207 } \ 208 } 209 210 sub_type_matrix(int8_t); 211 sub_type_matrix(uint8_t); 212 sub_type_matrix(int16_t); 213 sub_type_matrix(uint16_t); 214 sub_type_matrix(int32_t); 215 sub_type_matrix(uint32_t); 216 sub_type_matrix(int64_t); 217 sub_type_matrix(uint64_t); 218 sub_type_matrix(float); 219 sub_type_matrix(double); 220 221 746 222 /* ----------------------------------------------------------------------------------------------- */ 747 IMAGE_EXPORT(void) sub_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y, rgb8 **Z)223 void sub_rgb8matrix(rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb8 ** Y, rgb8 ** Z) 748 224 /* ----------------------------------------------------------------------------------------------- */ 749 225 { 750 long i, j; 751 rgb8 x, y, z; 752 753 for(i=nrl; i<=nrh; i++) { 754 for(j=ncl; j<=nch; j++) { 755 x = X[i][j]; 756 y = Y[i][j]; 757 RGB8_SUB(x,y,z); 758 Z[i][j] = z; 759 } 760 } 761 } 226 for (int32_t i = nrl; i <= nrh; i++) { 227 for (int32_t j = ncl; j <= nch; j++) { 228 //z = x + y; 229 RGB8_SUB(X[i][j], Y[i][j], Z[i][j]); 230 } 231 } 232 } 233 762 234 /* --------------------------------------------------------------------------------------------------- */ 763 IMAGE_EXPORT(void) sub_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y, rgbx8 **Z)235 void sub_rgbx8matrix(rgbx8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx8 ** Y, rgbx8 ** Z) 764 236 /* --------------------------------------------------------------------------------------------------- */ 765 237 { 766 long i, j; 767 rgbx8 x, y, z; 768 769 for(i=nrl; i<=nrh; i++) { 770 for(j=ncl; j<=nch; j++) { 771 x = X[i][j]; 772 y = Y[i][j]; 773 RGBX8_SUB(x,y,z); 774 Z[i][j] = z; 775 } 776 } 777 } 238 for (int32_t i = nrl; i <= nrh; i++) { 239 for (int32_t j = ncl; j <= nch; j++) { 240 //z = x + y; 241 RGBX8_SUB(X[i][j], Y[i][j], Z[i][j]); 242 } 243 } 244 } 245 778 246 779 247 /* -------------------- */ … … 781 249 /* -------------------- */ 782 250 783 /* ------------------------------------------------------------------------------------------------ */ 784 IMAGE_EXPORT(void) subc_si8matrix(sint8 **X,long nrl,long nrh, long ncl, long nch, sint8 y, sint8 **Z) 785 /* ------------------------------------------------------------------------------------------------ */ 786 { 787 long i,j; 788 789 for(i=nrl; i<=nrh; i++) { 790 for(j=ncl; j<=nch; j++) { 791 Z[i][j] = X[i][j] - y; 792 } 793 } 794 } 795 /* ------------------------------------------------------------------------------------------------ */ 796 IMAGE_EXPORT(void) subc_ui8matrix(uint8 **X,long nrl,long nrh, long ncl, long nch, uint8 y, uint8 **Z) 797 /* ------------------------------------------------------------------------------------------------ */ 798 { 799 long i,j; 800 801 for(i=nrl; i<=nrh; i++) { 802 for(j=ncl; j<=nch; j++) { 803 Z[i][j] = X[i][j] - y; 804 } 805 } 806 } 807 /* ---------------------------------------------------------------------------------------------------- */ 808 IMAGE_EXPORT(void) subc_si16matrix(sint16 **X,long nrl,long nrh, long ncl, long nch, sint16 y, sint16 **Z) 809 /* ---------------------------------------------------------------------------------------------------- */ 810 { 811 long i,j; 812 813 for(i=nrl; i<=nrh; i++) { 814 for(j=ncl; j<=nch; j++) { 815 Z[i][j] = X[i][j] - y; 816 } 817 } 818 } 819 /* ---------------------------------------------------------------------------------------------------- */ 820 IMAGE_EXPORT(void) subc_ui16matrix(uint16 **X,long nrl,long nrh, long ncl, long nch, uint16 y, uint16 **Z) 821 /* ---------------------------------------------------------------------------------------------------- */ 822 { 823 long i,j; 824 825 for(i=nrl; i<=nrh; i++) { 826 for(j=ncl; j<=nch; j++) { 827 Z[i][j] = X[i][j] - y; 828 } 829 } 830 } 831 /* ---------------------------------------------------------------------------------------------------- */ 832 IMAGE_EXPORT(void) subc_si32matrix(sint32 **X,long nrl,long nrh, long ncl, long nch, sint32 y, sint32 **Z) 833 /* ---------------------------------------------------------------------------------------------------- */ 834 { 835 long i,j; 836 837 for(i=nrl; i<=nrh; i++) { 838 for(j=ncl; j<=nch; j++) { 839 Z[i][j] = X[i][j] - y; 840 } 841 } 842 } 843 /* ---------------------------------------------------------------------------------------------------- */ 844 IMAGE_EXPORT(void) subc_ui32matrix(uint32 **X,long nrl,long nrh, long ncl, long nch, uint32 y, uint32 **Z) 845 /* ---------------------------------------------------------------------------------------------------- */ 846 { 847 long i,j; 848 849 for(i=nrl; i<=nrh; i++) { 850 for(j=ncl; j<=nch; j++) { 851 Z[i][j] = X[i][j] - y; 852 } 853 } 854 } 855 /* ---------------------------------------------------------------------------------------------------- */ 856 IMAGE_EXPORT(void) subc_si64matrix(sint64 **X,long nrl,long nrh, long ncl, long nch, sint64 y, sint64 **Z) 857 /* ---------------------------------------------------------------------------------------------------- */ 858 { 859 long i,j; 860 861 for(i=nrl; i<=nrh; i++) { 862 for(j=ncl; j<=nch; j++) { 863 Z[i][j] = X[i][j] - y; 864 } 865 } 866 } 867 /* ---------------------------------------------------------------------------------------------------- */ 868 IMAGE_EXPORT(void) subc_ui64matrix(uint64 **X,long nrl,long nrh, long ncl, long nch, uint64 y, uint64 **Z) 869 /* ---------------------------------------------------------------------------------------------------- */ 870 { 871 long i,j; 872 873 for(i=nrl; i<=nrh; i++) { 874 for(j=ncl; j<=nch; j++) { 875 Z[i][j] = X[i][j] - y; 876 } 877 } 878 } 879 /* ------------------------------------------------------------------------------------------------------ */ 880 IMAGE_EXPORT(void) subc_f32matrix(float32 **X,long nrl,long nrh, long ncl, long nch, float32 y, float32 **Z) 881 /* ------------------------------------------------------------------------------------------------------ */ 882 { 883 long i,j; 884 885 for(i=nrl; i<=nrh; i++) { 886 for(j=ncl; j<=nch; j++) { 887 Z[i][j] = X[i][j] - y; 888 } 889 } 890 } 891 /* ------------------------------------------------------------------------------------------------------ */ 892 IMAGE_EXPORT(void) subc_f64matrix(float64 **X,long nrl,long nrh, long ncl, long nch, float64 y, float64 **Z) 893 /* ------------------------------------------------------------------------------------------------------ */ 894 { 895 long i,j; 896 897 for(i=nrl; i<=nrh; i++) { 898 for(j=ncl; j<=nch; j++) { 899 Z[i][j] = X[i][j] - y; 900 } 901 } 902 } 903 /* ---------------------------------------------------------------------------------------------- */ 904 IMAGE_EXPORT(void) subc_rgb8matrix(rgb8 **X,long nrl,long nrh, long ncl, long nch, rgb8 y, rgb8 **Z) 905 /* ---------------------------------------------------------------------------------------------- */ 906 { 907 long i,j; 908 rgb8 x, z; 909 910 for(i=nrl; i<=nrh; i++) { 911 for(j=ncl; j<=nch; j++) { 912 x = X[i][j]; 913 RGB8_SUB(x,y,z); 914 Z[i][j] = z; 915 } 916 } 917 } 918 /* -------------------------------------------------------------------------------------------------- */ 919 IMAGE_EXPORT(void) subc_rgbx8matrix(rgbx8 **X,long nrl,long nrh, long ncl, long nch, rgbx8 y, rgbx8 **Z) 920 /* -------------------------------------------------------------------------------------------------- */ 921 { 922 long i,j; 923 rgbx8 x, z; 924 925 for(i=nrl; i<=nrh; i++) { 926 for(j=ncl; j<=nch; j++) { 927 x = X[i][j]; 928 RGBX8_SUB(x,y,z); 929 Z[i][j] = z; 930 } 931 } 932 } 251 #undef subc_type_matrix 252 #define subc_type_matrix(t) \ 253 void short_name(t,subc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) \ 254 { \ 255 for (int32_t i = nrl; i <= nrh; i++) { \ 256 for (int32_t j = ncl; j <= nch; j++) { \ 257 Z[i][j] = X[i][j] - y; \ 258 } \ 259 } \ 260 } 261 262 subc_type_matrix(int8_t); 263 subc_type_matrix(uint8_t); 264 subc_type_matrix(int16_t); 265 subc_type_matrix(uint16_t); 266 subc_type_matrix(int32_t); 267 subc_type_matrix(uint32_t); 268 subc_type_matrix(int64_t); 269 subc_type_matrix(uint64_t); 270 subc_type_matrix(float); 271 subc_type_matrix(double); 272 273 274 275 /* ---------------------------------------------------------------------------------------------- */ 276 void subc_rgb8matrix(rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb8 y, rgb8 ** Z) 277 /* ---------------------------------------------------------------------------------------------- */ 278 { 279 for (int32_t i = nrl; i <= nrh; i++) { 280 for (int32_t j = ncl; j <= nch; j++) { 281 RGB8_SUB(X[i][j], y, Z[i][j]); 282 } 283 } 284 } 285 286 /* -------------------------------------------------------------------------------------------------- */ 287 void subc_rgbx8matrix(rgbx8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 ** Z) 288 /* -------------------------------------------------------------------------------------------------- */ 289 { 290 for (int32_t i = nrl; i <= nrh; i++) { 291 for (int32_t j = ncl; j <= nch; j++) { 292 RGBX8_SUB(X[i][j], y, Z[i][j]); 293 } 294 } 295 } 296 297 933 298 /* -------------------- */ 934 299 /* --- Mul constant --- */ 935 300 /* -------------------- */ 936 301 937 /* ------------------------------------------------------------------------------------------------ */ 938 IMAGE_EXPORT(void) mulc_si8matrix(sint8 **X,long nrl,long nrh, long ncl, long nch, sint8 y, sint8 **Z) 939 /* ------------------------------------------------------------------------------------------------ */ 940 { 941 long i,j; 942 943 for(i=nrl; i<=nrh; i++) { 944 for(j=ncl; j<=nch; j++) { 945 Z[i][j] = X[i][j] * y; 946 } 947 } 948 } 949 /* ------------------------------------------------------------------------------------------------ */ 950 IMAGE_EXPORT(void) mulc_ui8matrix(uint8 **X,long nrl,long nrh, long ncl, long nch, uint8 y, uint8 **Z) 951 /* ------------------------------------------------------------------------------------------------ */ 952 { 953 long i,j; 954 955 for(i=nrl; i<=nrh; i++) { 956 for(j=ncl; j<=nch; j++) { 957 Z[i][j] = X[i][j] * y; 958 } 959 } 960 } 961 /* ---------------------------------------------------------------------------------------------------- */ 962 IMAGE_EXPORT(void) mulc_si16matrix(sint16 **X,long nrl,long nrh, long ncl, long nch, sint16 y, sint16 **Z) 963 /* ---------------------------------------------------------------------------------------------------- */ 964 { 965 long i,j; 966 967 for(i=nrl; i<=nrh; i++) { 968 for(j=ncl; j<=nch; j++) { 969 Z[i][j] = X[i][j] * y; 970 } 971 } 972 } 973 /* ---------------------------------------------------------------------------------------------------- */ 974 IMAGE_EXPORT(void) mulc_ui16matrix(uint16 **X,long nrl,long nrh, long ncl, long nch, uint16 y, uint16 **Z) 975 /* ---------------------------------------------------------------------------------------------------- */ 976 { 977 long i,j; 978 979 for(i=nrl; i<=nrh; i++) { 980 for(j=ncl; j<=nch; j++) { 981 Z[i][j] = X[i][j] * y; 982 } 983 } 984 } 985 /* ---------------------------------------------------------------------------------------------------- */ 986 IMAGE_EXPORT(void) mulc_si32matrix(sint32 **X,long nrl,long nrh, long ncl, long nch, sint32 y, sint32 **Z) 987 /* ---------------------------------------------------------------------------------------------------- */ 988 { 989 long i,j; 990 991 for(i=nrl; i<=nrh; i++) { 992 for(j=ncl; j<=nch; j++) { 993 Z[i][j] = X[i][j] * y; 994 } 995 } 996 } 997 /* ---------------------------------------------------------------------------------------------------- */ 998 IMAGE_EXPORT(void) mulc_ui32matrix(uint32 **X,long nrl,long nrh, long ncl, long nch, uint32 y, uint32 **Z) 999 /* ---------------------------------------------------------------------------------------------------- */ 1000 { 1001 long i,j; 1002 1003 for(i=nrl; i<=nrh; i++) { 1004 for(j=ncl; j<=nch; j++) { 1005 Z[i][j] = X[i][j] * y; 1006 } 1007 } 1008 } 1009 /* ---------------------------------------------------------------------------------------------------- */ 1010 IMAGE_EXPORT(void) mulc_si64matrix(sint64 **X,long nrl,long nrh, long ncl, long nch, sint64 y, sint64 **Z) 1011 /* ---------------------------------------------------------------------------------------------------- */ 1012 { 1013 long i,j; 1014 1015 for(i=nrl; i<=nrh; i++) { 1016 for(j=ncl; j<=nch; j++) { 1017 Z[i][j] = X[i][j] * y; 1018 } 1019 } 1020 } 1021 /* ---------------------------------------------------------------------------------------------------- */ 1022 IMAGE_EXPORT(void) mulc_ui64matrix(uint64 **X,long nrl,long nrh, long ncl, long nch, uint64 y, uint64 **Z) 1023 /* ---------------------------------------------------------------------------------------------------- */ 1024 { 1025 long i,j; 1026 1027 for(i=nrl; i<=nrh; i++) { 1028 for(j=ncl; j<=nch; j++) { 1029 Z[i][j] = X[i][j] * y; 1030 } 1031 } 1032 } 1033 /* ------------------------------------------------------------------------------------------------------ */ 1034 IMAGE_EXPORT(void) mulc_f32matrix(float32 **X,long nrl,long nrh, long ncl, long nch, float32 y, float32 **Z) 1035 /* ------------------------------------------------------------------------------------------------------ */ 1036 { 1037 long i,j; 1038 1039 for(i=nrl; i<=nrh; i++) { 1040 for(j=ncl; j<=nch; j++) { 1041 Z[i][j] = X[i][j] * y; 1042 } 1043 } 1044 } 1045 /* ------------------------------------------------------------------------------------------------------ */ 1046 IMAGE_EXPORT(void) mulc_f64matrix(float64 **X,long nrl,long nrh, long ncl, long nch, float64 y, float64 **Z) 1047 /* ------------------------------------------------------------------------------------------------------ */ 1048 { 1049 long i,j; 1050 1051 for(i=nrl; i<=nrh; i++) { 1052 for(j=ncl; j<=nch; j++) { 1053 Z[i][j] = X[i][j] * y; 1054 } 1055 } 1056 } 1057 /* ---------------------------------------------------------------------------------------------- */ 1058 IMAGE_EXPORT(void) mulc_rgb8matrix(rgb8 **X,long nrl,long nrh, long ncl, long nch, rgb8 y, rgb8 **Z) 1059 /* ---------------------------------------------------------------------------------------------- */ 1060 { 1061 long i,j; 1062 rgb8 x, z; 1063 1064 for(i=nrl; i<=nrh; i++) { 1065 for(j=ncl; j<=nch; j++) { 1066 x = X[i][j]; 1067 RGB8_MUL(x,y,z); 1068 Z[i][j] = z; 1069 } 1070 } 1071 } 1072 /* -------------------------------------------------------------------------------------------------- */ 1073 IMAGE_EXPORT(void) mulc_rgbx8matrix(rgbx8 **X,long nrl,long nrh, long ncl, long nch, rgbx8 y, rgbx8 **Z) 1074 /* -------------------------------------------------------------------------------------------------- */ 1075 { 1076 long i,j; 1077 rgbx8 x, z; 1078 1079 for(i=nrl; i<=nrh; i++) { 1080 for(j=ncl; j<=nch; j++) { 1081 x = X[i][j]; 1082 RGBX8_MUL(x,y,z); 1083 Z[i][j] = z; 1084 } 1085 } 1086 } 302 #undef mulc_type_matrix 303 #define mulc_type_matrix(t) \ 304 void short_name(t,mulc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) \ 305 { \ 306 for (int32_t i = nrl; i <= nrh; i++) { \ 307 for (int32_t j = ncl; j <= nch; j++) { \ 308 Z[i][j] = X[i][j] * y; \ 309 } \ 310 } \ 311 } 312 313 mulc_type_matrix(int8_t); 314 mulc_type_matrix(uint8_t); 315 mulc_type_matrix(int16_t); 316 mulc_type_matrix(uint16_t); 317 mulc_type_matrix(int32_t); 318 mulc_type_matrix(uint32_t); 319 mulc_type_matrix(int64_t); 320 mulc_type_matrix(uint64_t); 321 mulc_type_matrix(float); 322 mulc_type_matrix(double); 323 324 325 326 /* ---------------------------------------------------------------------------------------------- */ 327 void mulc_rgb8matrix(rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb8 y, rgb8 ** Z) 328 /* ---------------------------------------------------------------------------------------------- */ 329 { 330 for (int32_t i = nrl; i <= nrh; i++) { 331 for (int32_t j = ncl; j <= nch; j++) { 332 RGB8_MUL(X[i][j], y, Z[i][j]); 333 } 334 } 335 } 336 337 /* -------------------------------------------------------------------------------------------------- */ 338 void mulc_rgbx8matrix(rgbx8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 ** Z) 339 /* -------------------------------------------------------------------------------------------------- */ 340 { 341 for (int32_t i = nrl; i <= nrh; i++) { 342 for (int32_t j = ncl; j <= nch; j++) { 343 RGBX8_MUL(X[i][j], y, Z[i][j]); 344 } 345 } 346 } 347 348 1087 349 /* --------------- */ 1088 350 /* --- MulFrac --- */ 1089 351 /* --------------- */ 1090 352 1091 // Y=(a*X)/b 1092 1093 /* -------------------------------------------------------------------------------------------------------------- */ 1094 IMAGE_EXPORT(void) mulfrac_si8matrix(sint8 **X, long nrl, long nrh, long ncl, long nch, int32 a, int32 b, sint8 **Y) 1095 /* -------------------------------------------------------------------------------------------------------------- */ 1096 { 1097 int i, j; 1098 int32 x, y; 1099 1100 for(i=nrl; i<=nrh; i++) { 1101 for(j=ncl; j<=nch; j++) { 1102 x = X[i][j]; 1103 y = (a * x) / b; 1104 Y[i][j] = (sint8) y; 1105 } 1106 } 1107 } 1108 /* -------------------------------------------------------------------------------------------------------------- */ 1109 IMAGE_EXPORT(void) mulfrac_ui8matrix(uint8 **X, long nrl, long nrh, long ncl, long nch, int32 a, int32 b, uint8 **Y) 1110 /* -------------------------------------------------------------------------------------------------------------- */ 1111 { 1112 int i, j; 1113 int32 x, y; 1114 1115 for(i=nrl; i<=nrh; i++) { 1116 for(j=ncl; j<=nch; j++) { 1117 x = X[i][j]; 1118 y = (a * x) / b; 1119 Y[i][j] = (uint8) y; 1120 } 1121 } 1122 } 353 // Y = (a * X) / b 354 355 #undef mulfrac_type_matrix 356 #define mulfrac_type_matrix(t) \ 357 void short_name(t,mulfrac_,matrix)(t ** X, int32_t nrl, int32_t nrh, \ 358 int32_t ncl, int32_t nch, int32_t a, int32_t b, t ** Y) \ 359 { \ 360 for (int32_t i = nrl; i <= nrh; i++) { \ 361 for (int32_t j = ncl; j <= nch; j++) { \ 362 Y[i][j] = (t) ((a * X[i][j]) / b); \ 363 } \ 364 } \ 365 } 366 367 mulfrac_type_matrix(int8_t); 368 mulfrac_type_matrix(uint8_t); 369 mulfrac_type_matrix(int16_t); 370 mulfrac_type_matrix(uint16_t); 371 mulfrac_type_matrix(int32_t); 372 mulfrac_type_matrix(uint32_t); 373 mulfrac_type_matrix(int64_t); 374 mulfrac_type_matrix(uint64_t); 375 mulfrac_type_matrix(float); 376 mulfrac_type_matrix(double); 377 378 379 /* ------------------------------------------------------------------------------------------------------------ */ 380 void mulfrac_rgb8matrix(rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb32 a, rgb32 b, rgb8 ** Y) 381 /* ------------------------------------------------------------------------------------------------------------ */ 382 { 383 rgb32 y32; 384 rgb8 x8, y8; 385 for (int32_t i = nrl; i <= nrh; i++) { 386 for (int32_t j = ncl; j <= nch; j++) { 387 x8 = X[i][j]; 388 RGB8_MULFRAC(x8, a, b, y32); 389 RGB32CAST8(y32, y8); 390 Y[i][j] = y8; 391 } 392 } 393 } 394 1123 395 /* ----------------------------------------------------------------------------------------------------------------- */ 1124 IMAGE_EXPORT(void) mulfrac_si16matrix(sint16 **X, long nrl, long nrh, long ncl, long nch, int32 a, int32 b, sint16 **Y)396 void mulfrac_rgb8xmatrix(rgbx8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx32 a, rgbx32 b, rgbx8 ** Y) 1125 397 /* ----------------------------------------------------------------------------------------------------------------- */ 1126 398 { 1127 int i, j; 1128 int32 x, y; 1129 1130 for(i=nrl; i<=nrh; i++) { 1131 for(j=ncl; j<=nch; j++) { 1132 x = X[i][j]; 1133 y = (a * x) / b; 1134 Y[i][j] = (sint16) y; 1135 } 1136 } 1137 } 1138 /* ----------------------------------------------------------------------------------------------------------------- */ 1139 IMAGE_EXPORT(void) mulfrac_ui16matrix(uint16 **X, long nrl, long nrh, long ncl, long nch, int32 a, int32 b, uint16 **Y) 1140 /* ----------------------------------------------------------------------------------------------------------------- */ 1141 { 1142 int i, j; 1143 int32 x, y; 1144 1145 for(i=nrl; i<=nrh; i++) { 1146 for(j=ncl; j<=nch; j++) { 1147 x = X[i][j]; 1148 y = (a * x) / b; 1149 Y[i][j] = (uint16) y; 1150 } 1151 } 1152 } 1153 /* ------------------------------------------------------------------------------------------------------------------ */ 1154 IMAGE_EXPORT(void) mulfrac_si32matrix(sint32 **X, long nrl, long nrh, long ncl, long nch, int32 a, int32 b, sint32 **Y) 1155 /* ------------------------------------------------------------------------------------------------------------------ */ 1156 { 1157 int i, j; 1158 int32 x, y; 1159 1160 for(i=nrl; i<=nrh; i++) { 1161 for(j=ncl; j<=nch; j++) { 1162 x = X[i][j]; 1163 y = (a * x) / b; 1164 Y[i][j] = (sint16) y; 1165 } 1166 } 1167 } 1168 /* ------------------------------------------------------------------------------------------------------------------ */ 1169 IMAGE_EXPORT(void) mulfrac_ui32matrix(uint32 **X, long nrl, long nrh, long ncl, long nch, int32 a, int32 b, uint32 **Y) 1170 /* ------------------------------------------------------------------------------------------------------------------ */ 1171 { 1172 int i, j; 1173 int32 x, y; 1174 1175 for(i=nrl; i<=nrh; i++) { 1176 for(j=ncl; j<=nch; j++) { 1177 x = X[i][j]; 1178 y = (a * x) / b; 1179 Y[i][j] = (uint16) y; 1180 } 1181 } 1182 } 1183 /* ----------------------------------------------------------------------------------------------------------------- */ 1184 IMAGE_EXPORT(void) mulfrac_si64matrix(sint64 **X, long nrl, long nrh, long ncl, long nch, int32 a, int32 b, sint64 **Y) 1185 /* ----------------------------------------------------------------------------------------------------------------- */ 1186 { 1187 int i, j; 1188 sint64 x, y; 1189 1190 for(i=nrl; i<=nrh; i++) { 1191 for(j=ncl; j<=nch; j++) { 1192 x = X[i][j]; 1193 y = (a * x) / b; 1194 Y[i][j] = (sint64) y; 1195 } 1196 } 1197 } 1198 /* ----------------------------------------------------------------------------------------------------------------- */ 1199 IMAGE_EXPORT(void) mulfrac_ui64matrix(uint64 **X, long nrl, long nrh, long ncl, long nch, int32 a, int32 b, uint64 **Y) 1200 /* ----------------------------------------------------------------------------------------------------------------- */ 1201 { 1202 int i, j; 1203 uint64 x, y; 1204 1205 for(i=nrl; i<=nrh; i++) { 1206 for(j=ncl; j<=nch; j++) { 1207 x = X[i][j]; 1208 y = (a * x) / b; 1209 Y[i][j] = (uint64) y; 1210 } 1211 } 1212 } 1213 /* ------------------------------------------------------------------------------------------------------------ */ 1214 IMAGE_EXPORT(void) mulfrac_rgb8matrix(rgb8 **X, long nrl,long nrh, long ncl, long nch, rgb32 a, rgb32 b, rgb8 **Y) 1215 /* ------------------------------------------------------------------------------------------------------------ */ 1216 { 1217 int i, j; 1218 rgb32 y32; 1219 rgb8 x8, y8; 1220 1221 1222 for(i=nrl; i<=nrh; i++) { 1223 for(j=ncl; j<=nch; j++) { 1224 x8 = X[i][j]; 1225 RGB8_MULFRAC(x8,a,b,y32); 1226 RGB32CAST8(y32,y8); 1227 Y[i][j] = y8; 1228 } 1229 } 1230 } 1231 /* ----------------------------------------------------------------------------------------------------------------- */ 1232 IMAGE_EXPORT(void) mulfrac_rgb8xmatrix(rgbx8 **X, long nrl,long nrh, long ncl, long nch, rgbx32 a, rgbx32 b, rgbx8 **Y) 1233 /* ----------------------------------------------------------------------------------------------------------------- */ 1234 { 1235 int i, j; 1236 rgbx32 y32; 1237 rgbx8 x8, y8; 1238 1239 for(i=nrl; i<=nrh; i++) { 1240 for(j=ncl; j<=nch; j++) { 1241 x8 = X[i][j]; 1242 RGBX8_MULFRAC(x8,a,b,y32); 1243 RGBX32CAST8(y32,y8); 1244 Y[i][j] = y8; 1245 } 1246 } 1247 } 399 rgbx32 y32; 400 rgbx8 x8, y8; 401 for (int32_t i = nrl; i <= nrh; i++) { 402 for (int32_t j = ncl; j <= nch; j++) { 403 x8 = X[i][j]; 404 RGBX8_MULFRAC(x8, a, b, y32); 405 RGBX32CAST8(y32, y8); 406 Y[i][j] = y8; 407 } 408 } 409 } 410 1248 411 1249 412 /* ---------------- */ … … 1251 414 /* ---------------- */ 1252 415 1253 // m3 = (a*m1)>>s 1254 1255 /* -------------------------------------------------------------------------------------------------------------- */ 1256 IMAGE_EXPORT(void) mulshift_si8matrix(sint8 **X, long nrl, long nrh,long ncl, long nch, int32 a, int32 s, sint8 **Y) 1257 /* -------------------------------------------------------------------------------------------------------------- */ 1258 { 1259 int i, j; 1260 int32 x, y; 1261 1262 for(i=nrl; i<=nrh; i++) { 1263 for(j=ncl; j<=nch; j++) { 1264 x = X[i][j]; 1265 y = (a * x) >> s; 1266 Y[i][j] = (sint8) y; 1267 } 1268 } 1269 } 1270 /* --------------------------------------------------------------------------------------------------------------- */ 1271 IMAGE_EXPORT(void) mulshift_ui8matrix(uint8 **X, long nrl,long nrh,long ncl, long nch, int32 a, int32 s, uint8 **Y) 1272 /* --------------------------------------------------------------------------------------------------------------- */ 1273 { 1274 int i, j; 1275 int32 x, y; 1276 1277 for(i=nrl; i<=nrh; i++) { 1278 for(j=ncl; j<=nch; j++) { 1279 x = X[i][j]; 1280 y = (a * x) >> s; 1281 Y[i][j] = (uint8) y; 1282 } 1283 } 1284 } 416 // m3 = (a * m1) >> s 417 418 #undef mulshift_type_matrix 419 #define mulshift_type_matrix(t) \ 420 void short_name(t,mulshift_,matrix)(t ** X, int32_t nrl, int32_t nrh, \ 421 int32_t ncl, int32_t nch, int32_t a, int32_t s, t ** Y) \ 422 { \ 423 for (int32_t i = nrl; i <= nrh; i++) { \ 424 for (int32_t j = ncl; j <= nch; j++) { \ 425 Y[i][j] = (t) ((a * X[i][j]) >> s); \ 426 } \ 427 } \ 428 } 429 430 mulshift_type_matrix(int8_t); 431 mulshift_type_matrix(uint8_t); 432 mulshift_type_matrix(int16_t); 433 mulshift_type_matrix(uint16_t); 434 mulshift_type_matrix(int32_t); 435 mulshift_type_matrix(uint32_t); 436 mulshift_type_matrix(int64_t); 437 mulshift_type_matrix(uint64_t); 438 439 440 /* ---------------------------------------------------------------------------------------------------------------- */ 441 void mulshift_rgb8matrix(rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb32 a, rgb32 s, rgb8 ** Y) 442 /* ---------------------------------------------------------------------------------------------------------------- */ 443 { 444 rgb32 y32; 445 rgb8 x8, y8; 446 for (int32_t i = nrl; i <= nrh; i++) { 447 for (int32_t j = ncl; j <= nch; j++) { 448 x8 = X[i][j]; 449 RGB8_MULSHIFT(x8, a, s, y32); 450 RGB32CAST8(y32, y8); 451 Y[i][j] = y8; 452 } 453 } 454 } 455 1285 456 /* ----------------------------------------------------------------------------------------------------------------- */ 1286 IMAGE_EXPORT(void) mulshift_si16matrix(sint16 **X, long nrl, long nrh,long ncl, long nch, int32 a, int32 s, sint16 **Y)457 void mulshift_rgbx8matrix(rgbx8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx32 a, rgbx32 s, rgbx8 ** Y) 1287 458 /* ----------------------------------------------------------------------------------------------------------------- */ 1288 459 { 1289 int i, j; 1290 int32 x, y; 1291 1292 for(i=nrl; i<=nrh; i++) { 1293 for(j=ncl; j<=nch; j++) { 1294 x = X[i][j]; 1295 y = (a * x) >> s; 1296 Y[i][j] = (sint16) y; 1297 } 1298 } 1299 } 1300 /* ------------------------------------------------------------------------------------------------------------------ */ 1301 IMAGE_EXPORT(void) mulshift_ui16matrix(uint16 **X, long nrl,long nrh,long ncl, long nch, int32 a, int32 s, uint16 **Y) 1302 /* ------------------------------------------------------------------------------------------------------------------ */ 1303 { 1304 int i, j; 1305 int32 x, y; 1306 1307 for(i=nrl; i<=nrh; i++) { 1308 for(j=ncl; j<=nch; j++) { 1309 x = X[i][j]; 1310 y = (a * x) >> s; 1311 Y[i][j] = (uint16) y; 1312 } 1313 } 1314 } 1315 /* ----------------------------------------------------------------------------------------------------------------- */ 1316 IMAGE_EXPORT(void) mulshift_si32matrix(sint32 **X, long nrl, long nrh,long ncl, long nch, int32 a, int32 s, sint32 **Y) 1317 /* ----------------------------------------------------------------------------------------------------------------- */ 1318 { 1319 int i, j; 1320 int32 x, y; 1321 1322 for(i=nrl; i<=nrh; i++) { 1323 for(j=ncl; j<=nch; j++) { 1324 x = X[i][j]; 1325 y = (a * x) >> s; 1326 Y[i][j] = (sint32) y; 1327 } 1328 } 1329 } 1330 /* ------------------------------------------------------------------------------------------------------------------ */ 1331 IMAGE_EXPORT(void) mulshift_ui32matrix(uint32 **X, long nrl,long nrh,long ncl, long nch, int32 a, int32 s, uint32 **Y) 1332 /* ------------------------------------------------------------------------------------------------------------------ */ 1333 { 1334 int i, j; 1335 int32 x, y; 1336 1337 for(i=nrl; i<=nrh; i++) { 1338 for(j=ncl; j<=nch; j++) { 1339 x = X[i][j]; 1340 y = (a * x) >> s; 1341 Y[i][j] = (uint32) y; 1342 } 1343 } 1344 } 1345 /* ---------------------------------------------------------------------------------------------------------------- */ 1346 IMAGE_EXPORT(void) mulshift_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb32 a, rgb32 s, rgb8 **Y) 1347 /* ---------------------------------------------------------------------------------------------------------------- */ 1348 { 1349 int i, j; 1350 rgb32 y32; 1351 rgb8 x8, y8; 1352 1353 for(i=nrl; i<=nrh; i++) { 1354 for(j=ncl; j<=nch; j++) { 1355 x8 = X[i][j]; 1356 RGB8_MULSHIFT(x8,a,s,y32); 1357 RGB32CAST8(y32,y8); 1358 Y[i][j] = y8; 1359 } 1360 } 1361 } 1362 /* ----------------------------------------------------------------------------------------------------------------- */ 1363 IMAGE_EXPORT(void) mulshift_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx32 a, rgbx32 s, rgbx8 **Y) 1364 /* ----------------------------------------------------------------------------------------------------------------- */ 1365 { 1366 int i, j; 1367 rgbx32 y32; 1368 rgbx8 x8, y8; 1369 1370 for(i=nrl; i<=nrh; i++) { 1371 for(j=ncl; j<=nch; j++) { 1372 x8 = X[i][j]; 1373 RGBX8_MULSHIFT(x8,a,s,y32); 1374 RGBX32CAST8(y32,y8); 1375 Y[i][j] = y8; 1376 } 1377 } 1378 } 460 rgbx32 y32; 461 rgbx8 x8, y8; 462 for (int32_t i = nrl; i <= nrh; i++) { 463 for (int32_t j = ncl; j <= nch; j++) { 464 x8 = X[i][j]; 465 RGBX8_MULSHIFT(x8, a, s, y32); 466 RGBX32CAST8(y32, y8); 467 Y[i][j] = y8; 468 } 469 } 470 } 471 472 // Local Variables: 473 // tab-width: 4 474 // c-basic-offset: 4 475 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 476 // indent-tabs-mode: nil 477 // End: 478 479 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 480 -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrarith2x.c
r772 r821 17 17 #include <malloc.h> 18 18 #include <math.h> // fabs 19 // #include <memory.h> // memcpy20 19 20 #include "nrc_os_config.h" 21 21 #include "mypredef.h" 22 22 #include "nrtype.h" … … 25 25 #include "nrkernel.h" 26 26 27 /* ------------------------------------------------------------------------------------- */ 28 IMAGE_EXPORT(void) addcnz_bmatrix(byte **src,long nrl,long nrh,long ncl, long nch, byte cte, byte **dst) 29 /* ------------------------------------------------------------------------------------- */ 30 { 31 long i,j; 32 byte *Xi, *Yi; 33 34 for(i=nrl; i<=nrh; i++) { 35 Xi = src[i]; 36 Yi = dst[i]; 37 for(j=ncl; j<=nch; j++) { 38 if(Xi[j]) 39 Yi[j] = Xi[j] + cte; 40 else 41 Yi[j] = Xi[j]; 42 } 43 } 27 28 #undef addcnz_type_matrix 29 #define addcnz_type_matrix(t) \ 30 void short_name(t,addcnz_,matrix)(t ** src, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t cte, t ** dst) \ 31 { \ 32 t * Xi; \ 33 t * Yi; \ 34 for (int32_t i = nrl; i <= nrh; i++) { \ 35 Xi = src[i]; \ 36 Yi = dst[i]; \ 37 for (int32_t j = ncl; j <= nch; j++) { \ 38 if (Xi[j] != 0) { \ 39 Yi[j] = Xi[j] + cte; \ 40 } \ 41 else { \ 42 Yi[j] = Xi[j]; \ 43 } \ 44 } \ 45 } \ 44 46 } 45 /* ----------------------------------------------------------------------------------- */ 46 IMAGE_EXPORT(void) addandc_bmatrix(byte **src,long nrl,long nrh,long ncl, long nch, byte cte, byte **dst) 47 /* ----------------------------------------------------------------------------------- */ 48 { 49 long i,j; 50 byte *Xi, *Yi; 51 52 for(i=nrl; i<=nrh; i++) { 53 Xi = src[i]; 54 Yi = dst[i]; 55 for(j=ncl; j<=nch; j++) { 56 if(Xi[j]) 57 Yi[j] = Xi[j] + cte; 58 else 59 Yi[j] = Xi[i]; 60 } 61 } 47 48 addcnz_type_matrix(int8_t); 49 addcnz_type_matrix(uint8_t); 50 addcnz_type_matrix(int16_t); 51 addcnz_type_matrix(uint16_t); 52 addcnz_type_matrix(int32_t); 53 addcnz_type_matrix(uint32_t); 54 addcnz_type_matrix(int64_t); 55 addcnz_type_matrix(uint64_t); 56 addcnz_type_matrix(float); 57 addcnz_type_matrix(double); 58 59 60 #undef addandc_type_matrix 61 #define addandc_type_matrix(t) \ 62 void short_name(t,addandc_,matrix)(t ** src, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t cte, t ** dst) \ 63 { \ 64 t * Xi; \ 65 t * Yi; \ 66 for (int32_t i = nrl; i <= nrh; i++) { \ 67 Xi = src[i]; \ 68 Yi = dst[i]; \ 69 for (int32_t j = ncl; j <= nch; j++) { \ 70 if (Xi[j] != 0) { \ 71 Yi[j] = Xi[j] + cte; \ 72 } \ 73 } \ 74 } \ 62 75 } 63 /* ---------------------------------------------------------------------------------------- */ 64 IMAGE_EXPORT(void) addandc_si16matrix(sint16 **src,long nrl,long nrh,long ncl, long nch, short cte, sint16 **dst) 65 /* ---------------------------------------------------------------------------------------- */ 66 { 67 long i,j; 68 sint16 *Xi, *Yi; 69 70 for(i=nrl; i<=nrh; i++) { 71 Xi = src[i]; 72 Yi = dst[i]; 73 for(j=ncl; j<=nch; j++) { 74 if(Xi[j]) Yi[j] = Xi[j] + cte; 75 } 76 } 76 77 addandc_type_matrix(int8_t); 78 addandc_type_matrix(uint8_t); 79 addandc_type_matrix(int16_t); 80 addandc_type_matrix(uint16_t); 81 addandc_type_matrix(int32_t); 82 addandc_type_matrix(uint32_t); 83 addandc_type_matrix(int64_t); 84 addandc_type_matrix(uint64_t); 85 addandc_type_matrix(float); 86 addandc_type_matrix(double); 87 88 89 #undef sum_type_matrix 90 #define sum_type_matrix(t,rt) \ 91 rt short_name(t,sum_,matrix)(t ** m, int32_t nrl, int32_t nrh,int32_t ncl, int32_t nch) \ 92 { \ 93 rt s = 0; \ 94 t * Xi; \ 95 for (int32_t i = nrl; i <= nrh; i++) { \ 96 Xi = m[i]; \ 97 for (int32_t j = ncl; j <= nch; j++) { \ 98 s += Xi[j]; \ 99 } \ 100 } \ 101 return s; \ 77 102 } 78 /* ------------------------------------------------------------------------------------------- */ 79 IMAGE_EXPORT(void) addandc_ui16matrix(uint16 **src,long nrl,long nrh,long ncl, long nch, short cte, uint16 **dst) 80 /* ------------------------------------------------------------------------------------------ */ 81 { 82 long i,j; 83 uint16 *Xi, *Yi; 84 85 for(i=nrl; i<=nrh; i++) { 86 Xi = src[i]; 87 Yi = dst[i]; 88 for(j=ncl; j<=nch; j++) { 89 if(Xi[j]) Yi[j] = Xi[j] + cte; 90 } 91 } 92 } 93 /* ----------------------------------------------------------- */ 94 IMAGE_EXPORT(int) count_bmatrix(byte **m, long nrl,long nrh,long ncl, long nch) 95 /* ----------------------------------------------------------- */ 96 { 97 long i, j; 98 int s = 0; 99 byte *Xi; 100 101 for(i=nrl; i<=nrh; i++) { 102 Xi = m[i]; 103 for(j=ncl; j<=nch; j++) { 104 s += Xi[j]; 105 } 106 } 107 return s; 108 } 103 104 105 sum_type_matrix(int8_t, int32_t); 106 sum_type_matrix(uint8_t, uint32_t); 107 sum_type_matrix(int16_t, int32_t); 108 sum_type_matrix(uint16_t, uint32_t); 109 sum_type_matrix(int32_t, int64_t); 110 sum_type_matrix(uint32_t, uint64_t); 111 sum_type_matrix(int64_t, int64_t); 112 sum_type_matrix(uint64_t, uint64_t); 113 sum_type_matrix(float, float); 114 sum_type_matrix(double, double); 115 116 117 // Local Variables: 118 // tab-width: 4 119 // c-basic-offset: 4 120 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 121 // indent-tabs-mode: nil 122 // End: 123 124 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 125 -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrio2.c
r805 r821 1001 1001 char buffer[80]; 1002 1002 int i; 1003 (void) gris; 1003 1004 1004 1005 // open file 1005 1006 fd = open(filename, O_RDONLY); 1006 1007 if (fd < 0) { 1007 printf("*** Error: Can't open file %s in %s.\n", filename, __func__); 1008 printf("\n*** Error: Can't open file %s in %s.\n", filename, __func__); 1009 exit(1); 1008 1010 } 1009 1011 … … 1046 1048 int i; 1047 1049 1050 //fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT); 1048 1051 fd = open(filename, O_TRUNC | O_CREAT); 1049 1052 if (fd < 0) { 1050 printf("*** Error: Impossible to open file %s in %s\n", filename, __func__); 1053 printf("\n*** Error: Impossible to open file %s in %s\n", filename, __func__); 1054 return; 1051 1055 } 1052 1056 -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrlut.c
r772 r821 304 304 rgb8 *Si; 305 305 int r, b, g; 306 (void) Si; 306 307 307 308 //FUNCTION_NAME("Histogram_rgbmatrix"); -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrmem1x.c
r772 r821 11 11 #include <stdio.h> 12 12 #include <stddef.h> 13 #include <string.h> 13 14 14 15 #include "mypredef.h" -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrwrap2.c
r772 r821 21 21 #include <math.h> // fabs 22 22 23 #include "nrc_os_config.h" 23 24 #include "mypredef.h" 24 25 #include "nrtype.h"
Note: See TracChangeset
for help on using the changeset viewer.