| 369 | } |
| 370 | |
| 371 | FL_OPTIMIZE_FUNCTION |
| 372 | void wave8Untranspose_4(const u8 (&FL_RESTRICT_PARAM transposed)[4 * sizeof(Wave8Byte)], |
| 373 | u8 (&FL_RESTRICT_PARAM output)[4 * sizeof(Wave8Byte)]) { |
| 374 | // Reverse the 4-lane transposition |
| 375 | // Input: 32 bytes of interleaved data (4 bytes per symbol, 8 symbols) |
| 376 | // Output: 4 Wave8Byte structures (32 bytes total, de-interleaved) |
| 377 | |
| 378 | Wave8Byte lane_waves[4]; |
| 379 | |
| 380 | // Process each of the 8 symbols |
| 381 | for (int symbol_idx = 0; symbol_idx < 8; symbol_idx++) { |
| 382 | u8 lane_bytes[4] = {0, 0, 0, 0}; |
| 383 | |
| 384 | // Process 4 input bytes (2 pulses per byte) |
| 385 | for (int byte_idx = 0; byte_idx < 4; byte_idx++) { |
| 386 | u8 input_byte = transposed[symbol_idx * 4 + byte_idx]; |
| 387 | |
| 388 | // Calculate which pulse bits these correspond to |
| 389 | int pulse_bit_hi = 7 - (byte_idx * 2); |
| 390 | int pulse_bit_lo = pulse_bit_hi - 1; |
| 391 | |
| 392 | // De-interleave 4 lanes from this byte |
| 393 | // Bit layout: [L3_hi, L2_hi, L1_hi, L0_hi, L3_lo, L2_lo, L1_lo, L0_lo] |
| 394 | for (int lane = 0; lane < 4; lane++) { |
| 395 | // Extract bits for this lane |
| 396 | u8 pulse_hi = (input_byte >> (4 + lane)) & 1; |
| 397 | u8 pulse_lo = (input_byte >> lane) & 1; |
| 398 | |
| 399 | // Reconstruct lane byte |
| 400 | lane_bytes[lane] |= (pulse_hi << pulse_bit_hi); |
| 401 | lane_bytes[lane] |= (pulse_lo << pulse_bit_lo); |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | // Store de-interleaved bytes |
| 406 | for (int lane = 0; lane < 4; lane++) { |
| 407 | lane_waves[lane].symbols[symbol_idx].data = lane_bytes[lane]; |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | // Copy de-interleaved data to output |
| 412 | for (int lane = 0; lane < 4; lane++) { |
| 413 | fl::isr::memcpy(output + lane * sizeof(Wave8Byte), &lane_waves[lane], sizeof(Wave8Byte)); |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | FL_OPTIMIZE_FUNCTION |
| 418 | void wave8Untranspose_8(const u8 (&FL_RESTRICT_PARAM transposed)[8 * sizeof(Wave8Byte)], |
no test coverage detected