package com.applovin.impl; import android.text.Layout; import android.text.SpannableString; import android.text.SpannableStringBuilder; import android.text.style.ForegroundColorSpan; import android.text.style.StyleSpan; import android.text.style.UnderlineSpan; import androidx.core.internal.view.SupportMenu; import com.applovin.exoplayer2.common.base.Ascii; import com.applovin.impl.b5; import com.mbridge.msdk.playercommon.exoplayer2.C; import com.mbridge.msdk.playercommon.exoplayer2.extractor.ts.PsExtractor; import com.mbridge.msdk.playercommon.exoplayer2.util.MimeTypes; import com.vungle.ads.internal.protos.Sdk; import com.vungle.ads.internal.signals.SignalKey; import java.util.ArrayList; import java.util.Collections; import java.util.List; /* loaded from: classes.dex */ public final class y2 extends a3 { private final int h; private final int i; private final int j; private final long k; private List n; private List o; private int p; private int q; private boolean r; private boolean s; private byte t; private byte u; private boolean w; private long x; private static final int[] y = {11, 1, 3, 12, 14, 5, 7, 9}; private static final int[] z = {0, 4, 8, 12, 16, 20, 24, 28}; private static final int[] A = {-1, -16711936, -16776961, -16711681, SupportMenu.CATEGORY_MASK, -256, -65281}; private static final int[] B = {32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 225, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 233, 93, 237, 243, 250, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, SignalKey.EVENT_ID, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 231, 247, 209, 241, 9632}; private static final int[] C = {174, 176, PsExtractor.PRIVATE_STREAM_1, 191, 8482, 162, 163, 9834, 224, 32, 232, 226, 234, 238, 244, 251}; private static final int[] D = {193, 201, 211, 218, 220, 252, 8216, 161, 42, 39, 8212, 169, 8480, 8226, 8220, 8221, PsExtractor.AUDIO_STREAM, 194, 199, 200, 202, 203, 235, 206, 207, 239, 212, 217, 249, 219, 171, 187}; private static final int[] E = {195, 227, 205, 204, 236, 210, 242, 213, 245, 123, 125, 92, 94, 95, 124, 126, 196, 228, 214, 246, Sdk.SDKError.Reason.STALE_CACHED_RESPONSE_VALUE, 165, 164, 9474, 197, 229, 216, 248, 9484, 9488, 9492, 9496}; private static final boolean[] F = {false, true, true, false, true, false, false, true, true, false, false, true, false, true, true, false, true, false, false, true, false, true, true, false, false, true, true, false, true, false, false, true, true, false, false, true, false, true, true, false, false, true, true, false, true, false, false, true, false, true, true, false, true, false, false, true, true, false, false, true, false, true, true, false, true, false, false, true, false, true, true, false, false, true, true, false, true, false, false, true, false, true, true, false, true, false, false, true, true, false, false, true, false, true, true, false, false, true, true, false, true, false, false, true, true, false, false, true, false, true, true, false, true, false, false, true, false, true, true, false, false, true, true, false, true, false, false, true, true, false, false, true, false, true, true, false, false, true, true, false, true, false, false, true, false, true, true, false, true, false, false, true, true, false, false, true, false, true, true, false, false, true, true, false, true, false, false, true, true, false, false, true, false, true, true, false, true, false, false, true, false, true, true, false, false, true, true, false, true, false, false, true, false, true, true, false, true, false, false, true, true, false, false, true, false, true, true, false, true, false, false, true, false, true, true, false, false, true, true, false, true, false, false, true, true, false, false, true, false, true, true, false, false, true, true, false, true, false, false, true, false, true, true, false, true, false, false, true, true, false, false, true, false, true, true, false}; private final bh g = new bh(); private final ArrayList l = new ArrayList(); private a m = new a(0, 4); private int v = 0; private static int b(byte b) { return (b >> 3) & 1; } private static boolean c(byte b, byte b2) { return (b & 246) == 18 && (b2 & 224) == 32; } private static boolean d(byte b, byte b2) { return (b & 247) == 17 && (b2 & 240) == 32; } private static boolean e(byte b, byte b2) { return (b & 246) == 20 && (b2 & 240) == 32; } private static boolean f(byte b, byte b2) { return (b & 240) == 16 && (b2 & 192) == 64; } private static boolean g(byte b, byte b2) { return (b & 247) == 17 && (b2 & 240) == 48; } private static boolean h(byte b) { return (b & 224) == 0; } private static boolean h(byte b, byte b2) { return (b & 247) == 23 && b2 >= 33 && b2 <= 35; } private static boolean i(byte b) { return (b & 240) == 16; } private static boolean j(byte b) { return (b & 247) == 20; } private static boolean k(byte b) { return 1 <= b && b <= 15; } @Override // com.applovin.impl.a3, com.applovin.impl.m5 public void a() { } @Override // com.applovin.impl.a3 public boolean j() { return this.n != this.o; } @Override // com.applovin.impl.a3 /* renamed from: f */ public /* bridge */ /* synthetic */ rl d() { return super.d(); } public y2(String str, int i, long j) { this.k = j > 0 ? j * 1000 : -9223372036854775807L; this.h = MimeTypes.APPLICATION_MP4CEA608.equals(str) ? 2 : 3; if (i == 1) { this.j = 0; this.i = 0; } else if (i == 2) { this.j = 1; this.i = 0; } else if (i == 3) { this.j = 0; this.i = 1; } else if (i != 4) { pc.d("Cea608Decoder", "Invalid channel. Defaulting to CC1."); this.j = 0; this.i = 0; } else { this.j = 1; this.i = 1; } a(0); m(); this.w = true; this.x = C.TIME_UNSET; } @Override // com.applovin.impl.a3, com.applovin.impl.m5 public void b() { super.b(); this.n = null; this.o = null; a(0); b(4); m(); this.r = false; this.s = false; this.t = (byte) 0; this.u = (byte) 0; this.v = 0; this.w = true; this.x = C.TIME_UNSET; } @Override // com.applovin.impl.a3, com.applovin.impl.m5 /* renamed from: g */ public sl c() { sl h; sl c = super.c(); if (c != null) { return c; } if (!n() || (h = h()) == null) { return null; } this.n = Collections.emptyList(); this.x = C.TIME_UNSET; h.a(i(), e(), Long.MAX_VALUE); return h; } @Override // com.applovin.impl.a3 public nl e() { List list = this.n; this.o = list; return new b3((List) b1.a(list)); } /* JADX WARN: Removed duplicated region for block: B:26:0x006e A[SYNTHETIC] */ /* JADX WARN: Removed duplicated region for block: B:69:0x0017 A[SYNTHETIC] */ @Override // com.applovin.impl.a3 /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public void a(com.applovin.impl.rl r10) { /* Method dump skipped, instructions count: 268 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.applovin.impl.y2.a(com.applovin.impl.rl):void"); } private void f(byte b) { this.m.a(' '); this.m.a((b >> 1) & 7, (b & 1) == 1); } private List l() { int size = this.l.size(); ArrayList arrayList = new ArrayList(size); int i = 2; for (int i2 = 0; i2 < size; i2++) { b5 a2 = ((a) this.l.get(i2)).a(Integer.MIN_VALUE); arrayList.add(a2); if (a2 != null) { i = Math.min(i, a2.j); } } ArrayList arrayList2 = new ArrayList(size); for (int i3 = 0; i3 < size; i3++) { b5 b5Var = (b5) arrayList.get(i3); if (b5Var != null) { if (b5Var.j != i) { b5Var = (b5) b1.a(((a) this.l.get(i3)).a(i)); } arrayList2.add(b5Var); } } return arrayList2; } private void m() { this.m.b(this.p); this.l.clear(); this.l.add(this.m); } private void i(byte b, byte b2) { if (k(b)) { this.w = false; return; } if (j(b)) { if (b2 != 32 && b2 != 47) { switch (b2) { case 37: case 38: case 39: break; default: switch (b2) { case 42: case 43: this.w = false; break; } } } this.w = true; } } private static char d(byte b) { return (char) E[b & Ascii.US]; } private static char c(byte b) { return (char) D[b & Ascii.US]; } public static final class a { private final List a = new ArrayList(); private final List b = new ArrayList(); private final StringBuilder c = new StringBuilder(); private int d; private int e; private int f; private int g; private int h; public void c(int i) { this.g = i; } public void d(int i) { this.h = i; } public a(int i, int i2) { b(i); this.h = i2; } public void d() { this.b.add(b()); this.c.setLength(0); this.a.clear(); int min = Math.min(this.h, this.d); while (this.b.size() >= min) { this.b.remove(0); } } /* renamed from: com.applovin.impl.y2$a$a, reason: collision with other inner class name */ public static class C0045a { public final int a; public final boolean b; public int c; public C0045a(int i, boolean z, int i2) { this.a = i; this.b = z; this.c = i2; } } public void b(int i) { this.g = i; this.a.clear(); this.b.clear(); this.c.setLength(0); this.d = 15; this.e = 0; this.f = 0; } public boolean c() { return this.a.isEmpty() && this.b.isEmpty() && this.c.length() == 0; } public void a(char c) { if (this.c.length() < 32) { this.c.append(c); } } private static void b(SpannableStringBuilder spannableStringBuilder, int i, int i2) { spannableStringBuilder.setSpan(new UnderlineSpan(), i, i2, 33); } private SpannableString b() { SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(this.c); int length = spannableStringBuilder.length(); int i = -1; int i2 = -1; int i3 = -1; int i4 = -1; int i5 = 0; int i6 = 0; boolean z = false; while (i5 < this.a.size()) { C0045a c0045a = (C0045a) this.a.get(i5); boolean z2 = c0045a.b; int i7 = c0045a.a; if (i7 != 8) { boolean z3 = i7 == 7; if (i7 != 7) { i4 = y2.A[i7]; } z = z3; } int i8 = c0045a.c; i5++; if (i8 != (i5 < this.a.size() ? ((C0045a) this.a.get(i5)).c : length)) { if (i != -1 && !z2) { b(spannableStringBuilder, i, i8); i = -1; } else if (i == -1 && z2) { i = i8; } if (i2 != -1 && !z) { a(spannableStringBuilder, i2, i8); i2 = -1; } else if (i2 == -1 && z) { i2 = i8; } if (i4 != i3) { a(spannableStringBuilder, i6, i8, i3); i3 = i4; i6 = i8; } } } if (i != -1 && i != length) { b(spannableStringBuilder, i, length); } if (i2 != -1 && i2 != length) { a(spannableStringBuilder, i2, length); } if (i6 != length) { a(spannableStringBuilder, i6, length, i3); } return new SpannableString(spannableStringBuilder); } public void a() { int length = this.c.length(); if (length > 0) { this.c.delete(length - 1, length); for (int size = this.a.size() - 1; size >= 0; size--) { C0045a c0045a = (C0045a) this.a.get(size); int i = c0045a.c; if (i != length) { return; } c0045a.c = i - 1; } } } public b5 a(int i) { float f; int i2 = this.e + this.f; int i3 = 32 - i2; SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(); for (int i4 = 0; i4 < this.b.size(); i4++) { spannableStringBuilder.append(xp.a((CharSequence) this.b.get(i4), i3)); spannableStringBuilder.append('\n'); } spannableStringBuilder.append(xp.a(b(), i3)); if (spannableStringBuilder.length() == 0) { return null; } int length = i3 - spannableStringBuilder.length(); int i5 = i2 - length; if (i == Integer.MIN_VALUE) { i = (this.g != 2 || (Math.abs(i5) >= 3 && length >= 0)) ? (this.g != 2 || i5 <= 0) ? 0 : 2 : 1; } if (i != 1) { if (i == 2) { i2 = 32 - length; } f = ((i2 / 32.0f) * 0.8f) + 0.1f; } else { f = 0.5f; } int i6 = this.d; if (i6 > 7) { i6 -= 17; } else if (this.g == 1) { i6 -= this.h - 1; } return new b5.b().a(spannableStringBuilder).b(Layout.Alignment.ALIGN_NORMAL).a(i6, 1).b(f).b(i).a(); } private static void a(SpannableStringBuilder spannableStringBuilder, int i, int i2, int i3) { if (i3 == -1) { return; } spannableStringBuilder.setSpan(new ForegroundColorSpan(i3), i, i2, 33); } private static void a(SpannableStringBuilder spannableStringBuilder, int i, int i2) { spannableStringBuilder.setSpan(new StyleSpan(2), i, i2, 33); } public void a(int i, boolean z) { this.a.add(new C0045a(i, z, this.c.length())); } } private void b(byte b, byte b2) { int i = y[b & 7]; if ((b2 & 32) != 0) { i++; } if (i != this.m.d) { if (this.p != 1 && !this.m.c()) { a aVar = new a(this.p, this.q); this.m = aVar; this.l.add(aVar); } this.m.d = i; } boolean z2 = (b2 & Ascii.DLE) == 16; boolean z3 = (b2 & 1) == 1; int i2 = (b2 >> 1) & 7; this.m.a(z2 ? 8 : i2, z3); if (z2) { this.m.e = z[i2]; } } @Override // com.applovin.impl.a3 /* renamed from: b */ public /* bridge */ /* synthetic */ void a(rl rlVar) { super.a(rlVar); } private void g(byte b) { if (b == 32) { a(2); return; } if (b != 41) { switch (b) { case 37: a(1); b(2); break; case 38: a(1); b(3); break; case 39: a(1); b(4); break; default: int i = this.p; if (i != 0) { if (b != 33) { switch (b) { case 44: this.n = Collections.emptyList(); int i2 = this.p; if (i2 == 1 || i2 == 3) { m(); break; } case 45: if (i == 1 && !this.m.c()) { this.m.d(); break; } break; case 46: m(); break; case 47: this.n = l(); m(); break; } } else { this.m.a(); break; } } break; } return; } a(3); } private boolean n() { return (this.k == C.TIME_UNSET || this.x == C.TIME_UNSET || i() - this.x < this.k) ? false : true; } private static char e(byte b) { return (char) C[b & Ascii.SI]; } private boolean l(byte b) { if (h(b)) { this.v = b(b); } return this.v == this.j; } private static char a(byte b) { return (char) B[(b & Byte.MAX_VALUE) - 32]; } private void b(int i) { this.q = i; this.m.d(i); } private static char a(byte b, byte b2) { if ((b & 1) == 0) { return c(b2); } return d(b2); } private boolean a(boolean z2, byte b, byte b2) { if (!z2 || !i(b)) { this.s = false; } else { if (this.s && this.t == b && this.u == b2) { this.s = false; return true; } this.s = true; this.t = b; this.u = b2; } return false; } private void a(int i) { int i2 = this.p; if (i2 == i) { return; } this.p = i; if (i == 3) { for (int i3 = 0; i3 < this.l.size(); i3++) { ((a) this.l.get(i3)).c(i); } return; } m(); if (i2 == 3 || i == 1 || i == 0) { this.n = Collections.emptyList(); } } @Override // com.applovin.impl.a3, com.applovin.impl.ol public /* bridge */ /* synthetic */ void a(long j) { super.a(j); } }