diff --git a/src/common/bit_util.h b/src/common/bit_util.h index 93e6e652..81a62b44 100644 --- a/src/common/bit_util.h +++ b/src/common/bit_util.h @@ -218,6 +218,11 @@ constexpr T RotateRight(T value, size_t amount) { return static_cast((x >> amount) | (x << (BitSize() - amount))); } +constexpr u32 SwapHalves32(u32 value) { + return ((value & 0xFFFF0000U) >> 16) | + ((value & 0x0000FFFFU) << 16); +} + constexpr u16 SwapBytes16(u16 value) { return static_cast(u32{value} >> 8 | u32{value} << 8); }