Issue 882 few more small DM issues

git-svn-id: https://zxing.googlecode.com/svn/trunk@1865 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2011-07-23 14:43:37 +00:00
parent 13f529aa80
commit 645a03c6a5
2 changed files with 10 additions and 3 deletions

View file

@ -20,7 +20,7 @@ package com.google.zxing.common;
* <p>This provides an easy abstraction to read bits at a time from a sequence of bytes, where the * <p>This provides an easy abstraction to read bits at a time from a sequence of bytes, where the
* number of bits read is not often a multiple of 8.</p> * number of bits read is not often a multiple of 8.</p>
* *
* <p>This class is thread-safe but not reentrant. Unless the caller modifies the bytes array * <p>This class is thread-safe but not reentrant -- unless the caller modifies the bytes array
* it passed in, in which case all bets are off.</p> * it passed in, in which case all bets are off.</p>
* *
* @author Sean Owen * @author Sean Owen
@ -39,6 +39,13 @@ public final class BitSource {
this.bytes = bytes; this.bytes = bytes;
} }
/**
* @return index of next byte in input byte array which would be read by the next call to {@link #readBits(int)}.
*/
public int getByteOffset() {
return byteOffset;
}
/** /**
* @param numBits number of bits to read * @param numBits number of bits to read
* @return int representing the bits read. The bits will appear as the least-significant * @return int representing the bits read. The bits will appear as the least-significant

View file

@ -235,7 +235,7 @@ final class DecodedBitStreamParser {
result.append(c40char); result.append(c40char);
} }
} else if (cValue == 27) { // FNC1 } else if (cValue == 27) { // FNC1
throw FormatException.getFormatInstance(); // ignore
} else if (cValue == 30) { // Upper Shift } else if (cValue == 30) { // Upper Shift
upperShift = true; upperShift = true;
} else { } else {
@ -437,7 +437,7 @@ final class DecodedBitStreamParser {
private static void decodeBase256Segment(BitSource bits, StringBuffer result, Vector byteSegments) private static void decodeBase256Segment(BitSource bits, StringBuffer result, Vector byteSegments)
throws FormatException { throws FormatException {
// Figure out how long the Base 256 Segment is. // Figure out how long the Base 256 Segment is.
int codewordPosition = 2; int codewordPosition = 1 + bits.getByteOffset(); // position is 1-indexed
int d1 = unrandomize255State(bits.readBits(8), codewordPosition++); int d1 = unrandomize255State(bits.readBits(8), codewordPosition++);
int count; int count;
if (d1 == 0) { // Read the remainder of the symbol if (d1 == 0) { // Read the remainder of the symbol