100 lines
3.4 KiB
Java
100 lines
3.4 KiB
Java
package com.google.zxing.qrcode.decoder;
|
|
|
|
import com.google.zxing.ChecksumException;
|
|
import com.google.zxing.DecodeHintType;
|
|
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;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class Decoder {
|
|
private final ReedSolomonDecoder a = new ReedSolomonDecoder(GenericGF.l);
|
|
|
|
public DecoderResult a(BitMatrix bitMatrix, Map<DecodeHintType, ?> map) throws FormatException, ChecksumException {
|
|
ChecksumException e;
|
|
BitMatrixParser bitMatrixParser = new BitMatrixParser(bitMatrix);
|
|
FormatException formatException = null;
|
|
try {
|
|
return a(bitMatrixParser, map);
|
|
} catch (ChecksumException e2) {
|
|
e = e2;
|
|
try {
|
|
bitMatrixParser.e();
|
|
bitMatrixParser.a(true);
|
|
bitMatrixParser.d();
|
|
bitMatrixParser.c();
|
|
bitMatrixParser.a();
|
|
DecoderResult a = a(bitMatrixParser, map);
|
|
a.a(new QRCodeDecoderMetaData(true));
|
|
return a;
|
|
} catch (ChecksumException | FormatException unused) {
|
|
if (formatException != null) {
|
|
throw formatException;
|
|
}
|
|
throw e;
|
|
}
|
|
} catch (FormatException e3) {
|
|
e = null;
|
|
formatException = e3;
|
|
bitMatrixParser.e();
|
|
bitMatrixParser.a(true);
|
|
bitMatrixParser.d();
|
|
bitMatrixParser.c();
|
|
bitMatrixParser.a();
|
|
DecoderResult a2 = a(bitMatrixParser, map);
|
|
a2.a(new QRCodeDecoderMetaData(true));
|
|
return a2;
|
|
}
|
|
}
|
|
|
|
private DecoderResult a(BitMatrixParser bitMatrixParser, Map<DecodeHintType, ?> map) throws FormatException, ChecksumException {
|
|
Version d = bitMatrixParser.d();
|
|
ErrorCorrectionLevel b = bitMatrixParser.c().b();
|
|
DataBlock[] a = DataBlock.a(bitMatrixParser.b(), d, b);
|
|
int i = 0;
|
|
for (DataBlock dataBlock : a) {
|
|
i += dataBlock.b();
|
|
}
|
|
byte[] bArr = new byte[i];
|
|
int length = a.length;
|
|
int i2 = 0;
|
|
int i3 = 0;
|
|
while (i2 < length) {
|
|
DataBlock dataBlock2 = a[i2];
|
|
byte[] a2 = dataBlock2.a();
|
|
int b2 = dataBlock2.b();
|
|
a(a2, b2);
|
|
int i4 = i3;
|
|
int i5 = 0;
|
|
while (i5 < b2) {
|
|
bArr[i4] = a2[i5];
|
|
i5++;
|
|
i4++;
|
|
}
|
|
i2++;
|
|
i3 = i4;
|
|
}
|
|
return DecodedBitStreamParser.a(bArr, d, b, map);
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
}
|