quirc 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,91 @@
1
+ /* quirc -- QR-code recognition library
2
+ * Copyright (C) 2010-2012 Daniel Beer <dlbeer@gmail.com>
3
+ *
4
+ * Permission to use, copy, modify, and/or distribute this software for any
5
+ * purpose with or without fee is hereby granted, provided that the above
6
+ * copyright notice and this permission notice appear in all copies.
7
+ *
8
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
+ */
16
+
17
+ #include <stdlib.h>
18
+ #include <string.h>
19
+ #include "quirc_internal.h"
20
+
21
+ const char *quirc_version(void)
22
+ {
23
+ return "1.0";
24
+ }
25
+
26
+ struct quirc *quirc_new(void)
27
+ {
28
+ struct quirc *q = malloc(sizeof(*q));
29
+
30
+ if (!q)
31
+ return NULL;
32
+
33
+ memset(q, 0, sizeof(*q));
34
+ return q;
35
+ }
36
+
37
+ void quirc_destroy(struct quirc *q)
38
+ {
39
+ if (q->image)
40
+ free(q->image);
41
+ if (sizeof(*q->image) != sizeof(*q->pixels))
42
+ free(q->pixels);
43
+
44
+ free(q);
45
+ }
46
+
47
+ int quirc_resize(struct quirc *q, int w, int h)
48
+ {
49
+ uint8_t *new_image = realloc(q->image, w * h);
50
+
51
+ if (!new_image)
52
+ return -1;
53
+
54
+ if (sizeof(*q->image) != sizeof(*q->pixels)) {
55
+ size_t new_size = w * h * sizeof(quirc_pixel_t);
56
+ quirc_pixel_t *new_pixels = realloc(q->pixels, new_size);
57
+ if (!new_pixels)
58
+ return -1;
59
+ q->pixels = new_pixels;
60
+ }
61
+
62
+ q->image = new_image;
63
+ q->w = w;
64
+ q->h = h;
65
+
66
+ return 0;
67
+ }
68
+
69
+ int quirc_count(const struct quirc *q)
70
+ {
71
+ return q->num_grids;
72
+ }
73
+
74
+ static const char *const error_table[] = {
75
+ [QUIRC_SUCCESS] = "Success",
76
+ [QUIRC_ERROR_INVALID_GRID_SIZE] = "Invalid grid size",
77
+ [QUIRC_ERROR_INVALID_VERSION] = "Invalid version",
78
+ [QUIRC_ERROR_FORMAT_ECC] = "Format data ECC failure",
79
+ [QUIRC_ERROR_DATA_ECC] = "ECC failure",
80
+ [QUIRC_ERROR_UNKNOWN_DATA_TYPE] = "Unknown data type",
81
+ [QUIRC_ERROR_DATA_OVERFLOW] = "Data overflow",
82
+ [QUIRC_ERROR_DATA_UNDERFLOW] = "Data underflow"
83
+ };
84
+
85
+ const char *quirc_strerror(quirc_decode_error_t err)
86
+ {
87
+ if (err >= 0 && err < sizeof(error_table) / sizeof(error_table[0]))
88
+ return error_table[err];
89
+
90
+ return "Unknown error";
91
+ }
@@ -0,0 +1,173 @@
1
+ /* quirc -- QR-code recognition library
2
+ * Copyright (C) 2010-2012 Daniel Beer <dlbeer@gmail.com>
3
+ *
4
+ * Permission to use, copy, modify, and/or distribute this software for any
5
+ * purpose with or without fee is hereby granted, provided that the above
6
+ * copyright notice and this permission notice appear in all copies.
7
+ *
8
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
+ */
16
+
17
+ #ifndef QUIRC_H_
18
+ #define QUIRC_H_
19
+
20
+ #include <stdint.h>
21
+
22
+ #ifdef __cplusplus
23
+ extern "C" {
24
+ #endif
25
+
26
+ struct quirc;
27
+
28
+ /* Obtain the library version string. */
29
+ const char *quirc_version(void);
30
+
31
+ /* Construct a new QR-code recognizer. This function will return NULL
32
+ * if sufficient memory could not be allocated.
33
+ */
34
+ struct quirc *quirc_new(void);
35
+
36
+ /* Destroy a QR-code recognizer. */
37
+ void quirc_destroy(struct quirc *q);
38
+
39
+ /* Resize the QR-code recognizer. The size of an image must be
40
+ * specified before codes can be analyzed.
41
+ *
42
+ * This function returns 0 on success, or -1 if sufficient memory could
43
+ * not be allocated.
44
+ */
45
+ int quirc_resize(struct quirc *q, int w, int h);
46
+
47
+ /* These functions are used to process images for QR-code recognition.
48
+ * quirc_begin() must first be called to obtain access to a buffer into
49
+ * which the input image should be placed. Optionally, the current
50
+ * width and height may be returned.
51
+ *
52
+ * After filling the buffer, quirc_end() should be called to process
53
+ * the image for QR-code recognition. The locations and content of each
54
+ * code may be obtained using accessor functions described below.
55
+ */
56
+ uint8_t *quirc_begin(struct quirc *q, int *w, int *h);
57
+ void quirc_end(struct quirc *q);
58
+
59
+ /* This structure describes a location in the input image buffer. */
60
+ struct quirc_point {
61
+ int x;
62
+ int y;
63
+ };
64
+
65
+ /* This enum describes the various decoder errors which may occur. */
66
+ typedef enum {
67
+ QUIRC_SUCCESS = 0,
68
+ QUIRC_ERROR_INVALID_GRID_SIZE,
69
+ QUIRC_ERROR_INVALID_VERSION,
70
+ QUIRC_ERROR_FORMAT_ECC,
71
+ QUIRC_ERROR_DATA_ECC,
72
+ QUIRC_ERROR_UNKNOWN_DATA_TYPE,
73
+ QUIRC_ERROR_DATA_OVERFLOW,
74
+ QUIRC_ERROR_DATA_UNDERFLOW
75
+ } quirc_decode_error_t;
76
+
77
+ /* Return a string error message for an error code. */
78
+ const char *quirc_strerror(quirc_decode_error_t err);
79
+
80
+ /* Limits on the maximum size of QR-codes and their content. */
81
+ #define QUIRC_MAX_BITMAP 3917
82
+ #define QUIRC_MAX_PAYLOAD 8896
83
+
84
+ /* QR-code ECC types. */
85
+ #define QUIRC_ECC_LEVEL_M 0
86
+ #define QUIRC_ECC_LEVEL_L 1
87
+ #define QUIRC_ECC_LEVEL_H 2
88
+ #define QUIRC_ECC_LEVEL_Q 3
89
+
90
+ /* QR-code data types. */
91
+ #define QUIRC_DATA_TYPE_NUMERIC 1
92
+ #define QUIRC_DATA_TYPE_ALPHA 2
93
+ #define QUIRC_DATA_TYPE_BYTE 4
94
+ #define QUIRC_DATA_TYPE_KANJI 8
95
+
96
+ /* Common character encodings */
97
+ #define QUIRC_ECI_ISO_8859_1 1
98
+ #define QUIRC_ECI_IBM437 2
99
+ #define QUIRC_ECI_ISO_8859_2 4
100
+ #define QUIRC_ECI_ISO_8859_3 5
101
+ #define QUIRC_ECI_ISO_8859_4 6
102
+ #define QUIRC_ECI_ISO_8859_5 7
103
+ #define QUIRC_ECI_ISO_8859_6 8
104
+ #define QUIRC_ECI_ISO_8859_7 9
105
+ #define QUIRC_ECI_ISO_8859_8 10
106
+ #define QUIRC_ECI_ISO_8859_9 11
107
+ #define QUIRC_ECI_WINDOWS_874 13
108
+ #define QUIRC_ECI_ISO_8859_13 15
109
+ #define QUIRC_ECI_ISO_8859_15 17
110
+ #define QUIRC_ECI_SHIFT_JIS 20
111
+ #define QUIRC_ECI_UTF_8 26
112
+
113
+ /* This structure is used to return information about detected QR codes
114
+ * in the input image.
115
+ */
116
+ struct quirc_code {
117
+ /* The four corners of the QR-code, from top left, clockwise */
118
+ struct quirc_point corners[4];
119
+
120
+ /* The number of cells across in the QR-code. The cell bitmap
121
+ * is a bitmask giving the actual values of cells. If the cell
122
+ * at (x, y) is black, then the following bit is set:
123
+ *
124
+ * cell_bitmap[i << 3] & (1 << (i & 7))
125
+ *
126
+ * where i = (y * size) + x.
127
+ */
128
+ int size;
129
+ uint8_t cell_bitmap[QUIRC_MAX_BITMAP];
130
+ };
131
+
132
+ /* This structure holds the decoded QR-code data */
133
+ struct quirc_data {
134
+ /* Various parameters of the QR-code. These can mostly be
135
+ * ignored if you only care about the data.
136
+ */
137
+ int version;
138
+ int ecc_level;
139
+ int mask;
140
+
141
+ /* This field is the highest-valued data type found in the QR
142
+ * code.
143
+ */
144
+ int data_type;
145
+
146
+ /* Data payload. For the Kanji datatype, payload is encoded as
147
+ * Shift-JIS. For all other datatypes, payload is ASCII text.
148
+ */
149
+ uint8_t payload[QUIRC_MAX_PAYLOAD];
150
+ int payload_len;
151
+
152
+ /* ECI assignment number */
153
+ uint32_t eci;
154
+ };
155
+
156
+ /* Return the number of QR-codes identified in the last processed
157
+ * image.
158
+ */
159
+ int quirc_count(const struct quirc *q);
160
+
161
+ /* Extract the QR-code specified by the given index. */
162
+ void quirc_extract(const struct quirc *q, int index,
163
+ struct quirc_code *code);
164
+
165
+ /* Decode a QR-code, returning the payload data. */
166
+ quirc_decode_error_t quirc_decode(const struct quirc_code *code,
167
+ struct quirc_data *data);
168
+
169
+ #ifdef __cplusplus
170
+ }
171
+ #endif
172
+
173
+ #endif
@@ -0,0 +1,114 @@
1
+ /* quirc -- QR-code recognition library
2
+ * Copyright (C) 2010-2012 Daniel Beer <dlbeer@gmail.com>
3
+ *
4
+ * Permission to use, copy, modify, and/or distribute this software for any
5
+ * purpose with or without fee is hereby granted, provided that the above
6
+ * copyright notice and this permission notice appear in all copies.
7
+ *
8
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
+ */
16
+
17
+ #ifndef QUIRC_INTERNAL_H_
18
+ #define QUIRC_INTERNAL_H_
19
+
20
+ #include "quirc.h"
21
+
22
+ #define QUIRC_PIXEL_WHITE 0
23
+ #define QUIRC_PIXEL_BLACK 1
24
+ #define QUIRC_PIXEL_REGION 2
25
+
26
+ #ifndef QUIRC_MAX_REGIONS
27
+ #define QUIRC_MAX_REGIONS 254
28
+ #endif
29
+ #define QUIRC_MAX_CAPSTONES 32
30
+ #define QUIRC_MAX_GRIDS 8
31
+
32
+ #define QUIRC_PERSPECTIVE_PARAMS 8
33
+
34
+ #if QUIRC_MAX_REGIONS < UINT8_MAX
35
+ typedef uint8_t quirc_pixel_t;
36
+ #elif QUIRC_MAX_REGIONS < UINT16_MAX
37
+ typedef uint16_t quirc_pixel_t;
38
+ #else
39
+ #error "QUIRC_MAX_REGIONS > 65534 is not supported"
40
+ #endif
41
+
42
+ struct quirc_region {
43
+ struct quirc_point seed;
44
+ int count;
45
+ int capstone;
46
+ };
47
+
48
+ struct quirc_capstone {
49
+ int ring;
50
+ int stone;
51
+
52
+ struct quirc_point corners[4];
53
+ struct quirc_point center;
54
+ double c[QUIRC_PERSPECTIVE_PARAMS];
55
+
56
+ int qr_grid;
57
+ };
58
+
59
+ struct quirc_grid {
60
+ /* Capstone indices */
61
+ int caps[3];
62
+
63
+ /* Alignment pattern region and corner */
64
+ int align_region;
65
+ struct quirc_point align;
66
+
67
+ /* Timing pattern endpoints */
68
+ struct quirc_point tpep[3];
69
+ int hscan;
70
+ int vscan;
71
+
72
+ /* Grid size and perspective transform */
73
+ int grid_size;
74
+ double c[QUIRC_PERSPECTIVE_PARAMS];
75
+ };
76
+
77
+ struct quirc {
78
+ uint8_t *image;
79
+ quirc_pixel_t *pixels;
80
+ int w;
81
+ int h;
82
+
83
+ int num_regions;
84
+ struct quirc_region regions[QUIRC_MAX_REGIONS];
85
+
86
+ int num_capstones;
87
+ struct quirc_capstone capstones[QUIRC_MAX_CAPSTONES];
88
+
89
+ int num_grids;
90
+ struct quirc_grid grids[QUIRC_MAX_GRIDS];
91
+ };
92
+
93
+ /************************************************************************
94
+ * QR-code version information database
95
+ */
96
+
97
+ #define QUIRC_MAX_VERSION 40
98
+ #define QUIRC_MAX_ALIGNMENT 7
99
+
100
+ struct quirc_rs_params {
101
+ int bs; /* Small block size */
102
+ int dw; /* Small data words */
103
+ int ns; /* Number of small blocks */
104
+ };
105
+
106
+ struct quirc_version_info {
107
+ int data_bytes;
108
+ int apat[QUIRC_MAX_ALIGNMENT];
109
+ struct quirc_rs_params ecc[4];
110
+ };
111
+
112
+ extern const struct quirc_version_info quirc_version_db[QUIRC_MAX_VERSION + 1];
113
+
114
+ #endif
@@ -0,0 +1,421 @@
1
+ /* quirc -- QR-code recognition library
2
+ * Copyright (C) 2010-2012 Daniel Beer <dlbeer@gmail.com>
3
+ *
4
+ * Permission to use, copy, modify, and/or distribute this software for any
5
+ * purpose with or without fee is hereby granted, provided that the above
6
+ * copyright notice and this permission notice appear in all copies.
7
+ *
8
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
+ */
16
+
17
+ #include "quirc_internal.h"
18
+
19
+ const struct quirc_version_info quirc_version_db[QUIRC_MAX_VERSION + 1] = {
20
+ {0},
21
+ { /* Version 1 */
22
+ .data_bytes = 26,
23
+ .apat = {0},
24
+ .ecc = {
25
+ {.bs = 26, .dw = 16, .ns = 1},
26
+ {.bs = 26, .dw = 19, .ns = 1},
27
+ {.bs = 26, .dw = 9, .ns = 1},
28
+ {.bs = 26, .dw = 13, .ns = 1}
29
+ }
30
+ },
31
+ { /* Version 2 */
32
+ .data_bytes = 44,
33
+ .apat = {6, 18, 0},
34
+ .ecc = {
35
+ {.bs = 44, .dw = 28, .ns = 1},
36
+ {.bs = 44, .dw = 34, .ns = 1},
37
+ {.bs = 44, .dw = 16, .ns = 1},
38
+ {.bs = 44, .dw = 22, .ns = 1}
39
+ }
40
+ },
41
+ { /* Version 3 */
42
+ .data_bytes = 70,
43
+ .apat = {6, 22, 0},
44
+ .ecc = {
45
+ {.bs = 70, .dw = 44, .ns = 1},
46
+ {.bs = 70, .dw = 55, .ns = 1},
47
+ {.bs = 35, .dw = 13, .ns = 2},
48
+ {.bs = 35, .dw = 17, .ns = 2}
49
+ }
50
+ },
51
+ { /* Version 4 */
52
+ .data_bytes = 100,
53
+ .apat = {6, 26, 0},
54
+ .ecc = {
55
+ {.bs = 50, .dw = 32, .ns = 2},
56
+ {.bs = 100, .dw = 80, .ns = 1},
57
+ {.bs = 25, .dw = 9, .ns = 4},
58
+ {.bs = 50, .dw = 24, .ns = 2}
59
+ }
60
+ },
61
+ { /* Version 5 */
62
+ .data_bytes = 134,
63
+ .apat = {6, 30, 0},
64
+ .ecc = {
65
+ {.bs = 67, .dw = 43, .ns = 2},
66
+ {.bs = 134, .dw = 108, .ns = 1},
67
+ {.bs = 33, .dw = 11, .ns = 2},
68
+ {.bs = 33, .dw = 15, .ns = 2}
69
+ }
70
+ },
71
+ { /* Version 6 */
72
+ .data_bytes = 172,
73
+ .apat = {6, 34, 0},
74
+ .ecc = {
75
+ {.bs = 43, .dw = 27, .ns = 4},
76
+ {.bs = 86, .dw = 68, .ns = 2},
77
+ {.bs = 43, .dw = 15, .ns = 4},
78
+ {.bs = 43, .dw = 19, .ns = 4}
79
+ }
80
+ },
81
+ { /* Version 7 */
82
+ .data_bytes = 196,
83
+ .apat = {6, 22, 38, 0},
84
+ .ecc = {
85
+ {.bs = 49, .dw = 31, .ns = 4},
86
+ {.bs = 98, .dw = 78, .ns = 2},
87
+ {.bs = 39, .dw = 13, .ns = 4},
88
+ {.bs = 32, .dw = 14, .ns = 2}
89
+ }
90
+ },
91
+ { /* Version 8 */
92
+ .data_bytes = 242,
93
+ .apat = {6, 24, 42, 0},
94
+ .ecc = {
95
+ {.bs = 60, .dw = 38, .ns = 2},
96
+ {.bs = 121, .dw = 97, .ns = 2},
97
+ {.bs = 40, .dw = 14, .ns = 4},
98
+ {.bs = 40, .dw = 18, .ns = 4}
99
+ }
100
+ },
101
+ { /* Version 9 */
102
+ .data_bytes = 292,
103
+ .apat = {6, 26, 46, 0},
104
+ .ecc = {
105
+ {.bs = 58, .dw = 36, .ns = 3},
106
+ {.bs = 146, .dw = 116, .ns = 2},
107
+ {.bs = 36, .dw = 12, .ns = 4},
108
+ {.bs = 36, .dw = 16, .ns = 4}
109
+ }
110
+ },
111
+ { /* Version 10 */
112
+ .data_bytes = 346,
113
+ .apat = {6, 28, 50, 0},
114
+ .ecc = {
115
+ {.bs = 69, .dw = 43, .ns = 4},
116
+ {.bs = 86, .dw = 68, .ns = 2},
117
+ {.bs = 43, .dw = 15, .ns = 6},
118
+ {.bs = 43, .dw = 19, .ns = 6}
119
+ }
120
+ },
121
+ { /* Version 11 */
122
+ .data_bytes = 404,
123
+ .apat = {6, 30, 54, 0},
124
+ .ecc = {
125
+ {.bs = 80, .dw = 50, .ns = 1},
126
+ {.bs = 101, .dw = 81, .ns = 4},
127
+ {.bs = 36, .dw = 12, .ns = 3},
128
+ {.bs = 50, .dw = 22, .ns = 4}
129
+ }
130
+ },
131
+ { /* Version 12 */
132
+ .data_bytes = 466,
133
+ .apat = {6, 32, 58, 0},
134
+ .ecc = {
135
+ {.bs = 58, .dw = 36, .ns = 6},
136
+ {.bs = 116, .dw = 92, .ns = 2},
137
+ {.bs = 42, .dw = 14, .ns = 7},
138
+ {.bs = 46, .dw = 20, .ns = 4}
139
+ }
140
+ },
141
+ { /* Version 13 */
142
+ .data_bytes = 532,
143
+ .apat = {6, 34, 62, 0},
144
+ .ecc = {
145
+ {.bs = 59, .dw = 37, .ns = 8},
146
+ {.bs = 133, .dw = 107, .ns = 4},
147
+ {.bs = 33, .dw = 11, .ns = 12},
148
+ {.bs = 44, .dw = 20, .ns = 8}
149
+ }
150
+ },
151
+ { /* Version 14 */
152
+ .data_bytes = 581,
153
+ .apat = {6, 26, 46, 66, 0},
154
+ .ecc = {
155
+ {.bs = 64, .dw = 40, .ns = 4},
156
+ {.bs = 145, .dw = 115, .ns = 3},
157
+ {.bs = 36, .dw = 12, .ns = 11},
158
+ {.bs = 36, .dw = 16, .ns = 11}
159
+ }
160
+ },
161
+ { /* Version 15 */
162
+ .data_bytes = 655,
163
+ .apat = {6, 26, 48, 70, 0},
164
+ .ecc = {
165
+ {.bs = 65, .dw = 41, .ns = 5},
166
+ {.bs = 109, .dw = 87, .ns = 5},
167
+ {.bs = 36, .dw = 12, .ns = 11},
168
+ {.bs = 54, .dw = 24, .ns = 5}
169
+ }
170
+ },
171
+ { /* Version 16 */
172
+ .data_bytes = 733,
173
+ .apat = {6, 26, 50, 74, 0},
174
+ .ecc = {
175
+ {.bs = 73, .dw = 45, .ns = 7},
176
+ {.bs = 122, .dw = 98, .ns = 5},
177
+ {.bs = 45, .dw = 15, .ns = 3},
178
+ {.bs = 43, .dw = 19, .ns = 15}
179
+ }
180
+ },
181
+ { /* Version 17 */
182
+ .data_bytes = 815,
183
+ .apat = {6, 30, 54, 78, 0},
184
+ .ecc = {
185
+ {.bs = 74, .dw = 46, .ns = 10},
186
+ {.bs = 135, .dw = 107, .ns = 1},
187
+ {.bs = 42, .dw = 14, .ns = 2},
188
+ {.bs = 50, .dw = 22, .ns = 1}
189
+ }
190
+ },
191
+ { /* Version 18 */
192
+ .data_bytes = 901,
193
+ .apat = {6, 30, 56, 82, 0},
194
+ .ecc = {
195
+ {.bs = 69, .dw = 43, .ns = 9},
196
+ {.bs = 150, .dw = 120, .ns = 5},
197
+ {.bs = 42, .dw = 14, .ns = 2},
198
+ {.bs = 50, .dw = 22, .ns = 17}
199
+ }
200
+ },
201
+ { /* Version 19 */
202
+ .data_bytes = 991,
203
+ .apat = {6, 30, 58, 86, 0},
204
+ .ecc = {
205
+ {.bs = 70, .dw = 44, .ns = 3},
206
+ {.bs = 141, .dw = 113, .ns = 3},
207
+ {.bs = 39, .dw = 13, .ns = 9},
208
+ {.bs = 47, .dw = 21, .ns = 17}
209
+ }
210
+ },
211
+ { /* Version 20 */
212
+ .data_bytes = 1085,
213
+ .apat = {6, 34, 62, 90, 0},
214
+ .ecc = {
215
+ {.bs = 67, .dw = 41, .ns = 3},
216
+ {.bs = 135, .dw = 107, .ns = 3},
217
+ {.bs = 43, .dw = 15, .ns = 15},
218
+ {.bs = 54, .dw = 24, .ns = 15}
219
+ }
220
+ },
221
+ { /* Version 21 */
222
+ .data_bytes = 1156,
223
+ .apat = {6, 28, 50, 72, 92, 0},
224
+ .ecc = {
225
+ {.bs = 68, .dw = 42, .ns = 17},
226
+ {.bs = 144, .dw = 116, .ns = 4},
227
+ {.bs = 46, .dw = 16, .ns = 19},
228
+ {.bs = 50, .dw = 22, .ns = 17}
229
+ }
230
+ },
231
+ { /* Version 22 */
232
+ .data_bytes = 1258,
233
+ .apat = {6, 26, 50, 74, 98, 0},
234
+ .ecc = {
235
+ {.bs = 74, .dw = 46, .ns = 17},
236
+ {.bs = 139, .dw = 111, .ns = 2},
237
+ {.bs = 37, .dw = 13, .ns = 34},
238
+ {.bs = 54, .dw = 24, .ns = 7}
239
+ }
240
+ },
241
+ { /* Version 23 */
242
+ .data_bytes = 1364,
243
+ .apat = {6, 30, 54, 78, 102, 0},
244
+ .ecc = {
245
+ {.bs = 75, .dw = 47, .ns = 4},
246
+ {.bs = 151, .dw = 121, .ns = 4},
247
+ {.bs = 45, .dw = 15, .ns = 16},
248
+ {.bs = 54, .dw = 24, .ns = 11}
249
+ }
250
+ },
251
+ { /* Version 24 */
252
+ .data_bytes = 1474,
253
+ .apat = {6, 28, 54, 80, 106, 0},
254
+ .ecc = {
255
+ {.bs = 73, .dw = 45, .ns = 6},
256
+ {.bs = 147, .dw = 117, .ns = 6},
257
+ {.bs = 46, .dw = 16, .ns = 30},
258
+ {.bs = 54, .dw = 24, .ns = 11}
259
+ }
260
+ },
261
+ { /* Version 25 */
262
+ .data_bytes = 1588,
263
+ .apat = {6, 32, 58, 84, 110, 0},
264
+ .ecc = {
265
+ {.bs = 75, .dw = 47, .ns = 8},
266
+ {.bs = 132, .dw = 106, .ns = 8},
267
+ {.bs = 45, .dw = 15, .ns = 22},
268
+ {.bs = 54, .dw = 24, .ns = 7}
269
+ }
270
+ },
271
+ { /* Version 26 */
272
+ .data_bytes = 1706,
273
+ .apat = {6, 30, 58, 86, 114, 0},
274
+ .ecc = {
275
+ {.bs = 74, .dw = 46, .ns = 19},
276
+ {.bs = 142, .dw = 114, .ns = 10},
277
+ {.bs = 46, .dw = 16, .ns = 33},
278
+ {.bs = 50, .dw = 22, .ns = 28}
279
+ }
280
+ },
281
+ { /* Version 27 */
282
+ .data_bytes = 1828,
283
+ .apat = {6, 34, 62, 90, 118, 0},
284
+ .ecc = {
285
+ {.bs = 73, .dw = 45, .ns = 22},
286
+ {.bs = 152, .dw = 122, .ns = 8},
287
+ {.bs = 45, .dw = 15, .ns = 12},
288
+ {.bs = 53, .dw = 23, .ns = 8}
289
+ }
290
+ },
291
+ { /* Version 28 */
292
+ .data_bytes = 1921,
293
+ .apat = {6, 26, 50, 74, 98, 122, 0},
294
+ .ecc = {
295
+ {.bs = 73, .dw = 45, .ns = 3},
296
+ {.bs = 147, .dw = 117, .ns = 3},
297
+ {.bs = 45, .dw = 15, .ns = 11},
298
+ {.bs = 54, .dw = 24, .ns = 4}
299
+ }
300
+ },
301
+ { /* Version 29 */
302
+ .data_bytes = 2051,
303
+ .apat = {6, 30, 54, 78, 102, 126, 0},
304
+ .ecc = {
305
+ {.bs = 73, .dw = 45, .ns = 21},
306
+ {.bs = 146, .dw = 116, .ns = 7},
307
+ {.bs = 45, .dw = 15, .ns = 19},
308
+ {.bs = 53, .dw = 23, .ns = 1}
309
+ }
310
+ },
311
+ { /* Version 30 */
312
+ .data_bytes = 2185,
313
+ .apat = {6, 26, 52, 78, 104, 130, 0},
314
+ .ecc = {
315
+ {.bs = 75, .dw = 47, .ns = 19},
316
+ {.bs = 145, .dw = 115, .ns = 5},
317
+ {.bs = 45, .dw = 15, .ns = 23},
318
+ {.bs = 54, .dw = 24, .ns = 15}
319
+ }
320
+ },
321
+ { /* Version 31 */
322
+ .data_bytes = 2323,
323
+ .apat = {6, 30, 56, 82, 108, 134, 0},
324
+ .ecc = {
325
+ {.bs = 74, .dw = 46, .ns = 2},
326
+ {.bs = 145, .dw = 115, .ns = 13},
327
+ {.bs = 45, .dw = 15, .ns = 23},
328
+ {.bs = 54, .dw = 24, .ns = 42}
329
+ }
330
+ },
331
+ { /* Version 32 */
332
+ .data_bytes = 2465,
333
+ .apat = {6, 34, 60, 86, 112, 138, 0},
334
+ .ecc = {
335
+ {.bs = 74, .dw = 46, .ns = 10},
336
+ {.bs = 145, .dw = 115, .ns = 17},
337
+ {.bs = 45, .dw = 15, .ns = 19},
338
+ {.bs = 54, .dw = 24, .ns = 10}
339
+ }
340
+ },
341
+ { /* Version 33 */
342
+ .data_bytes = 2611,
343
+ .apat = {6, 30, 58, 86, 114, 142, 0},
344
+ .ecc = {
345
+ {.bs = 74, .dw = 46, .ns = 14},
346
+ {.bs = 145, .dw = 115, .ns = 17},
347
+ {.bs = 45, .dw = 15, .ns = 11},
348
+ {.bs = 54, .dw = 24, .ns = 29}
349
+ }
350
+ },
351
+ { /* Version 34 */
352
+ .data_bytes = 2761,
353
+ .apat = {6, 34, 62, 90, 118, 146, 0},
354
+ .ecc = {
355
+ {.bs = 74, .dw = 46, .ns = 14},
356
+ {.bs = 145, .dw = 115, .ns = 13},
357
+ {.bs = 46, .dw = 16, .ns = 59},
358
+ {.bs = 54, .dw = 24, .ns = 44}
359
+ }
360
+ },
361
+ { /* Version 35 */
362
+ .data_bytes = 2876,
363
+ .apat = {6, 30, 54, 78, 102, 126, 150},
364
+ .ecc = {
365
+ {.bs = 75, .dw = 47, .ns = 12},
366
+ {.bs = 151, .dw = 121, .ns = 12},
367
+ {.bs = 45, .dw = 15, .ns = 22},
368
+ {.bs = 54, .dw = 24, .ns = 39}
369
+ }
370
+ },
371
+ { /* Version 36 */
372
+ .data_bytes = 3034,
373
+ .apat = {6, 24, 50, 76, 102, 128, 154},
374
+ .ecc = {
375
+ {.bs = 75, .dw = 47, .ns = 6},
376
+ {.bs = 151, .dw = 121, .ns = 6},
377
+ {.bs = 45, .dw = 15, .ns = 2},
378
+ {.bs = 54, .dw = 24, .ns = 46}
379
+ }
380
+ },
381
+ { /* Version 37 */
382
+ .data_bytes = 3196,
383
+ .apat = {6, 28, 54, 80, 106, 132, 158},
384
+ .ecc = {
385
+ {.bs = 74, .dw = 46, .ns = 29},
386
+ {.bs = 152, .dw = 122, .ns = 17},
387
+ {.bs = 45, .dw = 15, .ns = 24},
388
+ {.bs = 54, .dw = 24, .ns = 49}
389
+ }
390
+ },
391
+ { /* Version 38 */
392
+ .data_bytes = 3362,
393
+ .apat = {6, 32, 58, 84, 110, 136, 162},
394
+ .ecc = {
395
+ {.bs = 74, .dw = 46, .ns = 13},
396
+ {.bs = 152, .dw = 122, .ns = 4},
397
+ {.bs = 45, .dw = 15, .ns = 42},
398
+ {.bs = 54, .dw = 24, .ns = 48}
399
+ }
400
+ },
401
+ { /* Version 39 */
402
+ .data_bytes = 3532,
403
+ .apat = {6, 26, 54, 82, 110, 138, 166},
404
+ .ecc = {
405
+ {.bs = 75, .dw = 47, .ns = 40},
406
+ {.bs = 147, .dw = 117, .ns = 20},
407
+ {.bs = 45, .dw = 15, .ns = 10},
408
+ {.bs = 54, .dw = 24, .ns = 43}
409
+ }
410
+ },
411
+ { /* Version 40 */
412
+ .data_bytes = 3706,
413
+ .apat = {6, 30, 58, 86, 114, 142, 170},
414
+ .ecc = {
415
+ {.bs = 75, .dw = 47, .ns = 18},
416
+ {.bs = 148, .dw = 118, .ns = 19},
417
+ {.bs = 45, .dw = 15, .ns = 20},
418
+ {.bs = 54, .dw = 24, .ns = 34}
419
+ }
420
+ }
421
+ };