40 #include <visp3/core/vpEndian.h>
51 const unsigned int magic_8 = 8;
52 const unsigned int magic_0x00FF = 0x00FF;
53 const unsigned int magic_0xFF00 = 0xFF00;
54 return (((val >> magic_8) & magic_0x00FF) | ((val << magic_8) & magic_0xFF00));
63 const unsigned int magic_8 = 8;
64 const unsigned int magic_24 = 24;
65 const unsigned int magic_0x000000FF = 0x000000FFU;
66 const unsigned int magic_0x0000FF00 = 0x0000FF00U;
67 const unsigned int magic_0x00FF0000 = 0x00FF0000U;
68 const unsigned int magic_0xFF000000 = 0xFF000000U;
69 return (((val >> magic_24) & magic_0x000000FF) | ((val >> magic_8) & magic_0x0000FF00) | ((val << magic_8) & magic_0x00FF0000) |
70 ((val << magic_24) & magic_0xFF000000));
85 const unsigned int index_0 = 0;
86 const unsigned int index_1 = 1;
87 const unsigned int index_2 = 2;
88 const unsigned int index_3 = 3;
90 dat2.b[index_0] = dat1.b[index_3];
91 dat2.b[index_1] = dat1.b[index_2];
92 dat2.b[index_2] = dat1.b[index_1];
93 dat2.b[index_3] = dat1.b[index_0];
109 const unsigned int index_0 = 0;
110 const unsigned int index_1 = 1;
111 const unsigned int index_2 = 2;
112 const unsigned int index_3 = 3;
113 const unsigned int index_4 = 4;
114 const unsigned int index_5 = 5;
115 const unsigned int index_6 = 6;
116 const unsigned int index_7 = 7;
118 dat2.b[index_0] = dat1.b[index_7];
119 dat2.b[index_1] = dat1.b[index_6];
120 dat2.b[index_2] = dat1.b[index_5];
121 dat2.b[index_3] = dat1.b[index_4];
122 dat2.b[index_4] = dat1.b[index_3];
123 dat2.b[index_5] = dat1.b[index_2];
124 dat2.b[index_6] = dat1.b[index_1];
125 dat2.b[index_7] = dat1.b[index_0];
136 #ifdef VISP_LITTLE_ENDIAN
137 return *
reinterpret_cast<uint16_t *
>(ptr);
138 #elif defined(VISP_BIG_ENDIAN)
139 return swap16bits(*
reinterpret_cast<uint16_t *
>(ptr));
141 throw std::runtime_error(
"Not supported endianness for correct custom reinterpret_cast() function.");
VISP_EXPORT float swapFloat(float f)
VISP_EXPORT uint32_t swap32bits(uint32_t val)
VISP_EXPORT uint16_t reinterpret_cast_uchar_to_uint16_LE(unsigned char *const ptr)
VISP_EXPORT double swapDouble(double d)
VISP_EXPORT uint16_t swap16bits(uint16_t val)