|
|
@ -60,7 +60,7 @@ static void encodeQrCodeTail(uint8_t dataAndQrcode[], int bitLen, uint8_t tempBu
|
|
|
|
int version, enum qrcodegen_Ecc ecl, enum qrcodegen_Mask mask, bool boostEcl);
|
|
|
|
int version, enum qrcodegen_Ecc ecl, enum qrcodegen_Mask mask, bool boostEcl);
|
|
|
|
testable void appendBitsToBuffer(unsigned int val, int numBits, uint8_t buffer[], int *bitLen);
|
|
|
|
testable void appendBitsToBuffer(unsigned int val, int numBits, uint8_t buffer[], int *bitLen);
|
|
|
|
|
|
|
|
|
|
|
|
static void appendErrorCorrection(uint8_t data[], int version, enum qrcodegen_Ecc ecl, uint8_t result[]);
|
|
|
|
testable void appendErrorCorrection(uint8_t data[], int version, enum qrcodegen_Ecc ecl, uint8_t result[]);
|
|
|
|
testable int getNumDataCodewords(int version, enum qrcodegen_Ecc ecl);
|
|
|
|
testable int getNumDataCodewords(int version, enum qrcodegen_Ecc ecl);
|
|
|
|
testable int getNumRawDataModules(int version);
|
|
|
|
testable int getNumRawDataModules(int version);
|
|
|
|
|
|
|
|
|
|
|
@ -90,7 +90,7 @@ testable void setModuleBounded(uint8_t qrcode[], int x, int y, bool isBlack);
|
|
|
|
static const char *ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
|
|
|
static const char *ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
|
|
|
|
|
|
|
|
|
|
|
// For generating error correction codes.
|
|
|
|
// For generating error correction codes.
|
|
|
|
static const int8_t ECC_CODEWORDS_PER_BLOCK[4][41] = {
|
|
|
|
testable const int8_t ECC_CODEWORDS_PER_BLOCK[4][41] = {
|
|
|
|
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
|
|
|
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
|
|
|
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
|
|
|
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
|
|
|
{-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // Low
|
|
|
|
{-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // Low
|
|
|
@ -100,7 +100,7 @@ static const int8_t ECC_CODEWORDS_PER_BLOCK[4][41] = {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// For generating error correction codes.
|
|
|
|
// For generating error correction codes.
|
|
|
|
const int8_t NUM_ERROR_CORRECTION_BLOCKS[4][41] = {
|
|
|
|
testable const int8_t NUM_ERROR_CORRECTION_BLOCKS[4][41] = {
|
|
|
|
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
|
|
|
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
|
|
|
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
|
|
|
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
|
|
|
{-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25}, // Low
|
|
|
|
{-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25}, // Low
|
|
|
@ -356,7 +356,7 @@ testable void appendBitsToBuffer(unsigned int val, int numBits, uint8_t buffer[]
|
|
|
|
// from the blocks and stores them in the result array. data[0 : rawCodewords - totalEcc] contains
|
|
|
|
// from the blocks and stores them in the result array. data[0 : rawCodewords - totalEcc] contains
|
|
|
|
// the input data. data[rawCodewords - totalEcc : rawCodewords] is used as a temporary work area
|
|
|
|
// the input data. data[rawCodewords - totalEcc : rawCodewords] is used as a temporary work area
|
|
|
|
// and will be clobbered by this function. The final answer is stored in result[0 : rawCodewords].
|
|
|
|
// and will be clobbered by this function. The final answer is stored in result[0 : rawCodewords].
|
|
|
|
static void appendErrorCorrection(uint8_t data[], int version, enum qrcodegen_Ecc ecl, uint8_t result[]) {
|
|
|
|
testable void appendErrorCorrection(uint8_t data[], int version, enum qrcodegen_Ecc ecl, uint8_t result[]) {
|
|
|
|
// Calculate parameter numbers
|
|
|
|
// Calculate parameter numbers
|
|
|
|
assert(0 <= (int)ecl && (int)ecl < 4 && qrcodegen_VERSION_MIN <= version && version <= qrcodegen_VERSION_MAX);
|
|
|
|
assert(0 <= (int)ecl && (int)ecl < 4 && qrcodegen_VERSION_MIN <= version && version <= qrcodegen_VERSION_MAX);
|
|
|
|
int numBlocks = NUM_ERROR_CORRECTION_BLOCKS[(int)ecl][version];
|
|
|
|
int numBlocks = NUM_ERROR_CORRECTION_BLOCKS[(int)ecl][version];
|
|
|
|