41a42
> * Giacomo Travaglini
47a49,51
> #include <cassert>
> #include <cstddef>
> #include <type_traits>
48a53,55
> /** Lookup table used for High Speed bit reversing */
> extern const uint8_t reverseLookUpTable[];
>
58,59d64
<
<
157a163
>
158a165,192
> * Takes a variable lenght word and returns the mirrored version
> * (Bit by bit, LSB=>MSB).
> *
> * algorithm from
> * http://graphics.stanford.edu/~seander/bithacks.html
> * #ReverseBitsByLookupTable
> *
> * @param val: variable lenght word
> * @param size: number of bytes to mirror
> * @return mirrored word
> */
> template <class T>
> T
> reverseBits(T val, std::size_t size = sizeof(T))
> {
> static_assert(std::is_integral<T>::value, "Expecting an integer type");
>
> assert(size <= sizeof(T));
>
> T output = 0;
> for (auto byte = 0; byte < size; byte++, val >>= 8) {
> output = (output << 8) | reverseLookUpTable[val & 0xFF];
> }
>
> return output;
> }
>
> /**