mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2025-01-09 13:43:22 +00:00
55 lines
2.2 KiB
Java
55 lines
2.2 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: classes3.dex */
|
|
public final class Decoder {
|
|
private final ReedSolomonDecoder rsDecoder = new ReedSolomonDecoder(GenericGF.DATA_MATRIX_FIELD_256);
|
|
|
|
public DecoderResult decode(boolean[][] zArr) throws FormatException, ChecksumException {
|
|
return decode(BitMatrix.parse(zArr));
|
|
}
|
|
|
|
public DecoderResult decode(BitMatrix bitMatrix) throws FormatException, ChecksumException {
|
|
BitMatrixParser bitMatrixParser = new BitMatrixParser(bitMatrix);
|
|
DataBlock[] dataBlocks = DataBlock.getDataBlocks(bitMatrixParser.readCodewords(), bitMatrixParser.getVersion());
|
|
int i = 0;
|
|
for (DataBlock dataBlock : dataBlocks) {
|
|
i += dataBlock.getNumDataCodewords();
|
|
}
|
|
byte[] bArr = new byte[i];
|
|
int length = dataBlocks.length;
|
|
for (int i2 = 0; i2 < length; i2++) {
|
|
DataBlock dataBlock2 = dataBlocks[i2];
|
|
byte[] codewords = dataBlock2.getCodewords();
|
|
int numDataCodewords = dataBlock2.getNumDataCodewords();
|
|
correctErrors(codewords, numDataCodewords);
|
|
for (int i3 = 0; i3 < numDataCodewords; i3++) {
|
|
bArr[(i3 * length) + i2] = codewords[i3];
|
|
}
|
|
}
|
|
return DecodedBitStreamParser.decode(bArr);
|
|
}
|
|
|
|
private void correctErrors(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.rsDecoder.decode(iArr, bArr.length - i);
|
|
for (int i3 = 0; i3 < i; i3++) {
|
|
bArr[i3] = (byte) iArr[i3];
|
|
}
|
|
} catch (ReedSolomonException unused) {
|
|
throw ChecksumException.getChecksumInstance();
|
|
}
|
|
}
|
|
}
|