1 #ifndef __INC_BITSWAP_H
2 #define __INC_BITSWAP_H
6 FASTLED_NAMESPACE_BEGIN
14 #if defined(FASTLED_ARM) || defined(FASTLED_ESP8266)
77 #define SWAPSA(X,N) out. X ## 0 = in.a.a ## N; \
78 out. X ## 1 = in.a.b ## N; \
79 out. X ## 2 = in.a.c ## N; \
80 out. X ## 3 = in.a.d ## N;
82 #define SWAPSB(X,N) out. X ## 0 = in.b.a ## N; \
83 out. X ## 1 = in.b.b ## N; \
84 out. X ## 2 = in.b.c ## N; \
85 out. X ## 3 = in.b.d ## N;
87 #define SWAPS(X,N) out. X ## 0 = in.a.a ## N; \
88 out. X ## 1 = in.a.b ## N; \
89 out. X ## 2 = in.a.c ## N; \
90 out. X ## 3 = in.a.d ## N; \
91 out. X ## 4 = in.b.a ## N; \
92 out. X ## 5 = in.b.b ## N; \
93 out. X ## 6 = in.b.c ## N; \
94 out. X ## 7 = in.b.d ## N;
129 for(
int i = 0; i < 8; i++) {
131 work.a3 = in.word[0] >> 31;
132 work.a2 = in.word[0] >> 23;
133 work.a1 = in.word[0] >> 15;
134 work.a0 = in.word[0] >> 7;
136 work.a7 = in.word[1] >> 31;
137 work.a6 = in.word[1] >> 23;
138 work.a5 = in.word[1] >> 15;
139 work.a4 = in.word[1] >> 7;
141 out.bytes[i] = work.raw;
146 __attribute__((always_inline)) inline
void slowswap(
unsigned char *A,
unsigned char *B) {
148 for(
int row = 0; row < 7; row++) {
151 uint8_t bit = (1<<row);
152 unsigned char *p = B;
153 for(uint32_t mask = 1<<7 ; mask ; mask >>= 1) {
173 __attribute__((always_inline)) inline
void transpose8x1(
unsigned char *A,
unsigned char *B) {
177 y = *(
unsigned int*)(A);
178 x = *(
unsigned int*)(A+4);
181 t = (x ^ (x >> 7)) & 0x00AA00AA; x = x ^ t ^ (t << 7);
182 t = (x ^ (x >>14)) & 0x0000CCCC; x = x ^ t ^ (t <<14);
185 t = (y ^ (y >> 7)) & 0x00AA00AA; y = y ^ t ^ (t << 7);
186 t = (y ^ (y >>14)) & 0x0000CCCC; y = y ^ t ^ (t <<14);
189 t = (x & 0xF0F0F0F0) | ((y >> 4) & 0x0F0F0F0F);
190 y = ((x << 4) & 0xF0F0F0F0) | (y & 0x0F0F0F0F);
194 *((uint32_t*)(B+4)) = x;
198 __attribute__((always_inline)) inline
void transpose8x1_MSB(
unsigned char *A,
unsigned char *B) {
202 y = *(
unsigned int*)(A);
203 x = *(
unsigned int*)(A+4);
206 t = (x ^ (x >> 7)) & 0x00AA00AA; x = x ^ t ^ (t << 7);
207 t = (x ^ (x >>14)) & 0x0000CCCC; x = x ^ t ^ (t <<14);
210 t = (y ^ (y >> 7)) & 0x00AA00AA; y = y ^ t ^ (t << 7);
211 t = (y ^ (y >>14)) & 0x0000CCCC; y = y ^ t ^ (t <<14);
214 t = (x & 0xF0F0F0F0) | ((y >> 4) & 0x0F0F0F0F);
215 y = ((x << 4) & 0xF0F0F0F0) | (y & 0x0F0F0F0F);
230 template<
int m,
int n>
231 __attribute__((always_inline)) inline
void transpose8(
unsigned char *A,
unsigned char *B) {
236 y = *(
unsigned int*)(A);
237 x = *(
unsigned int*)(A+4);
239 x = (A[0]<<24) | (A[m]<<16) | (A[2*m]<<8) | A[3*m];
240 y = (A[4*m]<<24) | (A[5*m]<<16) | (A[6*m]<<8) | A[7*m];
244 t = (x ^ (x >> 7)) & 0x00AA00AA; x = x ^ t ^ (t << 7);
245 t = (x ^ (x >>14)) & 0x0000CCCC; x = x ^ t ^ (t <<14);
248 t = (y ^ (y >> 7)) & 0x00AA00AA; y = y ^ t ^ (t << 7);
249 t = (y ^ (y >>14)) & 0x0000CCCC; y = y ^ t ^ (t <<14);
252 t = (x & 0xF0F0F0F0) | ((y >> 4) & 0x0F0F0F0F);
253 y = ((x << 4) & 0xF0F0F0F0) | (y & 0x0F0F0F0F);
271 FASTLED_NAMESPACE_END
structure representing 8 bits of access
central include file for FastLED, defines the CFastLED class/object
structure representing 32 bits of access
__attribute__((always_inline)) inline void swapbits8(bitswap_type in
Do an 8byte by 8bit rotation.
union containing a full 8 bytes to swap the bit orientation on