qr shader: add format ec bits

This commit is contained in:
Crispy 2024-08-16 14:46:24 +02:00
parent f3f3f305e8
commit bdb2c20d59

View file

@ -18,9 +18,17 @@ CGPROGRAM
#define ALIGNER_SPACING ((WIDTH - 13) / (ALIGNERS-1)) #define ALIGNER_SPACING ((WIDTH - 13) / (ALIGNERS-1))
#define MISALIGNMENT ((WIDTH - 13) % (ALIGNERS-1)) #define MISALIGNMENT ((WIDTH - 13) % (ALIGNERS-1))
#define EC_LEVEL (3) #define EC_LEVEL_L 1
#define MASK_TYPE (4) #define EC_LEVEL_M 0
#define FORMAT_BITS ((EC_LEVEL << 3) | MASK_TYPE) #define EC_LEVEL_Q 3
#define EC_LEVEL_H 2
#define EC_LEVEL EC_LEVEL_L
#define MASK_TYPE 1
static const uint FORMAT_BIT_SETS[32] = {0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0, 0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976, 0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b, 0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed};
#define FORMAT_BITS_RAW ((EC_LEVEL << 3) | MASK_TYPE)
#define FORMAT_BITS FORMAT_BIT_SETS[FORMAT_BITS_RAW]
/* /*
v = 15 v = 15
@ -88,11 +96,16 @@ CGPROGRAM
} }
// Format bits // Format bits
if (px < 5 && py == 8) return (FORMAT_BITS & (1 << (4 - px))) == 0; // left
if (px == 8 && py > WIDTH - 6) return (FORMAT_BITS & (1 << py + 5 - WIDTH)) == 0; if (px < 6 && py == 8) return (FORMAT_BITS & (1 << (14 - px))) == 0;
if (px == 7 && py == 8) return (FORMAT_BITS & (1 << 8)) == 0;
if (px == 8 && (py < 9 || py > WIDTH - 9)) return PINK; // right
if (py == 8 && (px < 9 || px > WIDTH - 9)) return PINK; if (px > WIDTH - 9 && py == 8) return (FORMAT_BITS & (1 << (WIDTH - 1 - px))) == 0;
// top
if (px == 8 && py < 6) return (FORMAT_BITS & (1 << py)) == 0;
if (px == 8 && py < 9) return (FORMAT_BITS & (1 << (py-1))) == 0;
// bottom
if (px == 8 && py > WIDTH - 8) return (FORMAT_BITS & (1 << py + 15 - WIDTH)) == 0;
uint column = (WIDTH - px - (px > 6))/2; uint column = (WIDTH - px - (px > 6))/2;
uint direction_up = column & 1; uint direction_up = column & 1;