source: soft/giet_vm/applications/rosenfeld/nrc2/src/nrmem2.c @ 827

Last change on this file since 827 was 826, checked in by meunier, 7 years ago
  • Mise à jour NR2 et Rosenfeld
File size: 5.5 KB
Line 
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) \
37void 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
44dup_type_matrix(int8_t);
45dup_type_matrix(uint8_t);
46dup_type_matrix(int16_t);
47dup_type_matrix(uint16_t);
48dup_type_matrix(int32_t);
49dup_type_matrix(uint32_t);
50dup_type_matrix(int64_t);
51dup_type_matrix(uint64_t);
52dup_type_matrix(float);
53dup_type_matrix(double);
54dup_type_matrix(rgb8);
55dup_type_matrix(rgbx8);
56
57
58/*
59 * --------------
60 * --- resize ---
61 * --------------
62 */
63
64#undef resize_type_matrix
65#define resize_type_matrix(t) \
66void 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
74resize_type_matrix(int8_t);
75resize_type_matrix(uint8_t);
76resize_type_matrix(int16_t);
77resize_type_matrix(uint16_t);
78resize_type_matrix(int32_t);
79resize_type_matrix(uint32_t);
80resize_type_matrix(int64_t);
81resize_type_matrix(uint64_t);
82resize_type_matrix(float);
83resize_type_matrix(double);
84resize_type_matrix(rgb8);
85resize_type_matrix(rgbx8);
86
87
88
89/* ---------------- */
90/* -- Conversion -- */
91/* ---------------- */
92
93#undef convert_type_matrix
94#define convert_type_matrix(t1,t2) \
95void 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
102convert_type_matrix(int8_t,int16_t);
103convert_type_matrix(int8_t,int32_t);
104convert_type_matrix(int8_t,float);
105convert_type_matrix(int8_t,double);
106convert_type_matrix(uint8_t,uint16_t);
107convert_type_matrix(uint8_t,uint32_t);
108convert_type_matrix(uint8_t,float);
109convert_type_matrix(uint8_t,double);
110convert_type_matrix(uint8_t,rgb8);
111convert_type_matrix(uint8_t,rgbx8);
112convert_type_matrix(int16_t,int32_t);
113convert_type_matrix(int16_t,float);
114convert_type_matrix(int16_t,double);
115convert_type_matrix(uint16_t,uint32_t);
116convert_type_matrix(uint16_t,float);
117convert_type_matrix(uint16_t,double);
118convert_type_matrix(int32_t,float);
119convert_type_matrix(int32_t,double);
120convert_type_matrix(uint32_t,float);
121convert_type_matrix(uint32_t,double);
122
123convert_type_matrix(int16_t,int8_t);
124convert_type_matrix(uint16_t,uint8_t);
125convert_type_matrix(int32_t,int8_t);
126convert_type_matrix(uint32_t,uint8_t);
127convert_type_matrix(int32_t,int16_t);
128convert_type_matrix(uint32_t,uint16_t);
129convert_type_matrix(float,int8_t);
130convert_type_matrix(float,uint8_t);
131convert_type_matrix(float,int16_t);
132convert_type_matrix(float,uint16_t);
133convert_type_matrix(float,int32_t);
134convert_type_matrix(float,uint32_t);
135convert_type_matrix(double,int8_t);
136convert_type_matrix(double,uint8_t);
137convert_type_matrix(double,int16_t);
138convert_type_matrix(double,uint16_t);
139convert_type_matrix(double,int32_t);
140convert_type_matrix(double,uint32_t);
141convert_type_matrix(double,float);
142convert_type_matrix(rgb8,uint8_t);
143
144
145/*
146 * ----------------------
147 * --- lowpart_matrix ---
148 * ----------------------
149 */
150
151void 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
158void 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
171void 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
180void 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
Note: See TracBrowser for help on using the repository browser.