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

Last change on this file since 826 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
RevLine 
[772]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
[822]19#include "nrc_os_config.h"
[772]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
[822]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        }                                      \
[772]41}
[822]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
[772]53/* ----------------------------------------------------------------- */
[822]54void not_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y)
[772]55/* ----------------------------------------------------------------- */
56{
[822]57        for (int32_t j = ncl; j <= nch; j++) {
58        RGB8_NOT(X[j], Y[j]);
[772]59        }
60}
[822]61
[772]62/* -------------------------------------------------------------------- */
[822]63void not_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y)
[772]64/* -------------------------------------------------------------------- */
65{
[822]66        for (int32_t j = ncl; j <= nch; j++) {
67        RGBX8_NOT(X[j], Y[j]);
[772]68        }
69}
[822]70
[772]71/*
72 * -----------
73 * --- Or ---
74 * -----------
75 */
76
[822]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        }                                      \
[772]84}
[822]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
[772]96/* ------------------------------------------------------------------------- */
[822]97void or_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y, rgb8 * Z)
[772]98/* ------------------------------------------------------------------------- */
99{
[822]100        for (int32_t j = ncl; j <= nch; j++) {
101        RGB8_OR(X[j], Y[j], Z[j]);
[772]102        }
103}
104/* ----------------------------------------------------------------------------- */
[822]105void or_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y, rgbx8 * Z)
[772]106/* ----------------------------------------------------------------------------- */
107{
[822]108        for (int32_t j = ncl; j <= nch; j++) {
109        RGBX8_OR(X[j], Y[j], Z[j]);
[772]110        }
111}
[822]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        }                                      \
[772]121}
[822]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
[772]133/* ------------------------------------------------------------------------- */
[822]134void orc_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 y, rgb8 * Z)
[772]135/* ------------------------------------------------------------------------- */
136{
[822]137        for (int32_t j = ncl; j <= nch; j++) {
138        RGB8_OR(X[j], y, Z[j]);
[772]139        }
140}
[822]141
[772]142/* ----------------------------------------------------------------------------- */
[822]143void orc_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 * Z)
[772]144/* ----------------------------------------------------------------------------- */
145{
[822]146        for (int32_t j = ncl; j <= nch; j++) {
147        RGBX8_OR(X[j], y, Z[j]);
[772]148        }
149}
[822]150
151
[772]152/*
153 * -----------
154 * --- XOR ---
155 * -----------
156 */
[822]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        }                                      \
[772]165}
[822]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
[772]177/* -------------------------------------------------------------------------- */
[822]178void xor_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y, rgb8 * Z)
[772]179/* -------------------------------------------------------------------------- */
180{
[822]181        for (int32_t j = ncl; j <= nch; j++) {
182        RGB8_XOR(X[j], Y[j], Z[j]);
[772]183        }
184}
[822]185
[772]186/* ------------------------------------------------------------------------------ */
[822]187void xor_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y, rgbx8 * Z)
[772]188/* ------------------------------------------------------------------------------ */
189{
[822]190        for (int32_t j = ncl; j <= nch; j++) {
191        RGBX8_XOR(X[j], Y[j], Z[j]);
[772]192        }
193}
[822]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        }                                      \
[772]203}
[822]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
[772]215/* -------------------------------------------------------------------------- */
[822]216void xorc_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 y, rgb8 * Z)
[772]217/* -------------------------------------------------------------------------- */
218{
[822]219        for (int32_t j = ncl; j <= nch; j++) {
220        RGB8_XOR(X[j], y, Z[j]);
[772]221        }
222}
[822]223
[772]224/* ------------------------------------------------------------------------------ */
[822]225void xorc_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 * Z)
[772]226/* ------------------------------------------------------------------------------ */
227{
[822]228        for (int32_t j = ncl; j <= nch; j++) {
229        RGBX8_XOR(X[j], y, Z[j]);
[772]230        }
231}
[822]232
233
[772]234/*
235 * -----------
236 * --- AND ---
237 * -----------
238 */
[822]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        }                                      \
[772]248}
[822]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
[772]260/* -------------------------------------------------------------------------- */
[822]261void and_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y, rgb8 * Z)
[772]262/* -------------------------------------------------------------------------- */
263{
[822]264        for (int32_t j = ncl; j <= nch; j++) {
265        RGB8_AND(X[j], Y[j], Z[j]);
[772]266        }
267}
[822]268
[772]269/* ------------------------------------------------------------------------------ */
[822]270void and_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y, rgbx8 * Z)
[772]271/* ------------------------------------------------------------------------------ */
272{
[822]273        for (int32_t j = ncl; j <= nch; j++) {
274        RGBX8_AND(X[j], Y[j], Z[j]);
[772]275        }
276}
[822]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        }                                      \
[772]286}
[822]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
[772]298/* -------------------------------------------------------------------------- */
[822]299void andc_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 y, rgb8 * Z)
[772]300/* -------------------------------------------------------------------------- */
301{
[822]302        for (int32_t j = ncl; j <= nch; j++) {
303        RGB8_AND(X[j], y, Z[j]);
[772]304        }
305}
[822]306
[772]307/* ------------------------------------------------------------------------------ */
[822]308void andc_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 * Z)
[772]309/* ------------------------------------------------------------------------------ */
310{
[822]311        for (int32_t j = ncl; j <= nch; j++) {
312        RGBX8_AND(X[j], y, Z[j]);
[772]313        }
314}
[822]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.