[SCM] Multi-format 1D/2D barcode image processing library branch, upstream, updated. 24d4480bc48cf9eabf7b2bd2f528248b0e458809
srowen
srowen at 59b500cc-1b3d-0410-9834-0bbf25fbcc57
Wed Aug 4 01:31:08 UTC 2010
The following commit has been merged in the upstream branch:
commit e938ceb44a9f9af100fb6e93cc7dde52ff02b51a
Author: srowen <srowen at 59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Date: Mon Apr 19 20:49:54 2010 +0000
Issue 357
git-svn-id: http://zxing.googlecode.com/svn/trunk@1313 59b500cc-1b3d-0410-9834-0bbf25fbcc57
diff --git a/core/src/com/google/zxing/pdf417/decoder/DecodedBitStreamParser.java b/core/src/com/google/zxing/pdf417/decoder/DecodedBitStreamParser.java
index 0638843..8b801f3 100644
--- a/core/src/com/google/zxing/pdf417/decoder/DecodedBitStreamParser.java
+++ b/core/src/com/google/zxing/pdf417/decoder/DecodedBitStreamParser.java
@@ -347,19 +347,18 @@ final class DecodedBitStreamParser {
byteCompactedCodewords[count] = code;
count++;
// Base 900
- value *= 900;
- value += code;
+ value = 900 * value + code;
} else {
- if ((code == TEXT_COMPACTION_MODE_LATCH) ||
- (code == BYTE_COMPACTION_MODE_LATCH) ||
- (code == NUMERIC_COMPACTION_MODE_LATCH) ||
- (code == BYTE_COMPACTION_MODE_LATCH_6) ||
- (code == BEGIN_MACRO_PDF417_CONTROL_BLOCK) ||
- (code == BEGIN_MACRO_PDF417_OPTIONAL_FIELD) ||
- (code == MACRO_PDF417_TERMINATOR)) {
+ if (code == TEXT_COMPACTION_MODE_LATCH ||
+ code == BYTE_COMPACTION_MODE_LATCH ||
+ code == NUMERIC_COMPACTION_MODE_LATCH ||
+ code == BYTE_COMPACTION_MODE_LATCH_6 ||
+ code == BEGIN_MACRO_PDF417_CONTROL_BLOCK ||
+ code == BEGIN_MACRO_PDF417_OPTIONAL_FIELD ||
+ code == MACRO_PDF417_TERMINATOR) {
+ codeIndex--;
+ end = true;
}
- codeIndex--;
- end = true;
}
if ((count % 5 == 0) && (count > 0)) {
// Decode every 5 codewords
@@ -385,31 +384,30 @@ final class DecodedBitStreamParser {
int count = 0;
long value = 0;
boolean end = false;
- while ((codeIndex < codewords[0]) && !end) {
+ while (codeIndex < codewords[0] && !end) {
int code = codewords[codeIndex++];
if (code < TEXT_COMPACTION_MODE_LATCH) {
- count += 1;
+ count++;
// Base 900
- value *= 900;
- value += code;
+ value = 900 * value + code;
} else {
- if ((code == TEXT_COMPACTION_MODE_LATCH) ||
- (code == BYTE_COMPACTION_MODE_LATCH) ||
- (code == NUMERIC_COMPACTION_MODE_LATCH) ||
- (code == BYTE_COMPACTION_MODE_LATCH_6) ||
- (code == BEGIN_MACRO_PDF417_CONTROL_BLOCK) ||
- (code == BEGIN_MACRO_PDF417_OPTIONAL_FIELD) ||
- (code == MACRO_PDF417_TERMINATOR)) {
+ if (code == TEXT_COMPACTION_MODE_LATCH ||
+ code == BYTE_COMPACTION_MODE_LATCH ||
+ code == NUMERIC_COMPACTION_MODE_LATCH ||
+ code == BYTE_COMPACTION_MODE_LATCH_6 ||
+ code == BEGIN_MACRO_PDF417_CONTROL_BLOCK ||
+ code == BEGIN_MACRO_PDF417_OPTIONAL_FIELD ||
+ code == MACRO_PDF417_TERMINATOR) {
+ codeIndex--;
+ end = true;
}
- codeIndex--;
- end = true;
}
if ((count % 5 == 0) && (count > 0)) {
// Decode every 5 codewords
// Convert to Base 256
char[] decodedData = new char[6];
for (int j = 0; j < 6; ++j) {
- decodedData[5 - j] = (char) (value % 256);
+ decodedData[5 - j] = (char) (value & 0xFF);
value >>= 8;
}
result.append(decodedData);
@@ -433,24 +431,28 @@ final class DecodedBitStreamParser {
int[] numericCodewords = new int[MAX_NUMERIC_CODEWORDS];
- while ((codeIndex < codewords.length) && !end) {
+ while (codeIndex < codewords[0] && !end) {
int code = codewords[codeIndex++];
+ if (codeIndex == codewords[0]) {
+ end = true;
+ }
if (code < TEXT_COMPACTION_MODE_LATCH) {
numericCodewords[count] = code;
count++;
} else {
- if ((code == TEXT_COMPACTION_MODE_LATCH) ||
- (code == BYTE_COMPACTION_MODE_LATCH) ||
- (code == BYTE_COMPACTION_MODE_LATCH_6) ||
- (code == BEGIN_MACRO_PDF417_CONTROL_BLOCK) ||
- (code == BEGIN_MACRO_PDF417_OPTIONAL_FIELD) ||
- (code == MACRO_PDF417_TERMINATOR)) {
+ if (code == TEXT_COMPACTION_MODE_LATCH ||
+ code == BYTE_COMPACTION_MODE_LATCH ||
+ code == BYTE_COMPACTION_MODE_LATCH_6 ||
+ code == BEGIN_MACRO_PDF417_CONTROL_BLOCK ||
+ code == BEGIN_MACRO_PDF417_OPTIONAL_FIELD ||
+ code == MACRO_PDF417_TERMINATOR) {
+ codeIndex--;
+ end = true;
}
- codeIndex--;
- end = true;
}
- if ((count % MAX_NUMERIC_CODEWORDS) == 0 ||
- code == NUMERIC_COMPACTION_MODE_LATCH) {
+ if (count % MAX_NUMERIC_CODEWORDS == 0 ||
+ code == NUMERIC_COMPACTION_MODE_LATCH ||
+ end) {
// Re-invoking Numeric Compaction mode (by using codeword 902
// while in Numeric Compaction mode) serves to terminate the
// current Numeric Compaction mode grouping as described in 5.4.4.2,
--
Multi-format 1D/2D barcode image processing library
More information about the Pkg-google-commits
mailing list