Endian Swapper buffer swapper changes reverted
This commit is contained in:
parent
1d1bb88a6f
commit
1f4391f56e
@ -47,17 +47,25 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Swap endianness of buffer entries
|
||||
* Template argument specifies buffer type
|
||||
* @param out
|
||||
* @param in
|
||||
* @param size
|
||||
*/
|
||||
template<typename T>
|
||||
static void swap(uint8_t * out, const uint8_t * in, uint32_t size) {
|
||||
static void swap(T * out, const T * in, uint32_t size) {
|
||||
#ifndef BYTE_ORDER_SYSTEM
|
||||
#error BYTE_ORDER_SYSTEM not defined
|
||||
#elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN
|
||||
const uint8_t * in_buffer = reinterpret_cast<const uint8_t *>(in);
|
||||
uint8_t * out_buffer = reinterpret_cast<uint8_t *>(out);
|
||||
for (uint8_t count = 0; count < size; count++) {
|
||||
for(uint8_t i = 0; i < sizeof(T);i++) {
|
||||
out[sizeof(T)* (count + 1) - i - 1] = in[count * sizeof(T) + i];
|
||||
out_buffer[sizeof(T)* (count + 1) - i - 1] = in_buffer[count * sizeof(T) + i];
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
#elif BYTE_ORDER_SYSTEM == BIG_ENDIAN
|
||||
memcpy(out, in, size*sizeof(T));
|
||||
|
Loading…
Reference in New Issue
Block a user