262 lines
7.8 KiB
Java
262 lines
7.8 KiB
Java
package com.google.zxing.pdf417.decoder;
|
|
|
|
import java.util.Formatter;
|
|
|
|
/* loaded from: classes.dex */
|
|
final class DetectionResult {
|
|
private final BarcodeMetadata a;
|
|
private final DetectionResultColumn[] b;
|
|
private BoundingBox c;
|
|
private final int d;
|
|
|
|
DetectionResult(BarcodeMetadata barcodeMetadata, BoundingBox boundingBox) {
|
|
this.a = barcodeMetadata;
|
|
this.d = barcodeMetadata.a();
|
|
this.c = boundingBox;
|
|
this.b = new DetectionResultColumn[this.d + 2];
|
|
}
|
|
|
|
private void a(DetectionResultColumn detectionResultColumn) {
|
|
if (detectionResultColumn != null) {
|
|
((DetectionResultRowIndicatorColumn) detectionResultColumn).a(this.a);
|
|
}
|
|
}
|
|
|
|
private int f() {
|
|
int g = g();
|
|
if (g == 0) {
|
|
return 0;
|
|
}
|
|
for (int i = 1; i < this.d + 1; i++) {
|
|
Codeword[] b = this.b[i].b();
|
|
for (int i2 = 0; i2 < b.length; i2++) {
|
|
if (b[i2] != null && !b[i2].g()) {
|
|
a(i, i2, b);
|
|
}
|
|
}
|
|
}
|
|
return g;
|
|
}
|
|
|
|
private int g() {
|
|
h();
|
|
return i() + j();
|
|
}
|
|
|
|
private void h() {
|
|
DetectionResultColumn[] detectionResultColumnArr = this.b;
|
|
if (detectionResultColumnArr[0] == null || detectionResultColumnArr[this.d + 1] == null) {
|
|
return;
|
|
}
|
|
Codeword[] b = detectionResultColumnArr[0].b();
|
|
Codeword[] b2 = this.b[this.d + 1].b();
|
|
for (int i = 0; i < b.length; i++) {
|
|
if (b[i] != null && b2[i] != null && b[i].c() == b2[i].c()) {
|
|
for (int i2 = 1; i2 <= this.d; i2++) {
|
|
Codeword codeword = this.b[i2].b()[i];
|
|
if (codeword != null) {
|
|
codeword.b(b[i].c());
|
|
if (!codeword.g()) {
|
|
this.b[i2].b()[i] = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private int i() {
|
|
DetectionResultColumn[] detectionResultColumnArr = this.b;
|
|
if (detectionResultColumnArr[0] == null) {
|
|
return 0;
|
|
}
|
|
Codeword[] b = detectionResultColumnArr[0].b();
|
|
int i = 0;
|
|
for (int i2 = 0; i2 < b.length; i2++) {
|
|
if (b[i2] != null) {
|
|
int c = b[i2].c();
|
|
int i3 = i;
|
|
int i4 = 0;
|
|
for (int i5 = 1; i5 < this.d + 1 && i4 < 2; i5++) {
|
|
Codeword codeword = this.b[i5].b()[i2];
|
|
if (codeword != null) {
|
|
i4 = a(c, i4, codeword);
|
|
if (!codeword.g()) {
|
|
i3++;
|
|
}
|
|
}
|
|
}
|
|
i = i3;
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
|
|
private int j() {
|
|
DetectionResultColumn[] detectionResultColumnArr = this.b;
|
|
int i = this.d;
|
|
if (detectionResultColumnArr[i + 1] == null) {
|
|
return 0;
|
|
}
|
|
Codeword[] b = detectionResultColumnArr[i + 1].b();
|
|
int i2 = 0;
|
|
for (int i3 = 0; i3 < b.length; i3++) {
|
|
if (b[i3] != null) {
|
|
int c = b[i3].c();
|
|
int i4 = i2;
|
|
int i5 = 0;
|
|
for (int i6 = this.d + 1; i6 > 0 && i5 < 2; i6--) {
|
|
Codeword codeword = this.b[i6].b()[i3];
|
|
if (codeword != null) {
|
|
i5 = a(c, i5, codeword);
|
|
if (!codeword.g()) {
|
|
i4++;
|
|
}
|
|
}
|
|
}
|
|
i2 = i4;
|
|
}
|
|
}
|
|
return i2;
|
|
}
|
|
|
|
int b() {
|
|
return this.a.b();
|
|
}
|
|
|
|
int c() {
|
|
return this.a.c();
|
|
}
|
|
|
|
BoundingBox d() {
|
|
return this.c;
|
|
}
|
|
|
|
DetectionResultColumn[] e() {
|
|
a(this.b[0]);
|
|
a(this.b[this.d + 1]);
|
|
int i = 928;
|
|
while (true) {
|
|
int f = f();
|
|
if (f <= 0 || f >= i) {
|
|
break;
|
|
}
|
|
i = f;
|
|
}
|
|
return this.b;
|
|
}
|
|
|
|
public String toString() {
|
|
DetectionResultColumn[] detectionResultColumnArr = this.b;
|
|
DetectionResultColumn detectionResultColumn = detectionResultColumnArr[0];
|
|
if (detectionResultColumn == null) {
|
|
detectionResultColumn = detectionResultColumnArr[this.d + 1];
|
|
}
|
|
Formatter formatter = new Formatter();
|
|
for (int i = 0; i < detectionResultColumn.b().length; i++) {
|
|
try {
|
|
formatter.format("CW %3d:", Integer.valueOf(i));
|
|
for (int i2 = 0; i2 < this.d + 2; i2++) {
|
|
if (this.b[i2] == null) {
|
|
formatter.format(" | ", new Object[0]);
|
|
} else {
|
|
Codeword codeword = this.b[i2].b()[i];
|
|
if (codeword == null) {
|
|
formatter.format(" | ", new Object[0]);
|
|
} else {
|
|
formatter.format(" %3d|%3d", Integer.valueOf(codeword.c()), Integer.valueOf(codeword.e()));
|
|
}
|
|
}
|
|
}
|
|
formatter.format("%n", new Object[0]);
|
|
} catch (Throwable th) {
|
|
try {
|
|
throw th;
|
|
} catch (Throwable th2) {
|
|
try {
|
|
formatter.close();
|
|
} catch (Throwable th3) {
|
|
th.addSuppressed(th3);
|
|
}
|
|
throw th2;
|
|
}
|
|
}
|
|
}
|
|
String formatter2 = formatter.toString();
|
|
formatter.close();
|
|
return formatter2;
|
|
}
|
|
|
|
private static int a(int i, int i2, Codeword codeword) {
|
|
if (codeword == null || codeword.g()) {
|
|
return i2;
|
|
}
|
|
if (!codeword.a(i)) {
|
|
return i2 + 1;
|
|
}
|
|
codeword.b(i);
|
|
return 0;
|
|
}
|
|
|
|
private void a(int i, int i2, Codeword[] codewordArr) {
|
|
Codeword codeword = codewordArr[i2];
|
|
Codeword[] b = this.b[i - 1].b();
|
|
DetectionResultColumn[] detectionResultColumnArr = this.b;
|
|
int i3 = i + 1;
|
|
Codeword[] b2 = detectionResultColumnArr[i3] != null ? detectionResultColumnArr[i3].b() : b;
|
|
Codeword[] codewordArr2 = new Codeword[14];
|
|
codewordArr2[2] = b[i2];
|
|
codewordArr2[3] = b2[i2];
|
|
if (i2 > 0) {
|
|
int i4 = i2 - 1;
|
|
codewordArr2[0] = codewordArr[i4];
|
|
codewordArr2[4] = b[i4];
|
|
codewordArr2[5] = b2[i4];
|
|
}
|
|
if (i2 > 1) {
|
|
int i5 = i2 - 2;
|
|
codewordArr2[8] = codewordArr[i5];
|
|
codewordArr2[10] = b[i5];
|
|
codewordArr2[11] = b2[i5];
|
|
}
|
|
if (i2 < codewordArr.length - 1) {
|
|
int i6 = i2 + 1;
|
|
codewordArr2[1] = codewordArr[i6];
|
|
codewordArr2[6] = b[i6];
|
|
codewordArr2[7] = b2[i6];
|
|
}
|
|
if (i2 < codewordArr.length - 2) {
|
|
int i7 = i2 + 2;
|
|
codewordArr2[9] = codewordArr[i7];
|
|
codewordArr2[12] = b[i7];
|
|
codewordArr2[13] = b2[i7];
|
|
}
|
|
for (int i8 = 0; i8 < 14 && !a(codeword, codewordArr2[i8]); i8++) {
|
|
}
|
|
}
|
|
|
|
private static boolean a(Codeword codeword, Codeword codeword2) {
|
|
if (codeword2 == null || !codeword2.g() || codeword2.a() != codeword.a()) {
|
|
return false;
|
|
}
|
|
codeword.b(codeword2.c());
|
|
return true;
|
|
}
|
|
|
|
int a() {
|
|
return this.d;
|
|
}
|
|
|
|
void a(BoundingBox boundingBox) {
|
|
this.c = boundingBox;
|
|
}
|
|
|
|
void a(int i, DetectionResultColumn detectionResultColumn) {
|
|
this.b[i] = detectionResultColumn;
|
|
}
|
|
|
|
DetectionResultColumn a(int i) {
|
|
return this.b[i];
|
|
}
|
|
}
|