Issue 1762 PDF417 speed up and back-port to Java

git-svn-id: https://zxing.googlecode.com/svn/trunk@2870 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen@gmail.com 2013-08-19 08:54:10 +00:00
parent a1cd1991b8
commit 5fd33bb9d2
2 changed files with 10 additions and 2 deletions

View file

@ -98,9 +98,13 @@ final class PDF417CodewordDecoder {
int bestMatch = -1;
for (int j = 0; j < RATIOS_TABLE.length; j++) {
float error = 0.0f;
float[] ratioTableRow = RATIOS_TABLE[j];
for (int k = 0; k < PDF417Common.BARS_IN_MODULE; k++) {
float diff = RATIOS_TABLE[j][k] - bitCountRatios[k];
float diff = ratioTableRow[k] - bitCountRatios[k];
error += diff * diff;
if (error >= bestMatchError) {
break;
}
}
if (error < bestMatchError) {
bestMatchError = error;

View file

@ -408,7 +408,11 @@ void LinesSampler::linesMatrixToCodewords(vector<vector<int> >& clusterNumbers,
for (int j = 0; j < POSSIBLE_SYMBOLS; j++) {
float error = 0.0f;
for (int k = 0; k < BARS_IN_SYMBOL; k++) {
error += pow(RATIOS_TABLE[j * BARS_IN_SYMBOL + k] - cwRatios[i][k], 2);
float diff = RATIOS_TABLE[j * BARS_IN_SYMBOL + k] - cwRatios[i][k];
error += diff * diff;
if (error >= bestMatchError) {
break;
}
}
if (error < bestMatchError) {
bestMatchError = error;