discord-jadx/app/src/main/java/c/i/a/c/e2/m/d.java
2021-07-28 09:39:21 +02:00

879 lines
36 KiB
Java

package c.i.a.c.e2.m;
import android.graphics.Color;
import android.text.Layout;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.style.BackgroundColorSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.text.style.UnderlineSpan;
import android.util.Log;
import androidx.annotation.Nullable;
import c.i.a.c.e2.f;
import c.i.a.c.e2.i;
import c.i.a.c.i2.v;
import c.i.a.c.i2.w;
import com.airbnb.lottie.parser.AnimatableValueParser;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/* compiled from: Cea708Decoder */
public final class d extends e {
public final w g = new w();
public final v h = new v();
public int i = -1;
public final int j;
public final b[] k;
public b l;
@Nullable
public List<c.i.a.c.e2.c> m;
@Nullable
public List<c.i.a.c.e2.c> n;
@Nullable
public c o;
public int p;
/* compiled from: Cea708Decoder */
public static final class a {
public final c.i.a.c.e2.c a;
public final int b;
public a(CharSequence charSequence, Layout.Alignment alignment, float f, int i, int i2, float f2, int i3, float f3, boolean z2, int i4, int i5) {
int i6;
boolean z3;
if (z2) {
i6 = i4;
z3 = true;
} else {
z3 = false;
i6 = -16777216;
}
this.a = new c.i.a.c.e2.c(charSequence, alignment, null, f, i, i2, f2, i3, Integer.MIN_VALUE, -3.4028235E38f, f3, -3.4028235E38f, z3, i6, Integer.MIN_VALUE, 0.0f, null);
this.b = i5;
}
}
/* compiled from: Cea708Decoder */
public static final class b {
public static final int a = d(2, 2, 2, 0);
public static final int b;
/* renamed from: c reason: collision with root package name */
public static final int f825c;
public static final int[] d = {0, 0, 0, 0, 0, 2, 0};
public static final int[] e = {0, 0, 0, 0, 0, 0, 2};
public static final int[] f = {3, 3, 3, 3, 3, 3, 1};
public static final boolean[] g = {false, false, false, true, true, true, false};
public static final int[] h;
public static final int[] i = {0, 1, 2, 3, 4, 3, 4};
public static final int[] j = {0, 0, 0, 0, 0, 3, 3};
public static final int[] k;
public int A;
public int B;
public int C;
public int D;
public int E;
public int F;
public int G;
public final List<SpannableString> l = new ArrayList();
public final SpannableStringBuilder m = new SpannableStringBuilder();
public boolean n;
public boolean o;
public int p;
public boolean q;
public int r;
/* renamed from: s reason: collision with root package name */
public int f826s;
public int t;
public int u;
public boolean v;
public int w;
/* renamed from: x reason: collision with root package name */
public int f827x;
/* renamed from: y reason: collision with root package name */
public int f828y;
/* renamed from: z reason: collision with root package name */
public int f829z;
static {
int d2 = d(0, 0, 0, 0);
b = d2;
int d3 = d(0, 0, 0, 3);
f825c = d3;
h = new int[]{d2, d3, d2, d2, d3, d2, d2};
k = new int[]{d2, d2, d2, d2, d2, d3, d3};
}
public b() {
f();
}
/* JADX WARNING: Removed duplicated region for block: B:11:0x0025 */
/* JADX WARNING: Removed duplicated region for block: B:12:0x0028 */
/* JADX WARNING: Removed duplicated region for block: B:14:0x002b */
/* JADX WARNING: Removed duplicated region for block: B:15:0x002e */
/* JADX WARNING: Removed duplicated region for block: B:17:0x0031 */
public static int d(int i2, int i3, int i4, int i5) {
int i6;
int i7 = 0;
AnimatableValueParser.t(i2, 0, 4);
AnimatableValueParser.t(i3, 0, 4);
AnimatableValueParser.t(i4, 0, 4);
AnimatableValueParser.t(i5, 0, 4);
if (!(i5 == 0 || i5 == 1)) {
if (i5 == 2) {
i6 = 127;
} else if (i5 == 3) {
i6 = 0;
}
int i8 = i2 <= 1 ? 255 : 0;
int i9 = i3 <= 1 ? 255 : 0;
if (i4 > 1) {
i7 = 255;
}
return Color.argb(i6, i8, i9, i7);
}
i6 = 255;
if (i2 <= 1) {
}
if (i3 <= 1) {
}
if (i4 > 1) {
}
return Color.argb(i6, i8, i9, i7);
}
public void a(char c2) {
if (c2 == '\n') {
this.l.add(b());
this.m.clear();
if (this.A != -1) {
this.A = 0;
}
if (this.B != -1) {
this.B = 0;
}
if (this.C != -1) {
this.C = 0;
}
if (this.E != -1) {
this.E = 0;
}
while (true) {
if ((this.v && this.l.size() >= this.u) || this.l.size() >= 15) {
this.l.remove(0);
} else {
return;
}
}
} else {
this.m.append(c2);
}
}
public SpannableString b() {
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(this.m);
int length = spannableStringBuilder.length();
if (length > 0) {
if (this.A != -1) {
spannableStringBuilder.setSpan(new StyleSpan(2), this.A, length, 33);
}
if (this.B != -1) {
spannableStringBuilder.setSpan(new UnderlineSpan(), this.B, length, 33);
}
if (this.C != -1) {
spannableStringBuilder.setSpan(new ForegroundColorSpan(this.D), this.C, length, 33);
}
if (this.E != -1) {
spannableStringBuilder.setSpan(new BackgroundColorSpan(this.F), this.E, length, 33);
}
}
return new SpannableString(spannableStringBuilder);
}
public void c() {
this.l.clear();
this.m.clear();
this.A = -1;
this.B = -1;
this.C = -1;
this.E = -1;
this.G = 0;
}
public boolean e() {
return !this.n || (this.l.isEmpty() && this.m.length() == 0);
}
public void f() {
c();
this.n = false;
this.o = false;
this.p = 4;
this.q = false;
this.r = 0;
this.f826s = 0;
this.t = 0;
this.u = 15;
this.v = true;
this.w = 0;
this.f827x = 0;
this.f828y = 0;
int i2 = b;
this.f829z = i2;
this.D = a;
this.F = i2;
}
public void g(boolean z2, boolean z3) {
if (this.A != -1) {
if (!z2) {
this.m.setSpan(new StyleSpan(2), this.A, this.m.length(), 33);
this.A = -1;
}
} else if (z2) {
this.A = this.m.length();
}
if (this.B != -1) {
if (!z3) {
this.m.setSpan(new UnderlineSpan(), this.B, this.m.length(), 33);
this.B = -1;
}
} else if (z3) {
this.B = this.m.length();
}
}
public void h(int i2, int i3) {
if (!(this.C == -1 || this.D == i2)) {
this.m.setSpan(new ForegroundColorSpan(this.D), this.C, this.m.length(), 33);
}
if (i2 != a) {
this.C = this.m.length();
this.D = i2;
}
if (!(this.E == -1 || this.F == i3)) {
this.m.setSpan(new BackgroundColorSpan(this.F), this.E, this.m.length(), 33);
}
if (i3 != b) {
this.E = this.m.length();
this.F = i3;
}
}
}
/* compiled from: Cea708Decoder */
public static final class c {
public final int a;
public final int b;
/* renamed from: c reason: collision with root package name */
public final byte[] f830c;
public int d = 0;
public c(int i, int i2) {
this.a = i;
this.b = i2;
this.f830c = new byte[((i2 * 2) - 1)];
}
}
public d(int i, @Nullable List<byte[]> list) {
this.j = i == -1 ? 1 : i;
if (!(list == null || (list.size() == 1 && list.get(0).length == 1 && list.get(0)[0] == 1))) {
}
this.k = new b[8];
for (int i2 = 0; i2 < 8; i2++) {
this.k[i2] = new b();
}
this.l = this.k[0];
}
@Override // c.i.a.c.e2.m.e
public f e() {
List<c.i.a.c.e2.c> list = this.m;
this.n = list;
Objects.requireNonNull(list);
return new f(list);
}
@Override // c.i.a.c.e2.m.e
public void f(i iVar) {
ByteBuffer byteBuffer = iVar.k;
Objects.requireNonNull(byteBuffer);
this.g.B(byteBuffer.array(), byteBuffer.limit());
while (this.g.a() >= 3) {
int s2 = this.g.s() & 7;
int i = s2 & 3;
boolean z2 = false;
boolean z3 = (s2 & 4) == 4;
byte s3 = (byte) this.g.s();
byte s4 = (byte) this.g.s();
if (i == 2 || i == 3) {
if (z3) {
if (i == 3) {
j();
int i2 = (s3 & 192) >> 6;
int i3 = this.i;
if (!(i3 == -1 || i2 == (i3 + 1) % 4)) {
l();
Log.w("Cea708Decoder", "Sequence number discontinuity. previous=" + this.i + " current=" + i2);
}
this.i = i2;
int i4 = s3 & 63;
if (i4 == 0) {
i4 = 64;
}
c cVar = new c(i2, i4);
this.o = cVar;
byte[] bArr = cVar.f830c;
int i5 = cVar.d;
cVar.d = i5 + 1;
bArr[i5] = s4;
} else {
if (i == 2) {
z2 = true;
}
AnimatableValueParser.k(z2);
c cVar2 = this.o;
if (cVar2 == null) {
Log.e("Cea708Decoder", "Encountered DTVCC_PACKET_DATA before DTVCC_PACKET_START");
} else {
byte[] bArr2 = cVar2.f830c;
int i6 = cVar2.d;
int i7 = i6 + 1;
cVar2.d = i7;
bArr2[i6] = s3;
cVar2.d = i7 + 1;
bArr2[i7] = s4;
}
}
c cVar3 = this.o;
if (cVar3.d == (cVar3.b * 2) - 1) {
j();
}
}
}
}
}
@Override // c.i.a.c.e2.m.e, c.i.a.c.x1.c
public void flush() {
super.flush();
this.m = null;
this.n = null;
this.p = 0;
this.l = this.k[0];
l();
this.o = null;
}
@Override // c.i.a.c.e2.m.e
public boolean h() {
return this.m != this.n;
}
public final void j() {
c cVar = this.o;
if (cVar != null) {
if (cVar.d != (cVar.b * 2) - 1) {
StringBuilder K = c.d.b.a.a.K("DtvCcPacket ended prematurely; size is ");
K.append((this.o.b * 2) - 1);
K.append(", but current index is ");
K.append(this.o.d);
K.append(" (sequence number ");
K.append(this.o.a);
K.append(");");
Log.d("Cea708Decoder", K.toString());
}
v vVar = this.h;
c cVar2 = this.o;
vVar.j(cVar2.f830c, cVar2.d);
int i = 3;
int g = this.h.g(3);
int g2 = this.h.g(5);
int i2 = 7;
int i3 = 6;
if (g == 7) {
this.h.m(2);
g = this.h.g(6);
if (g < 7) {
c.d.b.a.a.d0("Invalid extended service number: ", g, "Cea708Decoder");
}
}
if (g2 == 0) {
if (g != 0) {
Log.w("Cea708Decoder", "serviceNumber is non-zero (" + g + ") when blockSize is 0");
}
} else if (g == this.j) {
boolean z2 = false;
while (this.h.b() > 0) {
int g3 = this.h.g(8);
if (g3 != 16) {
if (g3 <= 31) {
if (g3 != 0) {
if (g3 == i) {
this.m = k();
} else if (g3 != 8) {
switch (g3) {
case 12:
l();
continue;
case 13:
this.l.a('\n');
continue;
case 14:
break;
default:
if (g3 < 17 || g3 > 23) {
if (g3 < 24 || g3 > 31) {
c.d.b.a.a.d0("Invalid C0 command: ", g3, "Cea708Decoder");
break;
} else {
c.d.b.a.a.d0("Currently unsupported COMMAND_P16 Command: ", g3, "Cea708Decoder");
this.h.m(16);
break;
}
} else {
c.d.b.a.a.d0("Currently unsupported COMMAND_EXT1 Command: ", g3, "Cea708Decoder");
this.h.m(8);
continue;
}
}
} else {
b bVar = this.l;
int length = bVar.m.length();
if (length > 0) {
bVar.m.delete(length - 1, length);
}
}
}
} else if (g3 <= 127) {
if (g3 == 127) {
this.l.a(9835);
} else {
this.l.a((char) (g3 & 255));
}
} else if (g3 <= 159) {
switch (g3) {
case 128:
case 129:
case 130:
case 131:
case 132:
case 133:
case 134:
case 135:
int i4 = g3 - 128;
if (this.p != i4) {
this.p = i4;
this.l = this.k[i4];
break;
}
break;
case 136:
for (int i5 = 1; i5 <= 8; i5++) {
if (this.h.f()) {
this.k[8 - i5].c();
}
}
break;
case 137:
for (int i6 = 1; i6 <= 8; i6++) {
if (this.h.f()) {
this.k[8 - i6].o = true;
}
}
break;
case 138:
for (int i7 = 1; i7 <= 8; i7++) {
if (this.h.f()) {
this.k[8 - i7].o = false;
}
}
break;
case 139:
for (int i8 = 1; i8 <= 8; i8++) {
if (this.h.f()) {
b bVar2 = this.k[8 - i8];
bVar2.o = !bVar2.o;
}
}
break;
case 140:
for (int i9 = 1; i9 <= 8; i9++) {
if (this.h.f()) {
this.k[8 - i9].f();
}
}
break;
case 141:
this.h.m(8);
break;
case 142:
break;
case 143:
l();
break;
case 144:
if (!this.l.n) {
this.h.m(16);
break;
} else {
this.h.g(4);
this.h.g(2);
this.h.g(2);
boolean f = this.h.f();
boolean f2 = this.h.f();
this.h.g(3);
this.h.g(3);
this.l.g(f, f2);
break;
}
case 145:
if (!this.l.n) {
this.h.m(24);
break;
} else {
int d = b.d(this.h.g(2), this.h.g(2), this.h.g(2), this.h.g(2));
int d2 = b.d(this.h.g(2), this.h.g(2), this.h.g(2), this.h.g(2));
this.h.m(2);
b.d(this.h.g(2), this.h.g(2), this.h.g(2), 0);
this.l.h(d, d2);
break;
}
case 146:
if (!this.l.n) {
this.h.m(16);
break;
} else {
this.h.m(4);
int g4 = this.h.g(4);
this.h.m(2);
this.h.g(6);
b bVar3 = this.l;
if (bVar3.G != g4) {
bVar3.a('\n');
}
bVar3.G = g4;
break;
}
case 147:
case 148:
case 149:
case 150:
default:
Log.w("Cea708Decoder", c.d.b.a.a.j("Invalid C1 command: ", g3));
break;
case 151:
if (!this.l.n) {
this.h.m(32);
break;
} else {
int d3 = b.d(this.h.g(2), this.h.g(2), this.h.g(2), this.h.g(2));
this.h.g(2);
b.d(this.h.g(2), this.h.g(2), this.h.g(2), 0);
this.h.f();
this.h.f();
this.h.g(2);
this.h.g(2);
int g5 = this.h.g(2);
this.h.m(8);
b bVar4 = this.l;
bVar4.f829z = d3;
bVar4.w = g5;
break;
}
case 152:
case 153:
case 154:
case 155:
case 156:
case 157:
case 158:
case 159:
int i10 = g3 - 152;
b bVar5 = this.k[i10];
this.h.m(2);
boolean f3 = this.h.f();
boolean f4 = this.h.f();
this.h.f();
int g6 = this.h.g(i);
boolean f5 = this.h.f();
int g7 = this.h.g(i2);
int g8 = this.h.g(8);
int g9 = this.h.g(4);
int g10 = this.h.g(4);
this.h.m(2);
this.h.g(i3);
this.h.m(2);
int g11 = this.h.g(i);
int g12 = this.h.g(i);
bVar5.n = true;
bVar5.o = f3;
bVar5.v = f4;
bVar5.p = g6;
bVar5.q = f5;
bVar5.r = g7;
bVar5.f826s = g8;
bVar5.t = g9;
int i11 = g10 + 1;
if (bVar5.u != i11) {
bVar5.u = i11;
while (true) {
if ((f4 && bVar5.l.size() >= bVar5.u) || bVar5.l.size() >= 15) {
bVar5.l.remove(0);
}
}
}
if (!(g11 == 0 || bVar5.f827x == g11)) {
bVar5.f827x = g11;
int i12 = g11 - 1;
int i13 = b.h[i12];
boolean z3 = b.g[i12];
int i14 = b.e[i12];
int i15 = b.f[i12];
int i16 = b.d[i12];
bVar5.f829z = i13;
bVar5.w = i16;
}
if (!(g12 == 0 || bVar5.f828y == g12)) {
bVar5.f828y = g12;
int i17 = g12 - 1;
int i18 = b.j[i17];
int i19 = b.i[i17];
bVar5.g(false, false);
bVar5.h(b.a, b.k[i17]);
}
if (this.p != i10) {
this.p = i10;
this.l = this.k[i10];
break;
}
break;
}
} else if (g3 <= 255) {
this.l.a((char) (g3 & 255));
} else {
c.d.b.a.a.d0("Invalid base command: ", g3, "Cea708Decoder");
}
i = 3;
i2 = 7;
i3 = 6;
} else {
int g13 = this.h.g(8);
if (g13 <= 31) {
if (g13 > 7) {
if (g13 <= 15) {
this.h.m(8);
} else if (g13 <= 23) {
this.h.m(16);
} else if (g13 <= 31) {
this.h.m(24);
}
}
} else if (g13 <= 127) {
if (g13 == 32) {
this.l.a(' ');
} else if (g13 == 33) {
this.l.a(160);
} else if (g13 == 37) {
this.l.a(8230);
} else if (g13 == 42) {
this.l.a(352);
} else if (g13 == 44) {
this.l.a(338);
} else if (g13 == 63) {
this.l.a(376);
} else if (g13 == 57) {
this.l.a(8482);
} else if (g13 == 58) {
this.l.a(353);
} else if (g13 == 60) {
this.l.a(339);
} else if (g13 != 61) {
switch (g13) {
case 48:
this.l.a(9608);
break;
case 49:
this.l.a(8216);
break;
case 50:
this.l.a(8217);
break;
case 51:
this.l.a(8220);
break;
case 52:
this.l.a(8221);
break;
case 53:
this.l.a(8226);
break;
default:
switch (g13) {
case 118:
this.l.a(8539);
break;
case 119:
this.l.a(8540);
break;
case 120:
this.l.a(8541);
break;
case 121:
this.l.a(8542);
break;
case 122:
this.l.a(9474);
break;
case 123:
this.l.a(9488);
break;
case 124:
this.l.a(9492);
break;
case 125:
this.l.a(9472);
break;
case 126:
this.l.a(9496);
break;
case 127:
this.l.a(9484);
break;
default:
c.d.b.a.a.d0("Invalid G2 character: ", g13, "Cea708Decoder");
break;
}
}
} else {
this.l.a(8480);
}
} else if (g13 <= 159) {
if (g13 <= 135) {
this.h.m(32);
} else if (g13 <= 143) {
this.h.m(40);
} else if (g13 <= 159) {
this.h.m(2);
this.h.m(this.h.g(6) * 8);
}
} else if (g13 > 255) {
c.d.b.a.a.d0("Invalid extended command: ", g13, "Cea708Decoder");
} else if (g13 == 160) {
this.l.a(13252);
} else {
c.d.b.a.a.d0("Invalid G3 character: ", g13, "Cea708Decoder");
this.l.a('_');
}
i = 3;
i2 = 7;
i3 = 6;
}
z2 = true;
i = 3;
i2 = 7;
i3 = 6;
}
if (z2) {
this.m = k();
}
}
this.o = null;
}
}
/* JADX WARNING: Removed duplicated region for block: B:27:0x0082 */
/* JADX WARNING: Removed duplicated region for block: B:28:0x008d */
/* JADX WARNING: Removed duplicated region for block: B:31:0x00ae */
/* JADX WARNING: Removed duplicated region for block: B:32:0x00b0 */
/* JADX WARNING: Removed duplicated region for block: B:37:0x00b9 */
/* JADX WARNING: Removed duplicated region for block: B:38:0x00bc */
/* JADX WARNING: Removed duplicated region for block: B:43:0x00c9 */
/* JADX WARNING: Removed duplicated region for block: B:44:0x00cc */
public final List<c.i.a.c.e2.c> k() {
a aVar;
Layout.Alignment alignment;
float f;
float f2;
ArrayList arrayList = new ArrayList();
for (int i = 0; i < 8; i++) {
if (!this.k[i].e()) {
b[] bVarArr = this.k;
if (bVarArr[i].o) {
b bVar = bVarArr[i];
if (bVar.e()) {
aVar = null;
} else {
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
for (int i2 = 0; i2 < bVar.l.size(); i2++) {
spannableStringBuilder.append((CharSequence) bVar.l.get(i2));
spannableStringBuilder.append('\n');
}
spannableStringBuilder.append((CharSequence) bVar.b());
int i3 = bVar.w;
if (i3 != 0) {
if (i3 == 1) {
alignment = Layout.Alignment.ALIGN_OPPOSITE;
} else if (i3 == 2) {
alignment = Layout.Alignment.ALIGN_CENTER;
} else if (i3 != 3) {
StringBuilder K = c.d.b.a.a.K("Unexpected justification value: ");
K.append(bVar.w);
throw new IllegalArgumentException(K.toString());
}
if (!bVar.q) {
f2 = ((float) bVar.f826s) / 99.0f;
f = ((float) bVar.r) / 99.0f;
} else {
f2 = ((float) bVar.f826s) / 209.0f;
f = ((float) bVar.r) / 74.0f;
}
float f3 = (f2 * 0.9f) + 0.05f;
float f4 = (f * 0.9f) + 0.05f;
int i4 = bVar.t;
int i5 = i4 / 3;
int i6 = i4 % 3;
aVar = new a(spannableStringBuilder, alignment, f4, 0, i5 != 0 ? 0 : i5 == 1 ? 1 : 2, f3, i6 != 0 ? 0 : i6 == 1 ? 1 : 2, -3.4028235E38f, bVar.f829z == b.b, bVar.f829z, bVar.p);
}
alignment = Layout.Alignment.ALIGN_NORMAL;
if (!bVar.q) {
}
float f3 = (f2 * 0.9f) + 0.05f;
float f4 = (f * 0.9f) + 0.05f;
int i4 = bVar.t;
int i5 = i4 / 3;
int i6 = i4 % 3;
aVar = new a(spannableStringBuilder, alignment, f4, 0, i5 != 0 ? 0 : i5 == 1 ? 1 : 2, f3, i6 != 0 ? 0 : i6 == 1 ? 1 : 2, -3.4028235E38f, bVar.f829z == b.b, bVar.f829z, bVar.p);
}
if (aVar != null) {
arrayList.add(aVar);
}
} else {
continue;
}
}
}
Collections.sort(arrayList, a.i);
ArrayList arrayList2 = new ArrayList(arrayList.size());
for (int i7 = 0; i7 < arrayList.size(); i7++) {
arrayList2.add(((a) arrayList.get(i7)).a);
}
return Collections.unmodifiableList(arrayList2);
}
public final void l() {
for (int i = 0; i < 8; i++) {
this.k[i].f();
}
}
}