Issue 489 update the port
[zxing.git] / cpp / core / src / zxing / qrcode / Version.cpp
1 /*
2  *  Version.cpp
3  *  zxing
4  *
5  *  Created by Christian Brunschen on 14/05/2008.
6  *  Copyright 2008 ZXing authors All rights reserved.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20
21 #include <zxing/qrcode/Version.h>
22 #include <zxing/qrcode/FormatInformation.h>
23 #include <limits>
24 #include <iostream>
25 #include <cstdarg>
26
27 namespace zxing {
28 namespace qrcode {
29 using namespace std;
30
31 ECB::ECB(int count, int dataCodewords) :
32     count_(count), dataCodewords_(dataCodewords) {
33 }
34
35 int ECB::getCount() {
36   return count_;
37 }
38
39 int ECB::getDataCodewords() {
40   return dataCodewords_;
41 }
42
43 ECBlocks::ECBlocks(int ecCodewords, ECB *ecBlocks) :
44     ecCodewords_(ecCodewords), ecBlocks_(1, ecBlocks) {
45 }
46
47 ECBlocks::ECBlocks(int ecCodewords, ECB *ecBlocks1, ECB *ecBlocks2) :
48     ecCodewords_(ecCodewords), ecBlocks_(1, ecBlocks1) {
49   ecBlocks_.push_back(ecBlocks2);
50 }
51
52 int ECBlocks::getECCodewords() {
53   return ecCodewords_;
54 }
55
56 std::vector<ECB*>& ECBlocks::getECBlocks() {
57   return ecBlocks_;
58 }
59
60 ECBlocks::~ECBlocks() {
61   for (size_t i = 0; i < ecBlocks_.size(); i++) {
62     delete ecBlocks_[i];
63   }
64 }
65
66 unsigned int Version::VERSION_DECODE_INFO[] = { 0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, 0x0C762, 0x0D847, 0x0E60D,
67     0x0F928, 0x10B78, 0x1145D, 0x12A17, 0x13532, 0x149A6, 0x15683, 0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB,
68     0x1B08E, 0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250, 0x209D5, 0x216F0, 0x228BA, 0x2379F, 0x24B0B, 0x2542E, 0x26A64,
69     0x27541, 0x28C69
70                                               };
71 int Version::N_VERSION_DECODE_INFOS = 34;
72 vector<Ref<Version> > Version::VERSIONS;
73 static int N_VERSIONS = Version::buildVersions();
74
75 int Version::getVersionNumber() {
76   return versionNumber_;
77 }
78
79 vector<int> &Version::getAlignmentPatternCenters() {
80   return alignmentPatternCenters_;
81 }
82
83 int Version::getTotalCodewords() {
84   return totalCodewords_;
85 }
86
87 int Version::getDimensionForVersion() {
88   return 17 + 4 * versionNumber_;
89 }
90
91 ECBlocks& Version::getECBlocksForLevel(ErrorCorrectionLevel &ecLevel) {
92   return *ecBlocks_[ecLevel.ordinal()];
93 }
94
95 Version *Version::getProvisionalVersionForDimension(int dimension) {
96   if (dimension % 4 != 1) {
97     throw ReaderException("Dimension must be 1 mod 4");
98   }
99   return Version::getVersionForNumber((dimension - 17) >> 2);
100 }
101
102 Version *Version::getVersionForNumber(int versionNumber) {
103   if (versionNumber < 1 || versionNumber > N_VERSIONS) {
104     throw ReaderException("versionNumber must be between 1 and 40");
105   }
106
107   return VERSIONS[versionNumber - 1];
108 }
109
110 Version::Version(int versionNumber, vector<int> *alignmentPatternCenters, ECBlocks *ecBlocks1, ECBlocks *ecBlocks2,
111                  ECBlocks *ecBlocks3, ECBlocks *ecBlocks4) :
112     versionNumber_(versionNumber), alignmentPatternCenters_(*alignmentPatternCenters), ecBlocks_(4), totalCodewords_(0) {
113   ecBlocks_[0] = ecBlocks1;
114   ecBlocks_[1] = ecBlocks2;
115   ecBlocks_[2] = ecBlocks3;
116   ecBlocks_[3] = ecBlocks4;
117
118   int total = 0;
119   int ecCodewords = ecBlocks1->getECCodewords();
120   vector<ECB*> &ecbArray = ecBlocks1->getECBlocks();
121   for (size_t i = 0; i < ecbArray.size(); i++) {
122     ECB *ecBlock = ecbArray[i];
123     total += ecBlock->getCount() * (ecBlock->getDataCodewords() + ecCodewords);
124   }
125   totalCodewords_ = total;
126 }
127
128 Version::~Version() {
129   delete &alignmentPatternCenters_;
130   for (size_t i = 0; i < ecBlocks_.size(); i++) {
131     delete ecBlocks_[i];
132   }
133 }
134
135 Version *Version::decodeVersionInformation(unsigned int versionBits) {
136   int bestDifference = numeric_limits<int>::max();
137   size_t bestVersion = 0;
138   for (int i = 0; i < N_VERSION_DECODE_INFOS; i++) {
139     unsigned targetVersion = VERSION_DECODE_INFO[i];
140     // Do the version info bits match exactly? done.
141     if (targetVersion == versionBits) {
142       return getVersionForNumber(i + 7);
143     }
144     // Otherwise see if this is the closest to a real version info bit
145     // string we have seen so far
146     int bitsDifference = FormatInformation::numBitsDiffering(versionBits, targetVersion);
147     if (bitsDifference < bestDifference) {
148       bestVersion = i + 7;
149       bestDifference = bitsDifference;
150     }
151   }
152   // We can tolerate up to 3 bits of error since no two version info codewords will
153   // differ in less than 4 bits.
154   if (bestDifference <= 3) {
155     return getVersionForNumber(bestVersion);
156   }
157   // If we didn't find a close enough match, fail
158   return 0;
159 }
160
161 Ref<BitMatrix> Version::buildFunctionPattern() {
162   int dimension = getDimensionForVersion();
163   Ref<BitMatrix> functionPattern(new BitMatrix(dimension));
164
165
166   // Top left finder pattern + separator + format
167   functionPattern->setRegion(0, 0, 9, 9);
168   // Top right finder pattern + separator + format
169   functionPattern->setRegion(dimension - 8, 0, 8, 9);
170   // Bottom left finder pattern + separator + format
171   functionPattern->setRegion(0, dimension - 8, 9, 8);
172
173
174   // Alignment patterns
175   size_t max = alignmentPatternCenters_.size();
176   for (size_t x = 0; x < max; x++) {
177     int i = alignmentPatternCenters_[x] - 2;
178     for (size_t y = 0; y < max; y++) {
179       if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) {
180         // No alignment patterns near the three finder patterns
181         continue;
182       }
183       functionPattern->setRegion(alignmentPatternCenters_[y] - 2, i, 5, 5);
184     }
185   }
186
187   // Vertical timing pattern
188   functionPattern->setRegion(6, 9, 1, dimension - 17);
189   // Horizontal timing pattern
190   functionPattern->setRegion(9, 6, dimension - 17, 1);
191
192   if (versionNumber_ > 6) {
193     // Version info, top right
194     functionPattern->setRegion(dimension - 11, 0, 3, 6);
195     // Version info, bottom left
196     functionPattern->setRegion(0, dimension - 11, 6, 3);
197   }
198
199
200   //#ifdef DEBUG
201   //    cout << "version " << versionNumber_ << " built function pattern:\n";
202   //    cout << *functionPattern;
203   //#endif
204
205   return functionPattern;
206 }
207
208 static vector<int> *intArray(size_t n...) {
209   va_list ap;
210   va_start(ap, n);
211   vector<int> *result = new vector<int>(n);
212   for (size_t i = 0; i < n; i++) {
213     (*result)[i] = va_arg(ap, int);
214   }
215   va_end(ap);
216   return result;
217 }
218
219 int Version::buildVersions() {
220   VERSIONS.push_back(Ref<Version>(new Version(1, intArray(0),
221                                   new ECBlocks(7, new ECB(1, 19)),
222                                   new ECBlocks(10, new ECB(1, 16)),
223                                   new ECBlocks(13, new ECB(1, 13)),
224                                   new ECBlocks(17, new ECB(1, 9)))));
225   VERSIONS.push_back(Ref<Version>(new Version(2, intArray(2, 6, 18),
226                                   new ECBlocks(10, new ECB(1, 34)),
227                                   new ECBlocks(16, new ECB(1, 28)),
228                                   new ECBlocks(22, new ECB(1, 22)),
229                                   new ECBlocks(28, new ECB(1, 16)))));
230   VERSIONS.push_back(Ref<Version>(new Version(3, intArray(2, 6, 22),
231                                   new ECBlocks(15, new ECB(1, 55)),
232                                   new ECBlocks(26, new ECB(1, 44)),
233                                   new ECBlocks(18, new ECB(2, 17)),
234                                   new ECBlocks(22, new ECB(2, 13)))));
235   VERSIONS.push_back(Ref<Version>(new Version(4, intArray(2, 6, 26),
236                                   new ECBlocks(20, new ECB(1, 80)),
237                                   new ECBlocks(18, new ECB(2, 32)),
238                                   new ECBlocks(26, new ECB(2, 24)),
239                                   new ECBlocks(16, new ECB(4, 9)))));
240   VERSIONS.push_back(Ref<Version>(new Version(5, intArray(2, 6, 30),
241                                   new ECBlocks(26, new ECB(1, 108)),
242                                   new ECBlocks(24, new ECB(2, 43)),
243                                   new ECBlocks(18, new ECB(2, 15),
244                                                new ECB(2, 16)),
245                                   new ECBlocks(22, new ECB(2, 11),
246                                                new ECB(2, 12)))));
247   VERSIONS.push_back(Ref<Version>(new Version(6, intArray(2, 6, 34),
248                                   new ECBlocks(18, new ECB(2, 68)),
249                                   new ECBlocks(16, new ECB(4, 27)),
250                                   new ECBlocks(24, new ECB(4, 19)),
251                                   new ECBlocks(28, new ECB(4, 15)))));
252   VERSIONS.push_back(Ref<Version>(new Version(7, intArray(3, 6, 22, 38),
253                                   new ECBlocks(20, new ECB(2, 78)),
254                                   new ECBlocks(18, new ECB(4, 31)),
255                                   new ECBlocks(18, new ECB(2, 14),
256                                                new ECB(4, 15)),
257                                   new ECBlocks(26, new ECB(4, 13),
258                                                new ECB(1, 14)))));
259   VERSIONS.push_back(Ref<Version>(new Version(8, intArray(3, 6, 24, 42),
260                                   new ECBlocks(24, new ECB(2, 97)),
261                                   new ECBlocks(22, new ECB(2, 38),
262                                                new ECB(2, 39)),
263                                   new ECBlocks(22, new ECB(4, 18),
264                                                new ECB(2, 19)),
265                                   new ECBlocks(26, new ECB(4, 14),
266                                                new ECB(2, 15)))));
267   VERSIONS.push_back(Ref<Version>(new Version(9, intArray(3, 6, 26, 46),
268                                   new ECBlocks(30, new ECB(2, 116)),
269                                   new ECBlocks(22, new ECB(3, 36),
270                                                new ECB(2, 37)),
271                                   new ECBlocks(20, new ECB(4, 16),
272                                                new ECB(4, 17)),
273                                   new ECBlocks(24, new ECB(4, 12),
274                                                new ECB(4, 13)))));
275   VERSIONS.push_back(Ref<Version>(new Version(10, intArray(3, 6, 28, 50),
276                                   new ECBlocks(18, new ECB(2, 68),
277                                                new ECB(2, 69)),
278                                   new ECBlocks(26, new ECB(4, 43),
279                                                new ECB(1, 44)),
280                                   new ECBlocks(24, new ECB(6, 19),
281                                                new ECB(2, 20)),
282                                   new ECBlocks(28, new ECB(6, 15),
283                                                new ECB(2, 16)))));
284   VERSIONS.push_back(Ref<Version>(new Version(11, intArray(3, 6, 30, 54),
285                                   new ECBlocks(20, new ECB(4, 81)),
286                                   new ECBlocks(30, new ECB(1, 50),
287                                                new ECB(4, 51)),
288                                   new ECBlocks(28, new ECB(4, 22),
289                                                new ECB(4, 23)),
290                                   new ECBlocks(24, new ECB(3, 12),
291                                                new ECB(8, 13)))));
292   VERSIONS.push_back(Ref<Version>(new Version(12, intArray(3, 6, 32, 58),
293                                   new ECBlocks(24, new ECB(2, 92),
294                                                new ECB(2, 93)),
295                                   new ECBlocks(22, new ECB(6, 36),
296                                                new ECB(2, 37)),
297                                   new ECBlocks(26, new ECB(4, 20),
298                                                new ECB(6, 21)),
299                                   new ECBlocks(28, new ECB(7, 14),
300                                                new ECB(4, 15)))));
301   VERSIONS.push_back(Ref<Version>(new Version(13, intArray(3, 6, 34, 62),
302                                   new ECBlocks(26, new ECB(4, 107)),
303                                   new ECBlocks(22, new ECB(8, 37),
304                                                new ECB(1, 38)),
305                                   new ECBlocks(24, new ECB(8, 20),
306                                                new ECB(4, 21)),
307                                   new ECBlocks(22, new ECB(12, 11),
308                                                new ECB(4, 12)))));
309   VERSIONS.push_back(Ref<Version>(new Version(14, intArray(4, 6, 26, 46, 66),
310                                   new ECBlocks(30, new ECB(3, 115),
311                                                new ECB(1, 116)),
312                                   new ECBlocks(24, new ECB(4, 40),
313                                                new ECB(5, 41)),
314                                   new ECBlocks(20, new ECB(11, 16),
315                                                new ECB(5, 17)),
316                                   new ECBlocks(24, new ECB(11, 12),
317                                                new ECB(5, 13)))));
318   VERSIONS.push_back(Ref<Version>(new Version(15, intArray(4, 6, 26, 48, 70),
319                                   new ECBlocks(22, new ECB(5, 87),
320                                                new ECB(1, 88)),
321                                   new ECBlocks(24, new ECB(5, 41),
322                                                new ECB(5, 42)),
323                                   new ECBlocks(30, new ECB(5, 24),
324                                                new ECB(7, 25)),
325                                   new ECBlocks(24, new ECB(11, 12),
326                                                new ECB(7, 13)))));
327   VERSIONS.push_back(Ref<Version>(new Version(16, intArray(4, 6, 26, 50, 74),
328                                   new ECBlocks(24, new ECB(5, 98),
329                                                new ECB(1, 99)),
330                                   new ECBlocks(28, new ECB(7, 45),
331                                                new ECB(3, 46)),
332                                   new ECBlocks(24, new ECB(15, 19),
333                                                new ECB(2, 20)),
334                                   new ECBlocks(30, new ECB(3, 15),
335                                                new ECB(13, 16)))));
336   VERSIONS.push_back(Ref<Version>(new Version(17, intArray(4, 6, 30, 54, 78),
337                                   new ECBlocks(28, new ECB(1, 107),
338                                                new ECB(5, 108)),
339                                   new ECBlocks(28, new ECB(10, 46),
340                                                new ECB(1, 47)),
341                                   new ECBlocks(28, new ECB(1, 22),
342                                                new ECB(15, 23)),
343                                   new ECBlocks(28, new ECB(2, 14),
344                                                new ECB(17, 15)))));
345   VERSIONS.push_back(Ref<Version>(new Version(18, intArray(4, 6, 30, 56, 82),
346                                   new ECBlocks(30, new ECB(5, 120),
347                                                new ECB(1, 121)),
348                                   new ECBlocks(26, new ECB(9, 43),
349                                                new ECB(4, 44)),
350                                   new ECBlocks(28, new ECB(17, 22),
351                                                new ECB(1, 23)),
352                                   new ECBlocks(28, new ECB(2, 14),
353                                                new ECB(19, 15)))));
354   VERSIONS.push_back(Ref<Version>(new Version(19, intArray(4, 6, 30, 58, 86),
355                                   new ECBlocks(28, new ECB(3, 113),
356                                                new ECB(4, 114)),
357                                   new ECBlocks(26, new ECB(3, 44),
358                                                new ECB(11, 45)),
359                                   new ECBlocks(26, new ECB(17, 21),
360                                                new ECB(4, 22)),
361                                   new ECBlocks(26, new ECB(9, 13),
362                                                new ECB(16, 14)))));
363   VERSIONS.push_back(Ref<Version>(new Version(20, intArray(4, 6, 34, 62, 90),
364                                   new ECBlocks(28, new ECB(3, 107),
365                                                new ECB(5, 108)),
366                                   new ECBlocks(26, new ECB(3, 41),
367                                                new ECB(13, 42)),
368                                   new ECBlocks(30, new ECB(15, 24),
369                                                new ECB(5, 25)),
370                                   new ECBlocks(28, new ECB(15, 15),
371                                                new ECB(10, 16)))));
372   VERSIONS.push_back(Ref<Version>(new Version(21, intArray(5, 6, 28, 50, 72, 94),
373                                   new ECBlocks(28, new ECB(4, 116),
374                                                new ECB(4, 117)),
375                                   new ECBlocks(26, new ECB(17, 42)),
376                                   new ECBlocks(28, new ECB(17, 22),
377                                                new ECB(6, 23)),
378                                   new ECBlocks(30, new ECB(19, 16),
379                                                new ECB(6, 17)))));
380   VERSIONS.push_back(Ref<Version>(new Version(22, intArray(5, 6, 26, 50, 74, 98),
381                                   new ECBlocks(28, new ECB(2, 111),
382                                                new ECB(7, 112)),
383                                   new ECBlocks(28, new ECB(17, 46)),
384                                   new ECBlocks(30, new ECB(7, 24),
385                                                new ECB(16, 25)),
386                                   new ECBlocks(24, new ECB(34, 13)))));
387   VERSIONS.push_back(Ref<Version>(new Version(23, intArray(5, 6, 30, 54, 74, 102),
388                                   new ECBlocks(30, new ECB(4, 121),
389                                                new ECB(5, 122)),
390                                   new ECBlocks(28, new ECB(4, 47),
391                                                new ECB(14, 48)),
392                                   new ECBlocks(30, new ECB(11, 24),
393                                                new ECB(14, 25)),
394                                   new ECBlocks(30, new ECB(16, 15),
395                                                new ECB(14, 16)))));
396   VERSIONS.push_back(Ref<Version>(new Version(24, intArray(5, 6, 28, 54, 80, 106),
397                                   new ECBlocks(30, new ECB(6, 117),
398                                                new ECB(4, 118)),
399                                   new ECBlocks(28, new ECB(6, 45),
400                                                new ECB(14, 46)),
401                                   new ECBlocks(30, new ECB(11, 24),
402                                                new ECB(16, 25)),
403                                   new ECBlocks(30, new ECB(30, 16),
404                                                new ECB(2, 17)))));
405   VERSIONS.push_back(Ref<Version>(new Version(25, intArray(5, 6, 32, 58, 84, 110),
406                                   new ECBlocks(26, new ECB(8, 106),
407                                                new ECB(4, 107)),
408                                   new ECBlocks(28, new ECB(8, 47),
409                                                new ECB(13, 48)),
410                                   new ECBlocks(30, new ECB(7, 24),
411                                                new ECB(22, 25)),
412                                   new ECBlocks(30, new ECB(22, 15),
413                                                new ECB(13, 16)))));
414   VERSIONS.push_back(Ref<Version>(new Version(26, intArray(5, 6, 30, 58, 86, 114),
415                                   new ECBlocks(28, new ECB(10, 114),
416                                                new ECB(2, 115)),
417                                   new ECBlocks(28, new ECB(19, 46),
418                                                new ECB(4, 47)),
419                                   new ECBlocks(28, new ECB(28, 22),
420                                                new ECB(6, 23)),
421                                   new ECBlocks(30, new ECB(33, 16),
422                                                new ECB(4, 17)))));
423   VERSIONS.push_back(Ref<Version>(new Version(27, intArray(5, 6, 34, 62, 90, 118),
424                                   new ECBlocks(30, new ECB(8, 122),
425                                                new ECB(4, 123)),
426                                   new ECBlocks(28, new ECB(22, 45),
427                                                new ECB(3, 46)),
428                                   new ECBlocks(30, new ECB(8, 23),
429                                                new ECB(26, 24)),
430                                   new ECBlocks(30, new ECB(12, 15),
431                                                new ECB(28, 16)))));
432   VERSIONS.push_back(Ref<Version>(new Version(28, intArray(6, 6, 26, 50, 74, 98, 122),
433                                   new ECBlocks(30, new ECB(3, 117),
434                                                new ECB(10, 118)),
435                                   new ECBlocks(28, new ECB(3, 45),
436                                                new ECB(23, 46)),
437                                   new ECBlocks(30, new ECB(4, 24),
438                                                new ECB(31, 25)),
439                                   new ECBlocks(30, new ECB(11, 15),
440                                                new ECB(31, 16)))));
441   VERSIONS.push_back(Ref<Version>(new Version(29, intArray(6, 6, 30, 54, 78, 102, 126),
442                                   new ECBlocks(30, new ECB(7, 116),
443                                                new ECB(7, 117)),
444                                   new ECBlocks(28, new ECB(21, 45),
445                                                new ECB(7, 46)),
446                                   new ECBlocks(30, new ECB(1, 23),
447                                                new ECB(37, 24)),
448                                   new ECBlocks(30, new ECB(19, 15),
449                                                new ECB(26, 16)))));
450   VERSIONS.push_back(Ref<Version>(new Version(30, intArray(6, 6, 26, 52, 78, 104, 130),
451                                   new ECBlocks(30, new ECB(5, 115),
452                                                new ECB(10, 116)),
453                                   new ECBlocks(28, new ECB(19, 47),
454                                                new ECB(10, 48)),
455                                   new ECBlocks(30, new ECB(15, 24),
456                                                new ECB(25, 25)),
457                                   new ECBlocks(30, new ECB(23, 15),
458                                                new ECB(25, 16)))));
459   VERSIONS.push_back(Ref<Version>(new Version(31, intArray(6, 6, 30, 56, 82, 108, 134),
460                                   new ECBlocks(30, new ECB(13, 115),
461                                                new ECB(3, 116)),
462                                   new ECBlocks(28, new ECB(2, 46),
463                                                new ECB(29, 47)),
464                                   new ECBlocks(30, new ECB(42, 24),
465                                                new ECB(1, 25)),
466                                   new ECBlocks(30, new ECB(23, 15),
467                                                new ECB(28, 16)))));
468   VERSIONS.push_back(Ref<Version>(new Version(32, intArray(6, 6, 34, 60, 86, 112, 138),
469                                   new ECBlocks(30, new ECB(17, 115)),
470                                   new ECBlocks(28, new ECB(10, 46),
471                                                new ECB(23, 47)),
472                                   new ECBlocks(30, new ECB(10, 24),
473                                                new ECB(35, 25)),
474                                   new ECBlocks(30, new ECB(19, 15),
475                                                new ECB(35, 16)))));
476   VERSIONS.push_back(Ref<Version>(new Version(33, intArray(6, 6, 30, 58, 86, 114, 142),
477                                   new ECBlocks(30, new ECB(17, 115),
478                                                new ECB(1, 116)),
479                                   new ECBlocks(28, new ECB(14, 46),
480                                                new ECB(21, 47)),
481                                   new ECBlocks(30, new ECB(29, 24),
482                                                new ECB(19, 25)),
483                                   new ECBlocks(30, new ECB(11, 15),
484                                                new ECB(46, 16)))));
485   VERSIONS.push_back(Ref<Version>(new Version(34, intArray(6, 6, 34, 62, 90, 118, 146),
486                                   new ECBlocks(30, new ECB(13, 115),
487                                                new ECB(6, 116)),
488                                   new ECBlocks(28, new ECB(14, 46),
489                                                new ECB(23, 47)),
490                                   new ECBlocks(30, new ECB(44, 24),
491                                                new ECB(7, 25)),
492                                   new ECBlocks(30, new ECB(59, 16),
493                                                new ECB(1, 17)))));
494   VERSIONS.push_back(Ref<Version>(new Version(35, intArray(7, 6, 30, 54, 78,
495                                   102, 126, 150),
496                                   new ECBlocks(30, new ECB(12, 121),
497                                                new ECB(7, 122)),
498                                   new ECBlocks(28, new ECB(12, 47),
499                                                new ECB(26, 48)),
500                                   new ECBlocks(30, new ECB(39, 24),
501                                                new ECB(14, 25)),
502                                   new ECBlocks(30, new ECB(22, 15),
503                                                new ECB(41, 16)))));
504   VERSIONS.push_back(Ref<Version>(new Version(36, intArray(7, 6, 24, 50, 76,
505                                   102, 128, 154),
506                                   new ECBlocks(30, new ECB(6, 121),
507                                                new ECB(14, 122)),
508                                   new ECBlocks(28, new ECB(6, 47),
509                                                new ECB(34, 48)),
510                                   new ECBlocks(30, new ECB(46, 24),
511                                                new ECB(10, 25)),
512                                   new ECBlocks(30, new ECB(2, 15),
513                                                new ECB(64, 16)))));
514   VERSIONS.push_back(Ref<Version>(new Version(37, intArray(7, 6, 28, 54, 80,
515                                   106, 132, 158),
516                                   new ECBlocks(30, new ECB(17, 122),
517                                                new ECB(4, 123)),
518                                   new ECBlocks(28, new ECB(29, 46),
519                                                new ECB(14, 47)),
520                                   new ECBlocks(30, new ECB(49, 24),
521                                                new ECB(10, 25)),
522                                   new ECBlocks(30, new ECB(24, 15),
523                                                new ECB(46, 16)))));
524   VERSIONS.push_back(Ref<Version>(new Version(38, intArray(7, 6, 32, 58, 84,
525                                   110, 136, 162),
526                                   new ECBlocks(30, new ECB(4, 122),
527                                                new ECB(18, 123)),
528                                   new ECBlocks(28, new ECB(13, 46),
529                                                new ECB(32, 47)),
530                                   new ECBlocks(30, new ECB(48, 24),
531                                                new ECB(14, 25)),
532                                   new ECBlocks(30, new ECB(42, 15),
533                                                new ECB(32, 16)))));
534   VERSIONS.push_back(Ref<Version>(new Version(39, intArray(7, 6, 26, 54, 82,
535                                   110, 138, 166),
536                                   new ECBlocks(30, new ECB(20, 117),
537                                                new ECB(4, 118)),
538                                   new ECBlocks(28, new ECB(40, 47),
539                                                new ECB(7, 48)),
540                                   new ECBlocks(30, new ECB(43, 24),
541                                                new ECB(22, 25)),
542                                   new ECBlocks(30, new ECB(10, 15),
543                                                new ECB(67, 16)))));
544   VERSIONS.push_back(Ref<Version>(new Version(40, intArray(7, 6, 30, 58, 86,
545                                   114, 142, 170),
546                                   new ECBlocks(30, new ECB(19, 118),
547                                                new ECB(6, 119)),
548                                   new ECBlocks(28, new ECB(18, 47),
549                                                new ECB(31, 48)),
550                                   new ECBlocks(30, new ECB(34, 24),
551                                                new ECB(34, 25)),
552                                   new ECBlocks(30, new ECB(20, 15),
553                                                new ECB(61, 16)))));
554   return VERSIONS.size();
555 }
556 }
557 }