Index: soft/giet_vm/applications/rosenfeld/nrc2/include/nrmem2x.h
===================================================================
--- soft/giet_vm/applications/rosenfeld/nrc2/include/nrmem2x.h	(revision 772)
+++ soft/giet_vm/applications/rosenfeld/nrc2/include/nrmem2x.h	(revision 826)
@@ -12,10 +12,4 @@
 #define _NRMEM2X_H_
 
-#ifdef __cplusplus
-#ifdef PRAGMA_VERBOSE
-#pragma message ("C++")
-#endif
-extern "C" {
-#endif
 
 /* ------------------------------------------ */
@@ -27,78 +21,88 @@
 /* ------------------------------------------ */
 
-IMAGE_EXPORT(void) reset_endline_bmatrix   (byte   **m, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) reset_endline_i16matrix (int16  **m, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) reset_endline_ui16matrix(uint16 **m, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) reset_endline_imatrix   (int    **m, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) reset_endline_i32matrix (int32  **m, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) reset_endline_ui32matrix(uint32 **m, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) reset_endline_i64matrix (int64  **m, long nrl, long nrh, long ncl, long nch);
+#define reset_endline_type_matrix(t) \
+void short_name(t,reset_endline_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch); \
+void short_name(t,endline_,matrix)(t ** m, int32_t i, int32_t l); \
+void short_name(t,endline0_,matrix)(t ** m, int32_t i, int32_t l, int32_t ncl); \
+void short_name(t,endline1_,matrix)(t ** m, int32_t i, int32_t l, int32_t ncl);
 
-IMAGE_EXPORT(void) endline_bmatrix   (byte   **m, long i, long l);
-IMAGE_EXPORT(void) endline_i16matrix (int16  **m, long i, long l);
-IMAGE_EXPORT(void) endline_ui16matrix(uint16 **m, long i, long l);
-IMAGE_EXPORT(void) endline_imatrix   (int    **m, long i, long l);
-IMAGE_EXPORT(void) endline_i32matrix (int32  **m, long i, long l);
-IMAGE_EXPORT(void) endline_ui32matrix(uint32 **m, long i, long l);
-IMAGE_EXPORT(void) endline_i64matrix (int64  **m, long i, long l);
+reset_endline_type_matrix(int8_t);
+reset_endline_type_matrix(uint8_t);
+reset_endline_type_matrix(int16_t);
+reset_endline_type_matrix(uint16_t);
+reset_endline_type_matrix(int32_t);
+reset_endline_type_matrix(uint32_t);
+reset_endline_type_matrix(int64_t);
+reset_endline_type_matrix(uint64_t);
 
-IMAGE_EXPORT(void) endline0_bmatrix   (byte   **m, long i, long l, long ncl);
-IMAGE_EXPORT(void) endline0_i16matrix (int16  **m, long i, long l, long ncl);
-IMAGE_EXPORT(void) endline0_ui16matrix(uint16 **m, long i, long l, long ncl);
-IMAGE_EXPORT(void) endline0_imatrix   (int    **m, long i, long l, long ncl);
-IMAGE_EXPORT(void) endline0_i32matrix (int32  **m, long i, long l, long ncl);
-IMAGE_EXPORT(void) endline0_ui32matrix(uint32 **m, long i, long l, long ncl);
-IMAGE_EXPORT(void) endline0_i64matrix (int64  **m, long i, long l, long ncl);
 
-IMAGE_EXPORT(void) endline1_bmatrix   (byte   **m, long i, long l, long ncl);
-IMAGE_EXPORT(void) endline1_i16matrix (int16  **m, long i, long l, long ncl);
-IMAGE_EXPORT(void) endline1_ui16matrix(uint16 **m, long i, long l, long ncl);
-IMAGE_EXPORT(void) endline1_imatrix   (int    **m, long i, long l, long ncl);
-IMAGE_EXPORT(void) endline1_i32matrix (int32  **m, long i, long l, long ncl);
-IMAGE_EXPORT(void) endline1_ui32matrix(uint32 **m, long i, long l, long ncl);
-IMAGE_EXPORT(void) endline1_i64matrix (int64  **m, long i, long l, long ncl);
+#undef resize_type_matrix
+#define resize_type_matrix(t) \
+void short_name(t,resize_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch);
 
-IMAGE_EXPORT(void) resize_si16Pmatrix(si16Point **m, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) resize_ui16Pmatrix(ui16Point **m, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) resize_si32Pmatrix(si32Point **m, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) resize_ui32Pmatrix(ui32Point **m, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) resize_f32Pmatrix(f32Point   **m, long nrl, long nrh, long ncl, long nch);
+resize_type_matrix(si16Point);
+resize_type_matrix(ui16Point);
+resize_type_matrix(si32Point);
+resize_type_matrix(ui32Point);
+resize_type_matrix(f32Point);
+resize_type_matrix(si16Triplet);
+resize_type_matrix(ui16Triplet);
+resize_type_matrix(si32Triplet);
+resize_type_matrix(ui32Triplet);
+resize_type_matrix(f32Triplet);
 
-// Triplet Matrix
-IMAGE_EXPORT(void) resize_si16Tmatrix(si16Triplet **m, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) resize_ui16Tmatrix(ui16Triplet **m, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) resize_si32Tmatrix(si32Triplet **m, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) resize_ui32Tmatrix(ui32Triplet **m, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) resize_f32Tmatrix (f32Triplet  **m, long nrl, long nrh, long ncl, long nch);
+
+#define type_matrix_reverse(t) \
+void short_name(t,,matrix_reverse)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch);
+
+type_matrix_reverse(int8_t);
+type_matrix_reverse(uint8_t);
+type_matrix_reverse(int16_t);
+type_matrix_reverse(uint16_t);
+type_matrix_reverse(int32_t);
+type_matrix_reverse(uint32_t);
+type_matrix_reverse(int64_t);
+type_matrix_reverse(uint64_t);
+type_matrix_reverse(float);
+type_matrix_reverse(double);
 
 
 
+#define desinterlace_type_matrix(t) \
+void short_name(t,desinterlace_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** D0, t ** D1);
 
-/*
- * --------------
- * matrix_reverse
- * --------------
- */
+desinterlace_type_matrix(int8_t);
+desinterlace_type_matrix(uint8_t);
+desinterlace_type_matrix(int16_t);
+desinterlace_type_matrix(uint16_t);
+desinterlace_type_matrix(int32_t);
+desinterlace_type_matrix(uint32_t);
+desinterlace_type_matrix(int64_t);
+desinterlace_type_matrix(uint64_t);
+desinterlace_type_matrix(float);
+desinterlace_type_matrix(double);
+desinterlace_type_matrix(rgb8);
+desinterlace_type_matrix(rgbx8);
 
-//IMAGE_EXPORT(void) bmatrix_reverse (byte   **m, long nrl, long nrh, long ncl, long nch);
-//IMAGE_EXPORT(void) si16matrix_reverse (sint16   **m, long nrl, long nrh, long ncl, long nch);
-//IMAGE_EXPORT(void) usmatrix_reverse(uint16 **m, long nrl, long nrh, long ncl, long nch);
 
-/* copie */
-IMAGE_EXPORT(void) copyc_bmatrix(byte **src,long nrl,long nrh,long ncl, long nch, byte **cond, byte c, byte **dst);
+#define interlace_type_matrix(t) \
+void short_name(t,interlace_,matrix)(t ** S0, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** S1, t ** D);
 
-IMAGE_EXPORT(void) complete_border_bmatrix (byte **m, long nrl,long nrh,long ncl, long nch, long n);
-IMAGE_EXPORT(void) complete_border1_bmatrix(byte **m, long nrl,long nrh,long ncl, long nch);
-IMAGE_EXPORT(void) complete_border2_bmatrix(byte **m, long nrl,long nrh,long ncl, long nch);
+interlace_type_matrix(int8_t);
+interlace_type_matrix(uint8_t);
+interlace_type_matrix(int16_t);
+interlace_type_matrix(uint16_t);
+interlace_type_matrix(int32_t);
+interlace_type_matrix(uint32_t);
+interlace_type_matrix(int64_t);
+interlace_type_matrix(uint64_t);
+interlace_type_matrix(float);
+interlace_type_matrix(double);
+interlace_type_matrix(rgb8);
+interlace_type_matrix(rgbx8);
 
-IMAGE_EXPORT(void) copy1c_bmatrix    (byte    **X, long nc, byte    **Y, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) copy1c_si16matrix (sint16  **X, long nc, sint16  **Y, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) copy1c_ui16matrix (uint16  **X, long nc, uint16  **Y, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) copy1c_si32matrix (sint32  **X, long nc, sint32  **Y, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) copy1c_ui32matrix (uint32  **X, long nc, uint32  **Y, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) copy1c_f32matrix  (float32 **X, long nc, float32 **Y, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) copy1c_f64matrix  (float64 **X, long nc, float64 **Y, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) copy1c_rgb8matrix (rgb8    **X, long nc, rgb8    **Y, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) copy1c_rgbx8matrix(rgbx8   **X, long nc, rgbx8   **Y, long nrl, long nrh, long ncl, long nch);
+
+#define copyc_type_matrix(t) \
+void short_name(t,copyc_,matrix)(t ** src, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** cond, t c, t ** dst) \
 
 /*
@@ -106,57 +110,56 @@
  * dst(i,j) = src(i,j) si cond(i,j) == c
  */
-/*
-IMAGE_EXPORT(void) copy1r_bmatrix    (byte   **X, long nr, byte   **Y, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) copy1r_smatrix    (sint16   **X, long nr, sint16   **Y, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) copy1r_usmatrix   (uint16 **X, long nr, uint16 **Y, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) copy1r_imatrix    (int    **X, long nr, int    **Y, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) copy1r_uimatrix   (uint   **X, long nr, uint   **Y, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) copy1r_matrix     (float  **X, long nr, float  **Y, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) copy1r_dmatrix    (double **X, long nr, double **Y, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) copy1r_rgb8matrix (rgb8   **X, long nr, rgb8   **Y, long nrl, long nrh, long ncl, long nch);
-IMAGE_EXPORT(void) copy1r_rgbx8matrix(rgbx8  **X, long nr, rgbx8  **Y, long nrl, long nrh, long ncl, long nch);
 
-IMAGE_EXPORT(void) copy_bmatrix    (byte   **m1, long nrl1,long nrh1,long ncl1, long nch1, byte   **m2, long nrl2, long nrh2, long ncl2, long nch2);
-IMAGE_EXPORT(void) copy_smatrix    (sint16   **m1, long nrl1,long nrh1,long ncl1, long nch1, sint16   **m2, long nrl2, long nrh2, long ncl2, long nch2);
-IMAGE_EXPORT(void) copy_usmatrix   (uint16 **m1, long nrl1,long nrh1,long ncl1, long nch1, uint16 **m2, long nrl2, long nrh2, long ncl2, long nch2);
-IMAGE_EXPORT(void) copy_imatrix    (int    **m1, long nrl1,long nrh1,long ncl1, long nch1, int    **m2, long nrl2, long nrh2, long ncl2, long nch2);
-IMAGE_EXPORT(void) copy_uimatrix   (uint   **m1, long nrl1,long nrh1,long ncl1, long nch1, uint   **m2, long nrl2, long nrh2, long ncl2, long nch2);
-IMAGE_EXPORT(void) copy_matrix     (float  **m1, long nrl1,long nrh1,long ncl1, long nch1, float  **m2, long nrl2, long nrh2, long ncl2, long nch2);
-IMAGE_EXPORT(void) copy_dmatrix    (double **m1, long nrl1,long nrh1,long ncl1, long nch1, double **m2, long nrl2, long nrh2, long ncl2, long nch2);
-IMAGE_EXPORT(void) copy_rgb8matrix (rgb8   **m1, long nrl1,long nrh1,long ncl1, long nch1, rgb8   **m2, long nrl2, long nrh2, long ncl2, long nch2);
-IMAGE_EXPORT(void) copy_rgbx8matrix(rgbx8  **m1, long nrl1,long nrh1,long ncl1, long nch1, rgbx8  **m2, long nrl2, long nrh2, long ncl2, long nch2);
-
-IMAGE_EXPORT(void) copy_sub_bmatrix(byte **src, long nrl,long nrh,long ncl, long nch, byte **dst);
-
-IMAGE_EXPORT(void) extract_bmatrix (byte   **src, long nrl,long nrh,long ncl, long nch, byte   **dst);
-IMAGE_EXPORT(void) extract_smatrix (sint16   **src, long nrl,long nrh,long ncl, long nch, sint16   **dst);
-IMAGE_EXPORT(void) extract_usmatrix(uint16 **src, long nrl,long nrh,long ncl, long nch, uint16 **dst);
-IMAGE_EXPORT(void) extract_imatrix (int    **src, long nrl,long nrh,long ncl, long nch, int    **dst);
-IMAGE_EXPORT(void) extract_uimatrix(uint   **src, long nrl,long nrh,long ncl, long nch, uint   **dst);
-IMAGE_EXPORT(void) extract_matrix  (float  **src, long nrl,long nrh,long ncl, long nch, float  **dst);
-IMAGE_EXPORT(void) extract_dmatrix (double **src, long nrl,long nrh,long ncl, long nch, double **dst);
-*/
-IMAGE_EXPORT(void) copy_center_bmatrix(byte **src, long nrl0,long nrh0,long ncl0, long nch0, byte **dst, long nrl1,long nrh1,long ncl1, long nch1);
-
-IMAGE_EXPORT(void) copy_sub_imatrix(int  **src, long nrl,long nrh,long ncl, long nch, int **dst);
-
-IMAGE_EXPORT(void) copy_sub_imatrix_index(int **src, long nrl,long nrh, long ncl, long nch, int **dst,int *index);
-
-/* --------------------- */
-/* --- De-Interleave --- */
-/* --------------------- */
-
-IMAGE_EXPORT(void) desinterlace_bmatrix   (byte **S, long nrl, long nrh, long ncl, long nch, byte **D0, byte **D1);
-IMAGE_EXPORT(void) desinterlace_rgb8matrix(rgb8 **S, long nrl, long nrh, long ncl, long nch, rgb8 **D0, rgb8 **D1);
-
-IMAGE_EXPORT(void) interlace_bmatrix   (byte **S0, long nrl, long nrh, long ncl, long nch, byte **S1, byte **D);
-IMAGE_EXPORT(void) interlace_rgb8matrix(rgb8 **S0, long nrl, long nrh, long ncl, long nch, rgb8 **S1, rgb8 **D);
+copyc_type_matrix(int8_t);
+copyc_type_matrix(uint8_t);
+copyc_type_matrix(int16_t);
+copyc_type_matrix(uint16_t);
+copyc_type_matrix(int32_t);
+copyc_type_matrix(uint32_t);
+copyc_type_matrix(int64_t);
+copyc_type_matrix(uint64_t);
+copyc_type_matrix(float);
+copyc_type_matrix(double);
+copyc_type_matrix(rgb8);
+copyc_type_matrix(rgbx8);
 
 
-#ifdef __cplusplus
-}
-#endif
+#define complete_border_type_matrix(t) \
+void short_name(t,complete_border_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, int32_t n); \
+void short_name(t,complete_border1_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch); \
+void short_name(t,complete_border2_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch);
 
-#else
-//#pragma message(" Warning : attemp to re-include nrmem2x.h")
+complete_border_type_matrix(int8_t);
+complete_border_type_matrix(uint8_t);
+complete_border_type_matrix(int16_t);
+complete_border_type_matrix(uint16_t);
+complete_border_type_matrix(int32_t);
+complete_border_type_matrix(uint32_t);
+complete_border_type_matrix(int64_t);
+complete_border_type_matrix(uint64_t);
+complete_border_type_matrix(float);
+complete_border_type_matrix(double);
+complete_border_type_matrix(rgb8);
+complete_border_type_matrix(rgbx8);
+
+
+#define copy1c_type_matrix(t) \
+void short_name(t,copy1c_,matrix)(t ** X, int32_t nc, t ** Y, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch); \
+void short_name(t,copy1r_,matrix)(t ** X, int32_t nr, t ** Y, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch);
+
+copy1c_type_matrix(int8_t);
+copy1c_type_matrix(uint8_t);
+copy1c_type_matrix(int16_t);
+copy1c_type_matrix(uint16_t);
+copy1c_type_matrix(int32_t);
+copy1c_type_matrix(uint32_t);
+copy1c_type_matrix(int64_t);
+copy1c_type_matrix(uint64_t);
+copy1c_type_matrix(float);
+copy1c_type_matrix(double);
+copy1c_type_matrix(rgb8);
+copy1c_type_matrix(rgbx8);
+
+
 #endif /* _NRMEM2X_H_ */
+
