mirror of
https://github.com/zxing/zxing.git
synced 2025-01-27 02:52:01 -08:00
Tiny speedups
git-svn-id: https://zxing.googlecode.com/svn/trunk@1111 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
58b5bf7b0f
commit
57cebcc697
|
@ -165,19 +165,17 @@ final class DecodeThread extends Thread {
|
|||
*/
|
||||
private void decode(byte[] data, int width, int height) {
|
||||
long start = System.currentTimeMillis();
|
||||
boolean success;
|
||||
Result rawResult = null;
|
||||
BaseLuminanceSource source = CameraManager.get().buildLuminanceSource(data, width, height);
|
||||
BinaryBitmap bitmap = new BinaryBitmap(new GlobalHistogramBinarizer(source));
|
||||
try {
|
||||
rawResult = multiFormatReader.decodeWithState(bitmap);
|
||||
success = true;
|
||||
} catch (ReaderException e) {
|
||||
success = false;
|
||||
} catch (ReaderException re) {
|
||||
// continue
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
if (success) {
|
||||
if (rawResult != null) {
|
||||
long end = System.currentTimeMillis();
|
||||
Log.v(TAG, "Found barcode (" + (end - start) + " ms):\n" + rawResult.toString());
|
||||
Message message = Message.obtain(activity.getHandler(), R.id.decode_succeeded, rawResult);
|
||||
Bundle bundle = new Bundle();
|
||||
|
|
|
@ -61,7 +61,7 @@ public final class InterleavedYUV422LuminanceSource extends BaseLuminanceSource
|
|||
if (row == null || row.length < width) {
|
||||
row = new byte[width];
|
||||
}
|
||||
int offset = (y + top) * dataWidth * 2 + (left * 2);
|
||||
int offset = ((y + top) * dataWidth << 1) + (left << 1);
|
||||
byte[] yuv = yuvData;
|
||||
for (int x = 0; x < width; x++) {
|
||||
row[x] = yuv[offset + (x << 1)];
|
||||
|
@ -75,7 +75,8 @@ public final class InterleavedYUV422LuminanceSource extends BaseLuminanceSource
|
|||
int height = getHeight();
|
||||
int area = width * height;
|
||||
byte[] matrix = new byte[area];
|
||||
int inputOffset = top * dataWidth * 2 + (left * 2);
|
||||
int dataWidth = this.dataWidth;
|
||||
int inputOffset = (top * dataWidth << 1) + (left << 1);
|
||||
byte[] yuv = yuvData;
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
|
@ -83,7 +84,7 @@ public final class InterleavedYUV422LuminanceSource extends BaseLuminanceSource
|
|||
for (int x = 0; x < width; x++) {
|
||||
matrix[outputOffset + x] = yuv[inputOffset + (x << 1)];
|
||||
}
|
||||
inputOffset += (dataWidth * 2);
|
||||
inputOffset += (dataWidth << 1);
|
||||
}
|
||||
return matrix;
|
||||
}
|
||||
|
@ -115,7 +116,8 @@ public final class InterleavedYUV422LuminanceSource extends BaseLuminanceSource
|
|||
int height = getHeight();
|
||||
int[] pixels = new int[width * height];
|
||||
byte[] yuv = yuvData;
|
||||
int inputOffset = top * dataWidth * 2 + (left * 2);
|
||||
int dataWidth = this.dataWidth;
|
||||
int inputOffset = (top * dataWidth << 1) + (left << 1);
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
int outputOffset = y * width;
|
||||
|
@ -123,7 +125,7 @@ public final class InterleavedYUV422LuminanceSource extends BaseLuminanceSource
|
|||
int grey = yuv[inputOffset + (x << 1)] & 0xff;
|
||||
pixels[outputOffset + x] = (0xff000000) | (grey * 0x00010101);
|
||||
}
|
||||
inputOffset += (dataWidth * 2);
|
||||
inputOffset += (dataWidth << 1);
|
||||
}
|
||||
|
||||
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
|
|
Loading…
Reference in a new issue