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

◆ transpose8()

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

Templated 8x8 bit transpose with custom stride.

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

Template Parameters
mInput stride (1 for sequential bytes)
nOutput stride (1 for sequential bytes)
Parameters
AInput array (8 bytes at stride m)
BOutput array (8 bytes at stride n, transposed)
Examples
/home/runner/work/FastLED/FastLED/src/fl/math/transposition.h.

Definition at line 186 of file transposition.h.

186 {
187 fl::u32 x, y, t;
188
189 // Load the array and pack it into x and y.
190 if(m == 1) {
191 y = *(fl::u32*)(A);
192 x = *(fl::u32*)(A+4);
193 } else {
194 x = (fl::u32(A[0])<<24) | (fl::u32(A[m])<<16) | (fl::u32(A[2*m])<<8) | A[3*m];
195 y = (fl::u32(A[4*m])<<24) | (fl::u32(A[5*m])<<16) | (fl::u32(A[6*m])<<8) | A[7*m];
196 }
197
198 // pre-transform x
199 t = (x ^ (x >> 7)) & 0x00AA00AA; x = x ^ t ^ (t << 7);
200 t = (x ^ (x >>14)) & 0x0000CCCC; x = x ^ t ^ (t <<14);
201
202 // pre-transform y
203 t = (y ^ (y >> 7)) & 0x00AA00AA; y = y ^ t ^ (t << 7);
204 t = (y ^ (y >>14)) & 0x0000CCCC; y = y ^ t ^ (t <<14);
205
206 // final transform
207 t = (x & 0xF0F0F0F0) | ((y >> 4) & 0x0F0F0F0F);
208 y = ((x << 4) & 0xF0F0F0F0) | (y & 0x0F0F0F0F);
209 x = t;
210
211 B[7*n] = y; y >>= 8;
212 B[6*n] = y; y >>= 8;
213 B[5*n] = y; y >>= 8;
214 B[4*n] = y;
215
216 B[3*n] = x; x >>= 8;
217 B[2*n] = x; x >>= 8;
218 B[n] = x; x >>= 8;
219 B[0] = x;
220}
int y
Definition simple.h:93
int x
Definition simple.h:92
FL_DISABLE_WARNING_PUSH unsigned char * B

References B, FASTLED_FORCE_INLINE, FL_NOEXCEPT, t, x, and y.