FastLED 3.9.15
Loading...
Searching...
No Matches

◆ transpose8()

template<int m, int n>
FASTLED_FORCE_INLINE void transpose8 ( unsigned char * A,
unsigned char * B )

Templated bit-rotating function.

Based on code found here: https://web.archive.org/web/20190108225554/http://www.hackersdelight.org/hdcodetxt/transpose8.c.txt

Definition at line 254 of file bitswap.h.

254 {
255 fl::u32 x, y, t;
256
257 // Load the array and pack it into x and y.
258 if(m == 1) {
259 y = *(unsigned int*)(A);
260 x = *(unsigned int*)(A+4);
261 } else {
262 x = (A[0]<<24) | (A[m]<<16) | (A[2*m]<<8) | A[3*m];
263 y = (A[4*m]<<24) | (A[5*m]<<16) | (A[6*m]<<8) | A[7*m];
264 }
265
266 // pre-transform x
267 t = (x ^ (x >> 7)) & 0x00AA00AA; x = x ^ t ^ (t << 7);
268 t = (x ^ (x >>14)) & 0x0000CCCC; x = x ^ t ^ (t <<14);
269
270 // pre-transform y
271 t = (y ^ (y >> 7)) & 0x00AA00AA; y = y ^ t ^ (t << 7);
272 t = (y ^ (y >>14)) & 0x0000CCCC; y = y ^ t ^ (t <<14);
273
274 // final transform
275 t = (x & 0xF0F0F0F0) | ((y >> 4) & 0x0F0F0F0F);
276 y = ((x << 4) & 0xF0F0F0F0) | (y & 0x0F0F0F0F);
277 x = t;
278
279 B[7*n] = y; y >>= 8;
280 B[6*n] = y; y >>= 8;
281 B[5*n] = y; y >>= 8;
282 B[4*n] = y;
283
284 B[3*n] = x; x >>= 8;
285 B[2*n] = x; x >>= 8;
286 B[n] = x; x >>= 8;
287 B[0] = x;
288 // B[0]=x>>24; B[n]=x>>16; B[2*n]=x>>8; B[3*n]=x>>0;
289 // B[4*n]=y>>24; B[5*n]=y>>16; B[6*n]=y>>8; B[7*n]=y>>0;
290}
int y
Definition simple.h:93
int x
Definition simple.h:92
static uint32_t t
Definition Luminova.h:54

References FASTLED_FORCE_INLINE, t, x, and y.