Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,117 @@
package com.google.zxing.pdf417.decoder.ec;
import com.google.zxing.ChecksumException;
/* loaded from: classes.dex */
public final class ErrorCorrection {
private final ModulusGF a = ModulusGF.f;
public int a(int[] iArr, int i, int[] iArr2) throws ChecksumException {
ModulusPoly modulusPoly = new ModulusPoly(this.a, iArr);
int[] iArr3 = new int[i];
boolean z = false;
for (int i2 = i; i2 > 0; i2--) {
int a = modulusPoly.a(this.a.a(i2));
iArr3[i - i2] = a;
if (a != 0) {
z = true;
}
}
if (!z) {
return 0;
}
ModulusPoly a2 = this.a.a();
if (iArr2 != null) {
ModulusPoly modulusPoly2 = a2;
for (int i3 : iArr2) {
int a3 = this.a.a((iArr.length - 1) - i3);
ModulusGF modulusGF = this.a;
modulusPoly2 = modulusPoly2.b(new ModulusPoly(modulusGF, new int[]{modulusGF.d(0, a3), 1}));
}
}
ModulusPoly[] a4 = a(this.a.b(i, 1), new ModulusPoly(this.a, iArr3), i);
ModulusPoly modulusPoly3 = a4[0];
ModulusPoly modulusPoly4 = a4[1];
int[] a5 = a(modulusPoly3);
int[] a6 = a(modulusPoly4, modulusPoly3, a5);
for (int i4 = 0; i4 < a5.length; i4++) {
int length = (iArr.length - 1) - this.a.c(a5[i4]);
if (length < 0) {
throw ChecksumException.getChecksumInstance();
}
iArr[length] = this.a.d(iArr[length], a6[i4]);
}
return a5.length;
}
private ModulusPoly[] a(ModulusPoly modulusPoly, ModulusPoly modulusPoly2, int i) throws ChecksumException {
if (modulusPoly.a() < modulusPoly2.a()) {
modulusPoly2 = modulusPoly;
modulusPoly = modulusPoly2;
}
ModulusPoly c = this.a.c();
ModulusPoly a = this.a.a();
while (true) {
ModulusPoly modulusPoly3 = modulusPoly2;
modulusPoly2 = modulusPoly;
modulusPoly = modulusPoly3;
ModulusPoly modulusPoly4 = a;
ModulusPoly modulusPoly5 = c;
c = modulusPoly4;
if (modulusPoly.a() >= i / 2) {
if (!modulusPoly.b()) {
ModulusPoly c2 = this.a.c();
int b = this.a.b(modulusPoly.b(modulusPoly.a()));
while (modulusPoly2.a() >= modulusPoly.a() && !modulusPoly2.b()) {
int a2 = modulusPoly2.a() - modulusPoly.a();
int c3 = this.a.c(modulusPoly2.b(modulusPoly2.a()), b);
c2 = c2.a(this.a.b(a2, c3));
modulusPoly2 = modulusPoly2.c(modulusPoly.a(a2, c3));
}
a = c2.b(c).c(modulusPoly5).c();
} else {
throw ChecksumException.getChecksumInstance();
}
} else {
int b2 = c.b(0);
if (b2 != 0) {
int b3 = this.a.b(b2);
return new ModulusPoly[]{c.c(b3), modulusPoly.c(b3)};
}
throw ChecksumException.getChecksumInstance();
}
}
}
private int[] a(ModulusPoly modulusPoly) throws ChecksumException {
int a = modulusPoly.a();
int[] iArr = new int[a];
int i = 0;
for (int i2 = 1; i2 < this.a.b() && i < a; i2++) {
if (modulusPoly.a(i2) == 0) {
iArr[i] = this.a.b(i2);
i++;
}
}
if (i == a) {
return iArr;
}
throw ChecksumException.getChecksumInstance();
}
private int[] a(ModulusPoly modulusPoly, ModulusPoly modulusPoly2, int[] iArr) {
int a = modulusPoly2.a();
int[] iArr2 = new int[a];
for (int i = 1; i <= a; i++) {
iArr2[a - i] = this.a.c(i, modulusPoly2.b(i));
}
ModulusPoly modulusPoly3 = new ModulusPoly(this.a, iArr2);
int length = iArr.length;
int[] iArr3 = new int[length];
for (int i2 = 0; i2 < length; i2++) {
int b = this.a.b(iArr[i2]);
iArr3[i2] = this.a.c(this.a.d(0, modulusPoly.a(b)), this.a.b(modulusPoly3.a(b)));
}
return iArr3;
}
}

View File

@@ -0,0 +1,87 @@
package com.google.zxing.pdf417.decoder.ec;
/* loaded from: classes.dex */
public final class ModulusGF {
public static final ModulusGF f = new ModulusGF(929, 3);
private final int[] a;
private final int[] b;
private final ModulusPoly c;
private final ModulusPoly d;
private final int e;
private ModulusGF(int i, int i2) {
this.e = i;
this.a = new int[i];
this.b = new int[i];
int i3 = 1;
for (int i4 = 0; i4 < i; i4++) {
this.a[i4] = i3;
i3 = (i3 * i2) % i;
}
for (int i5 = 0; i5 < i - 1; i5++) {
this.b[this.a[i5]] = i5;
}
this.c = new ModulusPoly(this, new int[]{0});
this.d = new ModulusPoly(this, new int[]{1});
}
ModulusPoly a() {
return this.d;
}
ModulusPoly b(int i, int i2) {
if (i < 0) {
throw new IllegalArgumentException();
}
if (i2 == 0) {
return this.c;
}
int[] iArr = new int[i + 1];
iArr[0] = i2;
return new ModulusPoly(this, iArr);
}
ModulusPoly c() {
return this.c;
}
int d(int i, int i2) {
int i3 = this.e;
return ((i + i3) - i2) % i3;
}
int a(int i, int i2) {
return (i + i2) % this.e;
}
int c(int i) {
if (i != 0) {
return this.b[i];
}
throw new IllegalArgumentException();
}
int a(int i) {
return this.a[i];
}
int c(int i, int i2) {
if (i == 0 || i2 == 0) {
return 0;
}
int[] iArr = this.a;
int[] iArr2 = this.b;
return iArr[(iArr2[i] + iArr2[i2]) % (this.e - 1)];
}
int b(int i) {
if (i != 0) {
return this.a[(this.e - this.b[i]) - 1];
}
throw new ArithmeticException();
}
int b() {
return this.e;
}
}

View File

@@ -0,0 +1,184 @@
package com.google.zxing.pdf417.decoder.ec;
/* loaded from: classes.dex */
final class ModulusPoly {
private final ModulusGF a;
private final int[] b;
ModulusPoly(ModulusGF modulusGF, int[] iArr) {
if (iArr.length == 0) {
throw new IllegalArgumentException();
}
this.a = modulusGF;
int length = iArr.length;
if (length <= 1 || iArr[0] != 0) {
this.b = iArr;
return;
}
int i = 1;
while (i < length && iArr[i] == 0) {
i++;
}
if (i == length) {
this.b = new int[]{0};
return;
}
this.b = new int[length - i];
int[] iArr2 = this.b;
System.arraycopy(iArr, i, iArr2, 0, iArr2.length);
}
int a() {
return this.b.length - 1;
}
boolean b() {
return this.b[0] == 0;
}
ModulusPoly c(ModulusPoly modulusPoly) {
if (this.a.equals(modulusPoly.a)) {
return modulusPoly.b() ? this : a(modulusPoly.c());
}
throw new IllegalArgumentException("ModulusPolys do not have same ModulusGF field");
}
public String toString() {
StringBuilder sb = new StringBuilder(a() * 8);
for (int a = a(); a >= 0; a--) {
int b = b(a);
if (b != 0) {
if (b < 0) {
sb.append(" - ");
b = -b;
} else if (sb.length() > 0) {
sb.append(" + ");
}
if (a == 0 || b != 1) {
sb.append(b);
}
if (a != 0) {
if (a == 1) {
sb.append('x');
} else {
sb.append("x^");
sb.append(a);
}
}
}
}
return sb.toString();
}
int a(int i) {
if (i == 0) {
return b(0);
}
if (i == 1) {
int i2 = 0;
for (int i3 : this.b) {
i2 = this.a.a(i2, i3);
}
return i2;
}
int[] iArr = this.b;
int i4 = iArr[0];
int length = iArr.length;
for (int i5 = 1; i5 < length; i5++) {
ModulusGF modulusGF = this.a;
i4 = modulusGF.a(modulusGF.c(i, i4), this.b[i5]);
}
return i4;
}
int b(int i) {
return this.b[(r0.length - 1) - i];
}
ModulusPoly b(ModulusPoly modulusPoly) {
if (this.a.equals(modulusPoly.a)) {
if (!b() && !modulusPoly.b()) {
int[] iArr = this.b;
int length = iArr.length;
int[] iArr2 = modulusPoly.b;
int length2 = iArr2.length;
int[] iArr3 = new int[(length + length2) - 1];
for (int i = 0; i < length; i++) {
int i2 = iArr[i];
for (int i3 = 0; i3 < length2; i3++) {
int i4 = i + i3;
ModulusGF modulusGF = this.a;
iArr3[i4] = modulusGF.a(iArr3[i4], modulusGF.c(i2, iArr2[i3]));
}
}
return new ModulusPoly(this.a, iArr3);
}
return this.a.c();
}
throw new IllegalArgumentException("ModulusPolys do not have same ModulusGF field");
}
ModulusPoly c() {
int length = this.b.length;
int[] iArr = new int[length];
for (int i = 0; i < length; i++) {
iArr[i] = this.a.d(0, this.b[i]);
}
return new ModulusPoly(this.a, iArr);
}
ModulusPoly a(ModulusPoly modulusPoly) {
if (this.a.equals(modulusPoly.a)) {
if (b()) {
return modulusPoly;
}
if (modulusPoly.b()) {
return this;
}
int[] iArr = this.b;
int[] iArr2 = modulusPoly.b;
if (iArr.length > iArr2.length) {
iArr = iArr2;
iArr2 = iArr;
}
int[] iArr3 = new int[iArr2.length];
int length = iArr2.length - iArr.length;
System.arraycopy(iArr2, 0, iArr3, 0, length);
for (int i = length; i < iArr2.length; i++) {
iArr3[i] = this.a.a(iArr[i - length], iArr2[i]);
}
return new ModulusPoly(this.a, iArr3);
}
throw new IllegalArgumentException("ModulusPolys do not have same ModulusGF field");
}
ModulusPoly c(int i) {
if (i == 0) {
return this.a.c();
}
if (i == 1) {
return this;
}
int length = this.b.length;
int[] iArr = new int[length];
for (int i2 = 0; i2 < length; i2++) {
iArr[i2] = this.a.c(this.b[i2], i);
}
return new ModulusPoly(this.a, iArr);
}
ModulusPoly a(int i, int i2) {
if (i < 0) {
throw new IllegalArgumentException();
}
if (i2 == 0) {
return this.a.c();
}
int length = this.b.length;
int[] iArr = new int[i + length];
for (int i3 = 0; i3 < length; i3++) {
iArr[i3] = this.a.c(this.b[i3], i2);
}
return new ModulusPoly(this.a, iArr);
}
}