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

◆ wave8_transpose_4_bf1()

FASTLED_FORCE_INLINE FL_IRAM FL_OPTIMIZE_FUNCTION void fl::detail::wave8_transpose_4_bf1 ( const u8 lanes[4],
u8 W0,
u8 W1,
u8 output[4 *sizeof(Wave8Byte)] )

BF1 for 4-lane Wave8.

Output: 8 symbols × 4 bytes = 32 bytes. Each byte packs 2 pulses × 4 lanes — high nibble = earlier pulse, low nibble = later pulse; within each nibble, lanes 0..3 in bits 0..3.

Definition at line 370 of file wave8.hpp.

372 {
373 u8 d_mask[8];
374 u8 m0_mask[8];
375 const u8 D_byte = W0 ^ W1;
376 for (int p = 0; p < 8; ++p) {
377 const int shift = 7 - p;
378 d_mask[p] = ((D_byte >> shift) & 1) ? 0xFFu : 0x00u;
379 m0_mask[p] = ((W0 >> shift) & 1) ? 0xFFu : 0x00u;
380 }
381 // Bit transpose: cols[s] (low nibble) = bit(7-s) of lanes 0..3.
382 // spreadA(lanes[L]) puts the 4 high-nibble bits of lanes[L] into bit 0 of
383 // 4 separate bytes; OR'd across lanes with shifts gives 4 bytes (cols[0..3]).
384 const u32 aLo = spreadA(lanes[0]) | (spreadA(lanes[1]) << 1)
385 | (spreadA(lanes[2]) << 2) | (spreadA(lanes[3]) << 3);
386 const u32 bLo = spreadB(lanes[0]) | (spreadB(lanes[1]) << 1)
387 | (spreadB(lanes[2]) << 2) | (spreadB(lanes[3]) << 3);
388 u8 cols[8];
389 cols[0] = static_cast<u8>(aLo);
390 cols[1] = static_cast<u8>(aLo >> 8);
391 cols[2] = static_cast<u8>(aLo >> 16);
392 cols[3] = static_cast<u8>(aLo >> 24);
393 cols[4] = static_cast<u8>(bLo);
394 cols[5] = static_cast<u8>(bLo >> 8);
395 cols[6] = static_cast<u8>(bLo >> 16);
396 cols[7] = static_cast<u8>(bLo >> 24);
397 for (int s = 0; s < 8; ++s) {
398 const u8 col = cols[s]; // bits 0..3 = lanes 0..3
399 for (int k = 0; k < 4; ++k) {
400 const int p_hi = 2 * k;
401 const int p_lo = 2 * k + 1;
402 const u8 hi = static_cast<u8>((m0_mask[p_hi] & 0xF0u) ^ ((col << 4) & d_mask[p_hi]));
403 const u8 lo = static_cast<u8>((m0_mask[p_lo] & 0x0Fu) ^ (col & d_mask[p_lo]));
404 output[s * 4 + k] = static_cast<u8>(hi | lo);
405 }
406 }
407}
FASTLED_FORCE_INLINE u32 spreadA(u8 v)
Pulses 7,6,5,4 of v (byte j = bit (7-j)). Depends only on the high nibble.
FASTLED_FORCE_INLINE u32 spreadB(u8 v)
Pulses 3,2,1,0 of v (byte j = bit (3-j)). Depends only on the low nibble.
unsigned char u8
Definition stdint.h:131
@ W1
White is second.
Definition eorder.h:26
@ W0
White is first.
Definition eorder.h:27

References spreadA(), spreadB(), fl::W0, and fl::W1.

Referenced by fl::wave8Transpose_4_bf1().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: