what-the-bank/sources/o/Vni.java

271 lines
10 KiB
Java

package o;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.Log;
import com.bumptech.glide.load.ImageHeaderParser;
import com.google.common.primitives.UnsignedBytes;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import o.hKF;
/* loaded from: classes.dex */
public final class Vni implements iYP<ByteBuffer, RiR> {
private static final LWm d = new LWm();
private static final IeS e = new IeS();
private final Context a;
private final IeS b;
private final LWm c;
private final UiP f;
private final List<ImageHeaderParser> j;
@Override // o.iYP
public final /* synthetic */ boolean a(ByteBuffer byteBuffer, unA una) throws IOException {
ImageHeaderParser.ImageType e2;
ByteBuffer byteBuffer2 = byteBuffer;
wrW<Boolean> wrw = C17312vih.e;
if (!((Boolean) (una.d.containsKey(wrw) ? una.d.get(wrw) : wrw.a)).booleanValue()) {
List<ImageHeaderParser> list = this.j;
if (byteBuffer2 == null) {
e2 = ImageHeaderParser.ImageType.UNKNOWN;
} else {
e2 = hKF.e(list, new hKF.AnonymousClass2(byteBuffer2));
}
if (e2 == ImageHeaderParser.ImageType.GIF) {
return true;
}
}
return false;
}
public Vni(Context context, List<ImageHeaderParser> list, sqY sqy, Opg opg) {
this(context, list, sqy, opg, e, d);
}
private Vni(Context context, List<ImageHeaderParser> list, sqY sqy, Opg opg, IeS ieS, LWm lWm) {
this.a = context.getApplicationContext();
this.j = list;
this.c = lWm;
this.f = new UiP(sqy, opg);
this.b = ieS;
}
/* JADX INFO: Access modifiers changed from: private */
@Override // o.iYP
public Qqx a(ByteBuffer byteBuffer, int i, int i2, unA una) {
tHq b = this.b.b(byteBuffer);
try {
Qqx e2 = e(byteBuffer, i, i2, b, una);
IeS ieS = this.b;
synchronized (ieS) {
b.a = null;
b.c = null;
ieS.e.offer(b);
}
return e2;
} catch (Throwable th) {
IeS ieS2 = this.b;
synchronized (ieS2) {
b.a = null;
b.c = null;
ieS2.e.offer(b);
throw th;
}
}
}
private Qqx e(ByteBuffer byteBuffer, int i, int i2, tHq thq, unA una) {
boolean z;
OPq oPq;
long e2 = PYC.e();
try {
if (thq.a == null) {
throw new IllegalStateException("You must call setData() before parseHeader()");
}
int i3 = 0;
if (thq.c.f8302o != 0) {
oPq = thq.c;
} else {
StringBuilder sb = new StringBuilder();
for (int i4 = 0; i4 < 6; i4++) {
sb.append((char) thq.d());
}
if (sb.toString().startsWith("GIF")) {
thq.c.m = thq.a.getShort();
thq.c.j = thq.a.getShort();
thq.c.g = (thq.d() & 128) != 0;
thq.c.i = (int) Math.pow(2.0d, (r7 & 7) + 1);
thq.c.a = thq.d();
thq.c.k = thq.d();
if (thq.c.g && thq.c.f8302o == 0) {
OPq oPq2 = thq.c;
oPq2.h = thq.d(oPq2.i);
OPq oPq3 = thq.c;
oPq3.b = oPq3.h[thq.c.a];
}
} else {
thq.c.f8302o = 1;
}
if (thq.c.f8302o == 0) {
boolean z2 = false;
while (!z2 && thq.c.f8302o == 0 && thq.c.d <= Integer.MAX_VALUE) {
int d2 = thq.d();
if (d2 == 33) {
z = z2;
int d3 = thq.d();
if (d3 == 1) {
thq.e();
} else if (d3 == 249) {
thq.c.e = new C0569JrT();
thq.d();
int d4 = thq.d();
thq.c.e.d = (d4 & 28) >> 2;
if (thq.c.e.d == 0) {
thq.c.e.d = 1;
}
thq.c.e.m = (d4 & 1) != 0;
short s = thq.a.getShort();
if (s < 2) {
s = 10;
}
thq.c.e.a = s * 10;
thq.c.e.f = thq.d();
thq.d();
} else if (d3 == 254) {
thq.e();
} else if (d3 == 255) {
thq.b();
StringBuilder sb2 = new StringBuilder();
for (int i5 = 0; i5 < 11; i5++) {
sb2.append((char) thq.e[i5]);
}
if (!sb2.toString().equals("NETSCAPE2.0")) {
thq.e();
}
do {
thq.b();
byte[] bArr = thq.e;
if (bArr[0] == 1) {
thq.c.f = ((bArr[2] & UnsignedBytes.MAX_VALUE) << 8) | (bArr[1] & UnsignedBytes.MAX_VALUE);
}
if (thq.b <= 0) {
break;
}
} while (thq.c.f8302o == 0);
} else {
thq.e();
}
} else if (d2 == 44) {
if (thq.c.e == null) {
thq.c.e = new C0569JrT();
}
thq.c.e.g = thq.a.getShort();
thq.c.e.j = thq.a.getShort();
thq.c.e.i = thq.a.getShort();
thq.c.e.c = thq.a.getShort();
int d5 = thq.d();
boolean z3 = (d5 & 128) != 0;
z = z2;
int pow = (int) Math.pow(2.0d, (d5 & 7) + 1);
thq.c.e.e = (d5 & 64) != 0;
if (z3) {
thq.c.e.h = thq.d(pow);
} else {
thq.c.e.h = null;
}
thq.c.e.b = thq.a.position();
thq.d();
thq.e();
if (thq.c.f8302o == 0) {
thq.c.d++;
thq.c.c.add(thq.c.e);
}
} else if (d2 != 59) {
thq.c.f8302o = 1;
z = z2;
} else {
z2 = true;
}
z2 = z;
}
if (thq.c.d < 0) {
thq.c.f8302o = 1;
}
}
oPq = thq.c;
}
if (oPq.d > 0 && oPq.f8302o == 0) {
wrW<EnumC16061koj> wrw = C17312vih.c;
Bitmap.Config config = (una.d.containsKey(wrw) ? una.d.get(wrw) : wrw.a) == EnumC16061koj.PREFER_RGB_565 ? Bitmap.Config.RGB_565 : Bitmap.Config.ARGB_8888;
int min = Math.min(oPq.j / i2, oPq.m / i);
if (min != 0) {
i3 = Integer.highestOneBit(min);
}
int max = Math.max(1, i3);
if (Log.isLoggable("BufferGifDecoder", 2) && max > 1) {
int i6 = oPq.m;
int i7 = oPq.j;
}
rTS rts = new rTS(this.f, oPq, byteBuffer, max);
rts.DC_(config);
rts.c();
Bitmap DB_ = rts.DB_();
if (DB_ == null) {
return null;
}
Qqx qqx = new Qqx(new RiR(this.a, rts, tiJ.e(), i, i2, DB_));
if (Log.isLoggable("BufferGifDecoder", 2)) {
PYC.e(e2);
}
return qqx;
}
if (Log.isLoggable("BufferGifDecoder", 2)) {
PYC.e(e2);
}
return null;
} finally {
if (Log.isLoggable("BufferGifDecoder", 2)) {
PYC.e(e2);
}
}
}
/* loaded from: classes.dex */
static class LWm {
LWm() {
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public static class IeS {
final Queue<tHq> e = FKd.e(0);
IeS() {
}
final tHq b(ByteBuffer byteBuffer) {
tHq poll;
synchronized (this) {
poll = this.e.poll();
if (poll == null) {
poll = new tHq();
}
poll.a = null;
Arrays.fill(poll.e, (byte) 0);
poll.c = new OPq();
poll.b = 0;
ByteBuffer asReadOnlyBuffer = byteBuffer.asReadOnlyBuffer();
poll.a = asReadOnlyBuffer;
asReadOnlyBuffer.position(0);
poll.a.order(ByteOrder.LITTLE_ENDIAN);
}
return poll;
}
}
}