1 | /* ---------------- */ |
---|
2 | /* --- nrmem2.c --- */ |
---|
3 | /* ---------------- */ |
---|
4 | |
---|
5 | /* |
---|
6 | * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved |
---|
7 | * Univ Paris Sud XI, CNRS |
---|
8 | * |
---|
9 | * Distributed under the Boost Software License, Version 1.0 |
---|
10 | * see accompanying file LICENSE.txt or copy it at |
---|
11 | * http://www.boost.org/LICENSE_1_0.txt |
---|
12 | */ |
---|
13 | |
---|
14 | #include <stdio.h> |
---|
15 | #include <stddef.h> |
---|
16 | #include <stdlib.h> |
---|
17 | #include <math.h> // fabs |
---|
18 | |
---|
19 | #include "mypredef.h" |
---|
20 | #include "nrtype.h" |
---|
21 | #include "nrdef.h" |
---|
22 | #include "nrmacro.h" |
---|
23 | #include "nrkernel.h" |
---|
24 | |
---|
25 | #include "nrmem1.h" |
---|
26 | #include "nrmem2.h" |
---|
27 | |
---|
28 | /* |
---|
29 | * ------------------ |
---|
30 | * --- dup_matrix --- |
---|
31 | * ------------------ |
---|
32 | */ |
---|
33 | |
---|
34 | |
---|
35 | #undef dup_type_matrix |
---|
36 | #define dup_type_matrix(t) \ |
---|
37 | void short_name(t,dup_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y) \ |
---|
38 | { \ |
---|
39 | for (int32_t i = nrl; i <= nrh; i++) { \ |
---|
40 | short_name(t,dup_,vector)(X[i], ncl, nch, Y[i]); \ |
---|
41 | } \ |
---|
42 | } |
---|
43 | |
---|
44 | dup_type_matrix(int8_t); |
---|
45 | dup_type_matrix(uint8_t); |
---|
46 | dup_type_matrix(int16_t); |
---|
47 | dup_type_matrix(uint16_t); |
---|
48 | dup_type_matrix(int32_t); |
---|
49 | dup_type_matrix(uint32_t); |
---|
50 | dup_type_matrix(int64_t); |
---|
51 | dup_type_matrix(uint64_t); |
---|
52 | dup_type_matrix(float); |
---|
53 | dup_type_matrix(double); |
---|
54 | dup_type_matrix(rgb8); |
---|
55 | dup_type_matrix(rgbx8); |
---|
56 | |
---|
57 | |
---|
58 | /* |
---|
59 | * -------------- |
---|
60 | * --- resize --- |
---|
61 | * -------------- |
---|
62 | */ |
---|
63 | |
---|
64 | #undef resize_type_matrix |
---|
65 | #define resize_type_matrix(t) \ |
---|
66 | void short_name(t,resize_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ |
---|
67 | { \ |
---|
68 | int32_t ncol = nch - ncl + 1; \ |
---|
69 | for (int32_t i = nrl + 1; i <= nrh; i++) { \ |
---|
70 | m[i] = m[i - 1] + ncol; \ |
---|
71 | } \ |
---|
72 | } |
---|
73 | |
---|
74 | resize_type_matrix(int8_t); |
---|
75 | resize_type_matrix(uint8_t); |
---|
76 | resize_type_matrix(int16_t); |
---|
77 | resize_type_matrix(uint16_t); |
---|
78 | resize_type_matrix(int32_t); |
---|
79 | resize_type_matrix(uint32_t); |
---|
80 | resize_type_matrix(int64_t); |
---|
81 | resize_type_matrix(uint64_t); |
---|
82 | resize_type_matrix(float); |
---|
83 | resize_type_matrix(double); |
---|
84 | resize_type_matrix(rgb8); |
---|
85 | resize_type_matrix(rgbx8); |
---|
86 | |
---|
87 | |
---|
88 | |
---|
89 | /* ---------------- */ |
---|
90 | /* -- Conversion -- */ |
---|
91 | /* ---------------- */ |
---|
92 | |
---|
93 | #undef convert_type_matrix |
---|
94 | #define convert_type_matrix(t1,t2) \ |
---|
95 | void short_name(t1,convert_,short_name(t2,matrix_,matrix))(t1 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t2 ** Y) \ |
---|
96 | { \ |
---|
97 | for (int32_t i = nrl; i <= nrh; i++) { \ |
---|
98 | short_name(t1,convert_,short_name(t2,vector_,vector))(X[i], ncl, nch, Y[i]); \ |
---|
99 | } \ |
---|
100 | } |
---|
101 | |
---|
102 | convert_type_matrix(int8_t,int16_t); |
---|
103 | convert_type_matrix(int8_t,int32_t); |
---|
104 | convert_type_matrix(int8_t,float); |
---|
105 | convert_type_matrix(int8_t,double); |
---|
106 | convert_type_matrix(uint8_t,uint16_t); |
---|
107 | convert_type_matrix(uint8_t,uint32_t); |
---|
108 | convert_type_matrix(uint8_t,float); |
---|
109 | convert_type_matrix(uint8_t,double); |
---|
110 | convert_type_matrix(uint8_t,rgb8); |
---|
111 | convert_type_matrix(uint8_t,rgbx8); |
---|
112 | convert_type_matrix(int16_t,int32_t); |
---|
113 | convert_type_matrix(int16_t,float); |
---|
114 | convert_type_matrix(int16_t,double); |
---|
115 | convert_type_matrix(uint16_t,uint32_t); |
---|
116 | convert_type_matrix(uint16_t,float); |
---|
117 | convert_type_matrix(uint16_t,double); |
---|
118 | convert_type_matrix(int32_t,float); |
---|
119 | convert_type_matrix(int32_t,double); |
---|
120 | convert_type_matrix(uint32_t,float); |
---|
121 | convert_type_matrix(uint32_t,double); |
---|
122 | |
---|
123 | convert_type_matrix(int16_t,int8_t); |
---|
124 | convert_type_matrix(uint16_t,uint8_t); |
---|
125 | convert_type_matrix(int32_t,int8_t); |
---|
126 | convert_type_matrix(uint32_t,uint8_t); |
---|
127 | convert_type_matrix(int32_t,int16_t); |
---|
128 | convert_type_matrix(uint32_t,uint16_t); |
---|
129 | convert_type_matrix(float,int8_t); |
---|
130 | convert_type_matrix(float,uint8_t); |
---|
131 | convert_type_matrix(float,int16_t); |
---|
132 | convert_type_matrix(float,uint16_t); |
---|
133 | convert_type_matrix(float,int32_t); |
---|
134 | convert_type_matrix(float,uint32_t); |
---|
135 | convert_type_matrix(double,int8_t); |
---|
136 | convert_type_matrix(double,uint8_t); |
---|
137 | convert_type_matrix(double,int16_t); |
---|
138 | convert_type_matrix(double,uint16_t); |
---|
139 | convert_type_matrix(double,int32_t); |
---|
140 | convert_type_matrix(double,uint32_t); |
---|
141 | convert_type_matrix(double,float); |
---|
142 | convert_type_matrix(rgb8,uint8_t); |
---|
143 | |
---|
144 | |
---|
145 | /* |
---|
146 | * ---------------------- |
---|
147 | * --- lowpart_matrix --- |
---|
148 | * ---------------------- |
---|
149 | */ |
---|
150 | |
---|
151 | void lowpart_ui16matrix_ui8matrix(uint16_t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint8_t ** Y) |
---|
152 | { |
---|
153 | for (int32_t i = nrl; i <= nrh; i++) { |
---|
154 | lowpart_ui16vector_ui8vector(X[i], ncl, nch, Y[i]); |
---|
155 | } |
---|
156 | } |
---|
157 | |
---|
158 | void lowpart_ui32matrix_ui8matrix(uint32_t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint8_t ** Y) |
---|
159 | { |
---|
160 | for (int32_t i = nrl; i <= nrh; i++) { |
---|
161 | lowpart_ui32vector_ui8vector(X[i], ncl,nch, Y[i]); |
---|
162 | } |
---|
163 | } |
---|
164 | |
---|
165 | /* |
---|
166 | * ------------------- |
---|
167 | * --- split-merge --- |
---|
168 | * ------------------- |
---|
169 | */ |
---|
170 | |
---|
171 | void split_rgb8matrix(rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint8_t ** R, uint8_t ** G, uint8_t ** B) |
---|
172 | { |
---|
173 | for (int32_t i = nrl; i <= nrh; i++) { |
---|
174 | for (int32_t j = ncl; j <= nch; j++) { |
---|
175 | split_rgb8vector(X[i], ncl, nch, R[i], G[i], B[i]); |
---|
176 | } |
---|
177 | } |
---|
178 | } |
---|
179 | |
---|
180 | void merge_rgb8matrix(uint8_t ** R, uint8_t ** G, uint8_t ** B, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb8 ** X) |
---|
181 | { |
---|
182 | for (int32_t i = nrl; i <= nrh; i++) { |
---|
183 | for (int32_t j = ncl; j <= nch; j++) { |
---|
184 | merge_rgb8vector(R[i], G[i], B[i], ncl, nch, X[i]); |
---|
185 | } |
---|
186 | } |
---|
187 | } |
---|
188 | |
---|
189 | |
---|
190 | // Local Variables: |
---|
191 | // tab-width: 4 |
---|
192 | // c-basic-offset: 4 |
---|
193 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
194 | // indent-tabs-mode: nil |
---|
195 | // End: |
---|
196 | |
---|
197 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
198 | |
---|