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

Last change on this file since 826 was 826, checked in by meunier, 7 years ago
  • Mise à jour NR2 et Rosenfeld
File size: 3.7 KB
Line 
1/* ----------------- */
2/* --- nrmem1x.c --- */
3/* ----------------- */
4
5/*
6 * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved
7 * Univ Paris Sud XI, CNRS
8 */
9
10#include <stdlib.h>
11#include <stdio.h>
12#include <stddef.h>
13#include <string.h>
14
15#include "mypredef.h"
16#include "nrtype.h"
17#include "nrdef.h"
18#include "nrmacro.h"
19#include "nrkernel.h"
20
21#include "nrmem1x.h"
22
23void roll_si16vector(int16_t * v, int32_t nl, int32_t nh)
24/*
25 * left rotate a uint16 vector with subscript range v[nl..nh]
26 * nl & nh can be, respectively bigger and smaller than the
27 * values used to allocate the vector (svector)
28 * no check on nl and nh is done
29 */
30{
31    sint16 tmp;
32    tmp = v[nl];
33    for (int32_t i = nl; i < nh; i++) {
34        v[i] = v[i + 1];
35    }
36    v[nh] = tmp;
37}
38
39
40void roll_ui16vector(uint16_t * v, int32_t nl, int32_t nh)
41/*
42 * left rotate a uint16 vector with subscript range v[nl..nh]
43 * nl & nh can be, respectively bigger and smaller than the
44 * values used to allocate the vector (svector)
45 * no check on nl and nh is done
46 */
47{
48    uint16 tmp;
49    tmp = v[nl];
50    for (int32_t i = nl; i < nh; i++) {
51        v[i] = v[i + 1];
52    }
53    v[nh] = tmp;
54}
55
56/*
57 * -------------------
58 * --- copy_vector ---
59 * -------------------
60 */
61
62#undef copy_type_vector
63#define copy_type_vector(t) \
64void short_name(t,copy_,vector)(t * src, int32_t nl1, int32_t nh1, t * dst, int32_t nl2, int32_t nh2) \
65{                                                  \
66    int32_t len = nh1 - nl1 + 1;                   \
67    memcpy(dst + nl2, src + nl1, len * sizeof(t)); \
68}
69
70copy_type_vector(int8_t);
71copy_type_vector(uint8_t);
72copy_type_vector(int16_t);
73copy_type_vector(uint16_t);
74copy_type_vector(int32_t);
75copy_type_vector(uint32_t);
76copy_type_vector(float);
77copy_type_vector(double);
78copy_type_vector(rgb8);
79copy_type_vector(rgbx8);
80
81
82#undef copy1c_type_vector
83#define copy1c_type_vector(t) \
84void short_name(t,copy1c_,vector)(t * src, int32_t nc, t * dst, int32_t nl, int32_t nh) \
85{                                       \
86    t c = src[nc];                      \
87    for (int32_t j = nl; j < nh; j++) { \
88        dst[j] = c;                     \
89    }                                   \
90}
91
92copy1c_type_vector(int8_t);
93copy1c_type_vector(uint8_t);
94copy1c_type_vector(int16_t);
95copy1c_type_vector(uint16_t);
96copy1c_type_vector(int32_t);
97copy1c_type_vector(uint32_t);
98copy1c_type_vector(float);
99copy1c_type_vector(double);
100copy1c_type_vector(rgb8);
101copy1c_type_vector(rgbx8);
102
103
104
105#undef copy_type_vector_mod
106#define copy_type_vector_mod(t) \
107void short_name(t,copy_,vector_mod)(t * src, int32_t nl, int32_t nh, int32_t m, t * dst) \
108{                                                       \
109    if (nh > nl) {                                      \
110        int32_t len = nh - nl + 1;                      \
111        memcpy(dst, src + nl, len * sizeof(t));         \
112    }                                                   \
113    else {                                              \
114        int32_t len1 = m - nl;                          \
115        int32_t len2 = nh + 1;                          \
116        memcpy(dst, src + nl, len1 * sizeof(t));        \
117        memcpy(dst + len1, src + nh, len2 * sizeof(t)); \
118    }                                                   \
119}
120
121
122copy_type_vector_mod(int8_t);
123copy_type_vector_mod(uint8_t);
124copy_type_vector_mod(int16_t);
125copy_type_vector_mod(uint16_t);
126copy_type_vector_mod(int32_t);
127copy_type_vector_mod(uint32_t);
128copy_type_vector_mod(float);
129copy_type_vector_mod(double);
130copy_type_vector_mod(rgb8);
131copy_type_vector_mod(rgbx8);
132
133
134
135// Local Variables:
136// tab-width: 4
137// c-basic-offset: 4
138// c-file-offsets:((innamespace . 0)(inline-open . 0))
139// indent-tabs-mode: nil
140// End:
141
142// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
143
Note: See TracBrowser for help on using the repository browser.