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

Last change on this file was 826, checked in by meunier, 7 years ago
  • Mise à jour NR2 et Rosenfeld
File size: 5.5 KB
RevLine 
[772]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 * ------------------
[826]30 * --- dup_matrix ---
[772]31 * ------------------
32 */
[826]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    }                                                    \
[772]42}
[826]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
[772]58/*
59 * --------------
60 * --- resize ---
61 * --------------
62 */
[826]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    }                                          \
[772]72}
[826]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
[772]89/* ---------------- */
[826]90/* -- Conversion -- */
[772]91/* ---------------- */
[826]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    }                                                                                \
[772]100}
101
[826]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
[772]145/*
146 * ----------------------
147 * --- lowpart_matrix ---
148 * ----------------------
149 */
[826]150
151void lowpart_ui16matrix_ui8matrix(uint16_t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint8_t ** Y)
[772]152{
[826]153    for (int32_t i = nrl; i <= nrh; i++) {
154        lowpart_ui16vector_ui8vector(X[i], ncl, nch, Y[i]);
155    }
[772]156}
[826]157
158void lowpart_ui32matrix_ui8matrix(uint32_t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint8_t ** Y)
[772]159{
[826]160    for (int32_t i = nrl; i <= nrh; i++) {
161        lowpart_ui32vector_ui8vector(X[i], ncl,nch, Y[i]);
162    }
[772]163}
[826]164
[772]165/*
166 * -------------------
167 * --- split-merge ---
168 * -------------------
169 */
[826]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)
[772]172{
[826]173    for (int32_t i = nrl; i <= nrh; i++) {
174        for (int32_t j = ncl; j <= nch; j++) {
[772]175            split_rgb8vector(X[i], ncl, nch, R[i], G[i], B[i]);
[826]176        }
177    }
[772]178}
[826]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)
[772]181{
[826]182    for (int32_t i = nrl; i <= nrh; i++) {
183        for (int32_t j = ncl; j <= nch; j++) {
[772]184            merge_rgb8vector(R[i], G[i], B[i], ncl, nch, X[i]);
[826]185        }
186    }
[772]187}
[826]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.