package com.google.zxing.oned.rss; import com.google.zxing.BarcodeFormat; import com.google.zxing.DecodeHintType; import com.google.zxing.NotFoundException; import com.google.zxing.Result; import com.google.zxing.ResultPoint; import com.google.zxing.ResultPointCallback; import com.google.zxing.common.BitArray; import com.google.zxing.common.detector.MathUtils; import com.google.zxing.oned.OneDReader; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Map; /* loaded from: classes.dex */ public final class RSS14Reader extends AbstractRSSReader { private static final int[] i = {1, 10, 34, 70, 126}; private static final int[] j = {4, 20, 48, 81}; private static final int[] k = {0, 161, 961, 2015, 2715}; private static final int[] l = {0, 336, 1036, 1516}; private static final int[] m = {8, 6, 4, 3, 1}; private static final int[] n = {2, 4, 6, 8}; private static final int[][] o = {new int[]{3, 8, 2, 1}, new int[]{3, 5, 5, 1}, new int[]{3, 3, 7, 1}, new int[]{3, 1, 9, 1}, new int[]{2, 7, 4, 1}, new int[]{2, 5, 6, 1}, new int[]{2, 3, 8, 1}, new int[]{1, 5, 7, 1}, new int[]{1, 3, 9, 1}}; private final List g = new ArrayList(); private final List h = new ArrayList(); private static Result b(Pair pair, Pair pair2) { String valueOf = String.valueOf((pair.b() * 4537077) + pair2.b()); StringBuilder sb = new StringBuilder(14); for (int length = 13 - valueOf.length(); length > 0; length--) { sb.append('0'); } sb.append(valueOf); int i2 = 0; for (int i3 = 0; i3 < 13; i3++) { int charAt = sb.charAt(i3) - '0'; if ((i3 & 1) == 0) { charAt *= 3; } i2 += charAt; } int i4 = 10 - (i2 % 10); if (i4 == 10) { i4 = 0; } sb.append(i4); ResultPoint[] a = pair.d().a(); ResultPoint[] a2 = pair2.d().a(); return new Result(sb.toString(), null, new ResultPoint[]{a[0], a[1], a2[0], a2[1]}, BarcodeFormat.RSS_14); } @Override // com.google.zxing.oned.OneDReader public Result a(int i2, BitArray bitArray, Map map) throws NotFoundException { a(this.g, a(bitArray, false, i2, map)); bitArray.j(); a(this.h, a(bitArray, true, i2, map)); bitArray.j(); for (Pair pair : this.g) { if (pair.c() > 1) { for (Pair pair2 : this.h) { if (pair2.c() > 1 && a(pair, pair2)) { return b(pair, pair2); } } } } throw NotFoundException.getNotFoundInstance(); } @Override // com.google.zxing.oned.OneDReader, com.google.zxing.Reader public void reset() { this.g.clear(); this.h.clear(); } private static void a(Collection collection, Pair pair) { if (pair == null) { return; } boolean z = false; Iterator it = collection.iterator(); while (true) { if (!it.hasNext()) { break; } Pair next = it.next(); if (next.b() == pair.b()) { next.e(); z = true; break; } } if (z) { return; } collection.add(pair); } private static boolean a(Pair pair, Pair pair2) { int a = (pair.a() + (pair2.a() * 16)) % 79; int c = (pair.d().c() * 9) + pair2.d().c(); if (c > 72) { c--; } if (c > 8) { c--; } return a == c; } private Pair a(BitArray bitArray, boolean z, int i2, Map map) { try { FinderPattern a = a(bitArray, i2, z, a(bitArray, z)); ResultPointCallback resultPointCallback = map == null ? null : (ResultPointCallback) map.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); if (resultPointCallback != null) { float f = (r1[0] + r1[1]) / 2.0f; if (z) { f = (bitArray.h() - 1) - f; } resultPointCallback.a(new ResultPoint(f, i2)); } DataCharacter a2 = a(bitArray, a, true); DataCharacter a3 = a(bitArray, a, false); return new Pair((a2.b() * 1597) + a3.b(), a2.a() + (a3.a() * 4), a); } catch (NotFoundException unused) { return null; } } private DataCharacter a(BitArray bitArray, FinderPattern finderPattern, boolean z) throws NotFoundException { int[] a = a(); for (int i2 = 0; i2 < a.length; i2++) { a[i2] = 0; } if (z) { OneDReader.b(bitArray, finderPattern.b()[0], a); } else { OneDReader.a(bitArray, finderPattern.b()[1] + 1, a); int i3 = 0; for (int length = a.length - 1; i3 < length; length--) { int i4 = a[i3]; a[i3] = a[length]; a[length] = i4; i3++; } } int i5 = z ? 16 : 15; float a2 = MathUtils.a(a) / i5; int[] e = e(); int[] c = c(); float[] f = f(); float[] d = d(); for (int i6 = 0; i6 < a.length; i6++) { float f2 = a[i6] / a2; int i7 = (int) (0.5f + f2); if (i7 <= 0) { i7 = 1; } else if (i7 > 8) { i7 = 8; } int i8 = i6 / 2; if ((i6 & 1) == 0) { e[i8] = i7; f[i8] = f2 - i7; } else { c[i8] = i7; d[i8] = f2 - i7; } } a(z, i5); int i9 = 0; int i10 = 0; for (int length2 = e.length - 1; length2 >= 0; length2--) { i9 = (i9 * 9) + e[length2]; i10 += e[length2]; } int i11 = 0; int i12 = 0; for (int length3 = c.length - 1; length3 >= 0; length3--) { i11 = (i11 * 9) + c[length3]; i12 += c[length3]; } int i13 = i9 + (i11 * 3); if (!z) { if ((i12 & 1) == 0 && i12 <= 10 && i12 >= 4) { int i14 = (10 - i12) / 2; int i15 = n[i14]; return new DataCharacter((RSSUtils.a(c, 9 - i15, false) * j[i14]) + RSSUtils.a(e, i15, true) + l[i14], i13); } throw NotFoundException.getNotFoundInstance(); } if ((i10 & 1) == 0 && i10 <= 12 && i10 >= 4) { int i16 = (12 - i10) / 2; int i17 = m[i16]; return new DataCharacter((RSSUtils.a(e, i17, false) * i[i16]) + RSSUtils.a(c, 9 - i17, true) + k[i16], i13); } throw NotFoundException.getNotFoundInstance(); } private int[] a(BitArray bitArray, boolean z) throws NotFoundException { int[] b = b(); b[0] = 0; b[1] = 0; b[2] = 0; b[3] = 0; int h = bitArray.h(); int i2 = 0; boolean z2 = false; while (i2 < h) { z2 = !bitArray.a(i2); if (z == z2) { break; } i2++; } int i3 = i2; int i4 = 0; while (i2 < h) { if (bitArray.a(i2) != z2) { b[i4] = b[i4] + 1; } else { if (i4 != 3) { i4++; } else { if (AbstractRSSReader.a(b)) { return new int[]{i3, i2}; } i3 += b[0] + b[1]; b[0] = b[2]; b[1] = b[3]; b[2] = 0; b[3] = 0; i4--; } b[i4] = 1; z2 = !z2; } i2++; } throw NotFoundException.getNotFoundInstance(); } private FinderPattern a(BitArray bitArray, int i2, boolean z, int[] iArr) throws NotFoundException { int i3; int i4; boolean a = bitArray.a(iArr[0]); int i5 = iArr[0] - 1; while (i5 >= 0 && a != bitArray.a(i5)) { i5--; } int i6 = i5 + 1; int i7 = iArr[0] - i6; int[] b = b(); System.arraycopy(b, 0, b, 1, b.length - 1); b[0] = i7; int a2 = AbstractRSSReader.a(b, o); int i8 = iArr[1]; if (z) { int h = (bitArray.h() - 1) - i6; i3 = (bitArray.h() - 1) - i8; i4 = h; } else { i3 = i8; i4 = i6; } return new FinderPattern(a2, new int[]{i6, iArr[1]}, i4, i3, i2); } /* JADX WARN: Code restructure failed: missing block: B:68:0x0029, code lost: if (r1 < 4) goto L28; */ /* JADX WARN: Code restructure failed: missing block: B:69:0x0045, code lost: r2 = false; */ /* JADX WARN: Code restructure failed: missing block: B:70:0x0046, code lost: r7 = false; */ /* JADX WARN: Code restructure failed: missing block: B:71:0x0043, code lost: r2 = true; */ /* JADX WARN: Code restructure failed: missing block: B:81:0x0041, code lost: if (r1 < 4) goto L28; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ private void a(boolean r10, int r11) throws com.google.zxing.NotFoundException { /* Method dump skipped, instructions count: 229 To view this dump change 'Code comments level' option to 'DEBUG' */ throw new UnsupportedOperationException("Method not decompiled: com.google.zxing.oned.rss.RSS14Reader.a(boolean, int):void"); } }