package o; import com.google.common.base.Ascii; import com.google.common.primitives.UnsignedBytes; import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; /* loaded from: classes.dex */ public final class WTb extends FilterInputStream { private static final byte[] b = {-1, -31, 0, 28, 69, 120, 105, 102, 0, 0, 77, 77, 0, 0, 0, 0, 0, 8, 0, 1, 1, Ascii.DC2, 0, 2, 0, 0, 0, 1, 0}; private static final int c = 31; private int a; private final byte d; @Override // java.io.FilterInputStream, java.io.InputStream public final boolean markSupported() { return false; } public WTb(InputStream inputStream, int i) { super(inputStream); if (i < -1 || i > 8) { throw new IllegalArgumentException("Cannot add invalid orientation: ".concat(String.valueOf(i))); } this.d = (byte) i; } @Override // java.io.FilterInputStream, java.io.InputStream public final void mark(int i) { throw new UnsupportedOperationException(); } @Override // java.io.FilterInputStream, java.io.InputStream public final int read() throws IOException { int read; int i; int i2 = this.a; if (i2 < 2 || i2 > (i = c)) { read = super.read(); } else { read = i2 == i ? this.d : b[i2 - 2] & UnsignedBytes.MAX_VALUE; } if (read != -1) { this.a++; } return read; } @Override // java.io.FilterInputStream, java.io.InputStream public final int read(byte[] bArr, int i, int i2) throws IOException { int i3; int i4 = this.a; int i5 = c; if (i4 > i5) { i3 = super.read(bArr, i, i2); } else if (i4 == i5) { bArr[i] = this.d; i3 = 1; } else if (i4 < 2) { i3 = super.read(bArr, i, 2 - i4); } else { int min = Math.min(i5 - i4, i2); System.arraycopy(b, this.a - 2, bArr, i, min); i3 = min; } if (i3 > 0) { this.a += i3; } return i3; } @Override // java.io.FilterInputStream, java.io.InputStream public final long skip(long j) throws IOException { long skip = super.skip(j); if (skip > 0) { this.a = (int) (this.a + skip); } return skip; } @Override // java.io.FilterInputStream, java.io.InputStream public final void reset() throws IOException { throw new UnsupportedOperationException(); } }