2016-08-10 03:27:59 +00:00
|
|
|
#include "Util/ByteSwap.h"
|
|
|
|
|
|
|
|
namespace Util
|
|
|
|
{
|
2016-08-11 03:53:19 +00:00
|
|
|
void FlipEndian16(uint8_t *buffer, size_t size)
|
2016-08-10 03:27:59 +00:00
|
|
|
{
|
|
|
|
for (size_t i = 0; i < (size & ~1); i += 2)
|
|
|
|
{
|
2016-08-11 03:53:19 +00:00
|
|
|
uint8_t tmp = buffer[i + 0];
|
2016-08-10 03:27:59 +00:00
|
|
|
buffer[i + 0] = buffer[i + 1];
|
2016-08-11 03:53:19 +00:00
|
|
|
buffer[i + 1] = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FlipEndian32(uint8_t *buffer, size_t size)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < (size & ~3); i += 4)
|
|
|
|
{
|
|
|
|
uint8_t tmp1 = buffer[i+0];
|
|
|
|
uint8_t tmp2 = buffer[i+1];
|
|
|
|
buffer[i+0] = buffer[i+3];
|
|
|
|
buffer[i+1] = buffer[i+2];
|
|
|
|
buffer[i+2] = tmp2;
|
|
|
|
buffer[i+3] = tmp1;
|
2016-08-10 03:27:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} // Util
|