52 lines
1.8 KiB
Java
52 lines
1.8 KiB
Java
package com.google.zxing.datamatrix.decoder;
|
|
|
|
import com.google.zxing.ChecksumException;
|
|
import com.google.zxing.FormatException;
|
|
import com.google.zxing.common.BitMatrix;
|
|
import com.google.zxing.common.DecoderResult;
|
|
import com.google.zxing.common.reedsolomon.GenericGF;
|
|
import com.google.zxing.common.reedsolomon.ReedSolomonDecoder;
|
|
import com.google.zxing.common.reedsolomon.ReedSolomonException;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class Decoder {
|
|
private final ReedSolomonDecoder a = new ReedSolomonDecoder(GenericGF.m);
|
|
|
|
public DecoderResult a(BitMatrix bitMatrix) throws FormatException, ChecksumException {
|
|
BitMatrixParser bitMatrixParser = new BitMatrixParser(bitMatrix);
|
|
DataBlock[] a = DataBlock.a(bitMatrixParser.b(), bitMatrixParser.a());
|
|
int i = 0;
|
|
for (DataBlock dataBlock : a) {
|
|
i += dataBlock.b();
|
|
}
|
|
byte[] bArr = new byte[i];
|
|
int length = a.length;
|
|
for (int i2 = 0; i2 < length; i2++) {
|
|
DataBlock dataBlock2 = a[i2];
|
|
byte[] a2 = dataBlock2.a();
|
|
int b = dataBlock2.b();
|
|
a(a2, b);
|
|
for (int i3 = 0; i3 < b; i3++) {
|
|
bArr[(i3 * length) + i2] = a2[i3];
|
|
}
|
|
}
|
|
return DecodedBitStreamParser.a(bArr);
|
|
}
|
|
|
|
private void a(byte[] bArr, int i) throws ChecksumException {
|
|
int length = bArr.length;
|
|
int[] iArr = new int[length];
|
|
for (int i2 = 0; i2 < length; i2++) {
|
|
iArr[i2] = bArr[i2] & 255;
|
|
}
|
|
try {
|
|
this.a.a(iArr, bArr.length - i);
|
|
for (int i3 = 0; i3 < i; i3++) {
|
|
bArr[i3] = (byte) iArr[i3];
|
|
}
|
|
} catch (ReedSolomonException unused) {
|
|
throw ChecksumException.getChecksumInstance();
|
|
}
|
|
}
|
|
}
|