jimu-decompiled/sources/com/google/zxing/aztec/decoder/Decoder.java
2025-05-13 19:24:51 +02:00

318 lines
10 KiB
Java

package com.google.zxing.aztec.decoder;
import com.google.zxing.FormatException;
import com.google.zxing.aztec.AztecDetectorResult;
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 com.ubt.jimu.message.OfficalMsgBean;
import java.util.Arrays;
/* loaded from: classes.dex */
public final class Decoder {
private static final String[] b = {"CTRL_PS", " ", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "CTRL_LL", "CTRL_ML", "CTRL_DL", "CTRL_BS"};
private static final String[] c = {"CTRL_PS", " ", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "CTRL_US", "CTRL_ML", "CTRL_DL", "CTRL_BS"};
private static final String[] d = {"CTRL_PS", " ", "\u0001", "\u0002", "\u0003", "\u0004", "\u0005", "\u0006", "\u0007", "\b", "\t", "\n", "\u000b", "\f", "\r", "\u001b", "\u001c", "\u001d", "\u001e", "\u001f", "@", "\\", "^", "_", "`", "|", "~", "\u007f", "CTRL_LL", "CTRL_UL", "CTRL_PL", "CTRL_BS"};
private static final String[] e = {"", "\r", "\r\n", ". ", ", ", ": ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", ":", ";", "<", "=", ">", "?", "[", "]", "{", "}", "CTRL_UL"};
private static final String[] f = {"CTRL_PS", " ", "0", "1", "2", "3", "4", "5", OfficalMsgBean.TYPE_ONLINE, "7", "8", "9", ",", ".", "CTRL_UL", "CTRL_US"};
private AztecDetectorResult a;
/* renamed from: com.google.zxing.aztec.decoder.Decoder$1, reason: invalid class name */
static /* synthetic */ class AnonymousClass1 {
static final /* synthetic */ int[] a = new int[Table.values().length];
static {
try {
a[Table.UPPER.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
a[Table.LOWER.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
a[Table.MIXED.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
a[Table.PUNCT.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
a[Table.DIGIT.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
}
}
private enum Table {
UPPER,
LOWER,
MIXED,
DIGIT,
PUNCT,
BINARY
}
private static int a(int i, boolean z) {
return ((z ? 88 : 112) + (i << 4)) * i;
}
private boolean[] b(boolean[] zArr) throws FormatException {
GenericGF genericGF;
int i = 8;
if (this.a.d() <= 2) {
i = 6;
genericGF = GenericGF.j;
} else if (this.a.d() <= 8) {
genericGF = GenericGF.n;
} else if (this.a.d() <= 22) {
i = 10;
genericGF = GenericGF.i;
} else {
i = 12;
genericGF = GenericGF.h;
}
int c2 = this.a.c();
int length = zArr.length / i;
if (length < c2) {
throw FormatException.getFormatInstance();
}
int[] iArr = new int[length];
int length2 = zArr.length % i;
int i2 = 0;
while (i2 < length) {
iArr[i2] = a(zArr, length2, i);
i2++;
length2 += i;
}
try {
new ReedSolomonDecoder(genericGF).a(iArr, length - c2);
int i3 = (1 << i) - 1;
int i4 = 0;
for (int i5 = 0; i5 < c2; i5++) {
int i6 = iArr[i5];
if (i6 == 0 || i6 == i3) {
throw FormatException.getFormatInstance();
}
if (i6 == 1 || i6 == i3 - 1) {
i4++;
}
}
boolean[] zArr2 = new boolean[(c2 * i) - i4];
int i7 = 0;
for (int i8 = 0; i8 < c2; i8++) {
int i9 = iArr[i8];
if (i9 == 1 || i9 == i3 - 1) {
Arrays.fill(zArr2, i7, (i7 + i) - 1, i9 > 1);
i7 += i - 1;
} else {
int i10 = i - 1;
while (i10 >= 0) {
int i11 = i7 + 1;
zArr2[i7] = ((1 << i10) & i9) != 0;
i10--;
i7 = i11;
}
}
}
return zArr2;
} catch (ReedSolomonException e2) {
throw FormatException.getFormatInstance(e2);
}
}
private static String c(boolean[] zArr) {
int length = zArr.length;
Table table = Table.UPPER;
StringBuilder sb = new StringBuilder(20);
Table table2 = table;
Table table3 = table2;
int i = 0;
while (i < length) {
if (table2 != Table.BINARY) {
int i2 = table2 == Table.DIGIT ? 4 : 5;
if (length - i < i2) {
break;
}
int a = a(zArr, i, i2);
i += i2;
String a2 = a(table2, a);
if (a2.startsWith("CTRL_")) {
table3 = a(a2.charAt(5));
if (a2.charAt(6) != 'L') {
table3 = table2;
table2 = table3;
}
} else {
sb.append(a2);
}
table2 = table3;
} else {
if (length - i < 5) {
break;
}
int a3 = a(zArr, i, 5);
int i3 = i + 5;
if (a3 == 0) {
if (length - i3 < 11) {
break;
}
a3 = a(zArr, i3, 11) + 31;
i3 += 11;
}
int i4 = i3;
int i5 = 0;
while (true) {
if (i5 >= a3) {
i = i4;
break;
}
if (length - i4 < 8) {
i = length;
break;
}
sb.append((char) a(zArr, i4, 8));
i4 += 8;
i5++;
}
table2 = table3;
}
}
return sb.toString();
}
public DecoderResult a(AztecDetectorResult aztecDetectorResult) throws FormatException {
this.a = aztecDetectorResult;
boolean[] b2 = b(a(aztecDetectorResult.a()));
DecoderResult decoderResult = new DecoderResult(a(b2), c(b2), null, null);
decoderResult.a(b2.length);
return decoderResult;
}
private static Table a(char c2) {
if (c2 == 'B') {
return Table.BINARY;
}
if (c2 == 'D') {
return Table.DIGIT;
}
if (c2 == 'P') {
return Table.PUNCT;
}
if (c2 == 'L') {
return Table.LOWER;
}
if (c2 != 'M') {
return Table.UPPER;
}
return Table.MIXED;
}
private static String a(Table table, int i) {
int i2 = AnonymousClass1.a[table.ordinal()];
if (i2 == 1) {
return b[i];
}
if (i2 == 2) {
return c[i];
}
if (i2 == 3) {
return d[i];
}
if (i2 == 4) {
return e[i];
}
if (i2 == 5) {
return f[i];
}
throw new IllegalStateException("Bad table");
}
private boolean[] a(BitMatrix bitMatrix) {
boolean e2 = this.a.e();
int d2 = this.a.d();
int i = (e2 ? 11 : 14) + (d2 << 2);
int[] iArr = new int[i];
boolean[] zArr = new boolean[a(d2, e2)];
int i2 = 2;
if (e2) {
for (int i3 = 0; i3 < iArr.length; i3++) {
iArr[i3] = i3;
}
} else {
int i4 = i / 2;
int i5 = ((i + 1) + (((i4 - 1) / 15) * 2)) / 2;
for (int i6 = 0; i6 < i4; i6++) {
iArr[(i4 - i6) - 1] = (i5 - r12) - 1;
iArr[i4 + i6] = (i6 / 15) + i6 + i5 + 1;
}
}
int i7 = 0;
int i8 = 0;
while (i7 < d2) {
int i9 = ((d2 - i7) << i2) + (e2 ? 9 : 12);
int i10 = i7 << 1;
int i11 = (i - 1) - i10;
int i12 = 0;
while (i12 < i9) {
int i13 = i12 << 1;
int i14 = 0;
while (i14 < i2) {
int i15 = i10 + i14;
int i16 = i10 + i12;
zArr[i8 + i13 + i14] = bitMatrix.b(iArr[i15], iArr[i16]);
int i17 = iArr[i16];
int i18 = i11 - i14;
zArr[(i9 * 2) + i8 + i13 + i14] = bitMatrix.b(i17, iArr[i18]);
int i19 = i11 - i12;
zArr[(i9 * 4) + i8 + i13 + i14] = bitMatrix.b(iArr[i18], iArr[i19]);
zArr[(i9 * 6) + i8 + i13 + i14] = bitMatrix.b(iArr[i19], iArr[i15]);
i14++;
d2 = d2;
e2 = e2;
i2 = 2;
}
i12++;
i2 = 2;
}
i8 += i9 << 3;
i7++;
i2 = 2;
}
return zArr;
}
private static int a(boolean[] zArr, int i, int i2) {
int i3 = 0;
for (int i4 = i; i4 < i + i2; i4++) {
i3 <<= 1;
if (zArr[i4]) {
i3 |= 1;
}
}
return i3;
}
private static byte a(boolean[] zArr, int i) {
int a;
int length = zArr.length - i;
if (length >= 8) {
a = a(zArr, i, 8);
} else {
a = a(zArr, i, length) << (8 - length);
}
return (byte) a;
}
static byte[] a(boolean[] zArr) {
byte[] bArr = new byte[(zArr.length + 7) / 8];
for (int i = 0; i < bArr.length; i++) {
bArr[i] = a(zArr, i << 3);
}
return bArr;
}
}