Ignore:
Timestamp:
Jul 13, 2017, 11:01:58 AM (7 years ago)
Author:
meunier
Message:
  • Mise à jour NR2 et Rosenfeld
File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrmem1x.c

    r821 r826  
    44
    55/*
    6 * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved
    7 * Univ Paris Sud XI, CNRS
    8 */
     6 * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved
     7 * Univ Paris Sud XI, CNRS
     8 */
    99
    1010#include <stdlib.h>
     
    2020
    2121#include "nrmem1x.h"
    22 /* --------------------------------------- */
    23 IMAGE_EXPORT(void) roll_si16vector(sint16 *v, long nl, long nh)
    24 /* --------------------------------------- */
     22
     23void roll_si16vector(int16_t * v, int32_t nl, int32_t nh)
    2524/*
    26 * left rotate a uint16 vector with subscript range v[nl..nh]
    27 * nl & nh can be, respectively bigger and smaller than the
    28 * values used to allocate the vector (svector)
    29 * no check on nl and nh is done
    30 */
     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 */
    3130{
    32         long i;
    33         sint16 tmp;
    34        
    35         tmp = v[nl];
    36         for(i=nl; i<nh; i++) {
    37                 v[i] = v[i+1];
    38         }
    39         v[nh] = tmp;
     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;
    4037}
    41 /* ----------------------------------------- */
    42 IMAGE_EXPORT(void) roll_ui16vector(uint16 *v, long nl, long nh)
    43 /* ----------------------------------------- */
     38
     39
     40void roll_ui16vector(uint16_t * v, int32_t nl, int32_t nh)
    4441/*
    45 * left rotate a uint16 vector with subscript range v[nl..nh]
    46 * nl & nh can be, respectively bigger and smaller than the
    47 * values used to allocate the vector (svector)
    48 * no check on nl and nh is done
    49 */
     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 */
    5047{
    51         long i;
    52         uint16 tmp;
    53        
    54         tmp = v[nl];
    55         for(i=nl; i<nh; i++) {
    56                 v[i] = v[i+1];
    57         }
    58         v[nh] = tmp;
     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;
    5954}
     55
    6056/*
    6157 * -------------------
     
    6460 */
    6561
    66 /* --------------------------------------------------------------------------------------- */
    67 IMAGE_EXPORT(void) copy_bvector(uint8 *src, long nl1, long nh1, uint8 *dst, long nl2, long nh2)
    68 /* --------------------------------------------------------------------------------------- */
    69 {
    70     long len = nh1 - nl1 + 1;
    71     memcpy(dst + nl2, src + nl1, len);
    72 }
    73 /* ----------------------------------------------------------------------------------------- */
    74 IMAGE_EXPORT(void) copy_svector(uint16 *src, long nl1, long nh1, uint16 *dst, long nl2, long nh2)
    75 /* ----------------------------------------------------------------------------------------- */
    76 {
    77     long len = nh1 - nl1 + 1;
    78     static long size = sizeof(uint16);
    79     memcpy(dst + nl2, src + nl1, len*size);
    80 }
    81 // ------------------------------------------------------------------------------------------------
    82 IMAGE_EXPORT(void) copy_si16vector(sint16 *src, long nl1, long nh1, int16 *dst, long nl2, long nh2)
    83 // ------------------------------------------------------------------------------------------------
    84 {
    85     long len = nh1 - nl1 + 1;
    86     memcpy(dst + nl2, src + nl1, 2*len);
    87 }
    88 // ------------------------------------------------------------------------------------------------
    89 IMAGE_EXPORT(void) copy_ui16vector(uint16 *src, long nl1, long nh1, uint16 *dst, long nl2, long nh2)
    90 // ------------------------------------------------------------------------------------------------
    91 {
    92     long len = nh1 - nl1 + 1;
    93     memcpy(dst + nl2, src + nl1, 2*len);
    94 }
    95 /* ------------------------------------------------------------------------------------- */
    96 IMAGE_EXPORT(void) copy_si32vector(sint32 *src, long nl1, long nh1, sint32 *dst, long nl2, long nh2)
    97 /* ------------------------------------------------------------------------------------- */
    98 {
    99     long len = nh1 - nl1 + 1;
    100     static long size = sizeof(sint32);
    101     memcpy(dst + nl2, src + nl1, len*size);
    102 }
    103 /* ---------------------------------------------------------------------------------------- */
    104 IMAGE_EXPORT(void) copy_ui32vector(uint32 *src, long nl1, long nh1, uint32 *dst, long nl2, long nh2)
    105 /* ---------------------------------------------------------------------------------------- */
    106 {
    107     long len = nh1 - nl1 + 1;
    108     static long size = sizeof(uint32);
    109     memcpy(dst + nl2, src + nl1, len*size);
    110 }
    111 /* ---------------------------------------------------------------------------------------- */
    112 IMAGE_EXPORT(void) copy_f32vector(float32 *src, long nl1, long nh1, float32 *dst, long nl2, long nh2)
    113 /* ---------------------------------------------------------------------------------------- */
    114 {
    115     long len = nh1 - nl1 + 1;
    116     static long size = sizeof(float32);
    117     memcpy(dst + nl2, src + nl1, len*size);
    118 }
    119 /* ------------------------------------------------------------------------------------------- */
    120 IMAGE_EXPORT(void) copy_f64vector(float64 *src, long nl1, long nh1, float64 *dst, long nl2, long nh2)
    121 /* ------------------------------------------------------------------------------------------- */
    122 {
    123     long len = nh1 - nl1 + 1;
    124     static long size = sizeof(float64);
    125     memcpy(dst + nl2, src + nl1, len*size);
    126 }
    127 /* ------------------------------------------------------------------------------------------ */
    128 IMAGE_EXPORT(void) copy_rgb8vector(rgb8 *src, long nl1, long nh1, rgb8 *dst, long nl2, long nh2)
    129 /* ------------------------------------------------------------------------------------------ */
    130 {
    131     long len = nh1 - nl1 + 1;
    132     static long size = sizeof(rgb8);
    133     memcpy(dst + nl2, src + nl1, len*size);
    134 }
    135 /* --------------------------------------------------------------------------------------------- */
    136 IMAGE_EXPORT(void) copy_rgbx8vector(rgbx8 *src, long nl1, long nh1, rgbx8 *dst, long nl2, long nh2)
    137 /* --------------------------------------------------------------------------------------------- */
    138 {
    139     long len = nh1 - nl1 + 1;
    140     static long size = sizeof(rgbx8);
    141     memcpy(dst + nl2, src + nl1, len*size);
    142 }
    143 /* ---------------------------------------------------------------------------- */
    144 IMAGE_EXPORT(void) copy1c_bvector(uint8 *src, long nc, uint8 *dst, long nl, long nh)
    145 /* ---------------------------------------------------------------------------- */
    146 {
    147     int j;
    148     uint8 c = src[nc];
    149     for(j=nl; j<=nh; j++) dst[j] = c;
    150 }
    151 /* ----------------------------------------------------------------------------------- */
    152 IMAGE_EXPORT(void) copy1c_ui16vector(uint16 *src, long nc, uint16 *dst, long nl, long nh)
    153 /* ----------------------------------------------------------------------------------- */
    154 {
    155     int j;
    156     uint16 c = src[nc];
    157     for(j=nl; j<=nh; j++) dst[j] = c;
    158 }
    159 /* ---------------------------------------------------------------------------------- */
    160 IMAGE_EXPORT(void) copy1c_si16vector(sint16 *src, long nc, sint16 *dst, long nl, long nh)
    161 /* ---------------------------------------------------------------------------------- */
    162 {
    163     int j;
    164     sint16 c = src[nc];
    165     for(j=nl; j<=nh; j++) dst[j] = c;
    166 }
    167 /* -------------------------------------------------------------------------- */
    168 IMAGE_EXPORT(void) copy1c_ui32vector(uint32 *src, long nc, uint32 *dst, long nl, long nh)
    169 /* -------------------------------------------------------------------------- */
    170 {
    171     int j;
    172     int c = src[nc];
    173     for(j=nl; j<=nh; j++) dst[j] = c;
    174 }
    175 /* ----------------------------------------------------------------------------- */
    176 IMAGE_EXPORT(void) copy1c_si32vector(sint32 *src, long nc, sint32 *dst, long nl, long nh)
    177 /* ----------------------------------------------------------------------------- */
    178 {
    179     int j;
    180     int c = src[nc];
    181     for(j=nl; j<=nh; j++) dst[j] = c;
    182 }
    183 /* ----------------------------------------------------------------------------- */
    184 IMAGE_EXPORT(void) copy1c_f32vector(float32 *src, long nc, float32 *dst, long nl, long nh)
    185 /* ----------------------------------------------------------------------------- */
    186 {
    187     int j;
    188     float c = src[nc];
    189     for(j=nl; j<=nh; j++) dst[j] = c;
    190 }
    191 /* -------------------------------------------------------------------------------- */
    192 IMAGE_EXPORT(void) copy1c_f64vector(float64 *src, long nc, float64 *dst, long nl, long nh)
    193 /* -------------------------------------------------------------------------------- */
    194 {
    195     int j;
    196     float64 c = src[nc];
    197     for(j=nl; j<=nh; j++) dst[j] = c;
    198 }
    199 /* ------------------------------------------------------------------------------- */
    200 IMAGE_EXPORT(void) copy1c_rgb8vector(rgb8 *src, long nc, rgb8 *dst, long nl, long nh)
    201 /* ------------------------------------------------------------------------------- */
    202 {
    203     int j;
    204     rgb8 c = src[nc];
    205     for(j=nl; j<=nh; j++) dst[j] = c;
    206 }
    207 /* ---------------------------------------------------------------------------------- */
    208 IMAGE_EXPORT(void) copy1c_rgbx8vector(rgbx8 *src, long nc, rgbx8 *dst, long nl, long nh)
    209 /* ---------------------------------------------------------------------------------- */
    210 {
    211     int j;
    212     rgbx8 c = src[nc];
    213     for(j=nl; j<=nh; j++) dst[j] = c;
    214 }
    215 /* ----------------------------------------------------------------------------- */
    216 IMAGE_EXPORT(void) copy_bvector_mod(uint8 *src, long nl, long nh, long m, uint8 *dst)
    217 /* ----------------------------------------------------------------------------- */
    218 {
    219     long len;
    220     long len1, len2;
    221    
    222     if(nh>nl) {
    223         len = nh - nl + 1; memcpy(dst, src + nl, len);
    224     } else {
    225         len1 = m - nl; memcpy(dst,      src + nl, len1);
    226         len2 = nh + 1; memcpy(dst+len1, src + nh, len2);
    227     }
    228 }
    229 /* ------------------------------------------------------------------------------- */
    230 IMAGE_EXPORT(void) copy_si16vector_mod(sint16 *src, long nl, long nh, long m, sint16 *dst)
    231 /* ------------------------------------------------------------------------------- */
    232 {
    233     long len;
    234     long len1, len2;
    235    
    236     if(nh>nl) {
    237         len = nh - nl + 1; memcpy(dst, src + nl, len*sizeof(uint16));
    238     } else {
    239         len1 = m - nl; memcpy(dst,      src + nl, len1*sizeof(uint16));
    240         len2 = nh + 1; memcpy(dst+len1, src + nh, len2*sizeof(uint16));
    241     }
    242 }
    243 /* --------------------------------------------------------------------------------- */
    244 IMAGE_EXPORT(void) copy_ui16vector_mod(uint16 *src, long nl, long nh, long m, uint16 *dst)
    245 /* --------------------------------------------------------------------------------- */
    246 {
    247     long len;
    248     long len1, len2;
    249    
    250     if(nh>nl) {
    251         len = nh - nl + 1; memcpy(dst, src + nl, len*sizeof(uint16));
    252     } else {
    253         len1 = m - nl; memcpy(dst,      src + nl, len1*sizeof(uint16));
    254         len2 = nh + 1; memcpy(dst+len1, src + nh, len2*sizeof(uint16));
    255     }
    256 }
    257 /* --------------------------------------------------------------------------- */
    258 IMAGE_EXPORT(void) copy_ui32vector_mod(uint32 *src, long nl, long nh, long m, uint32 *dst)
    259 /* --------------------------------------------------------------------------- */
    260 {
    261     long len;
    262     long len1, len2;
    263    
    264     if(nh>nl) {
    265         len = nh - nl + 1; memcpy(dst, src + nl, len*sizeof(uint32));
    266     } else {
    267         len1 = m - nl; memcpy(dst,      src + nl, len1*sizeof(uint32));
    268         len2 = nh + 1; memcpy(dst+len1, src + nh, len2*sizeof(uint32));
    269     }
    270 }
    271 /* --------------------------------------------------------------------------- */
    272 IMAGE_EXPORT(void) copy_si32vector_mod(sint32 *src, long nl, long nh, long m, sint32 *dst)
    273 /* --------------------------------------------------------------------------- */
    274 {
    275     long len;
    276     long len1, len2;
    277    
    278     if(nh>nl) {
    279         len = nh - nl + 1; memcpy(dst, src + nl, len*sizeof(sint32));
    280     } else {
    281         len1 = m - nl; memcpy(dst,      src + nl, len1*sizeof(sint32));
    282         len2 = nh + 1; memcpy(dst+len1, src + nh, len2*sizeof(sint32));
    283     }
    284 }
    285 /* ------------------------------------------------------------------------------ */
    286 IMAGE_EXPORT(void) copy_f32vector_mod(float32 *src, long nl, long nh, long m, float32 *dst)
    287 /* ------------------------------------------------------------------------------ */
    288 {
    289     long len;
    290     long len1, len2;
    291    
    292     if(nh>nl) {
    293         len = nh - nl + 1; memcpy(dst, src + nl, len*sizeof(float32));
    294     } else {
    295         len1 = m - nl; memcpy(dst,      src + nl, len1*sizeof(float32));
    296         len2 = nh + 1; memcpy(dst+len1, src + nh, len2*sizeof(float32));
    297     }
    298 }
    299 /* --------------------------------------------------------------------------------- */
    300 IMAGE_EXPORT(void) copy_f64vector_mod(float64 *src, long nl, long nh, long m, float64 *dst)
    301 /* --------------------------------------------------------------------------------- */
    302 {
    303     long len;
    304     long len1, len2;
    305    
    306     if(nh>nl) {
    307         len = nh - nl + 1; memcpy(dst, src + nl, len*sizeof(float64));
    308     } else {
    309         len1 = m - nl; memcpy(dst,      src + nl, len1*sizeof(float64));
    310         len2 = nh + 1; memcpy(dst+len1, src + nh, len2*sizeof(float64));
    311     }
     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)); \
    31268}
    31369
     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 TracChangeset for help on using the changeset viewer.