mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-09 13:41:59 -04:00
CODE128: reduce extended latch cut-off from 5 to 4 for better
encodation in certain cases (and no pessimizations found so far), props lyngklip (BWIPP); fix extended char latching when exactly 3 extended chars at end; count code set C (not digits) in loop deciding when to shift/latch to extended for better estimate AZTEC: return warning if ECC < 5% (due to bit-stuffing when version given); return error if > 22 layers (Zint 26) for Reader Initialisation symbol requested for better error message AZTEC/HANXIN/QRCODE: consolidate different ECC data size tables into one indexed by ECC DBAR_EXP: check for reduced length <= 77 up front for better error message HANXIN: use `malloc()` rather than `z_alloca()` for large binary array QRCODE: `ecc_level` now 0-based (not 1-based) MICROQR: consolidate different version end routines into one `microqr_end()` and use new `microqr_data` table to simplify code MICROPDF417: use table for max codewords per column library: centralize all error messages using new `errtxt()`, `errtxtf()`, `errtxt_adj()` funcs that protect `symbol->errtxt` from overflow, & try to make error messages more consistent thru-out, adding more feedback info to many, & use positional args "%n$" in prep for l10n (maybe); `is_sane/is_sane_lookup()` -> `not_sane/not_sane_lookup()`, returning 1-based position (zero on failure) instead of bool; `long` ints -> plain `int` (except those dealing with `ftell()`, `fread()` etc) as depend on int being 32-bits already GUI: in "grpDATF.ui" use "PlainText" rather than "RichText" for tracker ratio examples as height of text messing up sometimes manual: clarify Codablock-F length maximum & add examples docs: README: pandoc 3.5, Ubuntu 24.04 CMake: use "-Wpedantic" for Clang only as GNU complains about `errtxtf()` positional args "%n$"
This commit is contained in:
parent
752c1fae5d
commit
5e2044ff2e
104 changed files with 8102 additions and 7755 deletions
172
backend/qr.h
172
backend/qr.h
|
@ -43,32 +43,27 @@ static const signed char qr_alphanumeric[59] = {
|
|||
};
|
||||
|
||||
/* From ISO/IEC 18004:2015 Table 7 - Number of symbol characters and input data capacity for QR Code */
|
||||
static const unsigned short qr_data_codewords_L[40] = {
|
||||
19, 34, 55, 80, 108, 136, 156, 194, 232, 274,
|
||||
324, 370, 428, 461, 523, 589, 647, 721, 795, 861,
|
||||
932, 1006, 1094, 1174, 1276, 1370, 1468, 1531, 1631, 1735,
|
||||
1843, 1955, 2071, 2191, 2306, 2434, 2566, 2702, 2812, 2956
|
||||
};
|
||||
|
||||
static const unsigned short qr_data_codewords_M[40] = {
|
||||
16, 28, 44, 64, 86, 108, 124, 154, 182, 216,
|
||||
254, 290, 334, 365, 415, 453, 507, 563, 627, 669,
|
||||
714, 782, 860, 914, 1000, 1062, 1128, 1193, 1267, 1373,
|
||||
1455, 1541, 1631, 1725, 1812, 1914, 1992, 2102, 2216, 2334
|
||||
};
|
||||
|
||||
static const unsigned short qr_data_codewords_Q[40] = {
|
||||
13, 22, 34, 48, 62, 76, 88, 110, 132, 154,
|
||||
180, 206, 244, 261, 295, 325, 367, 397, 445, 485,
|
||||
512, 568, 614, 664, 718, 754, 808, 871, 911, 985,
|
||||
1033, 1115, 1171, 1231, 1286, 1354, 1426, 1502, 1582, 1666
|
||||
};
|
||||
|
||||
static const unsigned short qr_data_codewords_H[40] = {
|
||||
9, 16, 26, 36, 46, 60, 66, 86, 100, 122,
|
||||
140, 158, 180, 197, 223, 253, 283, 313, 341, 385,
|
||||
406, 442, 464, 514, 538, 596, 628, 661, 701, 745,
|
||||
793, 845, 901, 961, 986, 1054, 1096, 1142, 1222, 1276
|
||||
static const unsigned short qr_data_codewords[4][40] = { {
|
||||
19, 34, 55, 80, 108, 136, 156, 194, 232, 274, /* L */
|
||||
324, 370, 428, 461, 523, 589, 647, 721, 795, 861,
|
||||
932, 1006, 1094, 1174, 1276, 1370, 1468, 1531, 1631, 1735,
|
||||
1843, 1955, 2071, 2191, 2306, 2434, 2566, 2702, 2812, 2956
|
||||
}, {
|
||||
16, 28, 44, 64, 86, 108, 124, 154, 182, 216, /* M */
|
||||
254, 290, 334, 365, 415, 453, 507, 563, 627, 669,
|
||||
714, 782, 860, 914, 1000, 1062, 1128, 1193, 1267, 1373,
|
||||
1455, 1541, 1631, 1725, 1812, 1914, 1992, 2102, 2216, 2334
|
||||
}, {
|
||||
13, 22, 34, 48, 62, 76, 88, 110, 132, 154, /* Q */
|
||||
180, 206, 244, 261, 295, 325, 367, 397, 445, 485,
|
||||
512, 568, 614, 664, 718, 754, 808, 871, 911, 985,
|
||||
1033, 1115, 1171, 1231, 1286, 1354, 1426, 1502, 1582, 1666
|
||||
}, {
|
||||
9, 16, 26, 36, 46, 60, 66, 86, 100, 122, /* H */
|
||||
140, 158, 180, 197, 223, 253, 283, 313, 341, 385,
|
||||
406, 442, 464, 514, 538, 596, 628, 661, 701, 745,
|
||||
793, 845, 901, 961, 986, 1054, 1096, 1142, 1222, 1276
|
||||
}
|
||||
};
|
||||
|
||||
/* From ISO/IEC 18004:2015 Table 1 - Codeword capacity of all versions of QRCode */
|
||||
|
@ -99,22 +94,21 @@ static const unsigned char rmqr_width[32] = {
|
|||
};
|
||||
|
||||
/* From ISO/IEC 23941:2022 Table 6 - Number of data codewords and input data capacity for rMQR */
|
||||
static const unsigned char rmqr_data_codewords_M[32] = {
|
||||
6, 12, 20, 28, 44, /* R7x */
|
||||
12, 21, 31, 42, 63, /* R9x */
|
||||
7, 19, 31, 43, 57, 84, /* R11x */
|
||||
12, 27, 38, 53, 73, 106, /* R13x */
|
||||
33, 48, 67, 88, 127, /* R15x */
|
||||
39, 56, 78, 100, 152 /* R17x */
|
||||
};
|
||||
|
||||
static const unsigned char rmqr_data_codewords_H[32] = {
|
||||
3, 7, 10, 14, 24, /* R7x */
|
||||
7, 11, 17, 22, 33, /* R9x */
|
||||
5, 11, 15, 23, 29, 42, /* R11x */
|
||||
7, 13, 20, 29, 35, 54, /* R13x */
|
||||
15, 26, 31, 48, 69, /* R15x */
|
||||
21, 28, 38, 56, 76 /* R17x */
|
||||
static const unsigned char rmqr_data_codewords[2][32] = { {
|
||||
6, 12, 20, 28, 44, /* R7x */ /* M */
|
||||
12, 21, 31, 42, 63, /* R9x */
|
||||
7, 19, 31, 43, 57, 84, /* R11x */
|
||||
12, 27, 38, 53, 73, 106, /* R13x */
|
||||
33, 48, 67, 88, 127, /* R15x */
|
||||
39, 56, 78, 100, 152 /* R17x */
|
||||
}, {
|
||||
3, 7, 10, 14, 24, /* R7x */ /* H */
|
||||
7, 11, 17, 22, 33, /* R9x */
|
||||
5, 11, 15, 23, 29, 42, /* R11x */
|
||||
7, 13, 20, 29, 35, 54, /* R13x */
|
||||
15, 26, 31, 48, 69, /* R15x */
|
||||
21, 28, 38, 56, 76 /* R17x */
|
||||
}
|
||||
};
|
||||
|
||||
/* Highest index in `rmqr_total_codewords` for each given row (R7x, R9x etc) */
|
||||
|
@ -170,54 +164,48 @@ static const unsigned char rmqr_kanji_cci[32] = {
|
|||
};
|
||||
|
||||
/* From ISO/IEC 18004:2015 Table 9 - Error correction characteristics for QR Code */
|
||||
static const char qr_blocks_L[40] = {
|
||||
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
|
||||
};
|
||||
|
||||
static const char qr_blocks_M[40] = {
|
||||
1, 1, 1, 2, 2, 4, 4, 4, 5, 5,
|
||||
5, 8, 9, 9, 10, 10, 11, 13, 14, 16,
|
||||
17, 17, 18, 20, 21, 23, 25, 26, 28, 29,
|
||||
31, 33, 35, 37, 38, 40, 43, 45, 47, 49
|
||||
};
|
||||
|
||||
static const char qr_blocks_Q[40] = {
|
||||
1, 1, 2, 2, 4, 4, 6, 6, 8, 8,
|
||||
8, 10, 12, 16, 12, 17, 16, 18, 21, 20,
|
||||
23, 23, 25, 27, 29, 34, 34, 35, 38, 40,
|
||||
43, 45, 48, 51, 53, 56, 59, 62, 65, 68
|
||||
};
|
||||
|
||||
static const char qr_blocks_H[40] = {
|
||||
1, 1, 2, 4, 4, 4, 5, 6, 8, 8,
|
||||
11, 11, 16, 16, 18, 16, 19, 21, 25, 25,
|
||||
25, 34, 30, 32, 35, 37, 40, 42, 45, 48,
|
||||
51, 54, 57, 60, 63, 66, 70, 74, 77, 81
|
||||
static const char qr_blocks[4][40] = { {
|
||||
1, 1, 1, 1, 1, 2, 2, 2, 2, 4, /* L */
|
||||
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
|
||||
}, {
|
||||
1, 1, 1, 2, 2, 4, 4, 4, 5, 5, /* M */
|
||||
5, 8, 9, 9, 10, 10, 11, 13, 14, 16,
|
||||
17, 17, 18, 20, 21, 23, 25, 26, 28, 29,
|
||||
31, 33, 35, 37, 38, 40, 43, 45, 47, 49
|
||||
}, {
|
||||
1, 1, 2, 2, 4, 4, 6, 6, 8, 8, /* Q */
|
||||
8, 10, 12, 16, 12, 17, 16, 18, 21, 20,
|
||||
23, 23, 25, 27, 29, 34, 34, 35, 38, 40,
|
||||
43, 45, 48, 51, 53, 56, 59, 62, 65, 68
|
||||
}, {
|
||||
1, 1, 2, 4, 4, 4, 5, 6, 8, 8, /* H */
|
||||
11, 11, 16, 16, 18, 16, 19, 21, 25, 25,
|
||||
25, 34, 30, 32, 35, 37, 40, 42, 45, 48,
|
||||
51, 54, 57, 60, 63, 66, 70, 74, 77, 81
|
||||
}
|
||||
};
|
||||
|
||||
/* From ISO/IEC 23941:2022 Table 8 - Error correction characteristics for rMQR */
|
||||
static const char rmqr_blocks_M[32] = {
|
||||
1, 1, 1, 1, 1, /* R7x */
|
||||
1, 1, 1, 1, 2, /* R9x */
|
||||
1, 1, 1, 1, 2, 2, /* R11x */
|
||||
1, 1, 1, 2, 2, 3, /* R13x */
|
||||
1, 1, 2, 2, 3, /* R15x */
|
||||
1, 2, 2, 3, 4 /* R17x */
|
||||
static const char rmqr_blocks[2][32] = { {
|
||||
1, 1, 1, 1, 1, /* R7x */ /* M */
|
||||
1, 1, 1, 1, 2, /* R9x */
|
||||
1, 1, 1, 1, 2, 2, /* R11x */
|
||||
1, 1, 1, 2, 2, 3, /* R13x */
|
||||
1, 1, 2, 2, 3, /* R15x */
|
||||
1, 2, 2, 3, 4 /* R17x */
|
||||
}, {
|
||||
1, 1, 1, 1, 2, /* R7x */ /* H */
|
||||
1, 1, 2, 2, 3, /* R9x */
|
||||
1, 1, 2, 2, 2, 3, /* R11x */
|
||||
1, 1, 2, 2, 3, 4, /* R13x */
|
||||
2, 2, 3, 4, 5, /* R15x */
|
||||
2, 2, 3, 4, 6 /* R17x */
|
||||
}
|
||||
};
|
||||
|
||||
static const char rmqr_blocks_H[32] = {
|
||||
1, 1, 1, 1, 2, /* R7x */
|
||||
1, 1, 2, 2, 3, /* R9x */
|
||||
1, 1, 2, 2, 2, 3, /* R11x */
|
||||
1, 1, 2, 2, 3, 4, /* R13x */
|
||||
2, 2, 3, 4, 5, /* R15x */
|
||||
2, 2, 3, 4, 6 /* R17x */
|
||||
};
|
||||
|
||||
/* From ISO/IEC 18004:2015 Table 1 - Codeword capacity of all versions of QRCode */
|
||||
/* From ISO/IEC 18004:2015 Table 1 - Codeword capacity of all versions of QR Code */
|
||||
static const unsigned char qr_sizes[40] = {
|
||||
21, 25, 29, 33, 37, 41, 45, 49, 53, 57,
|
||||
61, 65, 69, 73, 77, 81, 85, 89, 93, 97,
|
||||
|
@ -225,10 +213,22 @@ static const unsigned char qr_sizes[40] = {
|
|||
141, 145, 149, 153, 157, 161, 165, 169, 173, 177
|
||||
};
|
||||
|
||||
static const char micro_qr_sizes[4] = {
|
||||
static const char microqr_sizes[4] = {
|
||||
11, 13, 15, 17
|
||||
};
|
||||
|
||||
/* From ISO/IEC 18004:2015 Table 7 - Number of symbol characters and input data capacity for QR Code and
|
||||
Table 9 — Error correction characteristics for QR Code, M1-4 only, indexed by ecc_level & version as
|
||||
{ data bits, data codewords, ecc codewords } */
|
||||
static const unsigned char microqr_data[3][4][3] = { {
|
||||
{ 20, 3, 2 }, { 40, 5, 5 }, { 84, 11, 6 }, { 128, 16, 8 } /* L */
|
||||
}, {
|
||||
{ 0, 0, 0 }, { 32, 4, 6 }, { 68, 9, 8 }, { 112, 14, 10 } /* M */
|
||||
}, {
|
||||
{ 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 80, 10, 14 } /* Q */
|
||||
}
|
||||
};
|
||||
|
||||
/* No. of entries in `qr_table_e1` (Table E.1) per version */
|
||||
static const char qr_align_loopsize[40] = {
|
||||
0, 2, 2, 2, 2, 2, 3, 3, 3, 3,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue