-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCONSTANTS.py
More file actions
104 lines (94 loc) · 6.25 KB
/
CONSTANTS.py
File metadata and controls
104 lines (94 loc) · 6.25 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
MODE_INDICATOR = {'num': 1, 'alphanum': 2, 'byte': 4, 'kanji': 8}
EC_LEVEL = ('L', 'M', 'Q', 'H')
ALPHANUMERIC = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7,
'8': 8, '9': 9, 'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14, 'F': 15,
'G': 16, 'H': 17, 'I': 18, 'J': 19, 'K': 20, 'L': 21, 'M': 22, 'N': 23,
'O': 24, 'P': 25, 'Q': 26, 'R': 27, 'S': 28, 'T': 29, 'U': 30, 'V': 31,
'W': 32, 'X': 33, 'Y': 34, 'Z': 35, ' ': 36, '$': 37, '%': 38, '*': 39,
'+': 40, '-': 41, '.': 42, '/': 43, ':': 44}
# All collections below (ALIGNMENT_COORDS and FORMAT_INFO excluded) have 0 at index 0 just
# as a placeholder in order to make qr version and index relations unambiguous.
# Index 1 refers to version 1. Index 40 refers to version 40.
CHAR_COUNT_INDICATOR = {'num': [0] + [10] * 9 + [12] * 17 + [14] * 14,
'alphanum': [0] + [9] * 9 + [11] * 17 + [13] * 14,
'byte': [0] + [8] * 9 + [16] * 17 + [16] * 14,
'kanji': [0] + [8] * 9 + [10] * 17 + [12] * 14}
ECC_BLOCKS = ((0, 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),
(0, 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),
(0, 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),
(0, 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))
ECC_PER_BLOCK = ((0, 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),
(0, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26,
26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28),
(0, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30,
28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30),
(0, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28,
30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30))
NUM_DATA_CODEWORDS = ((0, 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),
(0, 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),
(0, 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),
(0, 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))
REMAINDER_BITS = tuple(map(int, '00777770000000333333344444443333333000000'))
# Format info depends on EC level (0-3) and mask number (0-7).
# EC level indicates tuple index, mask number points at index for right integer.
FORMAT_INFO = ((30660, 29427, 32170, 30877, 26159, 25368, 27713, 26998),
(21522, 20773, 24188, 23371, 17913, 16590, 20375, 19104),
(13663, 12392, 16177, 14854, 9396, 8579, 11994, 11245),
(5769, 5054, 7399, 6608, 1890, 597, 3340, 2107))
# Version info is applied from 7th version up. 0s are placeholders.
VERSION_INFO = (0, 0, 0, 0, 0, 0, 0, 31892, 34236, 39577, 42195, 48118, 51042, 55367,
58893, 63784, 68472, 70749, 76311, 79154, 84390, 87683, 92361, 96236,
102084, 102881, 110507, 110734, 117786, 119615, 126325, 127568, 133589,
136944, 141498, 145311, 150283, 152622, 158308, 161089, 167017)
ALIGNMENT_COORDS = {35: [6, 30, 54, 78, 102, 126, 150],
38: [6, 32, 58, 84, 110, 136, 162],
21: [6, 28, 50, 72, 94],
22: [6, 26, 50, 74, 98],
39: [6, 26, 54, 82, 110, 138, 166],
25: [6, 32, 58, 84, 110],
19: [6, 30, 58, 86],
34: [6, 34, 62, 90, 118, 146],
27: [6, 34, 62, 90, 118],
20: [6, 34, 62, 90],
31: [6, 30, 56, 82, 108, 134],
5: [6, 30],
18: [6, 30, 56, 82],
6: [6, 34],
26: [6, 30, 58, 86, 114],
4: [6, 26],
33: [6, 30, 58, 86, 114, 142],
9: [6, 26, 46],
3: [6, 22],
14: [6, 26, 46, 66],
10: [6, 28, 50],
15: [6, 26, 48, 70],
29: [6, 30, 54, 78, 102, 126],
40: [6, 30, 58, 86, 114, 142, 170],
30: [6, 26, 52, 78, 104, 130],
17: [6, 30, 54, 78],
13: [6, 34, 62],
11: [6, 30, 54],
24: [6, 28, 54, 80, 106],
28: [6, 26, 50, 74, 98, 122],
32: [6, 34, 60, 86, 112, 138],
8: [6, 24, 42],
36: [6, 24, 50, 76, 102, 128, 154],
23: [6, 30, 54, 78, 102],
16: [6, 26, 50, 74],
37: [6, 28, 54, 80, 106, 132, 158],
7: [6, 22, 38],
2: [6, 18],
12: [6, 32, 58]}