BC_QRCoderVersion.cpp revision 4d3acf4ec42bf6e838f9060103aff98fbf170794
1// Copyright 2014 PDFium Authors. All rights reserved.
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 "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
24#include "xfa/fxbarcode/qrcode/BC_QRCoderBitVector.h"
25#include "xfa/fxbarcode/qrcode/BC_QRCoderECB.h"
26#include "xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h"
27#include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h"
28#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h"
29#include "xfa/fxbarcode/utils.h"
30
31namespace {
32
33const uint8_t BITS_SET_IN_HALF_BYTE[] = {0, 1, 1, 2, 1, 2, 2, 3,
34                                         1, 2, 2, 3, 2, 3, 3, 4};
35
36int32_t NumBitsDiffering(int32_t a, int32_t b) {
37  a ^= b;
38  return BITS_SET_IN_HALF_BYTE[a & 0x0F] +
39         BITS_SET_IN_HALF_BYTE[(a >> 4) & 0x0F] +
40         BITS_SET_IN_HALF_BYTE[(a >> 8) & 0x0F] +
41         BITS_SET_IN_HALF_BYTE[(a >> 12) & 0x0F] +
42         BITS_SET_IN_HALF_BYTE[(a >> 16) & 0x0F] +
43         BITS_SET_IN_HALF_BYTE[(a >> 20) & 0x0F] +
44         BITS_SET_IN_HALF_BYTE[(a >> 24) & 0x0F] +
45         BITS_SET_IN_HALF_BYTE[(a >> 28) & 0x0F];
46}
47
48}  // namespace
49
50const int32_t CBC_QRCoderVersion::VERSION_DECODE_INFO[] = {
51    0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, 0x0C762, 0x0D847,
52    0x0E60D, 0x0F928, 0x10B78, 0x1145D, 0x12A17, 0x13532, 0x149A6,
53    0x15683, 0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB, 0x1B08E,
54    0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250, 0x209D5, 0x216F0, 0x228BA,
55    0x2379F, 0x24B0B, 0x2542E, 0x26A64, 0x27541, 0x28C69};
56
57CFX_ArrayTemplate<CBC_QRCoderVersion*>* CBC_QRCoderVersion::VERSION = nullptr;
58
59void CBC_QRCoderVersion::Initialize() {
60  VERSION = new CFX_ArrayTemplate<CBC_QRCoderVersion*>();
61}
62void CBC_QRCoderVersion::Finalize() {
63  for (int32_t i = 0; i < VERSION->GetSize(); i++)
64    delete VERSION->GetAt(i);
65
66  delete VERSION;
67  VERSION = nullptr;
68}
69CBC_QRCoderVersion::CBC_QRCoderVersion(int32_t versionNumber,
70                                       CBC_QRCoderECBlocks* ecBlocks1,
71                                       CBC_QRCoderECBlocks* ecBlocks2,
72                                       CBC_QRCoderECBlocks* ecBlocks3,
73                                       CBC_QRCoderECBlocks* ecBlocks4) {
74  m_versionNumber = versionNumber;
75  m_ecBlocksArray.Add(ecBlocks1);
76  m_ecBlocksArray.Add(ecBlocks2);
77  m_ecBlocksArray.Add(ecBlocks3);
78  m_ecBlocksArray.Add(ecBlocks4);
79  int32_t total = 0;
80  int32_t ecCodeWords = ecBlocks1->GetECCodeWordsPerBlock();
81  CFX_ArrayTemplate<CBC_QRCoderECB*>* ecbArray = ecBlocks1->GetECBlocks();
82  for (int32_t i = 0; i < ecbArray->GetSize(); i++) {
83    CBC_QRCoderECB* ecBlock = (*ecbArray)[i];
84    total += ecBlock->GetCount() * (ecBlock->GetDataCodeWords() + ecCodeWords);
85  }
86  m_totalCodeWords = total;
87  switch (versionNumber) {
88    case 1:
89      break;
90    case 2:
91      m_alignmentPatternCenters.Add(6);
92      m_alignmentPatternCenters.Add(18);
93      break;
94    case 3:
95      m_alignmentPatternCenters.Add(6);
96      m_alignmentPatternCenters.Add(22);
97      break;
98    case 4:
99      m_alignmentPatternCenters.Add(6);
100      m_alignmentPatternCenters.Add(26);
101      break;
102    case 5:
103      m_alignmentPatternCenters.Add(6);
104      m_alignmentPatternCenters.Add(30);
105      break;
106    case 6:
107      m_alignmentPatternCenters.Add(6);
108      m_alignmentPatternCenters.Add(34);
109      break;
110    case 7:
111      m_alignmentPatternCenters.Add(6);
112      m_alignmentPatternCenters.Add(22);
113      m_alignmentPatternCenters.Add(38);
114      break;
115    case 8:
116      m_alignmentPatternCenters.Add(6);
117      m_alignmentPatternCenters.Add(24);
118      m_alignmentPatternCenters.Add(42);
119      break;
120    case 9:
121      m_alignmentPatternCenters.Add(6);
122      m_alignmentPatternCenters.Add(26);
123      m_alignmentPatternCenters.Add(46);
124      break;
125    case 10:
126      m_alignmentPatternCenters.Add(6);
127      m_alignmentPatternCenters.Add(28);
128      m_alignmentPatternCenters.Add(50);
129      break;
130    case 11:
131      m_alignmentPatternCenters.Add(6);
132      m_alignmentPatternCenters.Add(30);
133      m_alignmentPatternCenters.Add(54);
134      break;
135    case 12:
136      m_alignmentPatternCenters.Add(6);
137      m_alignmentPatternCenters.Add(32);
138      m_alignmentPatternCenters.Add(58);
139      break;
140    case 13:
141      m_alignmentPatternCenters.Add(6);
142      m_alignmentPatternCenters.Add(34);
143      m_alignmentPatternCenters.Add(62);
144      break;
145    case 14:
146      m_alignmentPatternCenters.Add(6);
147      m_alignmentPatternCenters.Add(26);
148      m_alignmentPatternCenters.Add(46);
149      m_alignmentPatternCenters.Add(66);
150      break;
151    case 15:
152      m_alignmentPatternCenters.Add(6);
153      m_alignmentPatternCenters.Add(26);
154      m_alignmentPatternCenters.Add(48);
155      m_alignmentPatternCenters.Add(70);
156      break;
157    case 16:
158      m_alignmentPatternCenters.Add(6);
159      m_alignmentPatternCenters.Add(26);
160      m_alignmentPatternCenters.Add(50);
161      m_alignmentPatternCenters.Add(74);
162      break;
163    case 17:
164      m_alignmentPatternCenters.Add(6);
165      m_alignmentPatternCenters.Add(30);
166      m_alignmentPatternCenters.Add(54);
167      m_alignmentPatternCenters.Add(78);
168      break;
169    case 18:
170      m_alignmentPatternCenters.Add(6);
171      m_alignmentPatternCenters.Add(30);
172      m_alignmentPatternCenters.Add(56);
173      m_alignmentPatternCenters.Add(82);
174      break;
175    case 19:
176      m_alignmentPatternCenters.Add(6);
177      m_alignmentPatternCenters.Add(30);
178      m_alignmentPatternCenters.Add(58);
179      m_alignmentPatternCenters.Add(86);
180      break;
181    case 20:
182      m_alignmentPatternCenters.Add(6);
183      m_alignmentPatternCenters.Add(34);
184      m_alignmentPatternCenters.Add(62);
185      m_alignmentPatternCenters.Add(90);
186      break;
187    case 21:
188      m_alignmentPatternCenters.Add(6);
189      m_alignmentPatternCenters.Add(28);
190      m_alignmentPatternCenters.Add(50);
191      m_alignmentPatternCenters.Add(72);
192      m_alignmentPatternCenters.Add(94);
193      break;
194    case 22:
195      m_alignmentPatternCenters.Add(6);
196      m_alignmentPatternCenters.Add(26);
197      m_alignmentPatternCenters.Add(50);
198      m_alignmentPatternCenters.Add(74);
199      m_alignmentPatternCenters.Add(98);
200      break;
201    case 23:
202      m_alignmentPatternCenters.Add(6);
203      m_alignmentPatternCenters.Add(30);
204      m_alignmentPatternCenters.Add(54);
205      m_alignmentPatternCenters.Add(74);
206      m_alignmentPatternCenters.Add(102);
207      break;
208    case 24:
209      m_alignmentPatternCenters.Add(6);
210      m_alignmentPatternCenters.Add(28);
211      m_alignmentPatternCenters.Add(54);
212      m_alignmentPatternCenters.Add(80);
213      m_alignmentPatternCenters.Add(106);
214      break;
215    case 25:
216      m_alignmentPatternCenters.Add(6);
217      m_alignmentPatternCenters.Add(32);
218      m_alignmentPatternCenters.Add(58);
219      m_alignmentPatternCenters.Add(84);
220      m_alignmentPatternCenters.Add(110);
221      break;
222    case 26:
223      m_alignmentPatternCenters.Add(6);
224      m_alignmentPatternCenters.Add(30);
225      m_alignmentPatternCenters.Add(58);
226      m_alignmentPatternCenters.Add(86);
227      m_alignmentPatternCenters.Add(114);
228      break;
229    case 27:
230      m_alignmentPatternCenters.Add(6);
231      m_alignmentPatternCenters.Add(34);
232      m_alignmentPatternCenters.Add(62);
233      m_alignmentPatternCenters.Add(90);
234      m_alignmentPatternCenters.Add(118);
235      break;
236    case 28:
237      m_alignmentPatternCenters.Add(6);
238      m_alignmentPatternCenters.Add(26);
239      m_alignmentPatternCenters.Add(50);
240      m_alignmentPatternCenters.Add(74);
241      m_alignmentPatternCenters.Add(98);
242      m_alignmentPatternCenters.Add(122);
243      break;
244    case 29:
245      m_alignmentPatternCenters.Add(6);
246      m_alignmentPatternCenters.Add(30);
247      m_alignmentPatternCenters.Add(54);
248      m_alignmentPatternCenters.Add(78);
249      m_alignmentPatternCenters.Add(102);
250      m_alignmentPatternCenters.Add(126);
251      break;
252    case 30:
253      m_alignmentPatternCenters.Add(6);
254      m_alignmentPatternCenters.Add(26);
255      m_alignmentPatternCenters.Add(52);
256      m_alignmentPatternCenters.Add(78);
257      m_alignmentPatternCenters.Add(104);
258      m_alignmentPatternCenters.Add(130);
259      break;
260    case 31:
261      m_alignmentPatternCenters.Add(6);
262      m_alignmentPatternCenters.Add(30);
263      m_alignmentPatternCenters.Add(56);
264      m_alignmentPatternCenters.Add(82);
265      m_alignmentPatternCenters.Add(108);
266      m_alignmentPatternCenters.Add(134);
267      break;
268    case 32:
269      m_alignmentPatternCenters.Add(6);
270      m_alignmentPatternCenters.Add(34);
271      m_alignmentPatternCenters.Add(60);
272      m_alignmentPatternCenters.Add(86);
273      m_alignmentPatternCenters.Add(112);
274      m_alignmentPatternCenters.Add(138);
275      break;
276    case 33:
277      m_alignmentPatternCenters.Add(6);
278      m_alignmentPatternCenters.Add(30);
279      m_alignmentPatternCenters.Add(58);
280      m_alignmentPatternCenters.Add(86);
281      m_alignmentPatternCenters.Add(114);
282      m_alignmentPatternCenters.Add(142);
283      break;
284    case 34:
285      m_alignmentPatternCenters.Add(6);
286      m_alignmentPatternCenters.Add(34);
287      m_alignmentPatternCenters.Add(62);
288      m_alignmentPatternCenters.Add(90);
289      m_alignmentPatternCenters.Add(118);
290      m_alignmentPatternCenters.Add(146);
291      break;
292    case 35:
293      m_alignmentPatternCenters.Add(6);
294      m_alignmentPatternCenters.Add(30);
295      m_alignmentPatternCenters.Add(54);
296      m_alignmentPatternCenters.Add(78);
297      m_alignmentPatternCenters.Add(102);
298      m_alignmentPatternCenters.Add(126);
299      m_alignmentPatternCenters.Add(150);
300      break;
301    case 36:
302      m_alignmentPatternCenters.Add(6);
303      m_alignmentPatternCenters.Add(24);
304      m_alignmentPatternCenters.Add(50);
305      m_alignmentPatternCenters.Add(76);
306      m_alignmentPatternCenters.Add(102);
307      m_alignmentPatternCenters.Add(128);
308      m_alignmentPatternCenters.Add(154);
309      break;
310    case 37:
311      m_alignmentPatternCenters.Add(6);
312      m_alignmentPatternCenters.Add(28);
313      m_alignmentPatternCenters.Add(54);
314      m_alignmentPatternCenters.Add(80);
315      m_alignmentPatternCenters.Add(106);
316      m_alignmentPatternCenters.Add(132);
317      m_alignmentPatternCenters.Add(158);
318      break;
319    case 38:
320      m_alignmentPatternCenters.Add(6);
321      m_alignmentPatternCenters.Add(32);
322      m_alignmentPatternCenters.Add(58);
323      m_alignmentPatternCenters.Add(84);
324      m_alignmentPatternCenters.Add(110);
325      m_alignmentPatternCenters.Add(136);
326      m_alignmentPatternCenters.Add(162);
327      break;
328    case 39:
329      m_alignmentPatternCenters.Add(6);
330      m_alignmentPatternCenters.Add(26);
331      m_alignmentPatternCenters.Add(54);
332      m_alignmentPatternCenters.Add(82);
333      m_alignmentPatternCenters.Add(110);
334      m_alignmentPatternCenters.Add(138);
335      m_alignmentPatternCenters.Add(166);
336      break;
337    case 40:
338      m_alignmentPatternCenters.Add(6);
339      m_alignmentPatternCenters.Add(30);
340      m_alignmentPatternCenters.Add(58);
341      m_alignmentPatternCenters.Add(86);
342      m_alignmentPatternCenters.Add(114);
343      m_alignmentPatternCenters.Add(142);
344      m_alignmentPatternCenters.Add(170);
345      break;
346  }
347}
348
349CBC_QRCoderVersion::~CBC_QRCoderVersion() {
350  for (int32_t i = 0; i < m_ecBlocksArray.GetSize(); ++i)
351    delete m_ecBlocksArray[i];
352}
353
354int32_t CBC_QRCoderVersion::GetVersionNumber() {
355  return m_versionNumber;
356}
357CFX_Int32Array* CBC_QRCoderVersion::GetAlignmentPatternCenters() {
358  return &m_alignmentPatternCenters;
359}
360int32_t CBC_QRCoderVersion::GetTotalCodeWords() {
361  return m_totalCodeWords;
362}
363int32_t CBC_QRCoderVersion::GetDimensionForVersion() {
364  return 17 + 4 * m_versionNumber;
365}
366CBC_QRCoderECBlocks* CBC_QRCoderVersion::GetECBlocksForLevel(
367    CBC_QRCoderErrorCorrectionLevel* ecLevel) {
368  return m_ecBlocksArray[ecLevel->Ordinal()];
369}
370CBC_QRCoderVersion* CBC_QRCoderVersion::GetProvisionalVersionForDimension(
371    int32_t dimension,
372    int32_t& e) {
373  if ((dimension % 4) != 1) {
374    e = BCExceptionRead;
375    BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
376  }
377  CBC_QRCoderVersion* qcv = GetVersionForNumber((dimension - 17) >> 2, e);
378  BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
379  return qcv;
380}
381CBC_QRCoderVersion* CBC_QRCoderVersion::DecodeVersionInformation(
382    int32_t versionBits,
383    int32_t& e) {
384  int32_t bestDifference = FXSYS_IntMax;
385  int32_t bestVersion = 0;
386  for (int32_t i = 0; i < 34; i++) {
387    int32_t targetVersion = VERSION_DECODE_INFO[i];
388    if (targetVersion == versionBits) {
389      CBC_QRCoderVersion* qcv = GetVersionForNumber(i + 7, e);
390      BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
391      return qcv;
392    }
393    int32_t bitsDifference = NumBitsDiffering(versionBits, targetVersion);
394    if (bitsDifference < bestDifference) {
395      bestVersion = i + 7;
396      bestDifference = bitsDifference;
397    }
398  }
399  if (bestDifference <= 3) {
400    CBC_QRCoderVersion* qcv = GetVersionForNumber(bestVersion, e);
401    BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
402    return qcv;
403  }
404  return nullptr;
405}
406CBC_CommonBitMatrix* CBC_QRCoderVersion::BuildFunctionPattern(int32_t& e) {
407  int32_t dimension = GetDimensionForVersion();
408  CBC_CommonBitMatrix* bitMatrix = new CBC_CommonBitMatrix();
409  bitMatrix->Init(dimension);
410  bitMatrix->SetRegion(0, 0, 9, 9, e);
411  BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
412  bitMatrix->SetRegion(dimension - 8, 0, 8, 9, e);
413  BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
414  bitMatrix->SetRegion(0, dimension - 8, 9, 8, e);
415  BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
416  int32_t max = m_alignmentPatternCenters.GetSize();
417  for (int32_t x = 0; x < max; x++) {
418    int32_t i = m_alignmentPatternCenters[x] - 2;
419    for (int32_t y = 0; y < max; y++) {
420      if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) {
421        continue;
422      }
423      bitMatrix->SetRegion(m_alignmentPatternCenters[y] - 2, i, 5, 5, e);
424      BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
425    }
426  }
427  bitMatrix->SetRegion(6, 9, 1, dimension - 17, e);
428  BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
429  bitMatrix->SetRegion(9, 6, dimension - 17, 1, e);
430  BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
431  if (m_versionNumber > 6) {
432    bitMatrix->SetRegion(dimension - 11, 0, 3, 6, e);
433    BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
434    bitMatrix->SetRegion(0, dimension - 11, 6, 3, e);
435    BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
436  }
437  return bitMatrix;
438}
439CBC_QRCoderVersion* CBC_QRCoderVersion::GetVersionForNumber(
440    int32_t versionNumber,
441    int32_t& e) {
442  if (VERSION->GetSize() == 0) {
443    VERSION->Add(new CBC_QRCoderVersion(
444        1, new CBC_QRCoderECBlocks(7, new CBC_QRCoderECB(1, 19)),
445        new CBC_QRCoderECBlocks(10, new CBC_QRCoderECB(1, 16)),
446        new CBC_QRCoderECBlocks(13, new CBC_QRCoderECB(1, 13)),
447        new CBC_QRCoderECBlocks(17, new CBC_QRCoderECB(1, 9))));
448    VERSION->Add(new CBC_QRCoderVersion(
449        2, new CBC_QRCoderECBlocks(10, new CBC_QRCoderECB(1, 34)),
450        new CBC_QRCoderECBlocks(16, new CBC_QRCoderECB(1, 28)),
451        new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(1, 22)),
452        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(1, 16))));
453    VERSION->Add(new CBC_QRCoderVersion(
454        3, new CBC_QRCoderECBlocks(15, new CBC_QRCoderECB(1, 55)),
455        new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(1, 44)),
456        new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(2, 17)),
457        new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(2, 13))));
458    VERSION->Add(new CBC_QRCoderVersion(
459        4, new CBC_QRCoderECBlocks(20, new CBC_QRCoderECB(1, 80)),
460        new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(2, 32)),
461        new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(2, 24)),
462        new CBC_QRCoderECBlocks(16, new CBC_QRCoderECB(4, 9))));
463    VERSION->Add(new CBC_QRCoderVersion(
464        5, new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(1, 108)),
465        new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(2, 43)),
466        new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(2, 15),
467                                new CBC_QRCoderECB(2, 16)),
468        new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(2, 11),
469                                new CBC_QRCoderECB(2, 12))));
470    VERSION->Add(new CBC_QRCoderVersion(
471        6, new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(2, 68)),
472        new CBC_QRCoderECBlocks(16, new CBC_QRCoderECB(4, 27)),
473        new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(4, 19)),
474        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(4, 15))));
475    VERSION->Add(new CBC_QRCoderVersion(
476        7, new CBC_QRCoderECBlocks(20, new CBC_QRCoderECB(2, 78)),
477        new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(4, 31)),
478        new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(2, 14),
479                                new CBC_QRCoderECB(4, 15)),
480        new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(4, 13),
481                                new CBC_QRCoderECB(1, 14))));
482    VERSION->Add(new CBC_QRCoderVersion(
483        8, new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(2, 97)),
484        new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(2, 38),
485                                new CBC_QRCoderECB(2, 39)),
486        new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(4, 18),
487                                new CBC_QRCoderECB(2, 19)),
488        new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(4, 14),
489                                new CBC_QRCoderECB(2, 15))));
490    VERSION->Add(new CBC_QRCoderVersion(
491        9, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(2, 116)),
492        new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(3, 36),
493                                new CBC_QRCoderECB(2, 37)),
494        new CBC_QRCoderECBlocks(20, new CBC_QRCoderECB(4, 16),
495                                new CBC_QRCoderECB(4, 17)),
496        new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(4, 12),
497                                new CBC_QRCoderECB(4, 13))));
498    VERSION->Add(new CBC_QRCoderVersion(
499        10, new CBC_QRCoderECBlocks(18, new CBC_QRCoderECB(2, 68),
500                                    new CBC_QRCoderECB(2, 69)),
501        new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(4, 43),
502                                new CBC_QRCoderECB(1, 44)),
503        new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(6, 19),
504                                new CBC_QRCoderECB(2, 20)),
505        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(6, 15),
506                                new CBC_QRCoderECB(2, 16))));
507    VERSION->Add(new CBC_QRCoderVersion(
508        11, new CBC_QRCoderECBlocks(20, new CBC_QRCoderECB(4, 81)),
509        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(1, 50),
510                                new CBC_QRCoderECB(4, 51)),
511        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(4, 22),
512                                new CBC_QRCoderECB(4, 23)),
513        new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(3, 12),
514                                new CBC_QRCoderECB(8, 13))));
515    VERSION->Add(new CBC_QRCoderVersion(
516        12, new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(2, 92),
517                                    new CBC_QRCoderECB(2, 93)),
518        new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(6, 36),
519                                new CBC_QRCoderECB(2, 37)),
520        new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(4, 20),
521                                new CBC_QRCoderECB(6, 21)),
522        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(7, 14),
523                                new CBC_QRCoderECB(4, 15))));
524    VERSION->Add(new CBC_QRCoderVersion(
525        13, new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(4, 107)),
526        new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(8, 37),
527                                new CBC_QRCoderECB(1, 38)),
528        new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(8, 20),
529                                new CBC_QRCoderECB(4, 21)),
530        new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(12, 11),
531                                new CBC_QRCoderECB(4, 12))));
532    VERSION->Add(new CBC_QRCoderVersion(
533        14, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(3, 115),
534                                    new CBC_QRCoderECB(1, 116)),
535        new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(4, 40),
536                                new CBC_QRCoderECB(5, 41)),
537        new CBC_QRCoderECBlocks(20, new CBC_QRCoderECB(11, 16),
538                                new CBC_QRCoderECB(5, 17)),
539        new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(11, 12),
540                                new CBC_QRCoderECB(5, 13))));
541    VERSION->Add(new CBC_QRCoderVersion(
542        15, new CBC_QRCoderECBlocks(22, new CBC_QRCoderECB(5, 87),
543                                    new CBC_QRCoderECB(1, 88)),
544        new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(5, 41),
545                                new CBC_QRCoderECB(5, 42)),
546        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(5, 24),
547                                new CBC_QRCoderECB(7, 25)),
548        new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(11, 12),
549                                new CBC_QRCoderECB(7, 13))));
550    VERSION->Add(new CBC_QRCoderVersion(
551        16, new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(5, 98),
552                                    new CBC_QRCoderECB(1, 99)),
553        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(7, 45),
554                                new CBC_QRCoderECB(3, 46)),
555        new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(15, 19),
556                                new CBC_QRCoderECB(2, 20)),
557        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(3, 15),
558                                new CBC_QRCoderECB(13, 16))));
559    VERSION->Add(new CBC_QRCoderVersion(
560        17, new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(1, 107),
561                                    new CBC_QRCoderECB(5, 108)),
562        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(10, 46),
563                                new CBC_QRCoderECB(1, 47)),
564        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(1, 22),
565                                new CBC_QRCoderECB(15, 23)),
566        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(2, 14),
567                                new CBC_QRCoderECB(17, 15))));
568    VERSION->Add(new CBC_QRCoderVersion(
569        18, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(5, 120),
570                                    new CBC_QRCoderECB(1, 121)),
571        new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(9, 43),
572                                new CBC_QRCoderECB(4, 44)),
573        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(17, 22),
574                                new CBC_QRCoderECB(1, 23)),
575        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(2, 14),
576                                new CBC_QRCoderECB(19, 15))));
577    VERSION->Add(new CBC_QRCoderVersion(
578        19, new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(3, 113),
579                                    new CBC_QRCoderECB(4, 114)),
580        new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(3, 44),
581                                new CBC_QRCoderECB(11, 45)),
582        new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(17, 21),
583                                new CBC_QRCoderECB(4, 22)),
584        new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(9, 13),
585                                new CBC_QRCoderECB(16, 14))));
586    VERSION->Add(new CBC_QRCoderVersion(
587        20, new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(3, 107),
588                                    new CBC_QRCoderECB(5, 108)),
589        new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(3, 41),
590                                new CBC_QRCoderECB(13, 42)),
591        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(15, 24),
592                                new CBC_QRCoderECB(5, 25)),
593        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(15, 15),
594                                new CBC_QRCoderECB(10, 16))));
595    VERSION->Add(new CBC_QRCoderVersion(
596        21, new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(4, 116),
597                                    new CBC_QRCoderECB(4, 117)),
598        new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(17, 42)),
599        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(17, 22),
600                                new CBC_QRCoderECB(6, 23)),
601        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(19, 16),
602                                new CBC_QRCoderECB(6, 17))));
603    VERSION->Add(new CBC_QRCoderVersion(
604        22, new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(2, 111),
605                                    new CBC_QRCoderECB(7, 112)),
606        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(17, 46)),
607        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(7, 24),
608                                new CBC_QRCoderECB(16, 25)),
609        new CBC_QRCoderECBlocks(24, new CBC_QRCoderECB(34, 13))));
610    VERSION->Add(new CBC_QRCoderVersion(
611        23, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(4, 121),
612                                    new CBC_QRCoderECB(5, 122)),
613        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(4, 47),
614                                new CBC_QRCoderECB(14, 48)),
615        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(11, 24),
616                                new CBC_QRCoderECB(14, 25)),
617        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(16, 15),
618                                new CBC_QRCoderECB(14, 16))));
619    VERSION->Add(new CBC_QRCoderVersion(
620        24, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(6, 117),
621                                    new CBC_QRCoderECB(4, 118)),
622        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(6, 45),
623                                new CBC_QRCoderECB(14, 46)),
624        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(11, 24),
625                                new CBC_QRCoderECB(16, 25)),
626        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(30, 16),
627                                new CBC_QRCoderECB(2, 17))));
628    VERSION->Add(new CBC_QRCoderVersion(
629        25, new CBC_QRCoderECBlocks(26, new CBC_QRCoderECB(8, 106),
630                                    new CBC_QRCoderECB(4, 107)),
631        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(8, 47),
632                                new CBC_QRCoderECB(13, 48)),
633        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(7, 24),
634                                new CBC_QRCoderECB(22, 25)),
635        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(22, 15),
636                                new CBC_QRCoderECB(13, 16))));
637    VERSION->Add(new CBC_QRCoderVersion(
638        26, new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(10, 114),
639                                    new CBC_QRCoderECB(2, 115)),
640        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(19, 46),
641                                new CBC_QRCoderECB(4, 47)),
642        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(28, 22),
643                                new CBC_QRCoderECB(6, 23)),
644        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(33, 16),
645                                new CBC_QRCoderECB(4, 17))));
646    VERSION->Add(new CBC_QRCoderVersion(
647        27, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(8, 122),
648                                    new CBC_QRCoderECB(4, 123)),
649        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(22, 45),
650                                new CBC_QRCoderECB(3, 46)),
651        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(8, 23),
652                                new CBC_QRCoderECB(26, 24)),
653        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(12, 15),
654                                new CBC_QRCoderECB(28, 16))));
655    VERSION->Add(new CBC_QRCoderVersion(
656        28, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(3, 117),
657                                    new CBC_QRCoderECB(10, 118)),
658        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(3, 45),
659                                new CBC_QRCoderECB(23, 46)),
660        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(4, 24),
661                                new CBC_QRCoderECB(31, 25)),
662        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(11, 15),
663                                new CBC_QRCoderECB(31, 16))));
664    VERSION->Add(new CBC_QRCoderVersion(
665        29, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(7, 116),
666                                    new CBC_QRCoderECB(7, 117)),
667        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(21, 45),
668                                new CBC_QRCoderECB(7, 46)),
669        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(1, 23),
670                                new CBC_QRCoderECB(37, 24)),
671        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(19, 15),
672                                new CBC_QRCoderECB(26, 16))));
673    VERSION->Add(new CBC_QRCoderVersion(
674        30, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(5, 115),
675                                    new CBC_QRCoderECB(10, 116)),
676        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(19, 47),
677                                new CBC_QRCoderECB(10, 48)),
678        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(15, 24),
679                                new CBC_QRCoderECB(25, 25)),
680        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(23, 15),
681                                new CBC_QRCoderECB(25, 16))));
682    VERSION->Add(new CBC_QRCoderVersion(
683        31, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(13, 115),
684                                    new CBC_QRCoderECB(3, 116)),
685        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(2, 46),
686                                new CBC_QRCoderECB(29, 47)),
687        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(42, 24),
688                                new CBC_QRCoderECB(1, 25)),
689        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(23, 15),
690                                new CBC_QRCoderECB(28, 16))));
691    VERSION->Add(new CBC_QRCoderVersion(
692        32, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(17, 115)),
693        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(10, 46),
694                                new CBC_QRCoderECB(23, 47)),
695        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(10, 24),
696                                new CBC_QRCoderECB(35, 25)),
697        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(19, 15),
698                                new CBC_QRCoderECB(35, 16))));
699    VERSION->Add(new CBC_QRCoderVersion(
700        33, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(17, 115),
701                                    new CBC_QRCoderECB(1, 116)),
702        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(14, 46),
703                                new CBC_QRCoderECB(21, 47)),
704        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(29, 24),
705                                new CBC_QRCoderECB(19, 25)),
706        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(11, 15),
707                                new CBC_QRCoderECB(46, 16))));
708    VERSION->Add(new CBC_QRCoderVersion(
709        34, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(13, 115),
710                                    new CBC_QRCoderECB(6, 116)),
711        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(14, 46),
712                                new CBC_QRCoderECB(23, 47)),
713        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(44, 24),
714                                new CBC_QRCoderECB(7, 25)),
715        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(59, 16),
716                                new CBC_QRCoderECB(1, 17))));
717    VERSION->Add(new CBC_QRCoderVersion(
718        35, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(12, 121),
719                                    new CBC_QRCoderECB(7, 122)),
720        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(12, 47),
721                                new CBC_QRCoderECB(26, 48)),
722        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(39, 24),
723                                new CBC_QRCoderECB(14, 25)),
724        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(22, 15),
725                                new CBC_QRCoderECB(41, 16))));
726    VERSION->Add(new CBC_QRCoderVersion(
727        36, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(6, 121),
728                                    new CBC_QRCoderECB(14, 122)),
729        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(6, 47),
730                                new CBC_QRCoderECB(34, 48)),
731        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(46, 24),
732                                new CBC_QRCoderECB(10, 25)),
733        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(2, 15),
734                                new CBC_QRCoderECB(64, 16))));
735    VERSION->Add(new CBC_QRCoderVersion(
736        37, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(17, 122),
737                                    new CBC_QRCoderECB(4, 123)),
738        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(29, 46),
739                                new CBC_QRCoderECB(14, 47)),
740        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(49, 24),
741                                new CBC_QRCoderECB(10, 25)),
742        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(24, 15),
743                                new CBC_QRCoderECB(46, 16))));
744    VERSION->Add(new CBC_QRCoderVersion(
745        38, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(4, 122),
746                                    new CBC_QRCoderECB(18, 123)),
747        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(13, 46),
748                                new CBC_QRCoderECB(32, 47)),
749        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(48, 24),
750                                new CBC_QRCoderECB(14, 25)),
751        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(42, 15),
752                                new CBC_QRCoderECB(32, 16))));
753    VERSION->Add(new CBC_QRCoderVersion(
754        39, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(20, 117),
755                                    new CBC_QRCoderECB(4, 118)),
756        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(40, 47),
757                                new CBC_QRCoderECB(7, 48)),
758        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(43, 24),
759                                new CBC_QRCoderECB(22, 25)),
760        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(10, 15),
761                                new CBC_QRCoderECB(67, 16))));
762    VERSION->Add(new CBC_QRCoderVersion(
763        40, new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(19, 118),
764                                    new CBC_QRCoderECB(6, 119)),
765        new CBC_QRCoderECBlocks(28, new CBC_QRCoderECB(18, 47),
766                                new CBC_QRCoderECB(31, 48)),
767        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(34, 24),
768                                new CBC_QRCoderECB(34, 25)),
769        new CBC_QRCoderECBlocks(30, new CBC_QRCoderECB(20, 15),
770                                new CBC_QRCoderECB(61, 16))));
771  }
772  if (versionNumber < 1 || versionNumber > 40) {
773    e = BCExceptionIllegalArgument;
774    BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
775  }
776  return (*VERSION)[versionNumber - 1];
777}
778
779void CBC_QRCoderVersion::Destroy() {
780  for (int32_t i = 0; i < VERSION->GetSize(); i++)
781    delete (*VERSION)[i];
782  VERSION->RemoveAll();
783}
784