source: soft/giet_vm/applications/rosenfeld/nrc2/src/nrbool1.c @ 822

Last change on this file since 822 was 822, checked in by meunier, 8 years ago

In rosenfeld:

  • Updated nrio0, nrio1, nrio2, nrio1f, nrio2f, nrio1x, nrbool1, nrbool2 and nralloc1 in the nrc2 lib in order to use macro-typed functions
  • Updated the simulation script to include performance evaluation with random images, and a script to generate graphs
  • Updated the clock.h to use 64-bit integers, which potentially breaks the printing on the giet
File size: 8.9 KB
Line 
1/* ----------------- */
2/* --- nrbool1.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 "nrc_os_config.h"
20#include "mypredef.h"
21#include "nrtype.h"
22#include "nrdef.h"
23#include "nrmacro.h"
24#include "nrkernel.h"
25
26#include "nrbool1.h"
27
28/*
29 * -----------
30 * --- Not ---
31 * -----------
32 */
33
34#undef not_type_vector
35#define not_type_vector(t) \
36void short_name(t,not_,vector)(t * X, int32_t ncl, int32_t nch, t * Y) \
37{                                          \
38        for (int32_t j = ncl; j <= nch; j++) { \
39                Y[j] = ~X[j];                      \
40        }                                      \
41}
42
43not_type_vector(int8_t);
44not_type_vector(uint8_t);
45not_type_vector(int16_t);
46not_type_vector(uint16_t);
47not_type_vector(int32_t);
48not_type_vector(uint32_t);
49not_type_vector(int64_t);
50not_type_vector(uint64_t);
51
52
53/* ----------------------------------------------------------------- */
54void not_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y)
55/* ----------------------------------------------------------------- */
56{
57        for (int32_t j = ncl; j <= nch; j++) {
58        RGB8_NOT(X[j], Y[j]);
59        }
60}
61
62/* -------------------------------------------------------------------- */
63void not_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y)
64/* -------------------------------------------------------------------- */
65{
66        for (int32_t j = ncl; j <= nch; j++) {
67        RGBX8_NOT(X[j], Y[j]);
68        }
69}
70
71/*
72 * -----------
73 * --- Or ---
74 * -----------
75 */
76
77#undef or_type_vector
78#define or_type_vector(t) \
79void short_name(t,or_,vector)(t * X, int32_t ncl, int32_t nch, t * Y, t * Z) \
80{                                          \
81        for (int32_t j = ncl; j <= nch; j++) { \
82                Z[j] = X[j] | Y[j];                \
83        }                                      \
84}
85
86or_type_vector(int8_t);
87or_type_vector(uint8_t);
88or_type_vector(int16_t);
89or_type_vector(uint16_t);
90or_type_vector(int32_t);
91or_type_vector(uint32_t);
92or_type_vector(int64_t);
93or_type_vector(uint64_t);
94
95
96/* ------------------------------------------------------------------------- */
97void or_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y, rgb8 * Z)
98/* ------------------------------------------------------------------------- */
99{
100        for (int32_t j = ncl; j <= nch; j++) {
101        RGB8_OR(X[j], Y[j], Z[j]);
102        }
103}
104/* ----------------------------------------------------------------------------- */
105void or_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y, rgbx8 * Z)
106/* ----------------------------------------------------------------------------- */
107{
108        for (int32_t j = ncl; j <= nch; j++) {
109        RGBX8_OR(X[j], Y[j], Z[j]);
110        }
111}
112
113
114#undef orc_type_vector
115#define orc_type_vector(t) \
116void short_name(t,orc_,vector)(t * X, int32_t ncl, int32_t nch, t y, t * Z) \
117{                                          \
118        for (int32_t j = ncl; j <= nch; j++) { \
119                Z[j] = X[j] | y;                   \
120        }                                      \
121}
122
123orc_type_vector(int8_t);
124orc_type_vector(uint8_t);
125orc_type_vector(int16_t);
126orc_type_vector(uint16_t);
127orc_type_vector(int32_t);
128orc_type_vector(uint32_t);
129orc_type_vector(int64_t);
130orc_type_vector(uint64_t);
131
132
133/* ------------------------------------------------------------------------- */
134void orc_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 y, rgb8 * Z)
135/* ------------------------------------------------------------------------- */
136{
137        for (int32_t j = ncl; j <= nch; j++) {
138        RGB8_OR(X[j], y, Z[j]);
139        }
140}
141
142/* ----------------------------------------------------------------------------- */
143void orc_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 * Z)
144/* ----------------------------------------------------------------------------- */
145{
146        for (int32_t j = ncl; j <= nch; j++) {
147        RGBX8_OR(X[j], y, Z[j]);
148        }
149}
150
151
152/*
153 * -----------
154 * --- XOR ---
155 * -----------
156 */
157
158#undef xor_type_vector
159#define xor_type_vector(t) \
160void short_name(t,xor_,vector)(t * X, int32_t ncl, int32_t nch, t * Y, t * Z) \
161{                                          \
162        for (int32_t j = ncl; j <= nch; j++) { \
163                Z[j] = X[j] ^ Y[j];                \
164        }                                      \
165}
166
167xor_type_vector(int8_t);
168xor_type_vector(uint8_t);
169xor_type_vector(int16_t);
170xor_type_vector(uint16_t);
171xor_type_vector(int32_t);
172xor_type_vector(uint32_t);
173xor_type_vector(int64_t);
174xor_type_vector(uint64_t);
175
176
177/* -------------------------------------------------------------------------- */
178void xor_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y, rgb8 * Z)
179/* -------------------------------------------------------------------------- */
180{
181        for (int32_t j = ncl; j <= nch; j++) {
182        RGB8_XOR(X[j], Y[j], Z[j]);
183        }
184}
185
186/* ------------------------------------------------------------------------------ */
187void xor_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y, rgbx8 * Z)
188/* ------------------------------------------------------------------------------ */
189{
190        for (int32_t j = ncl; j <= nch; j++) {
191        RGBX8_XOR(X[j], Y[j], Z[j]);
192        }
193}
194
195
196#undef xorc_type_vector
197#define xorc_type_vector(t) \
198void short_name(t,xorc_,vector)(t * X, int32_t ncl, int32_t nch, t y, t * Z) \
199{                                          \
200        for (int32_t j = ncl; j <= nch; j++) { \
201                Z[j] = X[j] ^ y;                   \
202        }                                      \
203}
204
205xorc_type_vector(int8_t);
206xorc_type_vector(uint8_t);
207xorc_type_vector(int16_t);
208xorc_type_vector(uint16_t);
209xorc_type_vector(int32_t);
210xorc_type_vector(uint32_t);
211xorc_type_vector(int64_t);
212xorc_type_vector(uint64_t);
213
214
215/* -------------------------------------------------------------------------- */
216void xorc_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 y, rgb8 * Z)
217/* -------------------------------------------------------------------------- */
218{
219        for (int32_t j = ncl; j <= nch; j++) {
220        RGB8_XOR(X[j], y, Z[j]);
221        }
222}
223
224/* ------------------------------------------------------------------------------ */
225void xorc_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 * Z)
226/* ------------------------------------------------------------------------------ */
227{
228        for (int32_t j = ncl; j <= nch; j++) {
229        RGBX8_XOR(X[j], y, Z[j]);
230        }
231}
232
233
234/*
235 * -----------
236 * --- AND ---
237 * -----------
238 */
239
240
241#undef and_type_vector
242#define and_type_vector(t) \
243void short_name(t,and_,vector)(t * X, int32_t ncl, int32_t nch, t * Y, t * Z) \
244{                                          \
245        for (int32_t j = ncl; j <= nch; j++) { \
246                Z[j] = X[j] & Y[j];                \
247        }                                      \
248}
249
250and_type_vector(int8_t);
251and_type_vector(uint8_t);
252and_type_vector(int16_t);
253and_type_vector(uint16_t);
254and_type_vector(int32_t);
255and_type_vector(uint32_t);
256and_type_vector(int64_t);
257and_type_vector(uint64_t);
258
259
260/* -------------------------------------------------------------------------- */
261void and_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y, rgb8 * Z)
262/* -------------------------------------------------------------------------- */
263{
264        for (int32_t j = ncl; j <= nch; j++) {
265        RGB8_AND(X[j], Y[j], Z[j]);
266        }
267}
268
269/* ------------------------------------------------------------------------------ */
270void and_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y, rgbx8 * Z)
271/* ------------------------------------------------------------------------------ */
272{
273        for (int32_t j = ncl; j <= nch; j++) {
274        RGBX8_AND(X[j], Y[j], Z[j]);
275        }
276}
277
278
279#undef andc_type_vector
280#define andc_type_vector(t) \
281void short_name(t,andc_,vector)(t * X, int32_t ncl, int32_t nch, t y, t * Z) \
282{                                          \
283        for (int32_t j = ncl; j <= nch; j++) { \
284                Z[j] = X[j] ^ y;                   \
285        }                                      \
286}
287
288andc_type_vector(int8_t);
289andc_type_vector(uint8_t);
290andc_type_vector(int16_t);
291andc_type_vector(uint16_t);
292andc_type_vector(int32_t);
293andc_type_vector(uint32_t);
294andc_type_vector(int64_t);
295andc_type_vector(uint64_t);
296
297
298/* -------------------------------------------------------------------------- */
299void andc_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 y, rgb8 * Z)
300/* -------------------------------------------------------------------------- */
301{
302        for (int32_t j = ncl; j <= nch; j++) {
303        RGB8_AND(X[j], y, Z[j]);
304        }
305}
306
307/* ------------------------------------------------------------------------------ */
308void andc_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 * Z)
309/* ------------------------------------------------------------------------------ */
310{
311        for (int32_t j = ncl; j <= nch; j++) {
312        RGBX8_AND(X[j], y, Z[j]);
313        }
314}
315
316
317// Local Variables:
318// tab-width: 4
319// c-basic-offset: 4
320// c-file-offsets:((innamespace . 0)(inline-open . 0))
321// indent-tabs-mode: nil
322// End:
323
324// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
325
Note: See TracBrowser for help on using the repository browser.