262 lines
7.1 KiB
Java
262 lines
7.1 KiB
Java
package com.google.zxing.common;
|
|
|
|
import java.util.Arrays;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class BitMatrix implements Cloneable {
|
|
private final int a;
|
|
private final int b;
|
|
private final int c;
|
|
private final int[] d;
|
|
|
|
public BitMatrix(int i) {
|
|
this(i, i);
|
|
}
|
|
|
|
public void a(int i, int i2) {
|
|
int i3 = (i2 * this.c) + (i / 32);
|
|
int[] iArr = this.d;
|
|
iArr[i3] = (1 << (i & 31)) ^ iArr[i3];
|
|
}
|
|
|
|
public boolean b(int i, int i2) {
|
|
return ((this.d[(i2 * this.c) + (i / 32)] >>> (i & 31)) & 1) != 0;
|
|
}
|
|
|
|
public void c(int i, int i2) {
|
|
int i3 = (i2 * this.c) + (i / 32);
|
|
int[] iArr = this.d;
|
|
iArr[i3] = (1 << (i & 31)) | iArr[i3];
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (!(obj instanceof BitMatrix)) {
|
|
return false;
|
|
}
|
|
BitMatrix bitMatrix = (BitMatrix) obj;
|
|
return this.a == bitMatrix.a && this.b == bitMatrix.b && this.c == bitMatrix.c && Arrays.equals(this.d, bitMatrix.d);
|
|
}
|
|
|
|
public int[] h() {
|
|
int i = this.a;
|
|
int i2 = -1;
|
|
int i3 = this.b;
|
|
int i4 = -1;
|
|
int i5 = i;
|
|
int i6 = 0;
|
|
while (i6 < this.b) {
|
|
int i7 = i4;
|
|
int i8 = i2;
|
|
int i9 = i5;
|
|
int i10 = 0;
|
|
while (true) {
|
|
int i11 = this.c;
|
|
if (i10 < i11) {
|
|
int i12 = this.d[(i11 * i6) + i10];
|
|
if (i12 != 0) {
|
|
if (i6 < i3) {
|
|
i3 = i6;
|
|
}
|
|
if (i6 > i7) {
|
|
i7 = i6;
|
|
}
|
|
int i13 = i10 << 5;
|
|
int i14 = 31;
|
|
if (i13 < i9) {
|
|
int i15 = 0;
|
|
while ((i12 << (31 - i15)) == 0) {
|
|
i15++;
|
|
}
|
|
int i16 = i15 + i13;
|
|
if (i16 < i9) {
|
|
i9 = i16;
|
|
}
|
|
}
|
|
if (i13 + 31 > i8) {
|
|
while ((i12 >>> i14) == 0) {
|
|
i14--;
|
|
}
|
|
int i17 = i13 + i14;
|
|
if (i17 > i8) {
|
|
i8 = i17;
|
|
}
|
|
}
|
|
}
|
|
i10++;
|
|
}
|
|
}
|
|
i6++;
|
|
i5 = i9;
|
|
i2 = i8;
|
|
i4 = i7;
|
|
}
|
|
if (i2 < i5 || i4 < i3) {
|
|
return null;
|
|
}
|
|
return new int[]{i5, i3, (i2 - i5) + 1, (i4 - i3) + 1};
|
|
}
|
|
|
|
public int hashCode() {
|
|
int i = this.a;
|
|
return (((((((i * 31) + i) * 31) + this.b) * 31) + this.c) * 31) + Arrays.hashCode(this.d);
|
|
}
|
|
|
|
public int i() {
|
|
return this.b;
|
|
}
|
|
|
|
public int[] j() {
|
|
int i = 0;
|
|
while (true) {
|
|
int[] iArr = this.d;
|
|
if (i >= iArr.length || iArr[i] != 0) {
|
|
break;
|
|
}
|
|
i++;
|
|
}
|
|
int[] iArr2 = this.d;
|
|
if (i == iArr2.length) {
|
|
return null;
|
|
}
|
|
int i2 = this.c;
|
|
int i3 = i / i2;
|
|
int i4 = (i % i2) << 5;
|
|
int i5 = iArr2[i];
|
|
int i6 = 0;
|
|
while ((i5 << (31 - i6)) == 0) {
|
|
i6++;
|
|
}
|
|
return new int[]{i4 + i6, i3};
|
|
}
|
|
|
|
public int k() {
|
|
return this.a;
|
|
}
|
|
|
|
public void l() {
|
|
int k = k();
|
|
int i = i();
|
|
BitArray bitArray = new BitArray(k);
|
|
BitArray bitArray2 = new BitArray(k);
|
|
for (int i2 = 0; i2 < (i + 1) / 2; i2++) {
|
|
bitArray = a(i2, bitArray);
|
|
int i3 = (i - 1) - i2;
|
|
bitArray2 = a(i3, bitArray2);
|
|
bitArray.j();
|
|
bitArray2.j();
|
|
b(i2, bitArray2);
|
|
b(i3, bitArray);
|
|
}
|
|
}
|
|
|
|
public String toString() {
|
|
return a("X ", " ");
|
|
}
|
|
|
|
public BitMatrix(int i, int i2) {
|
|
if (i <= 0 || i2 <= 0) {
|
|
throw new IllegalArgumentException("Both dimensions must be greater than 0");
|
|
}
|
|
this.a = i;
|
|
this.b = i2;
|
|
this.c = (i + 31) / 32;
|
|
this.d = new int[this.c * i2];
|
|
}
|
|
|
|
/* renamed from: clone, reason: merged with bridge method [inline-methods] */
|
|
public BitMatrix m15clone() {
|
|
return new BitMatrix(this.a, this.b, this.c, (int[]) this.d.clone());
|
|
}
|
|
|
|
public void a() {
|
|
int length = this.d.length;
|
|
for (int i = 0; i < length; i++) {
|
|
this.d[i] = 0;
|
|
}
|
|
}
|
|
|
|
public void b(int i, BitArray bitArray) {
|
|
int[] b = bitArray.b();
|
|
int[] iArr = this.d;
|
|
int i2 = this.c;
|
|
System.arraycopy(b, 0, iArr, i * i2, i2);
|
|
}
|
|
|
|
public int[] b() {
|
|
int length = this.d.length - 1;
|
|
while (length >= 0 && this.d[length] == 0) {
|
|
length--;
|
|
}
|
|
if (length < 0) {
|
|
return null;
|
|
}
|
|
int i = this.c;
|
|
int i2 = length / i;
|
|
int i3 = (length % i) << 5;
|
|
int i4 = 31;
|
|
while ((this.d[length] >>> i4) == 0) {
|
|
i4--;
|
|
}
|
|
return new int[]{i3 + i4, i2};
|
|
}
|
|
|
|
public void a(int i, int i2, int i3, int i4) {
|
|
if (i2 < 0 || i < 0) {
|
|
throw new IllegalArgumentException("Left and top must be nonnegative");
|
|
}
|
|
if (i4 > 0 && i3 > 0) {
|
|
int i5 = i3 + i;
|
|
int i6 = i4 + i2;
|
|
if (i6 > this.b || i5 > this.a) {
|
|
throw new IllegalArgumentException("The region must fit inside the matrix");
|
|
}
|
|
while (i2 < i6) {
|
|
int i7 = this.c * i2;
|
|
for (int i8 = i; i8 < i5; i8++) {
|
|
int[] iArr = this.d;
|
|
int i9 = (i8 / 32) + i7;
|
|
iArr[i9] = iArr[i9] | (1 << (i8 & 31));
|
|
}
|
|
i2++;
|
|
}
|
|
return;
|
|
}
|
|
throw new IllegalArgumentException("Height and width must be at least 1");
|
|
}
|
|
|
|
private BitMatrix(int i, int i2, int i3, int[] iArr) {
|
|
this.a = i;
|
|
this.b = i2;
|
|
this.c = i3;
|
|
this.d = iArr;
|
|
}
|
|
|
|
public BitArray a(int i, BitArray bitArray) {
|
|
if (bitArray != null && bitArray.h() >= this.a) {
|
|
bitArray.a();
|
|
} else {
|
|
bitArray = new BitArray(this.a);
|
|
}
|
|
int i2 = i * this.c;
|
|
for (int i3 = 0; i3 < this.c; i3++) {
|
|
bitArray.b(i3 << 5, this.d[i2 + i3]);
|
|
}
|
|
return bitArray;
|
|
}
|
|
|
|
public String a(String str, String str2) {
|
|
return a(str, str2, "\n");
|
|
}
|
|
|
|
private String a(String str, String str2, String str3) {
|
|
StringBuilder sb = new StringBuilder(this.b * (this.a + 1));
|
|
for (int i = 0; i < this.b; i++) {
|
|
for (int i2 = 0; i2 < this.a; i2++) {
|
|
sb.append(b(i2, i) ? str : str2);
|
|
}
|
|
sb.append(str3);
|
|
}
|
|
return sb.toString();
|
|
}
|
|
}
|