Change all Version* usages to Ref<Version> to avoid valrgind of reporting memory leak on static Version objects. #155

This commit is contained in:
Nikos Ftylitakis 2020-02-12 11:37:14 +02:00
parent f0a78867d6
commit 9d70b9a33b
25 changed files with 201 additions and 200 deletions

View File

@ -119,7 +119,8 @@ ApplicationWindow
{ {
timePerFrameDecode = (decodeTime + framesDecoded * timePerFrameDecode) / (framesDecoded + 1); timePerFrameDecode = (decodeTime + framesDecoded * timePerFrameDecode) / (framesDecoded + 1);
framesDecoded++; framesDecoded++;
console.log("frame finished: " + succeeded, decodeTime, timePerFrameDecode, framesDecoded); if(succeeded)
console.log("frame finished: " + succeeded, decodeTime, timePerFrameDecode, framesDecoded);
} }
} }

View File

@ -61,7 +61,7 @@ ECBlocks::~ECBlocks() {
} }
} }
vector<Version*> Version::VERSIONS; vector<Ref<Version>> Version::VERSIONS;
static int N_VERSIONS = Version::buildVersions(); static int N_VERSIONS = Version::buildVersions();
Version::Version(int versionNumber, int symbolSizeRows, int symbolSizeColumns, int dataRegionSizeRows, Version::Version(int versionNumber, int symbolSizeRows, int symbolSizeColumns, int dataRegionSizeRows,
@ -112,7 +112,7 @@ ECBlocks* Version::getECBlocks() const {
return ecBlocks_; return ecBlocks_;
} }
Version* Version::getVersionForDimensions(int numRows, int numColumns) { Ref<Version> Version::getVersionForDimensions(int numRows, int numColumns) {
if ((numRows & 0x01) != 0 || (numColumns & 0x01) != 0) { if ((numRows & 0x01) != 0 || (numColumns & 0x01) != 0) {
throw ReaderException("Number of rows and columns must be even"); throw ReaderException("Number of rows and columns must be even");
} }
@ -121,7 +121,7 @@ Version* Version::getVersionForDimensions(int numRows, int numColumns) {
// If we interleave the rectangular versions with the square versions we could // If we interleave the rectangular versions with the square versions we could
// do a binary search. // do a binary search.
for (int i = 0; i < N_VERSIONS; ++i){ for (int i = 0; i < N_VERSIONS; ++i){
Version* version = VERSIONS[i]; Ref<Version> version = VERSIONS[i];
if (version->getSymbolSizeRows() == numRows && version->getSymbolSizeColumns() == numColumns) { if (version->getSymbolSizeRows() == numRows && version->getSymbolSizeColumns() == numColumns) {
return version; return version;
} }
@ -133,66 +133,66 @@ Version* Version::getVersionForDimensions(int numRows, int numColumns) {
* See ISO 16022:2006 5.5.1 Table 7 * See ISO 16022:2006 5.5.1 Table 7
*/ */
int Version::buildVersions() { int Version::buildVersions() {
VERSIONS.push_back(new Version(1, 10, 10, 8, 8, VERSIONS.push_back(Ref<Version>(new Version(1, 10, 10, 8, 8,
new ECBlocks(5, new ECB(1, 3)))); new ECBlocks(5, new ECB(1, 3)))));
VERSIONS.push_back(new Version(2, 12, 12, 10, 10, VERSIONS.push_back(Ref<Version>(new Version(2, 12, 12, 10, 10,
new ECBlocks(7, new ECB(1, 5)))); new ECBlocks(7, new ECB(1, 5)))));
VERSIONS.push_back(new Version(3, 14, 14, 12, 12, VERSIONS.push_back(Ref<Version>(new Version(3, 14, 14, 12, 12,
new ECBlocks(10, new ECB(1, 8)))); new ECBlocks(10, new ECB(1, 8)))));
VERSIONS.push_back(new Version(4, 16, 16, 14, 14, VERSIONS.push_back(Ref<Version>(new Version(4, 16, 16, 14, 14,
new ECBlocks(12, new ECB(1, 12)))); new ECBlocks(12, new ECB(1, 12)))));
VERSIONS.push_back(new Version(5, 18, 18, 16, 16, VERSIONS.push_back(Ref<Version>(new Version(5, 18, 18, 16, 16,
new ECBlocks(14, new ECB(1, 18)))); new ECBlocks(14, new ECB(1, 18)))));
VERSIONS.push_back(new Version(6, 20, 20, 18, 18, VERSIONS.push_back(Ref<Version>(new Version(6, 20, 20, 18, 18,
new ECBlocks(18, new ECB(1, 22)))); new ECBlocks(18, new ECB(1, 22)))));
VERSIONS.push_back(new Version(7, 22, 22, 20, 20, VERSIONS.push_back(Ref<Version>(new Version(7, 22, 22, 20, 20,
new ECBlocks(20, new ECB(1, 30)))); new ECBlocks(20, new ECB(1, 30)))));
VERSIONS.push_back(new Version(8, 24, 24, 22, 22, VERSIONS.push_back(Ref<Version>(new Version(8, 24, 24, 22, 22,
new ECBlocks(24, new ECB(1, 36)))); new ECBlocks(24, new ECB(1, 36)))));
VERSIONS.push_back(new Version(9, 26, 26, 24, 24, VERSIONS.push_back(Ref<Version>(new Version(9, 26, 26, 24, 24,
new ECBlocks(28, new ECB(1, 44)))); new ECBlocks(28, new ECB(1, 44)))));
VERSIONS.push_back(new Version(10, 32, 32, 14, 14, VERSIONS.push_back(Ref<Version>(new Version(10, 32, 32, 14, 14,
new ECBlocks(36, new ECB(1, 62)))); new ECBlocks(36, new ECB(1, 62)))));
VERSIONS.push_back(new Version(11, 36, 36, 16, 16, VERSIONS.push_back(Ref<Version>(new Version(11, 36, 36, 16, 16,
new ECBlocks(42, new ECB(1, 86)))); new ECBlocks(42, new ECB(1, 86)))));
VERSIONS.push_back(new Version(12, 40, 40, 18, 18, VERSIONS.push_back(Ref<Version>(new Version(12, 40, 40, 18, 18,
new ECBlocks(48, new ECB(1, 114)))); new ECBlocks(48, new ECB(1, 114)))));
VERSIONS.push_back(new Version(13, 44, 44, 20, 20, VERSIONS.push_back(Ref<Version>(new Version(13, 44, 44, 20, 20,
new ECBlocks(56, new ECB(1, 144)))); new ECBlocks(56, new ECB(1, 144)))));
VERSIONS.push_back(new Version(14, 48, 48, 22, 22, VERSIONS.push_back(Ref<Version>(new Version(14, 48, 48, 22, 22,
new ECBlocks(68, new ECB(1, 174)))); new ECBlocks(68, new ECB(1, 174)))));
VERSIONS.push_back(new Version(15, 52, 52, 24, 24, VERSIONS.push_back(Ref<Version>(new Version(15, 52, 52, 24, 24,
new ECBlocks(42, new ECB(2, 102)))); new ECBlocks(42, new ECB(2, 102)))));
VERSIONS.push_back(new Version(16, 64, 64, 14, 14, VERSIONS.push_back(Ref<Version>(new Version(16, 64, 64, 14, 14,
new ECBlocks(56, new ECB(2, 140)))); new ECBlocks(56, new ECB(2, 140)))));
VERSIONS.push_back(new Version(17, 72, 72, 16, 16, VERSIONS.push_back(Ref<Version>(new Version(17, 72, 72, 16, 16,
new ECBlocks(36, new ECB(4, 92)))); new ECBlocks(36, new ECB(4, 92)))));
VERSIONS.push_back(new Version(18, 80, 80, 18, 18, VERSIONS.push_back(Ref<Version>(new Version(18, 80, 80, 18, 18,
new ECBlocks(48, new ECB(4, 114)))); new ECBlocks(48, new ECB(4, 114)))));
VERSIONS.push_back(new Version(19, 88, 88, 20, 20, VERSIONS.push_back(Ref<Version>(new Version(19, 88, 88, 20, 20,
new ECBlocks(56, new ECB(4, 144)))); new ECBlocks(56, new ECB(4, 144)))));
VERSIONS.push_back(new Version(20, 96, 96, 22, 22, VERSIONS.push_back(Ref<Version>(new Version(20, 96, 96, 22, 22,
new ECBlocks(68, new ECB(4, 174)))); new ECBlocks(68, new ECB(4, 174)))));
VERSIONS.push_back(new Version(21, 104, 104, 24, 24, VERSIONS.push_back(Ref<Version>(new Version(21, 104, 104, 24, 24,
new ECBlocks(56, new ECB(6, 136)))); new ECBlocks(56, new ECB(6, 136)))));
VERSIONS.push_back(new Version(22, 120, 120, 18, 18, VERSIONS.push_back(Ref<Version>(new Version(22, 120, 120, 18, 18,
new ECBlocks(68, new ECB(6, 175)))); new ECBlocks(68, new ECB(6, 175)))));
VERSIONS.push_back(new Version(23, 132, 132, 20, 20, VERSIONS.push_back(Ref<Version>(new Version(23, 132, 132, 20, 20,
new ECBlocks(62, new ECB(8, 163)))); new ECBlocks(62, new ECB(8, 163)))));
VERSIONS.push_back(new Version(24, 144, 144, 22, 22, VERSIONS.push_back(Ref<Version>(new Version(24, 144, 144, 22, 22,
new ECBlocks(62, new ECB(8, 156), new ECB(2, 155)))); new ECBlocks(62, new ECB(8, 156), new ECB(2, 155)))));
VERSIONS.push_back(new Version(25, 8, 18, 6, 16, VERSIONS.push_back(Ref<Version>(new Version(25, 8, 18, 6, 16,
new ECBlocks(7, new ECB(1, 5)))); new ECBlocks(7, new ECB(1, 5)))));
VERSIONS.push_back(new Version(26, 8, 32, 6, 14, VERSIONS.push_back(Ref<Version>(new Version(26, 8, 32, 6, 14,
new ECBlocks(11, new ECB(1, 10)))); new ECBlocks(11, new ECB(1, 10)))));
VERSIONS.push_back(new Version(27, 12, 26, 10, 24, VERSIONS.push_back(Ref<Version>(new Version(27, 12, 26, 10, 24,
new ECBlocks(14, new ECB(1, 16)))); new ECBlocks(14, new ECB(1, 16)))));
VERSIONS.push_back(new Version(28, 12, 36, 10, 16, VERSIONS.push_back(Ref<Version>(new Version(28, 12, 36, 10, 16,
new ECBlocks(18, new ECB(1, 22)))); new ECBlocks(18, new ECB(1, 22)))));
VERSIONS.push_back(new Version(29, 16, 36, 14, 16, VERSIONS.push_back(Ref<Version>(new Version(29, 16, 36, 14, 16,
new ECBlocks(24, new ECB(1, 32)))); new ECBlocks(24, new ECB(1, 32)))));
VERSIONS.push_back(new Version(30, 16, 48, 14, 22, VERSIONS.push_back(Ref<Version>(new Version(30, 16, 48, 14, 22,
new ECBlocks(28, new ECB(1, 49)))); new ECBlocks(28, new ECB(1, 49)))));
return int(VERSIONS.size()); return int(VERSIONS.size());
} }
} }

View File

@ -64,7 +64,7 @@ private:
int dataRegionSizeColumns, ECBlocks *ecBlocks); int dataRegionSizeColumns, ECBlocks *ecBlocks);
public: public:
static std::vector<Version*> VERSIONS; static std::vector<Ref<Version>> VERSIONS;
~Version(); ~Version();
int getVersionNumber() const; int getVersionNumber() const;
@ -75,7 +75,7 @@ public:
int getTotalCodewords() const; int getTotalCodewords() const;
ECBlocks* getECBlocks() const; ECBlocks* getECBlocks() const;
static int buildVersions(); static int buildVersions();
Version *getVersionForDimensions(int numRows, int numColumns); Ref<Version>getVersionForDimensions(int numRows, int numColumns);
private: private:
Version(const Version&); Version(const Version&);

View File

@ -33,14 +33,14 @@ namespace datamatrix {
class BitMatrixParser : public Counted { class BitMatrixParser : public Counted {
private: private:
Ref<BitMatrix> bitMatrix_; Ref<BitMatrix> bitMatrix_;
Version* parsedVersion_; Ref<Version> parsedVersion_;
Ref<BitMatrix> readBitMatrix_; Ref<BitMatrix> readBitMatrix_;
int copyBit(size_t x, size_t y, int versionBits); int copyBit(size_t x, size_t y, int versionBits);
public: public:
BitMatrixParser(Ref<BitMatrix> bitMatrix); BitMatrixParser(Ref<BitMatrix> bitMatrix);
Version* readVersion(Ref<BitMatrix> bitMatrix); Ref<Version> readVersion(Ref<BitMatrix> bitMatrix);
ArrayRef<zxing::byte> readCodewords(); ArrayRef<zxing::byte> readCodewords();
bool readModule(int row, int column, int numRows, int numColumns); bool readModule(int row, int column, int numRows, int numColumns);

View File

@ -37,7 +37,7 @@ private:
DataBlock(int numDataCodewords, ArrayRef<zxing::byte> codewords); DataBlock(int numDataCodewords, ArrayRef<zxing::byte> codewords);
public: public:
static std::vector<Ref<DataBlock> > getDataBlocks(ArrayRef<zxing::byte> rawCodewords, Version *version); static std::vector<Ref<DataBlock> > getDataBlocks(ArrayRef<zxing::byte> rawCodewords, Ref<Version>version);
int getNumDataCodewords(); int getNumDataCodewords();
ArrayRef<zxing::byte> getCodewords(); ArrayRef<zxing::byte> getCodewords();

View File

@ -42,7 +42,7 @@ BitMatrixParser::BitMatrixParser(Ref<BitMatrix> bitMatrix) : bitMatrix_(NULL),
readBitMatrix_ = new BitMatrix(bitMatrix_->getWidth(), bitMatrix_->getHeight()); readBitMatrix_ = new BitMatrix(bitMatrix_->getWidth(), bitMatrix_->getHeight());
} }
Version* BitMatrixParser::readVersion(Ref<BitMatrix> bitMatrix) { Ref<Version> BitMatrixParser::readVersion(Ref<BitMatrix> bitMatrix) {
if (parsedVersion_ != 0) { if (parsedVersion_ != 0) {
return parsedVersion_; return parsedVersion_;
} }
@ -50,7 +50,7 @@ Version* BitMatrixParser::readVersion(Ref<BitMatrix> bitMatrix) {
int numRows = bitMatrix->getHeight(); int numRows = bitMatrix->getHeight();
int numColumns = bitMatrix->getWidth(); int numColumns = bitMatrix->getWidth();
Version* version = parsedVersion_->getVersionForDimensions(numRows, numColumns); Ref<Version> version = parsedVersion_->getVersionForDimensions(numRows, numColumns);
if (version != 0) { if (version != 0) {
return version; return version;
} }

View File

@ -38,7 +38,7 @@ ArrayRef<zxing::byte> DataBlock::getCodewords() {
return codewords_; return codewords_;
} }
std::vector<Ref<DataBlock> > DataBlock::getDataBlocks(ArrayRef<zxing::byte> rawCodewords, Version *version) { std::vector<Ref<DataBlock> > DataBlock::getDataBlocks(ArrayRef<zxing::byte> rawCodewords, Ref<Version>version) {
// Figure out the number and size of data blocks used by this version and // Figure out the number and size of data blocks used by this version and
// error correction level // error correction level
ECBlocks* ecBlocks = version->getECBlocks(); ECBlocks* ecBlocks = version->getECBlocks();

View File

@ -65,7 +65,7 @@ void Decoder::correctErrors(ArrayRef<zxing::byte> codewordBytes, int numDataCode
Ref<DecoderResult> Decoder::decode(Ref<BitMatrix> bits) { Ref<DecoderResult> Decoder::decode(Ref<BitMatrix> bits) {
// Construct a parser and read version, error-correction level // Construct a parser and read version, error-correction level
BitMatrixParser parser(bits); BitMatrixParser parser(bits);
Version *version = parser.readVersion(bits); Ref<Version>version = parser.readVersion(bits);
// Read codewords // Read codewords
ArrayRef<zxing::byte> codewords(parser.readCodewords()); ArrayRef<zxing::byte> codewords(parser.readCodewords());

View File

@ -88,7 +88,7 @@ unsigned int Version::VERSION_DECODE_INFO[] = { 0x07C94, 0x085BC, 0x09A99, 0x0A4
0x27541, 0x28C69 0x27541, 0x28C69
}; };
int Version::N_VERSION_DECODE_INFOS = 34; int Version::N_VERSION_DECODE_INFOS = 34;
vector<Version*> Version::VERSIONS; vector<Ref<Version>> Version::VERSIONS;
static int N_VERSIONS = Version::buildVersions(); static int N_VERSIONS = Version::buildVersions();
int Version::getVersionNumber() const { int Version::getVersionNumber() const {
@ -111,7 +111,7 @@ ECBlocks& Version::getECBlocksForLevel(const ErrorCorrectionLevel &ecLevel) cons
return *ecBlocks_[ecLevel.ordinal()]; return *ecBlocks_[ecLevel.ordinal()];
} }
Version* Version::getProvisionalVersionForDimension(int dimension) { Ref<Version> Version::getProvisionalVersionForDimension(int dimension) {
if (dimension % 4 != 1) { if (dimension % 4 != 1) {
throw FormatException(); throw FormatException();
} }
@ -123,7 +123,7 @@ Version* Version::getProvisionalVersionForDimension(int dimension) {
} }
} }
Version* Version::getVersionForNumber(int versionNumber) { Ref<Version> Version::getVersionForNumber(int versionNumber) {
if (versionNumber < 1 || versionNumber > N_VERSIONS) { if (versionNumber < 1 || versionNumber > N_VERSIONS) {
throw ReaderException("versionNumber must be between 1 and 40"); throw ReaderException("versionNumber must be between 1 and 40");
} }
@ -156,7 +156,7 @@ Version::~Version() {
} }
} }
Version* Version::decodeVersionInformation(unsigned int versionBits) { Ref<Version> Version::decodeVersionInformation(unsigned int versionBits) {
int bestDifference = numeric_limits<int>::max(); int bestDifference = numeric_limits<int>::max();
size_t bestVersion = 0; size_t bestVersion = 0;
for (int i = 0; i < N_VERSION_DECODE_INFOS; i++) { for (int i = 0; i < N_VERSION_DECODE_INFOS; i++) {
@ -179,7 +179,7 @@ Version* Version::decodeVersionInformation(unsigned int versionBits) {
return getVersionForNumber(int(bestVersion)); return getVersionForNumber(int(bestVersion));
} }
// If we didn't find a close enough match, fail // If we didn't find a close enough match, fail
return NULL; return Ref<Version>();
} }
Ref<BitMatrix> Version::buildFunctionPattern() { Ref<BitMatrix> Version::buildFunctionPattern() {
@ -235,62 +235,62 @@ static vector<int> *intArray(size_t n...) {
} }
int Version::buildVersions() { int Version::buildVersions() {
VERSIONS.push_back(new Version(1, intArray(0), VERSIONS.push_back(Ref<Version>( new Version(1, intArray(0),
new ECBlocks(7, new ECB(1, 19)), new ECBlocks(7, new ECB(1, 19)),
new ECBlocks(10, new ECB(1, 16)), new ECBlocks(10, new ECB(1, 16)),
new ECBlocks(13, new ECB(1, 13)), new ECBlocks(13, new ECB(1, 13)),
new ECBlocks(17, new ECB(1, 9)))); new ECBlocks(17, new ECB(1, 9)))));
VERSIONS.push_back(new Version(2, intArray(2, 6, 18), VERSIONS.push_back(Ref<Version>( new Version(2, intArray(2, 6, 18),
new ECBlocks(10, new ECB(1, 34)), new ECBlocks(10, new ECB(1, 34)),
new ECBlocks(16, new ECB(1, 28)), new ECBlocks(16, new ECB(1, 28)),
new ECBlocks(22, new ECB(1, 22)), new ECBlocks(22, new ECB(1, 22)),
new ECBlocks(28, new ECB(1, 16)))); new ECBlocks(28, new ECB(1, 16)))));
VERSIONS.push_back(new Version(3, intArray(2, 6, 22), VERSIONS.push_back(Ref<Version>( new Version(3, intArray(2, 6, 22),
new ECBlocks(15, new ECB(1, 55)), new ECBlocks(15, new ECB(1, 55)),
new ECBlocks(26, new ECB(1, 44)), new ECBlocks(26, new ECB(1, 44)),
new ECBlocks(18, new ECB(2, 17)), new ECBlocks(18, new ECB(2, 17)),
new ECBlocks(22, new ECB(2, 13)))); new ECBlocks(22, new ECB(2, 13)))));
VERSIONS.push_back(new Version(4, intArray(2, 6, 26), VERSIONS.push_back(Ref<Version>( new Version(4, intArray(2, 6, 26),
new ECBlocks(20, new ECB(1, 80)), new ECBlocks(20, new ECB(1, 80)),
new ECBlocks(18, new ECB(2, 32)), new ECBlocks(18, new ECB(2, 32)),
new ECBlocks(26, new ECB(2, 24)), new ECBlocks(26, new ECB(2, 24)),
new ECBlocks(16, new ECB(4, 9)))); new ECBlocks(16, new ECB(4, 9)))));
VERSIONS.push_back(new Version(5, intArray(2, 6, 30), VERSIONS.push_back(Ref<Version>( new Version(5, intArray(2, 6, 30),
new ECBlocks(26, new ECB(1, 108)), new ECBlocks(26, new ECB(1, 108)),
new ECBlocks(24, new ECB(2, 43)), new ECBlocks(24, new ECB(2, 43)),
new ECBlocks(18, new ECB(2, 15), new ECBlocks(18, new ECB(2, 15),
new ECB(2, 16)), new ECB(2, 16)),
new ECBlocks(22, new ECB(2, 11), new ECBlocks(22, new ECB(2, 11),
new ECB(2, 12)))); new ECB(2, 12)))));
VERSIONS.push_back(new Version(6, intArray(2, 6, 34), VERSIONS.push_back(Ref<Version>( new Version(6, intArray(2, 6, 34),
new ECBlocks(18, new ECB(2, 68)), new ECBlocks(18, new ECB(2, 68)),
new ECBlocks(16, new ECB(4, 27)), new ECBlocks(16, new ECB(4, 27)),
new ECBlocks(24, new ECB(4, 19)), new ECBlocks(24, new ECB(4, 19)),
new ECBlocks(28, new ECB(4, 15)))); new ECBlocks(28, new ECB(4, 15)))));
VERSIONS.push_back(new Version(7, intArray(3, 6, 22, 38), VERSIONS.push_back(Ref<Version>( new Version(7, intArray(3, 6, 22, 38),
new ECBlocks(20, new ECB(2, 78)), new ECBlocks(20, new ECB(2, 78)),
new ECBlocks(18, new ECB(4, 31)), new ECBlocks(18, new ECB(4, 31)),
new ECBlocks(18, new ECB(2, 14), new ECBlocks(18, new ECB(2, 14),
new ECB(4, 15)), new ECB(4, 15)),
new ECBlocks(26, new ECB(4, 13), new ECBlocks(26, new ECB(4, 13),
new ECB(1, 14)))); new ECB(1, 14)))));
VERSIONS.push_back(new Version(8, intArray(3, 6, 24, 42), VERSIONS.push_back(Ref<Version>( new Version(8, intArray(3, 6, 24, 42),
new ECBlocks(24, new ECB(2, 97)), new ECBlocks(24, new ECB(2, 97)),
new ECBlocks(22, new ECB(2, 38), new ECBlocks(22, new ECB(2, 38),
new ECB(2, 39)), new ECB(2, 39)),
new ECBlocks(22, new ECB(4, 18), new ECBlocks(22, new ECB(4, 18),
new ECB(2, 19)), new ECB(2, 19)),
new ECBlocks(26, new ECB(4, 14), new ECBlocks(26, new ECB(4, 14),
new ECB(2, 15)))); new ECB(2, 15)))));
VERSIONS.push_back(new Version(9, intArray(3, 6, 26, 46), VERSIONS.push_back(Ref<Version>( new Version(9, intArray(3, 6, 26, 46),
new ECBlocks(30, new ECB(2, 116)), new ECBlocks(30, new ECB(2, 116)),
new ECBlocks(22, new ECB(3, 36), new ECBlocks(22, new ECB(3, 36),
new ECB(2, 37)), new ECB(2, 37)),
new ECBlocks(20, new ECB(4, 16), new ECBlocks(20, new ECB(4, 16),
new ECB(4, 17)), new ECB(4, 17)),
new ECBlocks(24, new ECB(4, 12), new ECBlocks(24, new ECB(4, 12),
new ECB(4, 13)))); new ECB(4, 13)))));
VERSIONS.push_back(new Version(10, intArray(3, 6, 28, 50), VERSIONS.push_back(Ref<Version>( new Version(10, intArray(3, 6, 28, 50),
new ECBlocks(18, new ECB(2, 68), new ECBlocks(18, new ECB(2, 68),
new ECB(2, 69)), new ECB(2, 69)),
new ECBlocks(26, new ECB(4, 43), new ECBlocks(26, new ECB(4, 43),
@ -298,16 +298,16 @@ int Version::buildVersions() {
new ECBlocks(24, new ECB(6, 19), new ECBlocks(24, new ECB(6, 19),
new ECB(2, 20)), new ECB(2, 20)),
new ECBlocks(28, new ECB(6, 15), new ECBlocks(28, new ECB(6, 15),
new ECB(2, 16)))); new ECB(2, 16)))));
VERSIONS.push_back(new Version(11, intArray(3, 6, 30, 54), VERSIONS.push_back(Ref<Version>( new Version(11, intArray(3, 6, 30, 54),
new ECBlocks(20, new ECB(4, 81)), new ECBlocks(20, new ECB(4, 81)),
new ECBlocks(30, new ECB(1, 50), new ECBlocks(30, new ECB(1, 50),
new ECB(4, 51)), new ECB(4, 51)),
new ECBlocks(28, new ECB(4, 22), new ECBlocks(28, new ECB(4, 22),
new ECB(4, 23)), new ECB(4, 23)),
new ECBlocks(24, new ECB(3, 12), new ECBlocks(24, new ECB(3, 12),
new ECB(8, 13)))); new ECB(8, 13)))));
VERSIONS.push_back(new Version(12, intArray(3, 6, 32, 58), VERSIONS.push_back(Ref<Version>( new Version(12, intArray(3, 6, 32, 58),
new ECBlocks(24, new ECB(2, 92), new ECBlocks(24, new ECB(2, 92),
new ECB(2, 93)), new ECB(2, 93)),
new ECBlocks(22, new ECB(6, 36), new ECBlocks(22, new ECB(6, 36),
@ -315,16 +315,16 @@ int Version::buildVersions() {
new ECBlocks(26, new ECB(4, 20), new ECBlocks(26, new ECB(4, 20),
new ECB(6, 21)), new ECB(6, 21)),
new ECBlocks(28, new ECB(7, 14), new ECBlocks(28, new ECB(7, 14),
new ECB(4, 15)))); new ECB(4, 15)))));
VERSIONS.push_back(new Version(13, intArray(3, 6, 34, 62), VERSIONS.push_back(Ref<Version>( new Version(13, intArray(3, 6, 34, 62),
new ECBlocks(26, new ECB(4, 107)), new ECBlocks(26, new ECB(4, 107)),
new ECBlocks(22, new ECB(8, 37), new ECBlocks(22, new ECB(8, 37),
new ECB(1, 38)), new ECB(1, 38)),
new ECBlocks(24, new ECB(8, 20), new ECBlocks(24, new ECB(8, 20),
new ECB(4, 21)), new ECB(4, 21)),
new ECBlocks(22, new ECB(12, 11), new ECBlocks(22, new ECB(12, 11),
new ECB(4, 12)))); new ECB(4, 12)))));
VERSIONS.push_back(new Version(14, intArray(4, 6, 26, 46, 66), VERSIONS.push_back(Ref<Version>( new Version(14, intArray(4, 6, 26, 46, 66),
new ECBlocks(30, new ECB(3, 115), new ECBlocks(30, new ECB(3, 115),
new ECB(1, 116)), new ECB(1, 116)),
new ECBlocks(24, new ECB(4, 40), new ECBlocks(24, new ECB(4, 40),
@ -332,8 +332,8 @@ int Version::buildVersions() {
new ECBlocks(20, new ECB(11, 16), new ECBlocks(20, new ECB(11, 16),
new ECB(5, 17)), new ECB(5, 17)),
new ECBlocks(24, new ECB(11, 12), new ECBlocks(24, new ECB(11, 12),
new ECB(5, 13)))); new ECB(5, 13)))));
VERSIONS.push_back(new Version(15, intArray(4, 6, 26, 48, 70), VERSIONS.push_back(Ref<Version>( new Version(15, intArray(4, 6, 26, 48, 70),
new ECBlocks(22, new ECB(5, 87), new ECBlocks(22, new ECB(5, 87),
new ECB(1, 88)), new ECB(1, 88)),
new ECBlocks(24, new ECB(5, 41), new ECBlocks(24, new ECB(5, 41),
@ -341,8 +341,8 @@ int Version::buildVersions() {
new ECBlocks(30, new ECB(5, 24), new ECBlocks(30, new ECB(5, 24),
new ECB(7, 25)), new ECB(7, 25)),
new ECBlocks(24, new ECB(11, 12), new ECBlocks(24, new ECB(11, 12),
new ECB(7, 13)))); new ECB(7, 13)))));
VERSIONS.push_back(new Version(16, intArray(4, 6, 26, 50, 74), VERSIONS.push_back(Ref<Version>( new Version(16, intArray(4, 6, 26, 50, 74),
new ECBlocks(24, new ECB(5, 98), new ECBlocks(24, new ECB(5, 98),
new ECB(1, 99)), new ECB(1, 99)),
new ECBlocks(28, new ECB(7, 45), new ECBlocks(28, new ECB(7, 45),
@ -350,8 +350,8 @@ int Version::buildVersions() {
new ECBlocks(24, new ECB(15, 19), new ECBlocks(24, new ECB(15, 19),
new ECB(2, 20)), new ECB(2, 20)),
new ECBlocks(30, new ECB(3, 15), new ECBlocks(30, new ECB(3, 15),
new ECB(13, 16)))); new ECB(13, 16)))));
VERSIONS.push_back(new Version(17, intArray(4, 6, 30, 54, 78), VERSIONS.push_back(Ref<Version>( new Version(17, intArray(4, 6, 30, 54, 78),
new ECBlocks(28, new ECB(1, 107), new ECBlocks(28, new ECB(1, 107),
new ECB(5, 108)), new ECB(5, 108)),
new ECBlocks(28, new ECB(10, 46), new ECBlocks(28, new ECB(10, 46),
@ -359,8 +359,8 @@ int Version::buildVersions() {
new ECBlocks(28, new ECB(1, 22), new ECBlocks(28, new ECB(1, 22),
new ECB(15, 23)), new ECB(15, 23)),
new ECBlocks(28, new ECB(2, 14), new ECBlocks(28, new ECB(2, 14),
new ECB(17, 15)))); new ECB(17, 15)))));
VERSIONS.push_back(new Version(18, intArray(4, 6, 30, 56, 82), VERSIONS.push_back(Ref<Version>( new Version(18, intArray(4, 6, 30, 56, 82),
new ECBlocks(30, new ECB(5, 120), new ECBlocks(30, new ECB(5, 120),
new ECB(1, 121)), new ECB(1, 121)),
new ECBlocks(26, new ECB(9, 43), new ECBlocks(26, new ECB(9, 43),
@ -368,8 +368,8 @@ int Version::buildVersions() {
new ECBlocks(28, new ECB(17, 22), new ECBlocks(28, new ECB(17, 22),
new ECB(1, 23)), new ECB(1, 23)),
new ECBlocks(28, new ECB(2, 14), new ECBlocks(28, new ECB(2, 14),
new ECB(19, 15)))); new ECB(19, 15)))));
VERSIONS.push_back(new Version(19, intArray(4, 6, 30, 58, 86), VERSIONS.push_back(Ref<Version>( new Version(19, intArray(4, 6, 30, 58, 86),
new ECBlocks(28, new ECB(3, 113), new ECBlocks(28, new ECB(3, 113),
new ECB(4, 114)), new ECB(4, 114)),
new ECBlocks(26, new ECB(3, 44), new ECBlocks(26, new ECB(3, 44),
@ -377,8 +377,8 @@ int Version::buildVersions() {
new ECBlocks(26, new ECB(17, 21), new ECBlocks(26, new ECB(17, 21),
new ECB(4, 22)), new ECB(4, 22)),
new ECBlocks(26, new ECB(9, 13), new ECBlocks(26, new ECB(9, 13),
new ECB(16, 14)))); new ECB(16, 14)))));
VERSIONS.push_back(new Version(20, intArray(4, 6, 34, 62, 90), VERSIONS.push_back(Ref<Version>( new Version(20, intArray(4, 6, 34, 62, 90),
new ECBlocks(28, new ECB(3, 107), new ECBlocks(28, new ECB(3, 107),
new ECB(5, 108)), new ECB(5, 108)),
new ECBlocks(26, new ECB(3, 41), new ECBlocks(26, new ECB(3, 41),
@ -386,23 +386,23 @@ int Version::buildVersions() {
new ECBlocks(30, new ECB(15, 24), new ECBlocks(30, new ECB(15, 24),
new ECB(5, 25)), new ECB(5, 25)),
new ECBlocks(28, new ECB(15, 15), new ECBlocks(28, new ECB(15, 15),
new ECB(10, 16)))); new ECB(10, 16)))));
VERSIONS.push_back(new Version(21, intArray(5, 6, 28, 50, 72, 94), VERSIONS.push_back(Ref<Version>( new Version(21, intArray(5, 6, 28, 50, 72, 94),
new ECBlocks(28, new ECB(4, 116), new ECBlocks(28, new ECB(4, 116),
new ECB(4, 117)), new ECB(4, 117)),
new ECBlocks(26, new ECB(17, 42)), new ECBlocks(26, new ECB(17, 42)),
new ECBlocks(28, new ECB(17, 22), new ECBlocks(28, new ECB(17, 22),
new ECB(6, 23)), new ECB(6, 23)),
new ECBlocks(30, new ECB(19, 16), new ECBlocks(30, new ECB(19, 16),
new ECB(6, 17)))); new ECB(6, 17)))));
VERSIONS.push_back(new Version(22, intArray(5, 6, 26, 50, 74, 98), VERSIONS.push_back(Ref<Version>( new Version(22, intArray(5, 6, 26, 50, 74, 98),
new ECBlocks(28, new ECB(2, 111), new ECBlocks(28, new ECB(2, 111),
new ECB(7, 112)), new ECB(7, 112)),
new ECBlocks(28, new ECB(17, 46)), new ECBlocks(28, new ECB(17, 46)),
new ECBlocks(30, new ECB(7, 24), new ECBlocks(30, new ECB(7, 24),
new ECB(16, 25)), new ECB(16, 25)),
new ECBlocks(24, new ECB(34, 13)))); new ECBlocks(24, new ECB(34, 13)))));
VERSIONS.push_back(new Version(23, intArray(5, 6, 30, 54, 78, 102), VERSIONS.push_back(Ref<Version>( new Version(23, intArray(5, 6, 30, 54, 78, 102),
new ECBlocks(30, new ECB(4, 121), new ECBlocks(30, new ECB(4, 121),
new ECB(5, 122)), new ECB(5, 122)),
new ECBlocks(28, new ECB(4, 47), new ECBlocks(28, new ECB(4, 47),
@ -410,8 +410,8 @@ int Version::buildVersions() {
new ECBlocks(30, new ECB(11, 24), new ECBlocks(30, new ECB(11, 24),
new ECB(14, 25)), new ECB(14, 25)),
new ECBlocks(30, new ECB(16, 15), new ECBlocks(30, new ECB(16, 15),
new ECB(14, 16)))); new ECB(14, 16)))));
VERSIONS.push_back(new Version(24, intArray(5, 6, 28, 54, 80, 106), VERSIONS.push_back(Ref<Version>( new Version(24, intArray(5, 6, 28, 54, 80, 106),
new ECBlocks(30, new ECB(6, 117), new ECBlocks(30, new ECB(6, 117),
new ECB(4, 118)), new ECB(4, 118)),
new ECBlocks(28, new ECB(6, 45), new ECBlocks(28, new ECB(6, 45),
@ -419,8 +419,8 @@ int Version::buildVersions() {
new ECBlocks(30, new ECB(11, 24), new ECBlocks(30, new ECB(11, 24),
new ECB(16, 25)), new ECB(16, 25)),
new ECBlocks(30, new ECB(30, 16), new ECBlocks(30, new ECB(30, 16),
new ECB(2, 17)))); new ECB(2, 17)))));
VERSIONS.push_back(new Version(25, intArray(5, 6, 32, 58, 84, 110), VERSIONS.push_back(Ref<Version>( new Version(25, intArray(5, 6, 32, 58, 84, 110),
new ECBlocks(26, new ECB(8, 106), new ECBlocks(26, new ECB(8, 106),
new ECB(4, 107)), new ECB(4, 107)),
new ECBlocks(28, new ECB(8, 47), new ECBlocks(28, new ECB(8, 47),
@ -428,8 +428,8 @@ int Version::buildVersions() {
new ECBlocks(30, new ECB(7, 24), new ECBlocks(30, new ECB(7, 24),
new ECB(22, 25)), new ECB(22, 25)),
new ECBlocks(30, new ECB(22, 15), new ECBlocks(30, new ECB(22, 15),
new ECB(13, 16)))); new ECB(13, 16)))));
VERSIONS.push_back(new Version(26, intArray(5, 6, 30, 58, 86, 114), VERSIONS.push_back(Ref<Version>( new Version(26, intArray(5, 6, 30, 58, 86, 114),
new ECBlocks(28, new ECB(10, 114), new ECBlocks(28, new ECB(10, 114),
new ECB(2, 115)), new ECB(2, 115)),
new ECBlocks(28, new ECB(19, 46), new ECBlocks(28, new ECB(19, 46),
@ -437,8 +437,8 @@ int Version::buildVersions() {
new ECBlocks(28, new ECB(28, 22), new ECBlocks(28, new ECB(28, 22),
new ECB(6, 23)), new ECB(6, 23)),
new ECBlocks(30, new ECB(33, 16), new ECBlocks(30, new ECB(33, 16),
new ECB(4, 17)))); new ECB(4, 17)))));
VERSIONS.push_back(new Version(27, intArray(5, 6, 34, 62, 90, 118), VERSIONS.push_back(Ref<Version>( new Version(27, intArray(5, 6, 34, 62, 90, 118),
new ECBlocks(30, new ECB(8, 122), new ECBlocks(30, new ECB(8, 122),
new ECB(4, 123)), new ECB(4, 123)),
new ECBlocks(28, new ECB(22, 45), new ECBlocks(28, new ECB(22, 45),
@ -446,8 +446,8 @@ int Version::buildVersions() {
new ECBlocks(30, new ECB(8, 23), new ECBlocks(30, new ECB(8, 23),
new ECB(26, 24)), new ECB(26, 24)),
new ECBlocks(30, new ECB(12, 15), new ECBlocks(30, new ECB(12, 15),
new ECB(28, 16)))); new ECB(28, 16)))));
VERSIONS.push_back(new Version(28, intArray(6, 6, 26, 50, 74, 98, 122), VERSIONS.push_back(Ref<Version>( new Version(28, intArray(6, 6, 26, 50, 74, 98, 122),
new ECBlocks(30, new ECB(3, 117), new ECBlocks(30, new ECB(3, 117),
new ECB(10, 118)), new ECB(10, 118)),
new ECBlocks(28, new ECB(3, 45), new ECBlocks(28, new ECB(3, 45),
@ -455,8 +455,8 @@ int Version::buildVersions() {
new ECBlocks(30, new ECB(4, 24), new ECBlocks(30, new ECB(4, 24),
new ECB(31, 25)), new ECB(31, 25)),
new ECBlocks(30, new ECB(11, 15), new ECBlocks(30, new ECB(11, 15),
new ECB(31, 16)))); new ECB(31, 16)))));
VERSIONS.push_back(new Version(29, intArray(6, 6, 30, 54, 78, 102, 126), VERSIONS.push_back(Ref<Version>( new Version(29, intArray(6, 6, 30, 54, 78, 102, 126),
new ECBlocks(30, new ECB(7, 116), new ECBlocks(30, new ECB(7, 116),
new ECB(7, 117)), new ECB(7, 117)),
new ECBlocks(28, new ECB(21, 45), new ECBlocks(28, new ECB(21, 45),
@ -464,8 +464,8 @@ int Version::buildVersions() {
new ECBlocks(30, new ECB(1, 23), new ECBlocks(30, new ECB(1, 23),
new ECB(37, 24)), new ECB(37, 24)),
new ECBlocks(30, new ECB(19, 15), new ECBlocks(30, new ECB(19, 15),
new ECB(26, 16)))); new ECB(26, 16)))));
VERSIONS.push_back(new Version(30, intArray(6, 6, 26, 52, 78, 104, 130), VERSIONS.push_back(Ref<Version>( new Version(30, intArray(6, 6, 26, 52, 78, 104, 130),
new ECBlocks(30, new ECB(5, 115), new ECBlocks(30, new ECB(5, 115),
new ECB(10, 116)), new ECB(10, 116)),
new ECBlocks(28, new ECB(19, 47), new ECBlocks(28, new ECB(19, 47),
@ -473,8 +473,8 @@ int Version::buildVersions() {
new ECBlocks(30, new ECB(15, 24), new ECBlocks(30, new ECB(15, 24),
new ECB(25, 25)), new ECB(25, 25)),
new ECBlocks(30, new ECB(23, 15), new ECBlocks(30, new ECB(23, 15),
new ECB(25, 16)))); new ECB(25, 16)))));
VERSIONS.push_back(new Version(31, intArray(6, 6, 30, 56, 82, 108, 134), VERSIONS.push_back(Ref<Version>( new Version(31, intArray(6, 6, 30, 56, 82, 108, 134),
new ECBlocks(30, new ECB(13, 115), new ECBlocks(30, new ECB(13, 115),
new ECB(3, 116)), new ECB(3, 116)),
new ECBlocks(28, new ECB(2, 46), new ECBlocks(28, new ECB(2, 46),
@ -482,16 +482,16 @@ int Version::buildVersions() {
new ECBlocks(30, new ECB(42, 24), new ECBlocks(30, new ECB(42, 24),
new ECB(1, 25)), new ECB(1, 25)),
new ECBlocks(30, new ECB(23, 15), new ECBlocks(30, new ECB(23, 15),
new ECB(28, 16)))); new ECB(28, 16)))));
VERSIONS.push_back(new Version(32, intArray(6, 6, 34, 60, 86, 112, 138), VERSIONS.push_back(Ref<Version>( new Version(32, intArray(6, 6, 34, 60, 86, 112, 138),
new ECBlocks(30, new ECB(17, 115)), new ECBlocks(30, new ECB(17, 115)),
new ECBlocks(28, new ECB(10, 46), new ECBlocks(28, new ECB(10, 46),
new ECB(23, 47)), new ECB(23, 47)),
new ECBlocks(30, new ECB(10, 24), new ECBlocks(30, new ECB(10, 24),
new ECB(35, 25)), new ECB(35, 25)),
new ECBlocks(30, new ECB(19, 15), new ECBlocks(30, new ECB(19, 15),
new ECB(35, 16)))); new ECB(35, 16)))));
VERSIONS.push_back(new Version(33, intArray(6, 6, 30, 58, 86, 114, 142), VERSIONS.push_back(Ref<Version>( new Version(33, intArray(6, 6, 30, 58, 86, 114, 142),
new ECBlocks(30, new ECB(17, 115), new ECBlocks(30, new ECB(17, 115),
new ECB(1, 116)), new ECB(1, 116)),
new ECBlocks(28, new ECB(14, 46), new ECBlocks(28, new ECB(14, 46),
@ -499,8 +499,8 @@ int Version::buildVersions() {
new ECBlocks(30, new ECB(29, 24), new ECBlocks(30, new ECB(29, 24),
new ECB(19, 25)), new ECB(19, 25)),
new ECBlocks(30, new ECB(11, 15), new ECBlocks(30, new ECB(11, 15),
new ECB(46, 16)))); new ECB(46, 16)))));
VERSIONS.push_back(new Version(34, intArray(6, 6, 34, 62, 90, 118, 146), VERSIONS.push_back(Ref<Version>( new Version(34, intArray(6, 6, 34, 62, 90, 118, 146),
new ECBlocks(30, new ECB(13, 115), new ECBlocks(30, new ECB(13, 115),
new ECB(6, 116)), new ECB(6, 116)),
new ECBlocks(28, new ECB(14, 46), new ECBlocks(28, new ECB(14, 46),
@ -508,8 +508,8 @@ int Version::buildVersions() {
new ECBlocks(30, new ECB(44, 24), new ECBlocks(30, new ECB(44, 24),
new ECB(7, 25)), new ECB(7, 25)),
new ECBlocks(30, new ECB(59, 16), new ECBlocks(30, new ECB(59, 16),
new ECB(1, 17)))); new ECB(1, 17)))));
VERSIONS.push_back(new Version(35, intArray(7, 6, 30, 54, 78, VERSIONS.push_back(Ref<Version>( new Version(35, intArray(7, 6, 30, 54, 78,
102, 126, 150), 102, 126, 150),
new ECBlocks(30, new ECB(12, 121), new ECBlocks(30, new ECB(12, 121),
new ECB(7, 122)), new ECB(7, 122)),
@ -518,8 +518,8 @@ int Version::buildVersions() {
new ECBlocks(30, new ECB(39, 24), new ECBlocks(30, new ECB(39, 24),
new ECB(14, 25)), new ECB(14, 25)),
new ECBlocks(30, new ECB(22, 15), new ECBlocks(30, new ECB(22, 15),
new ECB(41, 16)))); new ECB(41, 16)))));
VERSIONS.push_back(new Version(36, intArray(7, 6, 24, 50, 76, VERSIONS.push_back(Ref<Version>( new Version(36, intArray(7, 6, 24, 50, 76,
102, 128, 154), 102, 128, 154),
new ECBlocks(30, new ECB(6, 121), new ECBlocks(30, new ECB(6, 121),
new ECB(14, 122)), new ECB(14, 122)),
@ -528,8 +528,8 @@ int Version::buildVersions() {
new ECBlocks(30, new ECB(46, 24), new ECBlocks(30, new ECB(46, 24),
new ECB(10, 25)), new ECB(10, 25)),
new ECBlocks(30, new ECB(2, 15), new ECBlocks(30, new ECB(2, 15),
new ECB(64, 16)))); new ECB(64, 16)))));
VERSIONS.push_back(new Version(37, intArray(7, 6, 28, 54, 80, VERSIONS.push_back(Ref<Version>( new Version(37, intArray(7, 6, 28, 54, 80,
106, 132, 158), 106, 132, 158),
new ECBlocks(30, new ECB(17, 122), new ECBlocks(30, new ECB(17, 122),
new ECB(4, 123)), new ECB(4, 123)),
@ -538,8 +538,8 @@ int Version::buildVersions() {
new ECBlocks(30, new ECB(49, 24), new ECBlocks(30, new ECB(49, 24),
new ECB(10, 25)), new ECB(10, 25)),
new ECBlocks(30, new ECB(24, 15), new ECBlocks(30, new ECB(24, 15),
new ECB(46, 16)))); new ECB(46, 16)))));
VERSIONS.push_back(new Version(38, intArray(7, 6, 32, 58, 84, VERSIONS.push_back(Ref<Version>( new Version(38, intArray(7, 6, 32, 58, 84,
110, 136, 162), 110, 136, 162),
new ECBlocks(30, new ECB(4, 122), new ECBlocks(30, new ECB(4, 122),
new ECB(18, 123)), new ECB(18, 123)),
@ -548,8 +548,8 @@ int Version::buildVersions() {
new ECBlocks(30, new ECB(48, 24), new ECBlocks(30, new ECB(48, 24),
new ECB(14, 25)), new ECB(14, 25)),
new ECBlocks(30, new ECB(42, 15), new ECBlocks(30, new ECB(42, 15),
new ECB(32, 16)))); new ECB(32, 16)))));
VERSIONS.push_back(new Version(39, intArray(7, 6, 26, 54, 82, VERSIONS.push_back(Ref<Version>( new Version(39, intArray(7, 6, 26, 54, 82,
110, 138, 166), 110, 138, 166),
new ECBlocks(30, new ECB(20, 117), new ECBlocks(30, new ECB(20, 117),
new ECB(4, 118)), new ECB(4, 118)),
@ -558,8 +558,8 @@ int Version::buildVersions() {
new ECBlocks(30, new ECB(43, 24), new ECBlocks(30, new ECB(43, 24),
new ECB(22, 25)), new ECB(22, 25)),
new ECBlocks(30, new ECB(10, 15), new ECBlocks(30, new ECB(10, 15),
new ECB(67, 16)))); new ECB(67, 16)))));
VERSIONS.push_back(new Version(40, intArray(7, 6, 30, 58, 86, VERSIONS.push_back(Ref<Version>( new Version(40, intArray(7, 6, 30, 58, 86,
114, 142, 170), 114, 142, 170),
new ECBlocks(30, new ECB(19, 118), new ECBlocks(30, new ECB(19, 118),
new ECB(6, 119)), new ECB(6, 119)),
@ -568,7 +568,7 @@ int Version::buildVersions() {
new ECBlocks(30, new ECB(34, 24), new ECBlocks(30, new ECB(34, 24),
new ECB(34, 25)), new ECB(34, 25)),
new ECBlocks(30, new ECB(20, 15), new ECBlocks(30, new ECB(20, 15),
new ECB(61, 16)))); new ECB(61, 16)))));
return int(VERSIONS.size()); return int(VERSIONS.size());
} }

View File

@ -54,7 +54,7 @@ public:
~ECBlocks(); ~ECBlocks();
}; };
class Version { class Version : public Counted {
private: private:
int versionNumber_; int versionNumber_;
@ -67,7 +67,7 @@ private:
public: public:
static unsigned int VERSION_DECODE_INFO[]; static unsigned int VERSION_DECODE_INFO[];
static int N_VERSION_DECODE_INFOS; static int N_VERSION_DECODE_INFOS;
static std::vector<Version* > VERSIONS; static std::vector<Ref<Version> > VERSIONS;
~Version(); ~Version();
int getVersionNumber() const; int getVersionNumber() const;
@ -75,9 +75,9 @@ public:
int getTotalCodewords(); int getTotalCodewords();
int getDimensionForVersion(); int getDimensionForVersion();
ECBlocks &getECBlocksForLevel(const ErrorCorrectionLevel &ecLevel) const; ECBlocks &getECBlocksForLevel(const ErrorCorrectionLevel &ecLevel) const;
static Version* getProvisionalVersionForDimension(int dimension); static Ref<Version> getProvisionalVersionForDimension(int dimension);
static Version* getVersionForNumber(int versionNumber); static Ref<Version> getVersionForNumber(int versionNumber);
static Version* decodeVersionInformation(unsigned int versionBits); static Ref<Version> decodeVersionInformation(unsigned int versionBits);
Ref<BitMatrix> buildFunctionPattern(); Ref<BitMatrix> buildFunctionPattern();
static int buildVersions(); static int buildVersions();
}; };

View File

@ -33,7 +33,7 @@ namespace qrcode {
class BitMatrixParser : public Counted { class BitMatrixParser : public Counted {
private: private:
Ref<BitMatrix> bitMatrix_; Ref<BitMatrix> bitMatrix_;
Version *parsedVersion_; Ref<Version>parsedVersion_;
Ref<FormatInformation> parsedFormatInfo_; Ref<FormatInformation> parsedFormatInfo_;
bool mirror_; bool mirror_;
@ -42,7 +42,7 @@ private:
public: public:
BitMatrixParser(Ref<BitMatrix> bitMatrix); BitMatrixParser(Ref<BitMatrix> bitMatrix);
Ref<FormatInformation> readFormatInformation(); Ref<FormatInformation> readFormatInformation();
Version *readVersion(); Ref<Version>readVersion();
ArrayRef<zxing::byte> readCodewords(); ArrayRef<zxing::byte> readCodewords();
void remask(); void remask();
void setMirror(boolean mirror); void setMirror(boolean mirror);

View File

@ -38,7 +38,7 @@ private:
public: public:
static std::vector<Ref<DataBlock> > static std::vector<Ref<DataBlock> >
getDataBlocks(ArrayRef<zxing::byte> rawCodewords, Version *version, ErrorCorrectionLevel &ecLevel); getDataBlocks(ArrayRef<zxing::byte> rawCodewords, Ref<Version>version, ErrorCorrectionLevel &ecLevel);
int getNumDataCodewords(); int getNumDataCodewords();
ArrayRef<zxing::byte> getCodewords(); ArrayRef<zxing::byte> getCodewords();

View File

@ -61,7 +61,7 @@ private:
public: public:
static Ref<DecoderResult> decode(ArrayRef<zxing::byte> bytes, static Ref<DecoderResult> decode(ArrayRef<zxing::byte> bytes,
Version *version, Ref<Version>version,
ErrorCorrectionLevel const& ecLevel, ErrorCorrectionLevel const& ecLevel,
Hashtable const& hints); Hashtable const& hints);
}; };

View File

@ -55,7 +55,7 @@ public:
static Mode HANZI; static Mode HANZI;
static Mode& forBits(int bits); static Mode& forBits(int bits);
int getCharacterCountBits(const Version *version) const; int getCharacterCountBits(const Ref<Version>version) const;
int getBits() const { return bits_; } int getBits() const { return bits_; }
Mode& operator=(const Mode& other); Mode& operator=(const Mode& other);

View File

@ -74,7 +74,7 @@ Ref<FormatInformation> BitMatrixParser::readFormatInformation() {
throw ReaderException("Could not decode format information"); throw ReaderException("Could not decode format information");
} }
Version *BitMatrixParser::readVersion() { Ref<Version>BitMatrixParser::readVersion() {
if (parsedVersion_ != 0) { if (parsedVersion_ != 0) {
return parsedVersion_; return parsedVersion_;
} }
@ -118,7 +118,7 @@ Version *BitMatrixParser::readVersion() {
ArrayRef<zxing::byte> BitMatrixParser::readCodewords() { ArrayRef<zxing::byte> BitMatrixParser::readCodewords() {
Ref<FormatInformation> formatInfo = readFormatInformation(); Ref<FormatInformation> formatInfo = readFormatInformation();
Version *version = readVersion(); Ref<Version>version = readVersion();
// Get the data mask for the format used in this QR Code. This will exclude // Get the data mask for the format used in this QR Code. This will exclude

View File

@ -39,7 +39,7 @@ ArrayRef<zxing::byte> DataBlock::getCodewords() {
} }
std::vector<Ref<DataBlock> > DataBlock::getDataBlocks(ArrayRef<zxing::byte> rawCodewords, Version *version, std::vector<Ref<DataBlock> > DataBlock::getDataBlocks(ArrayRef<zxing::byte> rawCodewords, Ref<Version>version,
ErrorCorrectionLevel &ecLevel) { ErrorCorrectionLevel &ecLevel) {

View File

@ -351,7 +351,7 @@ int parseECIValue(BitSource& bits) {
Ref<DecoderResult> Ref<DecoderResult>
DecodedBitStreamParser::decode(ArrayRef<zxing::byte> bytes, DecodedBitStreamParser::decode(ArrayRef<zxing::byte> bytes,
Version* version, Ref<Version> version,
ErrorCorrectionLevel const& ecLevel, ErrorCorrectionLevel const& ecLevel,
Hashtable const& hints) { Hashtable const& hints) {
Ref<BitSource> bits_ (new BitSource(bytes)); Ref<BitSource> bits_ (new BitSource(bytes));

View File

@ -69,7 +69,7 @@ Ref<DecoderResult> Decoder::decode(Ref<BitMatrix> bits) {
// std::cerr << *bits << std::endl; // std::cerr << *bits << std::endl;
Version *version = parser.readVersion(); Ref<Version>version = parser.readVersion();
ErrorCorrectionLevel &ecLevel = parser.readFormatInformation()->getErrorCorrectionLevel(); ErrorCorrectionLevel &ecLevel = parser.readFormatInformation()->getErrorCorrectionLevel();

View File

@ -96,7 +96,7 @@ Mode& Mode::forBits(int bits) {
} }
} }
int Mode::getCharacterCountBits(const Version *version) const int Mode::getCharacterCountBits(const Ref<Version>version) const
{ {
int number = version->getVersionNumber(); int number = version->getVersionNumber();
if (number <= 9) { if (number <= 9) {

View File

@ -80,7 +80,7 @@ Ref<DetectorResult> Detector::processFinderPatternInfo(Ref<FinderPatternInfo> in
throw zxing::ReaderException("bad module size"); throw zxing::ReaderException("bad module size");
} }
int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize); int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize);
Version *provisionalVersion = Version::getProvisionalVersionForDimension(dimension); Ref<Version>provisionalVersion = Version::getProvisionalVersionForDimension(dimension);
int modulesBetweenFPCenters = provisionalVersion->getDimensionForVersion() - 7; int modulesBetweenFPCenters = provisionalVersion->getDimensionForVersion() - 7;
Ref<AlignmentPattern> alignmentPattern; Ref<AlignmentPattern> alignmentPattern;

View File

@ -40,7 +40,7 @@ public:
/** /**
* Append length info. On success, store the result in "bits". * Append length info. On success, store the result in "bits".
*/ */
static void appendLengthInfo(int numLetters, const Version& version, const Mode& mode, BitArray& bits); static void appendLengthInfo(int numLetters, const Ref<Version> version, const Mode& mode, BitArray& bits);
/** /**
* Append "bytes" in "mode" mode (encoding) into "bits". On success, store the result in "bits". * Append "bytes" in "mode" mode (encoding) into "bits". On success, store the result in "bits".
@ -92,10 +92,10 @@ protected:
private: private:
static int chooseMaskPattern(Ref<BitArray> bits, static int chooseMaskPattern(Ref<BitArray> bits,
ErrorCorrectionLevel& ecLevel, ErrorCorrectionLevel& ecLevel,
Version* version, Ref<Version> version,
Ref<ByteMatrix> matrix); Ref<ByteMatrix> matrix);
static Version* chooseVersion(int numInputBits, const ErrorCorrectionLevel &ecLevel) ; static Ref<Version> chooseVersion(int numInputBits, const ErrorCorrectionLevel &ecLevel) ;
static void appendECI(const zxing::common::CharacterSetECI& eci, BitArray& bits); static void appendECI(const zxing::common::CharacterSetECI& eci, BitArray& bits);
@ -106,9 +106,9 @@ private:
static int calculateMaskPenalty(const ByteMatrix& matrix); static int calculateMaskPenalty(const ByteMatrix& matrix);
static int calculateBitsNeeded(const Mode &mode, const BitArray &headerBits, const BitArray &dataBits, const static int calculateBitsNeeded(const Mode &mode, const BitArray &headerBits, const BitArray &dataBits, const
Version* version); Ref<Version> version);
static bool willFit(int numInputBits, Version* version, const ErrorCorrectionLevel &ecLevel); static bool willFit(int numInputBits, Ref<Version> version, const ErrorCorrectionLevel &ecLevel);
static Version* recommendVersion(ErrorCorrectionLevel &ecLevel, static Ref<Version> recommendVersion(ErrorCorrectionLevel &ecLevel,
Mode &mode, Mode &mode,
BitArray &headerBits, BitArray &headerBits,
BitArray &dataBits); BitArray &dataBits);

View File

@ -25,7 +25,7 @@ Ref<ErrorCorrectionLevel> QRCode::getECLevel() const
return ecLevel_ptr_; return ecLevel_ptr_;
} }
Version* QRCode::getVersion() const Ref<Version> QRCode::getVersion() const
{ {
return version_ptr_; return version_ptr_;
} }
@ -88,7 +88,7 @@ void QRCode::setECLevel(Ref<ErrorCorrectionLevel> value)
ecLevel_ptr_ = value; ecLevel_ptr_ = value;
} }
void QRCode::setVersion(Version* version) void QRCode::setVersion(Ref<Version> version)
{ {
version_ptr_ = version; version_ptr_ = version;
} }

View File

@ -17,7 +17,7 @@ private:
Mode mode_; Mode mode_;
Ref<ErrorCorrectionLevel> ecLevel_ptr_; Ref<ErrorCorrectionLevel> ecLevel_ptr_;
Version* version_ptr_; Ref<Version> version_ptr_;
int maskPattern_; int maskPattern_;
Ref<ByteMatrix> matrix_ptr_; Ref<ByteMatrix> matrix_ptr_;
@ -28,13 +28,13 @@ public:
~QRCode(); ~QRCode();
Mode getMode() const; Mode getMode() const;
Ref<ErrorCorrectionLevel> getECLevel() const; Ref<ErrorCorrectionLevel> getECLevel() const;
Version* getVersion() const; Ref<Version> getVersion() const;
int getMaskPattern() const; int getMaskPattern() const;
Ref<ByteMatrix> getMatrix() const; Ref<ByteMatrix> getMatrix() const;
std::string toString() const; std::string toString() const;
void setMode(const Mode &value); void setMode(const Mode &value);
void setECLevel(Ref<ErrorCorrectionLevel> value); void setECLevel(Ref<ErrorCorrectionLevel> value);
void setVersion(Version* version); void setVersion(Ref<Version> version);
void setMaskPattern(int value); void setMaskPattern(int value);
void setMatrix(Ref<ByteMatrix> value); void setMatrix(Ref<ByteMatrix> value);

View File

@ -76,7 +76,7 @@ Ref<QRCode> Encoder::encode(const std::wstring& content, ErrorCorrectionLevel &e
BitArray dataBits; BitArray dataBits;
appendBytes(content, mode, dataBits, encoding); appendBytes(content, mode, dataBits, encoding);
Version* version; Ref<Version> version;
if (hints != ZXING_NULLPTR/* && hints->containsKey(EncodeHintType.QR_VERSION)*/) { if (hints != ZXING_NULLPTR/* && hints->containsKey(EncodeHintType.QR_VERSION)*/) {
version = Version::getVersionForNumber(1); //should version number be passed as argument? version = Version::getVersionForNumber(1); //should version number be passed as argument?
int bitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, version); int bitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, version);
@ -91,7 +91,7 @@ Ref<QRCode> Encoder::encode(const std::wstring& content, ErrorCorrectionLevel &e
headerAndDataBits.appendBitArray(headerBits); headerAndDataBits.appendBitArray(headerBits);
// Find "length" of main segment and write it // Find "length" of main segment and write it
int numLetters = (mode == Mode::BYTE) ? dataBits.getSizeInBytes() : int(content.length()); int numLetters = (mode == Mode::BYTE) ? dataBits.getSizeInBytes() : int(content.length());
appendLengthInfo(numLetters, *version, mode, headerAndDataBits); appendLengthInfo(numLetters, version, mode, headerAndDataBits);
// Put data together into the overall payload // Put data together into the overall payload
headerAndDataBits.appendBitArray(dataBits); headerAndDataBits.appendBitArray(dataBits);
@ -128,7 +128,7 @@ Ref<QRCode> Encoder::encode(const std::wstring& content, ErrorCorrectionLevel &e
//return NULL; //return NULL;
} }
bool Encoder::willFit(int numInputBits, Version* version, const ErrorCorrectionLevel &ecLevel) { bool Encoder::willFit(int numInputBits, Ref<Version> version, const ErrorCorrectionLevel &ecLevel) {
// In the following comments, we use numbers of Version 7-H. // In the following comments, we use numbers of Version 7-H.
// numBytes = 196 // numBytes = 196
int numBytes = version->getTotalCodewords(); int numBytes = version->getTotalCodewords();
@ -209,7 +209,7 @@ Mode Encoder::chooseMode(const std::wstring& content, const std::string& encodin
int Encoder::chooseMaskPattern(Ref<BitArray> bits, int Encoder::chooseMaskPattern(Ref<BitArray> bits,
ErrorCorrectionLevel& ecLevel, ErrorCorrectionLevel& ecLevel,
Version* version, Ref<Version> version,
Ref<ByteMatrix> matrix) Ref<ByteMatrix> matrix)
{ {
@ -227,11 +227,11 @@ int Encoder::chooseMaskPattern(Ref<BitArray> bits,
return bestMaskPattern; return bestMaskPattern;
} }
Version* Encoder::chooseVersion(int numInputBits, const ErrorCorrectionLevel &ecLevel) Ref<Version> Encoder::chooseVersion(int numInputBits, const ErrorCorrectionLevel &ecLevel)
{ {
// In the following comments, we use numbers of Version 7-H. // In the following comments, we use numbers of Version 7-H.
for (int versionNum = 1; versionNum <= 40; versionNum++) { for (int versionNum = 1; versionNum <= 40; versionNum++) {
Version* version = Version::getVersionForNumber(versionNum); Ref<Version> version = Version::getVersionForNumber(versionNum);
if (willFit(numInputBits, version, ecLevel)) { if (willFit(numInputBits, version, ecLevel)) {
return version; return version;
} }
@ -448,9 +448,9 @@ void Encoder::appendModeInfo(const Mode& mode, BitArray& bits)
/** /**
* Append length info. On success, store the result in "bits". * Append length info. On success, store the result in "bits".
*/ */
void Encoder::appendLengthInfo(int numLetters, const Version& version, const Mode& mode, BitArray& bits) void Encoder::appendLengthInfo(int numLetters, const Ref<Version> version, const Mode& mode, BitArray& bits)
{ {
int numBits = mode.getCharacterCountBits(&version); int numBits = mode.getCharacterCountBits(version);
if (numLetters >= (1 << numBits)) { if (numLetters >= (1 << numBits)) {
std::string message = zxing::common::StringUtils::intToStr(numLetters); std::string message = zxing::common::StringUtils::intToStr(numLetters);
message += " is bigger than "; message += " is bigger than ";
@ -579,12 +579,12 @@ void Encoder::appendECI(const zxing::common::CharacterSetECI& eci, BitArray& bit
} }
int Encoder::calculateBitsNeeded(const Mode &mode, const BitArray &headerBits, const BitArray &dataBits, const int Encoder::calculateBitsNeeded(const Mode &mode, const BitArray &headerBits, const BitArray &dataBits, const
Version* version) Ref<Version> version)
{ {
return headerBits.getSize() + mode.getCharacterCountBits(version) + dataBits.getSize(); return headerBits.getSize() + mode.getCharacterCountBits(version) + dataBits.getSize();
} }
Version* Encoder::recommendVersion(ErrorCorrectionLevel &ecLevel, Ref<Version> Encoder::recommendVersion(ErrorCorrectionLevel &ecLevel,
Mode &mode, Mode &mode,
BitArray &headerBits, BitArray &headerBits,
BitArray &dataBits) BitArray &dataBits)
@ -593,7 +593,7 @@ Version* Encoder::recommendVersion(ErrorCorrectionLevel &ecLevel,
// bits it takes to know version. First we take a guess at version by assuming version will be // bits it takes to know version. First we take a guess at version by assuming version will be
// the minimum, 1: // the minimum, 1:
int provisionalBitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, Version::getVersionForNumber(1)); int provisionalBitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, Version::getVersionForNumber(1));
Version* provisionalVersion = chooseVersion(provisionalBitsNeeded, ecLevel); Ref<Version> provisionalVersion = chooseVersion(provisionalBitsNeeded, ecLevel);
// Use that guess to calculate the right version. I am still not sure this works in 100% of cases. // Use that guess to calculate the right version. I am still not sure this works in 100% of cases.
int bitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, provisionalVersion); int bitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, provisionalVersion);

View File

@ -137,19 +137,19 @@ void EncoderTests::testAppendLengthInfo()
{ {
BitArray bits; BitArray bits;
EncoderHack::appendLengthInfo(1, // 1 letter (1/1). EncoderHack::appendLengthInfo(1, // 1 letter (1/1).
*Version::getVersionForNumber(1), Version::getVersionForNumber(1),
Mode::NUMERIC, Mode::NUMERIC,
bits); bits);
assertEquals(" ........ .X", bits.toString()); // 10 bits. assertEquals(" ........ .X", bits.toString()); // 10 bits.
bits = BitArray(); bits = BitArray();
EncoderHack::appendLengthInfo(2, // 2 letters (2/1). EncoderHack::appendLengthInfo(2, // 2 letters (2/1).
*Version::getVersionForNumber(10), Version::getVersionForNumber(10),
Mode::ALPHANUMERIC, Mode::ALPHANUMERIC,
bits); bits);
assertEquals(" ........ .X.", bits.toString()); // 11 bits. assertEquals(" ........ .X.", bits.toString()); // 11 bits.
bits = BitArray(); bits = BitArray();
EncoderHack::appendLengthInfo(255, // 255 letter (255/1). EncoderHack::appendLengthInfo(255, // 255 letter (255/1).
*Version::getVersionForNumber(27), Version::getVersionForNumber(27),
Mode::BYTE, Mode::BYTE,
bits); bits);
assertEquals(" ........ XXXXXXXX", bits.toString()); // 16 bits. assertEquals(" ........ XXXXXXXX", bits.toString()); // 16 bits.