玖星尚缘 v1.2.7版本的 MD5 值为:a5d3a854f0a33133433102e91a1193e3
以下内容为反编译后的 RSSExpandedReader.java 源代码,内容仅作参考
package com.dcloud.zxing2.oned.rss.expanded;
import com.alibaba.fastjson.asm.Opcodes;
import com.alipay.sdk.m.u.n;
import com.dcloud.zxing2.BarcodeFormat;
import com.dcloud.zxing2.DecodeHintType;
import com.dcloud.zxing2.FormatException;
import com.dcloud.zxing2.NotFoundException;
import com.dcloud.zxing2.Result;
import com.dcloud.zxing2.ResultPoint;
import com.dcloud.zxing2.common.BitArray;
import com.dcloud.zxing2.oned.OneDReader;
import com.dcloud.zxing2.oned.rss.AbstractRSSReader;
import com.dcloud.zxing2.oned.rss.DataCharacter;
import com.dcloud.zxing2.oned.rss.FinderPattern;
import com.dcloud.zxing2.oned.rss.RSSUtils;
import com.dcloud.zxing2.oned.rss.expanded.decoders.AbstractExpandedDecoder;
import com.facebook.imageutils.JfifUtil;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.mozilla.universalchardet.prober.contextanalysis.EUCJPContextAnalysis;
import org.mozilla.universalchardet.prober.contextanalysis.SJISContextAnalysis;
import org.mozilla.universalchardet.prober.distributionanalysis.EUCTWDistributionAnalysis;
import tv.danmaku.ijk.media.player.IjkMediaMeta;
import uni.www.buchangjiuye.com.BuildConfig;
public final class RSSExpandedReader extends AbstractRSSReader {
private static final int FINDER_PAT_A = 0;
private static final int FINDER_PAT_B = 1;
private static final int FINDER_PAT_C = 2;
private static final int FINDER_PAT_D = 3;
private static final int FINDER_PAT_E = 4;
private static final int FINDER_PAT_F = 5;
private static final int MAX_PAIRS = 11;
private final List<ExpandedPair> pairs = new ArrayList(11);
private final List<ExpandedRow> rows = new ArrayList();
private final int[] startEnd = new int[2];
private boolean startFromEven;
private static final int[] SYMBOL_WIDEST = {7, 5, 4, 3, 1};
private static final int[] EVEN_TOTAL_SUBSET = {4, 20, 52, 104, 204};
private static final int[] GSUM = {0, 348, 1388, 2948, 3988};
private static final int[][] FINDER_PATTERNS = {new int[]{1, 8, 4, 1}, new int[]{3, 6, 4, 1}, new int[]{3, 4, 6, 1}, new int[]{3, 2, 8, 1}, new int[]{2, 6, 5, 1}, new int[]{2, 2, 9, 1}};
private static final int[][] WEIGHTS = {new int[]{1, 3, 9, 27, 81, 32, 96, 77}, new int[]{20, 60, 180, 118, EUCJPContextAnalysis.SINGLE_SHIFT_3, 7, 21, 63}, new int[]{189, 145, 13, 39, 117, 140, 209, 205}, new int[]{Opcodes.INSTANCEOF, 157, 49, 147, 19, 57, 171, 91}, new int[]{62, 186, 136, 197, Opcodes.RET, 85, 44, 132}, new int[]{Opcodes.INVOKEINTERFACE, 133, Opcodes.NEWARRAY, EUCJPContextAnalysis.SINGLE_SHIFT_2, 4, 12, 36, 108}, new int[]{113, 128, 173, 97, 80, 29, 87, 50}, new int[]{150, 28, 84, 41, 123, Opcodes.IFLE, 52, 156}, new int[]{46, 138, 203, Opcodes.NEW, 139, 206, EUCTWDistributionAnalysis.HIGHBYTE_BEGIN, Opcodes.IF_ACMPNE}, new int[]{76, 17, 51, Opcodes.IFEQ, 37, 111, 122, 155}, new int[]{43, 129, 176, 106, 107, 110, 119, 146}, new int[]{16, 48, IjkMediaMeta.FF_PROFILE_H264_HIGH_444, 10, 30, 90, 59, Opcodes.RETURN}, new int[]{109, 116, 137, 200, Opcodes.GETSTATIC, 112, n.f, 164}, new int[]{70, 210, JfifUtil.MARKER_RST0, 202, Opcodes.INVOKESTATIC, SJISContextAnalysis.HIRAGANA_HIGHBYTE, 179, 115}, new int[]{134, 191, Opcodes.DCMPL, 31, 93, 68, 204, 190}, new int[]{Opcodes.LCMP, 22, 66, Opcodes.IFNULL, 172, 94, 71, 2}, new int[]{6, 18, 54, Opcodes.IF_ICMPGE, 64, 192, Opcodes.IFNE, 40}, new int[]{120, Opcodes.FCMPL, 25, 75, 14, 42, 126, Opcodes.GOTO}, new int[]{79, 26, 78, 23, 69, 207, Opcodes.IFNONNULL, 175}, new int[]{103, 98, 83, 38, 114, 131, Opcodes.INVOKEVIRTUAL, 124}, new int[]{161, 61, Opcodes.INVOKESPECIAL, BuildConfig.VERSION_CODE, 170, 88, 53, 159}, new int[]{55, Opcodes.IF_ACMPEQ, 73, 8, 24, 72, 5, 15}, new int[]{45, 135, 194, Opcodes.IF_ICMPNE, 58, 174, 100, 89}};
private static final int[][] FINDER_PATTERN_SEQUENCES = {new int[]{0, 0}, new int[]{0, 1, 1}, new int[]{0, 2, 1, 3}, new int[]{0, 4, 1, 3, 2}, new int[]{0, 4, 1, 3, 3, 5}, new int[]{0, 4, 1, 3, 4, 5, 5}, new int[]{0, 0, 1, 1, 2, 2, 3, 3}, new int[]{0, 0, 1, 1, 2, 2, 3, 4, 4}, new int[]{0, 0, 1, 1, 2, 2, 3, 4, 5, 5}, new int[]{0, 0, 1, 1, 2, 3, 3, 4, 4, 5, 5}};
private void adjustOddEvenCounts(int i) throws NotFoundException {
boolean z;
boolean z2;
boolean z3;
int count = AbstractRSSReader.count(getOddCounts());
int count2 = AbstractRSSReader.count(getEvenCounts());
int i2 = (count + count2) - i;
boolean z4 = true;
boolean z5 = (count & 1) == 1;
boolean z6 = (count2 & 1) == 0;
if (count > 13) {
z = false;
z2 = true;
} else {
z = count < 4;
z2 = false;
}
if (count2 > 13) {
z3 = true;
} else {
r3 = count2 < 4;
z3 = false;
}
if (i2 == 1) {
if (z5) {
if (z6) {
throw NotFoundException.getNotFoundInstance();
}
z4 = z;
z2 = true;
} else if (!z6) {
throw NotFoundException.getNotFoundInstance();
} else {
z4 = z;
z3 = true;
}
} else if (i2 == -1) {
if (z5) {
if (z6) {
throw NotFoundException.getNotFoundInstance();
}
} else if (!z6) {
throw NotFoundException.getNotFoundInstance();
} else {
z4 = z;
r3 = true;
}
} else if (i2 != 0) {
throw NotFoundException.getNotFoundInstance();
} else {
if (z5) {
if (!z6) {
throw NotFoundException.getNotFoundInstance();
}
if (count >= count2) {
z4 = z;
r3 = true;
z2 = true;
}
z3 = true;
} else if (z6) {
throw NotFoundException.getNotFoundInstance();
} else {
z4 = z;
}
}
if (z4) {
if (!z2) {
AbstractRSSReader.increment(getOddCounts(), getOddRoundingErrors());
} else {
throw NotFoundException.getNotFoundInstance();
}
}
if (z2) {
AbstractRSSReader.decrement(getOddCounts(), getOddRoundingErrors());
}
if (r3) {
if (!z3) {
AbstractRSSReader.increment(getEvenCounts(), getOddRoundingErrors());
} else {
throw NotFoundException.getNotFoundInstance();
}
}
if (z3) {
AbstractRSSReader.decrement(getEvenCounts(), getEvenRoundingErrors());
}
}
private boolean checkChecksum() {
ExpandedPair expandedPair = this.pairs.get(0);
DataCharacter leftChar = expandedPair.getLeftChar();
DataCharacter rightChar = expandedPair.getRightChar();
if (rightChar == null) {
return false;
}
int checksumPortion = rightChar.getChecksumPortion();
int i = 2;
for (int i2 = 1; i2 < this.pairs.size(); i2++) {
ExpandedPair expandedPair2 = this.pairs.get(i2);
checksumPortion += expandedPair2.getLeftChar().getChecksumPortion();
i++;
DataCharacter rightChar2 = expandedPair2.getRightChar();
if (rightChar2 != null) {
checksumPortion += rightChar2.getChecksumPortion();
i++;
}
}
return ((i + (-4)) * 211) + (checksumPortion % 211) == leftChar.getValue();
}
private List<ExpandedPair> checkRows(boolean z) {
List<ExpandedPair> list = null;
if (this.rows.size() > 25) {
this.rows.clear();
return null;
}
this.pairs.clear();
if (z) {
Collections.reverse(this.rows);
}
try {
list = checkRows(new ArrayList(), 0);
} catch (NotFoundException unused) {
}
if (z) {
Collections.reverse(this.rows);
}
return list;
}
static Result constructResult(List<ExpandedPair> list) throws NotFoundException, FormatException {
String parseInformation = AbstractExpandedDecoder.createDecoder(BitArrayBuilder.buildBitArray(list)).parseInformation();
ResultPoint[] resultPoints = list.get(0).getFinderPattern().getResultPoints();
ResultPoint[] resultPoints2 = list.get(list.size() - 1).getFinderPattern().getResultPoints();
return new Result(parseInformation, null, new ResultPoint[]{resultPoints[0], resultPoints[1], resultPoints2[0], resultPoints2[1]}, BarcodeFormat.RSS_EXPANDED);
}
private void findNextPair(BitArray bitArray, List<ExpandedPair> list, int i) throws NotFoundException {
int[] decodeFinderCounters = getDecodeFinderCounters();
decodeFinderCounters[0] = 0;
decodeFinderCounters[1] = 0;
decodeFinderCounters[2] = 0;
decodeFinderCounters[3] = 0;
int size = bitArray.getSize();
if (i < 0) {
i = list.isEmpty() ? 0 : list.get(list.size() - 1).getFinderPattern().getStartEnd()[1];
}
boolean z = list.size() % 2 != 0;
if (this.startFromEven) {
z = !z;
}
boolean z2 = false;
while (i < size) {
z2 = !bitArray.get(i);
if (!z2) {
break;
}
i++;
}
boolean z3 = z2;
int i2 = 0;
int i3 = i;
while (i < size) {
if (bitArray.get(i) ^ z3) {
decodeFinderCounters[i2] = decodeFinderCounters[i2] + 1;
} else {
if (i2 == 3) {
if (z) {
reverseCounters(decodeFinderCounters);
}
if (AbstractRSSReader.isFinderPattern(decodeFinderCounters)) {
int[] iArr = this.startEnd;
iArr[0] = i3;
iArr[1] = i;
return;
}
if (z) {
reverseCounters(decodeFinderCounters);
}
i3 += decodeFinderCounters[0] + decodeFinderCounters[1];
decodeFinderCounters[0] = decodeFinderCounters[2];
decodeFinderCounters[1] = decodeFinderCounters[3];
decodeFinderCounters[2] = 0;
decodeFinderCounters[3] = 0;
i2--;
} else {
i2++;
}
decodeFinderCounters[i2] = 1;
z3 = !z3;
}
i++;
}
throw NotFoundException.getNotFoundInstance();
}
private static int getNextSecondBar(BitArray bitArray, int i) {
if (bitArray.get(i)) {
return bitArray.getNextSet(bitArray.getNextUnset(i));
}
return bitArray.getNextUnset(bitArray.getNextSet(i));
}
private static boolean isNotA1left(FinderPattern finderPattern, boolean z, boolean z2) {
return (finderPattern.getValue() == 0 && z && z2) ? false : true;
}
private static boolean isPartialRow(Iterable<ExpandedPair> iterable, Iterable<ExpandedRow> iterable2) {
boolean z;
boolean z2;
Iterator<ExpandedRow> it = iterable2.iterator();
do {
z = false;
if (!it.hasNext()) {
return false;
}
ExpandedRow next = it.next();
Iterator<ExpandedPair> it2 = iterable.iterator();
while (true) {
if (!it2.hasNext()) {
z = true;
continue;
break;
}
ExpandedPair next2 = it2.next();
Iterator<ExpandedPair> it3 = next.getPairs().iterator();
while (true) {
if (!it3.hasNext()) {
z2 = false;
continue;
break;
} else if (next2.equals(it3.next())) {
z2 = true;
continue;
break;
}
}
if (!z2) {
break;
}
}
} while (!z);
return true;
}
private static boolean isValidSequence(List<ExpandedPair> list) {
int[][] iArr;
boolean z;
for (int[] iArr2 : FINDER_PATTERN_SEQUENCES) {
if (list.size() <= iArr2.length) {
int i = 0;
while (true) {
if (i >= list.size()) {
z = true;
break;
} else if (list.get(i).getFinderPattern().getValue() != iArr2[i]) {
z = false;
break;
} else {
i++;
}
}
if (z) {
return true;
}
}
}
return false;
}
private FinderPattern parseFoundFinderPattern(BitArray bitArray, int i, boolean z) {
int i2;
int i3;
int i4;
if (z) {
int i5 = this.startEnd[0] - 1;
while (i5 >= 0 && !bitArray.get(i5)) {
i5--;
}
int i6 = i5 + 1;
int[] iArr = this.startEnd;
i4 = iArr[0] - i6;
i2 = iArr[1];
i3 = i6;
} else {
int[] iArr2 = this.startEnd;
int i7 = iArr2[0];
int nextUnset = bitArray.getNextUnset(iArr2[1] + 1);
i2 = nextUnset;
i3 = i7;
i4 = nextUnset - this.startEnd[1];
}
int[] decodeFinderCounters = getDecodeFinderCounters();
System.arraycopy(decodeFinderCounters, 0, decodeFinderCounters, 1, decodeFinderCounters.length - 1);
decodeFinderCounters[0] = i4;
try {
return new FinderPattern(AbstractRSSReader.parseFinderValue(decodeFinderCounters, FINDER_PATTERNS), new int[]{i3, i2}, i3, i2, i);
} catch (NotFoundException unused) {
return null;
}
}
private static void removePartialRows(List<ExpandedPair> list, List<ExpandedRow> list2) {
boolean z;
Iterator<ExpandedRow> it = list2.iterator();
while (it.hasNext()) {
ExpandedRow next = it.next();
if (next.getPairs().size() != list.size()) {
Iterator<ExpandedPair> it2 = next.getPairs().iterator();
while (true) {
z = false;
boolean z2 = true;
if (!it2.hasNext()) {
z = true;
break;
}
ExpandedPair next2 = it2.next();
Iterator<ExpandedPair> it3 = list.iterator();
while (true) {
if (!it3.hasNext()) {
z2 = false;
continue;
break;
} else if (next2.equals(it3.next())) {
break;
}
}
if (!z2) {
break;
}
}
if (z) {
it.remove();
}
}
}
}
private static void reverseCounters(int[] iArr) {
int length = iArr.length;
for (int i = 0; i < length / 2; i++) {
int i2 = iArr[i];
int i3 = (length - i) - 1;
iArr[i] = iArr[i3];
iArr[i3] = i2;
}
}
private void storeRow(int i, boolean z) {
boolean z2 = false;
int i2 = 0;
boolean z3 = false;
while (true) {
if (i2 >= this.rows.size()) {
break;
}
ExpandedRow expandedRow = this.rows.get(i2);
if (expandedRow.getRowNumber() > i) {
z2 = expandedRow.isEquivalent(this.pairs);
break;
} else {
z3 = expandedRow.isEquivalent(this.pairs);
i2++;
}
}
if (z2 || z3 || isPartialRow(this.pairs, this.rows)) {
return;
}
this.rows.add(i2, new ExpandedRow(this.pairs, i, z));
removePartialRows(this.pairs, this.rows);
}
DataCharacter decodeDataCharacter(BitArray bitArray, FinderPattern finderPattern, boolean z, boolean z2) throws NotFoundException {
int[] dataCharacterCounters = getDataCharacterCounters();
dataCharacterCounters[0] = 0;
dataCharacterCounters[1] = 0;
dataCharacterCounters[2] = 0;
dataCharacterCounters[3] = 0;
dataCharacterCounters[4] = 0;
dataCharacterCounters[5] = 0;
dataCharacterCounters[6] = 0;
dataCharacterCounters[7] = 0;
if (z2) {
OneDReader.recordPatternInReverse(bitArray, finderPattern.getStartEnd()[0], dataCharacterCounters);
} else {
OneDReader.recordPattern(bitArray, finderPattern.getStartEnd()[1], dataCharacterCounters);
int i = 0;
for (int length = dataCharacterCounters.length - 1; i < length; length--) {
int i2 = dataCharacterCounters[i];
dataCharacterCounters[i] = dataCharacterCounters[length];
dataCharacterCounters[length] = i2;
i++;
}
}
float count = AbstractRSSReader.count(dataCharacterCounters) / 17;
float f = (finderPattern.getStartEnd()[1] - finderPattern.getStartEnd()[0]) / 15.0f;
if (Math.abs(count - f) / f <= 0.3f) {
int[] oddCounts = getOddCounts();
int[] evenCounts = getEvenCounts();
float[] oddRoundingErrors = getOddRoundingErrors();
float[] evenRoundingErrors = getEvenRoundingErrors();
for (int i3 = 0; i3 < dataCharacterCounters.length; i3++) {
float f2 = (dataCharacterCounters[i3] * 1.0f) / count;
int i4 = (int) (0.5f + f2);
if (i4 < 1) {
if (f2 < 0.3f) {
throw NotFoundException.getNotFoundInstance();
}
i4 = 1;
} else if (i4 > 8) {
if (f2 > 8.7f) {
throw NotFoundException.getNotFoundInstance();
}
i4 = 8;
}
int i5 = i3 / 2;
if ((i3 & 1) == 0) {
oddCounts[i5] = i4;
oddRoundingErrors[i5] = f2 - i4;
} else {
evenCounts[i5] = i4;
evenRoundingErrors[i5] = f2 - i4;
}
}
adjustOddEvenCounts(17);
int value = (((finderPattern.getValue() * 4) + (z ? 0 : 2)) + (!z2 ? 1 : 0)) - 1;
int i6 = 0;
int i7 = 0;
for (int length2 = oddCounts.length - 1; length2 >= 0; length2--) {
if (isNotA1left(finderPattern, z, z2)) {
i6 += oddCounts[length2] * WEIGHTS[value][length2 * 2];
}
i7 += oddCounts[length2];
}
int i8 = 0;
for (int length3 = evenCounts.length - 1; length3 >= 0; length3--) {
if (isNotA1left(finderPattern, z, z2)) {
i8 += evenCounts[length3] * WEIGHTS[value][(length3 * 2) + 1];
}
}
int i9 = i6 + i8;
if ((i7 & 1) == 0 && i7 <= 13 && i7 >= 4) {
int i10 = (13 - i7) / 2;
int i11 = SYMBOL_WIDEST[i10];
return new DataCharacter((RSSUtils.getRSSvalue(oddCounts, i11, true) * EVEN_TOTAL_SUBSET[i10]) + RSSUtils.getRSSvalue(evenCounts, 9 - i11, false) + GSUM[i10], i9);
}
throw NotFoundException.getNotFoundInstance();
}
throw NotFoundException.getNotFoundInstance();
}
@Override
public Result decodeRow(int i, BitArray bitArray, Map<DecodeHintType, ?> map) throws NotFoundException, FormatException {
this.pairs.clear();
this.startFromEven = false;
try {
return constructResult(decodeRow2pairs(i, bitArray));
} catch (NotFoundException unused) {
this.pairs.clear();
this.startFromEven = true;
return constructResult(decodeRow2pairs(i, bitArray));
}
}
List<ExpandedPair> decodeRow2pairs(int i, BitArray bitArray) throws NotFoundException {
while (true) {
try {
this.pairs.add(retrieveNextPair(bitArray, this.pairs, i));
} catch (NotFoundException e) {
if (this.pairs.isEmpty()) {
throw e;
}
if (checkChecksum()) {
return this.pairs;
}
boolean z = !this.rows.isEmpty();
storeRow(i, false);
if (z) {
List<ExpandedPair> checkRows = checkRows(false);
if (checkRows != null) {
return checkRows;
}
List<ExpandedPair> checkRows2 = checkRows(true);
if (checkRows2 != null) {
return checkRows2;
}
}
throw NotFoundException.getNotFoundInstance();
}
}
}
List<ExpandedRow> getRows() {
return this.rows;
}
@Override
public void reset() {
this.pairs.clear();
this.rows.clear();
}
ExpandedPair retrieveNextPair(BitArray bitArray, List<ExpandedPair> list, int i) throws NotFoundException {
FinderPattern parseFoundFinderPattern;
DataCharacter dataCharacter;
boolean z = list.size() % 2 == 0;
if (this.startFromEven) {
z = !z;
}
int i2 = -1;
boolean z2 = true;
do {
findNextPair(bitArray, list, i2);
parseFoundFinderPattern = parseFoundFinderPattern(bitArray, i, z);
if (parseFoundFinderPattern == null) {
i2 = getNextSecondBar(bitArray, this.startEnd[0]);
continue;
} else {
z2 = false;
continue;
}
} while (z2);
DataCharacter decodeDataCharacter = decodeDataCharacter(bitArray, parseFoundFinderPattern, z, true);
if (!list.isEmpty() && list.get(list.size() - 1).mustBeLast()) {
throw NotFoundException.getNotFoundInstance();
}
try {
dataCharacter = decodeDataCharacter(bitArray, parseFoundFinderPattern, z, false);
} catch (NotFoundException unused) {
dataCharacter = null;
}
return new ExpandedPair(decodeDataCharacter, dataCharacter, parseFoundFinderPattern, true);
}
private List<ExpandedPair> checkRows(List<ExpandedRow> list, int i) throws NotFoundException {
while (i < this.rows.size()) {
ExpandedRow expandedRow = this.rows.get(i);
this.pairs.clear();
int size = list.size();
for (int i2 = 0; i2 < size; i2++) {
this.pairs.addAll(list.get(i2).getPairs());
}
this.pairs.addAll(expandedRow.getPairs());
if (isValidSequence(this.pairs)) {
if (checkChecksum()) {
return this.pairs;
}
ArrayList arrayList = new ArrayList();
arrayList.addAll(list);
arrayList.add(expandedRow);
try {
return checkRows(arrayList, i + 1);
} catch (NotFoundException unused) {
continue;
}
}
i++;
}
throw NotFoundException.getNotFoundInstance();
}
}