@@ -1086,14 +1086,45 @@ uint8_t IRAM_ATTR __attribute__((hot)) realtimeBroadcast(uint8_t type, IPAddress
10861086 return 0 ; // let's give it a frame to set up.
10871087 }
10881088
1089- static uint16_t *parallel_buffer_repacked = NULL ;
1089+
1090+ static byte *parallel_buffer_remapped = NULL ;
1091+ #ifdef WLEDMM_REMAP_AT_OUTPUT
1092+ static byte *parallel_buffer_remapped1 = (byte*) heap_caps_calloc_prefer ((1024 * 16 * 4 )+15 , sizeof (byte), 3 , MALLOC_CAP_SPIRAM|MALLOC_CAP_DMA|MALLOC_CAP_32BIT|MALLOC_CAP_CACHE_ALIGNED|MALLOC_CAP_SIMD, MALLOC_CAP_DMA|MALLOC_CAP_32BIT|MALLOC_CAP_CACHE_ALIGNED|MALLOC_CAP_SIMD, MALLOC_CAP_INTERNAL);
1093+ static byte *parallel_buffer_remapped2 = (byte*) heap_caps_calloc_prefer ((1024 * 16 * 4 )+15 , sizeof (byte), 3 , MALLOC_CAP_SPIRAM|MALLOC_CAP_DMA|MALLOC_CAP_32BIT|MALLOC_CAP_CACHE_ALIGNED|MALLOC_CAP_SIMD, MALLOC_CAP_DMA|MALLOC_CAP_32BIT|MALLOC_CAP_CACHE_ALIGNED|MALLOC_CAP_SIMD, MALLOC_CAP_INTERNAL);
1094+ #endif
1095+ static uint16_t *parallel_buffer_repacked = NULL ;
10901096 static uint16_t *parallel_buffer_repacked1 = (uint16_t *) heap_caps_calloc_prefer ((1024 * 16 * 16 ), 1 , 3 , MALLOC_CAP_SPIRAM|MALLOC_CAP_DMA|MALLOC_CAP_32BIT|MALLOC_CAP_CACHE_ALIGNED|MALLOC_CAP_SIMD, MALLOC_CAP_DMA|MALLOC_CAP_32BIT|MALLOC_CAP_CACHE_ALIGNED|MALLOC_CAP_SIMD, MALLOC_CAP_INTERNAL);
10911097 static uint16_t *parallel_buffer_repacked2 = (uint16_t *) heap_caps_calloc_prefer ((1024 * 16 * 16 ), 1 , 3 , MALLOC_CAP_SPIRAM|MALLOC_CAP_DMA|MALLOC_CAP_32BIT|MALLOC_CAP_CACHE_ALIGNED|MALLOC_CAP_SIMD, MALLOC_CAP_DMA|MALLOC_CAP_32BIT|MALLOC_CAP_CACHE_ALIGNED|MALLOC_CAP_SIMD, MALLOC_CAP_INTERNAL);
10921098
1093- parallel_buffer_repacked = (parallel_buffer_repacked == parallel_buffer_repacked1) ? parallel_buffer_repacked2 : parallel_buffer_repacked1;
1094-
1095- create_transposed_led_output_optimized (buffer_in, parallel_buffer_repacked, leds_per_output, outputs, isRGBW, bri);
1096-
1099+ if (parallel_buffer_repacked == NULL ) parallel_buffer_repacked = parallel_buffer_repacked1;
1100+ #ifdef WLEDMM_REMAP_AT_OUTPUT
1101+ if (parallel_buffer_remapped == NULL ) parallel_buffer_remapped = parallel_buffer_remapped1;
1102+
1103+ uint32_t * mappingTable = strip.getCustomMappingTable ();
1104+ uint32_t mappingTableSize = strip.getCustomMappingTableSize ();
1105+ int my_bytes_per_pixel = isRGBW ? 4 : 3 ;
1106+
1107+ uint32_t buf_pos = 0 ;
1108+
1109+ for (uint32_t i = 0 ; i < length; i++) {
1110+ uint32_t dest_pixel_index = i;
1111+ if (mappingTable && i < mappingTableSize) {
1112+ dest_pixel_index = mappingTable[i];
1113+ }
1114+ uint32_t dest_byte_pos = dest_pixel_index * my_bytes_per_pixel;
1115+ parallel_buffer_remapped[dest_byte_pos + 0 ] = buffer_in[buf_pos++];
1116+ parallel_buffer_remapped[dest_byte_pos + 1 ] = buffer_in[buf_pos++];
1117+ parallel_buffer_remapped[dest_byte_pos + 2 ] = buffer_in[buf_pos++];
1118+ if (isRGBW) {
1119+ parallel_buffer_remapped[dest_byte_pos + 3 ] = buffer_in[buf_pos++];
1120+ }
1121+ }
1122+ #else
1123+ parallel_buffer_remapped = buffer_in;
1124+ #endif
1125+
1126+ create_transposed_led_output_optimized (parallel_buffer_remapped, parallel_buffer_repacked, leds_per_output, outputs, isRGBW, bri);
1127+
10971128 // Calculate the exact size of ONE PIXEL's data in bits and bytes.
10981129 const uint32_t symbols_per_pixel = isRGBW ? 128 : 96 ;
10991130 const uint32_t bits_per_pixel = symbols_per_pixel * parlio_config.data_width ;;
@@ -1133,6 +1164,11 @@ uint8_t IRAM_ATTR __attribute__((hot)) realtimeBroadcast(uint8_t type, IPAddress
11331164 ESP_ERROR_CHECK (parlio_tx_unit_wait_all_done (parlio_tx_unit, -1 ));
11341165 unsigned long after = micros ();
11351166
1167+ #ifdef WLEDMM_REMAP_AT_OUTPUT
1168+ parallel_buffer_remapped = (parallel_buffer_remapped == parallel_buffer_remapped1) ? parallel_buffer_remapped2 : parallel_buffer_remapped1;
1169+ #endif
1170+ parallel_buffer_repacked = (parallel_buffer_repacked == parallel_buffer_repacked1) ? parallel_buffer_repacked2 : parallel_buffer_repacked1;
1171+
11361172 if (after-before > 50 ) delayMicroseconds (20 );
11371173
11381174 for (int i = 0 ; i < num_chunks && i < 4 ; ++i) {
0 commit comments