FastLED 3.9.3
Loading...
Searching...
No Matches
bitswap.h File Reference

Detailed Description

Functions for doing a rotation of bits/bytes used by parallel output.

Definition in file bitswap.h.

#include "FastLED.h"
#include "force_inline.h"

Go to the source code of this file.

Classes

union  just8bits
 Structure representing 8 bits of access. More...
 
struct  sub4
 Structure representing 32 bits of access. More...
 
union  bitswap_type
 Union containing a full 8 bytes to swap the bit orientation on. More...
 

Macros

#define SWAPSA(X, N)
 Set out.X bits 0, 1, 2, and 3 to bit N of in.a.a, in.a.b, in.a.b, in.a.c, and in.a.d
 
#define SWAPSB(X, N)
 Set out.X bits 0, 1, 2, and 3 to bit N of in.b.a, in.b.b, in.b.b, in.b.c, and in.b.d
 
#define SWAPS(X, N)
 Set out.X bits to bit N of both in.a and in.b in order.
 

Functions

FASTLED_FORCE_INLINE void swapbits8 (bitswap_type in, bitswap_type &out)
 Do an 8-byte by 8-bit rotation.
 
FASTLED_FORCE_INLINE void slowswap (unsigned char *A, unsigned char *B)
 Slow version of the 8 byte by 8 bit rotation.
 
void transpose8x1_noinline (unsigned char *A, unsigned char *B)
 Simplified form of bits rotating function.
 
FASTLED_FORCE_INLINE void transpose8x1 (unsigned char *A, unsigned char *B)
 Simplified form of bits rotating function.
 
FASTLED_FORCE_INLINE void transpose8x1_MSB (unsigned char *A, unsigned char *B)
 Simplified form of bits rotating function.
 
template<int m, int n>
FASTLED_FORCE_INLINE void transpose8 (unsigned char *A, unsigned char *B)
 Templated bit-rotating function.
 

Macro Definition Documentation

◆ SWAPS

#define SWAPS ( X,
N )
Value:
out. X ## 0 = in.a.a ## N; \
out. X ## 1 = in.a.b ## N; \
out. X ## 2 = in.a.c ## N; \
out. X ## 3 = in.a.d ## N; \
out. X ## 4 = in.b.a ## N; \
out. X ## 5 = in.b.b ## N; \
out. X ## 6 = in.b.c ## N; \
out. X ## 7 = in.b.d ## N;

Set out.X bits to bit N of both in.a and in.b in order.

Parameters
Xthe sub4 of out to set
Nthe bit of each byte to retrieve
See also
bitswap_type

Definition at line 101 of file bitswap.h.

◆ SWAPSA

#define SWAPSA ( X,
N )
Value:
out. X ## 0 = in.a.a ## N; \
out. X ## 1 = in.a.b ## N; \
out. X ## 2 = in.a.c ## N; \
out. X ## 3 = in.a.d ## N;

Set out.X bits 0, 1, 2, and 3 to bit N of in.a.a, in.a.b, in.a.b, in.a.c, and in.a.d

Parameters
Xthe sub4 of out to set
Nthe bit of each byte to retrieve
See also
bitswap_type

Definition at line 81 of file bitswap.h.

◆ SWAPSB

#define SWAPSB ( X,
N )
Value:
out. X ## 0 = in.b.a ## N; \
out. X ## 1 = in.b.b ## N; \
out. X ## 2 = in.b.c ## N; \
out. X ## 3 = in.b.d ## N;

Set out.X bits 0, 1, 2, and 3 to bit N of in.b.a, in.b.b, in.b.b, in.b.c, and in.b.d

Parameters
Xthe sub4 of out to set
Nthe bit of each byte to retrieve
See also
bitswap_type

Definition at line 91 of file bitswap.h.

Function Documentation

◆ slowswap()

FASTLED_FORCE_INLINE void slowswap ( unsigned char * A,
unsigned char * B )

Slow version of the 8 byte by 8 bit rotation.

Definition at line 160 of file bitswap.h.

◆ swapbits8()

FASTLED_FORCE_INLINE void swapbits8 ( bitswap_type in,
bitswap_type & out )

Do an 8-byte by 8-bit rotation.

Definition at line 112 of file bitswap.h.

◆ transpose8()

template<int m, int n>
FASTLED_FORCE_INLINE void transpose8 ( unsigned char * A,
unsigned char * B )

Templated bit-rotating function.

Based on code found here: https://web.archive.org/web/20190108225554/http://www.hackersdelight.org/hdcodetxt/transpose8.c.txt

Definition at line 251 of file bitswap.h.

◆ transpose8x1()

FASTLED_FORCE_INLINE void transpose8x1 ( unsigned char * A,
unsigned char * B )

Simplified form of bits rotating function.

This rotates data into LSB for a faster write (the code using this data can happily walk the array backwards).
Based on code found here: https://web.archive.org/web/20190108225554/http://www.hackersdelight.org/hdcodetxt/transpose8.c.txt

Definition at line 191 of file bitswap.h.

◆ transpose8x1_MSB()

FASTLED_FORCE_INLINE void transpose8x1_MSB ( unsigned char * A,
unsigned char * B )

Simplified form of bits rotating function.

Based on code found here: https://web.archive.org/web/20190108225554/http://www.hackersdelight.org/hdcodetxt/transpose8.c.txt

Definition at line 217 of file bitswap.h.

◆ transpose8x1_noinline()

void transpose8x1_noinline ( unsigned char * A,
unsigned char * B )

Simplified form of bits rotating function.

This rotates data into LSB for a faster write (the code using this data can happily walk the array backwards).
Based on code found here: https://web.archive.org/web/20190108225554/http://www.hackersdelight.org/hdcodetxt/transpose8.c.txt

Definition at line 4 of file transpose8x1_noinline.cpp.