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 253 of file bitswap.h.

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

References FASTLED_FORCE_INLINE, x, and y.