package com.google.zxing.qrcode.decoder; import com.google.zxing.DecodeHintType; import com.google.zxing.FormatException; import com.google.zxing.common.BitSource; import com.google.zxing.common.CharacterSetECI; import com.google.zxing.common.StringUtils; import java.io.UnsupportedEncodingException; import java.util.Collection; import java.util.Map; /* loaded from: classes3.dex */ final class DecodedBitStreamParser { private static final char[] ALPHANUMERIC_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".toCharArray(); private static final int GB2312_SUBSET = 1; private DecodedBitStreamParser() { } /* JADX INFO: Access modifiers changed from: package-private */ /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */ /* JADX WARN: Failed to find 'out' block for switch in B:8:0x003a. Please report as an issue. */ /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Removed duplicated region for block: B:25:0x00da A[LOOP:0: B:2:0x001e->B:25:0x00da, LOOP_END] */ /* JADX WARN: Removed duplicated region for block: B:26:0x00b9 A[SYNTHETIC] */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public static com.google.zxing.common.DecoderResult decode(byte[] r17, com.google.zxing.qrcode.decoder.Version r18, com.google.zxing.qrcode.decoder.ErrorCorrectionLevel r19, java.util.Map r20) throws com.google.zxing.FormatException { /* Method dump skipped, instructions count: 242 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.google.zxing.qrcode.decoder.DecodedBitStreamParser.decode(byte[], com.google.zxing.qrcode.decoder.Version, com.google.zxing.qrcode.decoder.ErrorCorrectionLevel, java.util.Map):com.google.zxing.common.DecoderResult"); } private static void decodeHanziSegment(BitSource bitSource, StringBuilder sb, int i) throws FormatException { if (i * 13 > bitSource.available()) { throw FormatException.getFormatInstance(); } byte[] bArr = new byte[i * 2]; int i2 = 0; while (i > 0) { int readBits = bitSource.readBits(13); int i3 = (readBits % 96) | ((readBits / 96) << 8); int i4 = i3 + (i3 < 2560 ? 41377 : 42657); bArr[i2] = (byte) (i4 >> 8); bArr[i2 + 1] = (byte) i4; i2 += 2; i--; } try { sb.append(new String(bArr, StringUtils.GB2312)); } catch (UnsupportedEncodingException unused) { throw FormatException.getFormatInstance(); } } private static void decodeKanjiSegment(BitSource bitSource, StringBuilder sb, int i) throws FormatException { if (i * 13 > bitSource.available()) { throw FormatException.getFormatInstance(); } byte[] bArr = new byte[i * 2]; int i2 = 0; while (i > 0) { int readBits = bitSource.readBits(13); int i3 = (readBits % 192) | ((readBits / 192) << 8); int i4 = i3 + (i3 < 7936 ? 33088 : 49472); bArr[i2] = (byte) (i4 >> 8); bArr[i2 + 1] = (byte) i4; i2 += 2; i--; } try { sb.append(new String(bArr, StringUtils.SHIFT_JIS)); } catch (UnsupportedEncodingException unused) { throw FormatException.getFormatInstance(); } } private static void decodeByteSegment(BitSource bitSource, StringBuilder sb, int i, CharacterSetECI characterSetECI, Collection collection, Map map) throws FormatException { String name; if ((i << 3) > bitSource.available()) { throw FormatException.getFormatInstance(); } byte[] bArr = new byte[i]; for (int i2 = 0; i2 < i; i2++) { bArr[i2] = (byte) bitSource.readBits(8); } if (characterSetECI == null) { name = StringUtils.guessEncoding(bArr, map); } else { name = characterSetECI.name(); } try { sb.append(new String(bArr, name)); collection.add(bArr); } catch (UnsupportedEncodingException unused) { throw FormatException.getFormatInstance(); } } private static char toAlphaNumericChar(int i) throws FormatException { char[] cArr = ALPHANUMERIC_CHARS; if (i >= cArr.length) { throw FormatException.getFormatInstance(); } return cArr[i]; } private static void decodeAlphanumericSegment(BitSource bitSource, StringBuilder sb, int i, boolean z) throws FormatException { while (i > 1) { if (bitSource.available() < 11) { throw FormatException.getFormatInstance(); } int readBits = bitSource.readBits(11); sb.append(toAlphaNumericChar(readBits / 45)); sb.append(toAlphaNumericChar(readBits % 45)); i -= 2; } if (i == 1) { if (bitSource.available() < 6) { throw FormatException.getFormatInstance(); } sb.append(toAlphaNumericChar(bitSource.readBits(6))); } if (z) { for (int length = sb.length(); length < sb.length(); length++) { if (sb.charAt(length) == '%') { if (length < sb.length() - 1) { int i2 = length + 1; if (sb.charAt(i2) == '%') { sb.deleteCharAt(i2); } } sb.setCharAt(length, (char) 29); } } } } private static void decodeNumericSegment(BitSource bitSource, StringBuilder sb, int i) throws FormatException { while (i >= 3) { if (bitSource.available() < 10) { throw FormatException.getFormatInstance(); } int readBits = bitSource.readBits(10); if (readBits >= 1000) { throw FormatException.getFormatInstance(); } sb.append(toAlphaNumericChar(readBits / 100)); sb.append(toAlphaNumericChar((readBits / 10) % 10)); sb.append(toAlphaNumericChar(readBits % 10)); i -= 3; } if (i == 2) { if (bitSource.available() < 7) { throw FormatException.getFormatInstance(); } int readBits2 = bitSource.readBits(7); if (readBits2 >= 100) { throw FormatException.getFormatInstance(); } sb.append(toAlphaNumericChar(readBits2 / 10)); sb.append(toAlphaNumericChar(readBits2 % 10)); return; } if (i == 1) { if (bitSource.available() < 4) { throw FormatException.getFormatInstance(); } int readBits3 = bitSource.readBits(4); if (readBits3 >= 10) { throw FormatException.getFormatInstance(); } sb.append(toAlphaNumericChar(readBits3)); } } private static int parseECIValue(BitSource bitSource) throws FormatException { int readBits = bitSource.readBits(8); if ((readBits & 128) == 0) { return readBits & 127; } if ((readBits & 192) == 128) { return bitSource.readBits(8) | ((readBits & 63) << 8); } if ((readBits & 224) == 192) { return bitSource.readBits(16) | ((readBits & 31) << 16); } throw FormatException.getFormatInstance(); } }