MCPcopy Create free account
hub / github.com/FastLED/FastLED / wave8Untranspose_2

Function wave8Untranspose_2

src/fl/channels/wave8.cpp.hpp:330–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328// ============================================================================
329
330FL_OPTIMIZE_FUNCTION
331void wave8Untranspose_2(const u8 (&FL_RESTRICT_PARAM transposed)[2 * sizeof(Wave8Byte)],
332 u8 (&FL_RESTRICT_PARAM output)[2 * sizeof(Wave8Byte)]) {
333 // Reverse the 2-lane transposition
334 // Input: 16 bytes of interleaved data (2 bytes per symbol, 8 symbols)
335 // Output: 2 Wave8Byte structures (16 bytes total, de-interleaved)
336
337 Wave8Byte lane_waves[2];
338
339 // Process each of the 8 symbols
340 for (int symbol_idx = 0; symbol_idx < 8; symbol_idx++) {
341 // Read the 2 interleaved bytes for this symbol
342 u16 interleaved = ((u16)transposed[symbol_idx * 2] << 8) |
343 transposed[symbol_idx * 2 + 1];
344
345 // De-interleave bits back to lanes
346 u8 lane0_bits = 0;
347 u8 lane1_bits = 0;
348
349 // Extract bits: interleaved format has alternating bits [L0, L1, L0, L1, ...]
350 // Bits are ordered: [L1_b7, L0_b7, L1_b6, L0_b6, L1_b5, L0_b5, L1_b4, L0_b4, ...]
351 for (int bit = 0; bit < 8; bit++) {
352 // Lane 0 bits are at odd positions (shifted left by 1)
353 if (interleaved & (1 << (bit * 2 + 1))) {
354 lane0_bits |= (1 << bit);
355 }
356 // Lane 1 bits are at even positions
357 if (interleaved & (1 << (bit * 2))) {
358 lane1_bits |= (1 << bit);
359 }
360 }
361
362 lane_waves[0].symbols[symbol_idx].data = lane0_bits;
363 lane_waves[1].symbols[symbol_idx].data = lane1_bits;
364 }
365
366 // Copy de-interleaved data to output
367 fl::isr::memcpy(output, &lane_waves[0], sizeof(Wave8Byte));
368 fl::isr::memcpy(output + sizeof(Wave8Byte), &lane_waves[1], sizeof(Wave8Byte));
369}
370
371FL_OPTIMIZE_FUNCTION
372void wave8Untranspose_4(const u8 (&FL_RESTRICT_PARAM transposed)[4 * sizeof(Wave8Byte)],

Callers 1

FL_TEST_FILEFunction · 0.85

Calls 1

memcpyFunction · 0.50

Tested by

no test coverage detected