Ignore:
Timestamp:
May 6, 2016, 3:06:29 PM (8 years ago)
Author:
meunier
Message:
  • Added several versions of rosenfeld: { SLOW, FAST } x { FEATURES, NO_FEATURES }
  • Added native linux compilation support
  • Added a script to check results natively
  • Started to refactor nrc code
File:
1 edited

Legend:

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

    r772 r821  
    1717#include <malloc.h>
    1818#include <math.h> // fabs
    19 // #include <memory.h> // memcpy
    2019
     20#include "nrc_os_config.h"
    2121#include "mypredef.h"
    2222#include "nrtype.h"
     
    2525#include "nrkernel.h"
    2626
    27 /* ------------------------------------------------------------------------------------- */
    28 IMAGE_EXPORT(void) addcnz_bmatrix(byte **src,long nrl,long nrh,long ncl, long nch, byte  cte, byte **dst)
    29 /* ------------------------------------------------------------------------------------- */
    30 {
    31         long i,j;
    32         byte *Xi, *Yi;
    33        
    34         for(i=nrl; i<=nrh; i++) {
    35                 Xi = src[i];
    36                 Yi = dst[i];
    37                 for(j=ncl; j<=nch; j++) {
    38                         if(Xi[j])
    39                                 Yi[j] = Xi[j] + cte;
    40                         else
    41                                 Yi[j] = Xi[j];
    42                 }
    43         }
     27
     28#undef addcnz_type_matrix
     29#define addcnz_type_matrix(t) \
     30void short_name(t,addcnz_,matrix)(t ** src, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t cte, t ** dst) \
     31{                                              \
     32        t * Xi;                                    \
     33    t * Yi;                                    \
     34        for (int32_t i = nrl; i <= nrh; i++) {     \
     35                Xi = src[i];                           \
     36                Yi = dst[i];                           \
     37                for (int32_t j = ncl; j <= nch; j++) { \
     38                        if (Xi[j] != 0) {                  \
     39                                Yi[j] = Xi[j] + cte;           \
     40            }                                  \
     41                        else {                             \
     42                                Yi[j] = Xi[j];                 \
     43            }                                  \
     44                }                                      \
     45        }                                          \
    4446}
    45 /* ----------------------------------------------------------------------------------- */
    46 IMAGE_EXPORT(void) addandc_bmatrix(byte **src,long nrl,long nrh,long ncl, long nch, byte  cte, byte **dst)
    47 /* ----------------------------------------------------------------------------------- */
    48 {
    49         long i,j;
    50         byte *Xi, *Yi;
    51        
    52         for(i=nrl; i<=nrh; i++) {
    53                 Xi = src[i];
    54                 Yi = dst[i];
    55                 for(j=ncl; j<=nch; j++) {
    56                         if(Xi[j])
    57                                 Yi[j] = Xi[j] + cte;
    58                         else
    59                                 Yi[j] = Xi[i];
    60                 }
    61         }
     47
     48addcnz_type_matrix(int8_t);
     49addcnz_type_matrix(uint8_t);
     50addcnz_type_matrix(int16_t);
     51addcnz_type_matrix(uint16_t);
     52addcnz_type_matrix(int32_t);
     53addcnz_type_matrix(uint32_t);
     54addcnz_type_matrix(int64_t);
     55addcnz_type_matrix(uint64_t);
     56addcnz_type_matrix(float);
     57addcnz_type_matrix(double);
     58
     59
     60#undef addandc_type_matrix
     61#define addandc_type_matrix(t) \
     62void short_name(t,addandc_,matrix)(t ** src, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t cte, t ** dst) \
     63{                                              \
     64        t * Xi;                                    \
     65    t * Yi;                                    \
     66        for (int32_t i = nrl; i <= nrh; i++) {     \
     67                Xi = src[i];                           \
     68                Yi = dst[i];                           \
     69                for (int32_t j = ncl; j <= nch; j++) { \
     70                        if (Xi[j] != 0) {                  \
     71                Yi[j] = Xi[j] + cte;           \
     72            }                                  \
     73                }                                      \
     74        }                                          \
    6275}
    63 /* ---------------------------------------------------------------------------------------- */
    64 IMAGE_EXPORT(void) addandc_si16matrix(sint16 **src,long nrl,long nrh,long ncl, long nch, short cte, sint16 **dst)
    65 /* ---------------------------------------------------------------------------------------- */
    66 {
    67         long i,j;
    68         sint16 *Xi, *Yi;
    69        
    70         for(i=nrl; i<=nrh; i++) {
    71                 Xi = src[i];
    72                 Yi = dst[i];
    73                 for(j=ncl; j<=nch; j++) {
    74                         if(Xi[j]) Yi[j] = Xi[j] + cte;
    75                 }
    76         }
     76
     77addandc_type_matrix(int8_t);
     78addandc_type_matrix(uint8_t);
     79addandc_type_matrix(int16_t);
     80addandc_type_matrix(uint16_t);
     81addandc_type_matrix(int32_t);
     82addandc_type_matrix(uint32_t);
     83addandc_type_matrix(int64_t);
     84addandc_type_matrix(uint64_t);
     85addandc_type_matrix(float);
     86addandc_type_matrix(double);
     87
     88
     89#undef sum_type_matrix
     90#define sum_type_matrix(t,rt) \
     91rt short_name(t,sum_,matrix)(t ** m, int32_t nrl, int32_t nrh,int32_t ncl, int32_t nch) \
     92{                                              \
     93        rt s = 0;                                  \
     94        t * Xi;                                    \
     95        for (int32_t i = nrl; i <= nrh; i++) {     \
     96                Xi = m[i];                             \
     97                for (int32_t j = ncl; j <= nch; j++) { \
     98                        s += Xi[j];                        \
     99                }                                      \
     100    }                                          \
     101    return s;                                  \
    77102}
    78 /* ------------------------------------------------------------------------------------------- */
    79 IMAGE_EXPORT(void) addandc_ui16matrix(uint16 **src,long nrl,long nrh,long ncl, long nch, short cte, uint16 **dst)
    80 /* ------------------------------------------------------------------------------------------ */
    81 {
    82         long i,j;
    83         uint16 *Xi, *Yi;
    84        
    85         for(i=nrl; i<=nrh; i++) {
    86                 Xi = src[i];
    87                 Yi = dst[i];
    88                 for(j=ncl; j<=nch; j++) {
    89                         if(Xi[j]) Yi[j] = Xi[j] + cte;
    90                 }
    91         }
    92 }
    93 /* ----------------------------------------------------------- */
    94 IMAGE_EXPORT(int) count_bmatrix(byte **m, long nrl,long nrh,long ncl, long nch)
    95 /* ----------------------------------------------------------- */
    96 {
    97         long i, j;
    98         int s = 0;
    99         byte *Xi;
    100        
    101         for(i=nrl; i<=nrh; i++) {
    102                 Xi = m[i];
    103                 for(j=ncl; j<=nch; j++) {
    104                         s += Xi[j];
    105                 }
    106     }
    107     return s;
    108 }
     103
     104
     105sum_type_matrix(int8_t, int32_t);
     106sum_type_matrix(uint8_t, uint32_t);
     107sum_type_matrix(int16_t, int32_t);
     108sum_type_matrix(uint16_t, uint32_t);
     109sum_type_matrix(int32_t, int64_t);
     110sum_type_matrix(uint32_t, uint64_t);
     111sum_type_matrix(int64_t, int64_t);
     112sum_type_matrix(uint64_t, uint64_t);
     113sum_type_matrix(float, float);
     114sum_type_matrix(double, double);
     115
     116
     117// Local Variables:
     118// tab-width: 4
     119// c-basic-offset: 4
     120// c-file-offsets:((innamespace . 0)(inline-open . 0))
     121// indent-tabs-mode: nil
     122// End:
     123
     124// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     125
Note: See TracChangeset for help on using the changeset viewer.