1 // Copyright 2017 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 // Original code is licensed as follows:
7 /*
8 * Copyright 2007 ZXing authors
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 */
22
23 #include "fxbarcode/qrcode/BC_QRCoderECBlockData.h"
24
25 const std::array<const ECBlockDataRow, 40> kQRCoderECBDataTable = {{
26 {{{7, 1, 19, 0, 0},
27 {10, 1, 16, 0, 0},
28 {13, 1, 13, 0, 0},
29 {17, 1, 9, 0, 0}}},
30 {{{10, 1, 34, 0, 0},
31 {16, 1, 28, 0, 0},
32 {22, 1, 22, 0, 0},
33 {28, 1, 16, 0, 0}}},
34 {{{15, 1, 55, 0, 0},
35 {26, 1, 44, 0, 0},
36 {18, 2, 17, 0, 0},
37 {22, 2, 13, 0, 0}}},
38 {{{20, 1, 80, 0, 0},
39 {18, 2, 32, 0, 0},
40 {26, 2, 24, 0, 0},
41 {16, 4, 9, 0, 0}}},
42 {{{26, 1, 108, 0, 0},
43 {24, 2, 43, 0, 0},
44 {18, 2, 15, 2, 16},
45 {22, 2, 11, 2, 12}}},
46 {{{18, 2, 68, 0, 0},
47 {16, 4, 27, 0, 0},
48 {24, 4, 19, 0, 0},
49 {28, 4, 15, 0, 0}}},
50 {{{20, 2, 78, 0, 0},
51 {18, 4, 31, 0, 0},
52 {18, 2, 14, 4, 15},
53 {26, 4, 13, 1, 14}}},
54 {{{24, 2, 97, 0, 0},
55 {22, 2, 38, 2, 39},
56 {22, 4, 18, 2, 19},
57 {26, 4, 14, 2, 15}}},
58 {{{30, 2, 116, 0, 0},
59 {22, 3, 36, 2, 37},
60 {20, 4, 16, 4, 17},
61 {24, 4, 12, 4, 13}}},
62 {{{18, 2, 68, 2, 69},
63 {26, 4, 43, 1, 44},
64 {24, 6, 19, 2, 20},
65 {28, 6, 15, 2, 16}}},
66 {{{20, 4, 81, 0, 0},
67 {30, 1, 50, 4, 51},
68 {28, 4, 22, 4, 23},
69 {24, 3, 12, 8, 13}}},
70 {{{24, 2, 92, 2, 93},
71 {22, 6, 36, 2, 37},
72 {26, 4, 20, 6, 21},
73 {28, 7, 14, 4, 15}}},
74 {{{26, 4, 107, 0, 0},
75 {22, 8, 37, 1, 38},
76 {24, 8, 20, 4, 21},
77 {22, 12, 11, 4, 12}}},
78 {{{30, 3, 115, 1, 116},
79 {24, 4, 40, 5, 41},
80 {20, 11, 16, 5, 17},
81 {24, 11, 12, 5, 13}}},
82 {{{22, 5, 87, 1, 88},
83 {24, 5, 41, 5, 42},
84 {30, 5, 24, 7, 25},
85 {24, 11, 12, 7, 13}}},
86 {{{24, 5, 98, 1, 99},
87 {28, 7, 45, 3, 46},
88 {24, 15, 19, 2, 20},
89 {30, 3, 15, 13, 16}}},
90 {{{28, 1, 107, 5, 108},
91 {28, 10, 46, 1, 47},
92 {28, 1, 22, 15, 23},
93 {28, 2, 14, 17, 15}}},
94 {{{30, 5, 120, 1, 121},
95 {26, 9, 43, 4, 44},
96 {28, 17, 22, 1, 23},
97 {28, 2, 14, 19, 15}}},
98 {{{28, 3, 113, 4, 114},
99 {26, 3, 44, 11, 45},
100 {26, 17, 21, 4, 22},
101 {26, 9, 13, 16, 14}}},
102 {{{28, 3, 107, 5, 108},
103 {26, 3, 41, 13, 42},
104 {30, 15, 24, 5, 25},
105 {28, 15, 15, 10, 16}}},
106 {{{28, 4, 116, 4, 117},
107 {26, 17, 42, 0, 0},
108 {28, 17, 22, 6, 23},
109 {30, 19, 16, 6, 17}}},
110 {{{28, 2, 111, 7, 112},
111 {28, 17, 46, 0, 0},
112 {30, 7, 24, 16, 25},
113 {24, 34, 13, 0, 0}}},
114 {{{30, 4, 121, 5, 122},
115 {28, 4, 47, 14, 48},
116 {30, 11, 24, 14, 25},
117 {30, 16, 15, 14, 16}}},
118 {{{30, 6, 117, 4, 118},
119 {28, 6, 45, 14, 46},
120 {30, 11, 24, 16, 25},
121 {30, 30, 16, 2, 17}}},
122 {{{26, 8, 106, 4, 107},
123 {28, 8, 47, 13, 48},
124 {30, 7, 24, 22, 25},
125 {30, 22, 15, 13, 16}}},
126 {{{28, 10, 114, 2, 115},
127 {28, 19, 46, 4, 47},
128 {28, 28, 22, 6, 23},
129 {30, 33, 16, 4, 17}}},
130 {{{30, 8, 122, 4, 123},
131 {28, 22, 45, 3, 46},
132 {30, 8, 23, 26, 24},
133 {30, 12, 15, 28, 16}}},
134 {{{30, 3, 117, 10, 118},
135 {28, 3, 45, 23, 46},
136 {30, 4, 24, 31, 25},
137 {30, 11, 15, 31, 16}}},
138 {{{30, 7, 116, 7, 117},
139 {28, 21, 45, 7, 46},
140 {30, 1, 23, 37, 24},
141 {30, 19, 15, 26, 16}}},
142 {{{30, 5, 115, 10, 116},
143 {28, 19, 47, 10, 48},
144 {30, 15, 24, 25, 25},
145 {30, 23, 15, 25, 16}}},
146 {{{30, 13, 115, 3, 116},
147 {28, 2, 46, 29, 47},
148 {30, 42, 24, 1, 25},
149 {30, 23, 15, 28, 16}}},
150 {{{30, 17, 115, 0, 0},
151 {28, 10, 46, 23, 47},
152 {30, 10, 24, 35, 25},
153 {30, 19, 15, 35, 16}}},
154 {{{30, 17, 115, 1, 116},
155 {28, 14, 46, 21, 47},
156 {30, 29, 24, 19, 25},
157 {30, 11, 15, 46, 16}}},
158 {{{30, 13, 115, 6, 116},
159 {28, 14, 46, 23, 47},
160 {30, 44, 24, 7, 25},
161 {30, 59, 16, 1, 17}}},
162 {{{30, 12, 121, 7, 122},
163 {28, 12, 47, 26, 48},
164 {30, 39, 24, 14, 25},
165 {30, 22, 15, 41, 16}}},
166 {{{30, 6, 121, 14, 122},
167 {28, 6, 47, 34, 48},
168 {30, 46, 24, 10, 25},
169 {30, 2, 15, 64, 16}}},
170 {{{30, 17, 122, 4, 123},
171 {28, 29, 46, 14, 47},
172 {30, 49, 24, 10, 25},
173 {30, 24, 15, 46, 16}}},
174 {{{30, 4, 122, 18, 123},
175 {28, 13, 46, 32, 47},
176 {30, 48, 24, 14, 25},
177 {30, 42, 15, 32, 16}}},
178 {{{30, 20, 117, 4, 118},
179 {28, 40, 47, 7, 48},
180 {30, 43, 24, 22, 25},
181 {30, 10, 15, 67, 16}}},
182 {{{30, 19, 118, 6, 119},
183 {28, 18, 47, 31, 48},
184 {30, 34, 24, 34, 25},
185 {30, 20, 15, 61, 16}}},
186 }};
187
GetECCodeWordsPerBlock() const188 int32_t CBC_QRCoderECBlockData::GetECCodeWordsPerBlock() const {
189 return ecCodeWordsPerBlock;
190 }
191
GetNumBlocks() const192 int32_t CBC_QRCoderECBlockData::GetNumBlocks() const {
193 return count1 + count2;
194 }
195
GetTotalECCodeWords() const196 int32_t CBC_QRCoderECBlockData::GetTotalECCodeWords() const {
197 return GetECCodeWordsPerBlock() * GetNumBlocks();
198 }
199
GetTotalDataCodeWords() const200 int32_t CBC_QRCoderECBlockData::GetTotalDataCodeWords() const {
201 return count1 * (dataCodeWords1 + GetECCodeWordsPerBlock()) +
202 count2 * (dataCodeWords2 + GetECCodeWordsPerBlock());
203 }
204