Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: LazarSoft/jsqrcode
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: ez8-co/jsqrcode
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 7 commits
  • 19 files changed
  • 1 contributor

Commits on Oct 1, 2017

  1. grammar optimization

    post-increment to pre-increment if possible, simple array declaration
    orca-zhang committed Oct 1, 2017
    Copy the full SHA
    a094653 View commit details
  2. fix clean redundant centers error

    suffix change error after deleting, fix no rest centers size limit error
    orca-zhang committed Oct 1, 2017
    Copy the full SHA
    b53427b View commit details
  3. remove new operations of Array

    new ops can lead to low performance
    orca-zhang committed Oct 1, 2017
    Copy the full SHA
    51e9578 View commit details

Commits on Oct 6, 2017

  1. grammar optimization

    remove new operations of Array, quick init ops of Array
    orca-zhang committed Oct 6, 2017
    Copy the full SHA
    1f094b9 View commit details
  2. support more encoding

    support utf8 & sjis & hanzi encoding
    orca-zhang committed Oct 6, 2017
    Copy the full SHA
    af87bda View commit details

Commits on Oct 8, 2017

  1. fix Array bugs

    orca-zhang committed Oct 8, 2017
    Copy the full SHA
    e3d8d74 View commit details

Commits on Jan 3, 2019

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8fcc434 View commit details
Showing with 770 additions and 556 deletions.
  1. +21 −21 src/alignpat.js
  2. +5 −10 src/bitmat.js
  3. +12 −12 src/bmparser.js
  4. +10 −10 src/datablock.js
  5. +535 −306 src/databr.js
  6. +17 −17 src/datamask.js
  7. +5 −5 src/decoder.js
  8. +5 −5 src/detector.js
  9. +1 −1 src/errorlevel.js
  10. +73 −83 src/findpat.js
  11. +3 −3 src/formatinf.js
  12. +5 −7 src/gf256.js
  13. +14 −14 src/gf256poly.js
  14. +1 −1 src/grid.js
  15. +0 −2 src/qrcode.js
  16. +8 −8 src/rsdecoder.js
  17. +4 −0 src/shift_jis_table.js
  18. +2 −2 src/test.html
  19. +49 −49 src/version.js
42 changes: 21 additions & 21 deletions src/alignpat.js
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ function AlignmentPattern(posX, posY, estimatedModuleSize)
});
this.incrementCount = function()
{
this.count++;
++this.count;
}
this.aboutEquals=function( moduleSize, i, j)
{
@@ -65,13 +65,13 @@ function AlignmentPattern(posX, posY, estimatedModuleSize)
function AlignmentPatternFinder( image, startX, startY, width, height, moduleSize, resultPointCallback)
{
this.image = image;
this.possibleCenters = new Array();
this.possibleCenters = [];
this.startX = startX;
this.startY = startY;
this.width = width;
this.height = height;
this.moduleSize = moduleSize;
this.crossCheckStateCount = new Array(0,0,0);
this.crossCheckStateCount = [0,0,0];
this.resultPointCallback = resultPointCallback;

this.centerFromEnd=function(stateCount, end)
@@ -82,7 +82,7 @@ function AlignmentPatternFinder( image, startX, startY, width, height, modu
{
var moduleSize = this.moduleSize;
var maxVariance = moduleSize / 2.0;
for (var i = 0; i < 3; i++)
for (var i = 0; i < 3; ++i)
{
if (Math.abs(moduleSize - stateCount[i]) >= maxVariance)
{
@@ -106,8 +106,8 @@ function AlignmentPatternFinder( image, startX, startY, width, height, modu
var i = startI;
while (i >= 0 && image[centerJ + i*qrcode.width] && stateCount[1] <= maxCount)
{
stateCount[1]++;
i--;
++stateCount[1];
--i;
}
// If already too many modules in this state or ran off the edge:
if (i < 0 || stateCount[1] > maxCount)
@@ -116,8 +116,8 @@ function AlignmentPatternFinder( image, startX, startY, width, height, modu
}
while (i >= 0 && !image[centerJ + i*qrcode.width] && stateCount[0] <= maxCount)
{
stateCount[0]++;
i--;
++stateCount[0];
--i;
}
if (stateCount[0] > maxCount)
{
@@ -128,17 +128,17 @@ function AlignmentPatternFinder( image, startX, startY, width, height, modu
i = startI + 1;
while (i < maxI && image[centerJ + i*qrcode.width] && stateCount[1] <= maxCount)
{
stateCount[1]++;
i++;
++stateCount[1];
++i;
}
if (i == maxI || stateCount[1] > maxCount)
{
return NaN;
}
while (i < maxI && !image[centerJ + i*qrcode.width] && stateCount[2] <= maxCount)
{
stateCount[2]++;
i++;
++stateCount[2];
++i;
}
if (stateCount[2] > maxCount)
{
@@ -163,7 +163,7 @@ function AlignmentPatternFinder( image, startX, startY, width, height, modu
{
var estimatedModuleSize = (stateCount[0] + stateCount[1] + stateCount[2]) / 3.0;
var max = this.possibleCenters.length;
for (var index = 0; index < max; index++)
for (var index = 0; index < max; ++index)
{
var center = this.possibleCenters[index];
// Look for about the same center and module size:
@@ -191,8 +191,8 @@ function AlignmentPatternFinder( image, startX, startY, width, height, modu
var middleI = startY + (height >> 1);
// We are looking for black/white/black modules in 1:1:1 ratio;
// this tracks the number of black/white/black modules seen so far
var stateCount = new Array(0,0,0);
for (var iGen = 0; iGen < height; iGen++)
var stateCount = [0,0,0];
for (var iGen = 0; iGen < height; ++iGen)
{
// Search from middle outwards
var i = middleI + ((iGen & 0x01) == 0?((iGen + 1) >> 1):- ((iGen + 1) >> 1));
@@ -205,7 +205,7 @@ function AlignmentPatternFinder( image, startX, startY, width, height, modu
// white run continued to the left of the start point
while (j < maxJ && !image[j + qrcode.width* i])
{
j++;
++j;
}
var currentState = 0;
while (j < maxJ)
@@ -216,7 +216,7 @@ function AlignmentPatternFinder( image, startX, startY, width, height, modu
if (currentState == 1)
{
// Counting black pixels
stateCount[currentState]++;
++stateCount[currentState];
}
else
{
@@ -240,7 +240,7 @@ function AlignmentPatternFinder( image, startX, startY, width, height, modu
}
else
{
stateCount[++currentState]++;
++stateCount[++currentState];
}
}
}
@@ -250,11 +250,11 @@ function AlignmentPatternFinder( image, startX, startY, width, height, modu
if (currentState == 1)
{
// Counting black pixels
currentState++;
++currentState;
}
stateCount[currentState]++;
++stateCount[currentState];
}
j++;
++j;
}
if (this.foundPatternCross(stateCount))
{
15 changes: 5 additions & 10 deletions src/bitmat.js
Original file line number Diff line number Diff line change
@@ -36,12 +36,11 @@ function BitMatrix( width, height)
var rowSize = width >> 5;
if ((width & 0x1f) != 0)
{
rowSize++;
++rowSize;
}
this.rowSize = rowSize;
this.bits = new Array(rowSize * height);
for(var i=0;i<this.bits.length;i++)
this.bits[i]=0;
this.bits.fill(0);

this.__defineGetter__("Width", function()
{
@@ -77,11 +76,7 @@ function BitMatrix( width, height)
}
this.clear=function()
{
var max = this.bits.length;
for (var i = 0; i < max; i++)
{
this.bits[i] = 0;
}
this.bits.fill(0);
}
this.setRegion=function( left, top, width, height)
{
@@ -99,10 +94,10 @@ function BitMatrix( width, height)
{
throw "The region must fit inside the matrix";
}
for (var y = top; y < bottom; y++)
for (var y = top; y < bottom; ++y)
{
var offset = y * this.rowSize;
for (var x = left; x < right; x++)
for (var x = left; x < right; ++x)
{
this.bits[offset + (x >> 5)] |= 1 << (x & 0x1f);
}
24 changes: 12 additions & 12 deletions src/bmparser.js
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ function BitMatrixParser(bitMatrix)

// Read top-left format info bits
var formatInfoBits = 0;
for (var i = 0; i < 6; i++)
for (var i = 0; i < 6; ++i)
{
formatInfoBits = this.copyBit(i, 8, formatInfoBits);
}
@@ -57,7 +57,7 @@ function BitMatrixParser(bitMatrix)
formatInfoBits = this.copyBit(8, 8, formatInfoBits);
formatInfoBits = this.copyBit(8, 7, formatInfoBits);
// .. and skip a bit in the timing pattern ...
for (var j = 5; j >= 0; j--)
for (var j = 5; j >= 0; --j)
{
formatInfoBits = this.copyBit(8, j, formatInfoBits);
}
@@ -72,11 +72,11 @@ function BitMatrixParser(bitMatrix)
var dimension = this.bitMatrix.Dimension;
formatInfoBits = 0;
var iMin = dimension - 8;
for (var i = dimension - 1; i >= iMin; i--)
for (var i = dimension - 1; i >= iMin; --i)
{
formatInfoBits = this.copyBit(i, 8, formatInfoBits);
}
for (var j = dimension - 7; j < dimension; j++)
for (var j = dimension - 7; j < dimension; ++j)
{
formatInfoBits = this.copyBit(8, j, formatInfoBits);
}
@@ -107,9 +107,9 @@ function BitMatrixParser(bitMatrix)
// Read top-right version info: 3 wide by 6 tall
var versionBits = 0;
var ijMin = dimension - 11;
for (var j = 5; j >= 0; j--)
for (var j = 5; j >= 0; --j)
{
for (var i = dimension - 9; i >= ijMin; i--)
for (var i = dimension - 9; i >= ijMin; --i)
{
versionBits = this.copyBit(i, j, versionBits);
}
@@ -123,9 +123,9 @@ function BitMatrixParser(bitMatrix)

// Hmm, failed. Try bottom left: 6 wide by 3 tall
versionBits = 0;
for (var i = 5; i >= 0; i--)
for (var i = 5; i >= 0; --i)
{
for (var j = dimension - 9; j >= ijMin; j--)
for (var j = dimension - 9; j >= ijMin; --j)
{
versionBits = this.copyBit(i, j, versionBits);
}
@@ -164,19 +164,19 @@ function BitMatrixParser(bitMatrix)
{
// Skip whole column with vertical alignment pattern;
// saves time and makes the other code proceed more cleanly
j--;
--j;
}
// Read alternatingly from bottom to top then top to bottom
for (var count = 0; count < dimension; count++)
for (var count = 0; count < dimension; ++count)
{
var i = readingUp?dimension - 1 - count:count;
for (var col = 0; col < 2; col++)
for (var col = 0; col < 2; ++col)
{
// Ignore bits covered by the function pattern
if (!functionPattern.get_Renamed(j - col, i))
{
// Read a bit
bitsRead++;
++bitsRead;
currentByte <<= 1;
if (this.bitMatrix.get_Renamed(j - col, i))
{
20 changes: 10 additions & 10 deletions src/datablock.js
Original file line number Diff line number Diff line change
@@ -53,18 +53,18 @@ DataBlock.getDataBlocks=function(rawCodewords, version, ecLevel)
// First count the total number of data blocks
var totalBlocks = 0;
var ecBlockArray = ecBlocks.getECBlocks();
for (var i = 0; i < ecBlockArray.length; i++)
for (var i = 0; i < ecBlockArray.length; ++i)
{
totalBlocks += ecBlockArray[i].Count;
}

// Now establish DataBlocks of the appropriate size and number of data codewords
var result = new Array(totalBlocks);
var numResultBlocks = 0;
for (var j = 0; j < ecBlockArray.length; j++)
for (var j = 0; j < ecBlockArray.length; ++j)
{
var ecBlock = ecBlockArray[j];
for (var i = 0; i < ecBlock.Count; i++)
for (var i = 0; i < ecBlock.Count; ++i)
{
var numDataCodewords = ecBlock.DataCodewords;
var numBlockCodewords = ecBlocks.ECCodewordsPerBlock + numDataCodewords;
@@ -83,31 +83,31 @@ DataBlock.getDataBlocks=function(rawCodewords, version, ecLevel)
{
break;
}
longerBlocksStartAt--;
--longerBlocksStartAt;
}
longerBlocksStartAt++;
++longerBlocksStartAt;

var shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.ECCodewordsPerBlock;
// The last elements of result may be 1 element longer;
// first fill out as many elements as all of them have
var rawCodewordsOffset = 0;
for (var i = 0; i < shorterBlocksNumDataCodewords; i++)
for (var i = 0; i < shorterBlocksNumDataCodewords; ++i)
{
for (var j = 0; j < numResultBlocks; j++)
for (var j = 0; j < numResultBlocks; ++j)
{
result[j].codewords[i] = rawCodewords[rawCodewordsOffset++];
}
}
// Fill out the last data block in the longer ones
for (var j = longerBlocksStartAt; j < numResultBlocks; j++)
for (var j = longerBlocksStartAt; j < numResultBlocks; ++j)
{
result[j].codewords[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++];
}
// Now add in error correction blocks
var max = result[0].codewords.length;
for (var i = shorterBlocksNumDataCodewords; i < max; i++)
for (var i = shorterBlocksNumDataCodewords; i < max; ++i)
{
for (var j = 0; j < numResultBlocks; j++)
for (var j = 0; j < numResultBlocks; ++j)
{
var iOffset = j < longerBlocksStartAt?i:i + 1;
result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++];
Loading