Small tweak to last commit and test count, enable explicit conversion everywhere and patch a strange Java 7-only (JIT?) issue

git-svn-id: https://zxing.googlecode.com/svn/trunk@2495 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2012-11-04 13:35:40 +00:00
parent 33cb6a0745
commit 0636cb7b08
5 changed files with 308 additions and 305 deletions

View file

@ -116,6 +116,7 @@
<enable/>
</assertions>
<jvmarg value="-Djava.awt.headless=true"/>
<jvmarg value="-DexplicitLuminanceConversion=true"/>
<batchtest>
<fileset dir="test/src">
<include name="**/*TestCase.java"/>

View file

@ -25,6 +25,7 @@ import com.google.zxing.Result;
import com.google.zxing.ResultPoint;
import com.google.zxing.common.BitArray;
import java.util.Arrays;
import java.util.Map;
/**
@ -171,6 +172,9 @@ public final class Code39Reader extends OneDReader {
}
private static int[] findAsteriskPattern(BitArray row, int[] counters) throws NotFoundException {
// Should not be needed, but appears to work around a Java 7 JIT bug? This comes in corrupted
Arrays.fill(counters, 0);
int width = row.getSize();
int rowOffset = row.getNextSet(0);
@ -223,7 +227,7 @@ public final class Code39Reader extends OneDReader {
int pattern = 0;
for (int i = 0; i < numCounters; i++) {
int counter = counters[i];
if (counters[i] > maxNarrowCounter) {
if (counter > maxNarrowCounter) {
pattern |= 1 << (numCounters - 1 - i);
wideCounters++;
totalWideCountersWidth += counter;
@ -235,7 +239,7 @@ public final class Code39Reader extends OneDReader {
// counter is more than 1.5 times the average:
for (int i = 0; i < numCounters && wideCounters > 0; i++) {
int counter = counters[i];
if (counters[i] > maxNarrowCounter) {
if (counter > maxNarrowCounter) {
wideCounters--;
// totalWideCountersWidth = 3 * average, so this checks if counter >= 3/2 * average
if ((counter << 1) >= totalWideCountersWidth) {

View file

@ -77,13 +77,12 @@ public final class BufferedImageLuminanceSource extends LuminanceSource {
pixel = 0xFFFFFFFF; // = white
}
int luminance = 0;
// .229R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC)
luminance = (306 * ((pixel >> 16) & 0xFF) +
buffer[x] =
(306 * ((pixel >> 16) & 0xFF) +
601 * ((pixel >> 8) & 0xFF) +
117 * (pixel & 0xFF) +
(0x200)) >> 10; // 0x200 = 1<<9, half an lsb of the result to force rounding
buffer[x] = luminance;
0x200) >> 10;
}
raster.setPixels(left, y, width, 1, buffer);
}

View file

@ -27,7 +27,7 @@ public final class RSS14BlackBox2TestCase extends AbstractBlackBoxTestCase {
public RSS14BlackBox2TestCase() {
super("test/data/blackbox/rss14-2", new MultiFormatReader(), BarcodeFormat.RSS_14);
addTest(3, 8, 1, 1, 0.0f);
addTest(4, 8, 1, 1, 0.0f);
addTest(2, 8, 0, 1, 180.0f);
}

View file

@ -79,13 +79,12 @@ public final class BufferedImageLuminanceSource extends LuminanceSource {
pixel = 0xFFFFFFFF; // = white
}
int luminance = 0;
// .229R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC)
luminance = (306 * ((pixel >> 16) & 0xFF) +
buffer[x] =
(306 * ((pixel >> 16) & 0xFF) +
601 * ((pixel >> 8) & 0xFF) +
117 * (pixel & 0xFF) +
(0x200)) >> 10; // 0x200 = 1<<9, half an lsb of the result to force rounding
buffer[x] = luminance;
0x200) >> 10;
}
raster.setPixels(left, y, width, 1, buffer);
}