package o; import android.graphics.Bitmap; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.Iterator; import o.TTv; /* loaded from: classes.dex */ public final class rTS implements TTv { private static final String e = "StandardGifDecoder"; private int[] a; private byte[] b; private Bitmap.Config c; private final TTv.Sts d; private int f; private int g; private Boolean h; private int i; private OPq j; private byte[] k; private int[] l; private final int[] m; private short[] n; /* renamed from: o, reason: collision with root package name */ private byte[] f9256o; private Bitmap p; private boolean q; private int r; private int s; private ByteBuffer t; private byte[] y; public rTS(TTv.Sts sts, OPq oPq, ByteBuffer byteBuffer, int i) { this(sts); synchronized (this) { if (i <= 0) { StringBuilder sb = new StringBuilder("Sample size must be >=0, not: "); sb.append(i); throw new IllegalArgumentException(sb.toString()); } int highestOneBit = Integer.highestOneBit(i); this.s = 0; this.j = oPq; this.i = -1; ByteBuffer asReadOnlyBuffer = byteBuffer.asReadOnlyBuffer(); this.t = asReadOnlyBuffer; asReadOnlyBuffer.position(0); this.t.order(ByteOrder.LITTLE_ENDIAN); this.q = false; Iterator it = oPq.c.iterator(); while (true) { if (!it.hasNext()) { break; } else if (it.next().d == 3) { this.q = true; break; } } this.r = highestOneBit; this.g = oPq.m / highestOneBit; this.f = oPq.j / highestOneBit; this.f9256o = this.d.b(oPq.m * oPq.j); this.l = this.d.a(this.g * this.f); } } private rTS(TTv.Sts sts) { this.m = new int[256]; this.c = Bitmap.Config.ARGB_8888; this.d = sts; this.j = new OPq(); } @Override // o.TTv public final void c() { this.i = (this.i + 1) % this.j.d; } @Override // o.TTv public final int j() { int i; if (this.j.d <= 0 || (i = this.i) < 0) { return 0; } if (i < 0 || i >= this.j.d) { return -1; } return this.j.c.get(i).a; } @Override // o.TTv public final int i() { return this.j.d; } @Override // o.TTv public final int b() { return this.t.limit() + this.f9256o.length + (this.l.length << 2); } /* JADX WARN: Code restructure failed: missing block: B:56:0x00c6, code lost: if (r39.j.a == r6.f) goto L62; */ /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Removed duplicated region for block: B:60:0x00e7 */ @Override // o.TTv /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public final android.graphics.Bitmap DB_() { /* Method dump skipped, instructions count: 1254 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: o.rTS.DB_():android.graphics.Bitmap"); } @Override // o.TTv public final void a() { this.j = null; byte[] bArr = this.f9256o; if (bArr != null) { this.d.d(bArr); } int[] iArr = this.l; if (iArr != null) { this.d.e(iArr); } Bitmap bitmap = this.p; if (bitmap != null) { this.d.Fr_(bitmap); } this.p = null; this.t = null; this.h = null; byte[] bArr2 = this.b; if (bArr2 != null) { this.d.d(bArr2); } } @Override // o.TTv public final void DC_(Bitmap.Config config) { if (config == Bitmap.Config.ARGB_8888 || config == Bitmap.Config.RGB_565) { this.c = config; return; } StringBuilder sb = new StringBuilder("Unsupported format: "); sb.append(config); sb.append(", must be one of "); sb.append(Bitmap.Config.ARGB_8888); sb.append(" or "); sb.append(Bitmap.Config.RGB_565); throw new IllegalArgumentException(sb.toString()); } private Bitmap DA_() { Boolean bool = this.h; Bitmap Fq_ = this.d.Fq_(this.g, this.f, (bool == null || bool.booleanValue()) ? Bitmap.Config.ARGB_8888 : this.c); Fq_.setHasAlpha(true); return Fq_; } @Override // o.TTv public final ByteBuffer d() { return this.t; } @Override // o.TTv public final int e() { return this.i; } }