package A;

import android.util.Pair;
import b0.r;
import b0.t;
import com.mstar.android.tv.TvLanguage;
import java.util.Arrays;
import n.x;

/* JADX INFO: loaded from: classes.dex */
final class f extends e {

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    private static final double[] f39m = {23.976023976023978d, 24.0d, 25.0d, 29.97002997002997d, 30.0d, 50.0d, 59.94005994005994d, 60.0d};

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private boolean f40b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private long f41c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private final boolean[] f42d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private final a f43e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private boolean f44f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private long f45g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private long f46h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private boolean f47i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private boolean f48j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private long f49k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    private long f50l;

    private static final class a {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private boolean f51a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public int f52b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public int f53c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public byte[] f54d;

        public a(int i2) {
            this.f54d = new byte[i2];
        }

        public void a(byte[] bArr, int i2, int i3) {
            if (this.f51a) {
                int i4 = i3 - i2;
                byte[] bArr2 = this.f54d;
                int length = bArr2.length;
                int i5 = this.f52b;
                if (length < i5 + i4) {
                    this.f54d = Arrays.copyOf(bArr2, (i5 + i4) * 2);
                }
                System.arraycopy(bArr, i2, this.f54d, this.f52b, i4);
                this.f52b += i4;
            }
        }

        public boolean b(int i2, int i3) {
            if (this.f51a) {
                if (this.f53c != 0 || i2 != 181) {
                    this.f52b -= i3;
                    this.f51a = false;
                    return true;
                }
                this.f53c = this.f52b;
            } else if (i2 == 179) {
                this.f51a = true;
            }
            return false;
        }

        public void c() {
            this.f51a = false;
            this.f52b = 0;
            this.f53c = 0;
        }
    }

    public f(v.o oVar) {
        super(oVar);
        this.f42d = new boolean[4];
        this.f43e = new a(128);
    }

    /* JADX WARN: Removed duplicated region for block: B:15:0x0064  */
    /* JADX WARN: Removed duplicated region for block: B:21:0x0089  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    private static android.util.Pair e(A.f.a r19) {
        /*
            r0 = r19
            byte[] r1 = r0.f54d
            int r2 = r0.f52b
            byte[] r1 = java.util.Arrays.copyOf(r1, r2)
            r2 = 4
            r3 = r1[r2]
            r3 = r3 & 255(0xff, float:3.57E-43)
            r4 = 5
            r5 = r1[r4]
            r6 = r5 & 255(0xff, float:3.57E-43)
            r7 = 6
            r7 = r1[r7]
            r7 = r7 & 255(0xff, float:3.57E-43)
            int r3 = r3 << r2
            int r6 = r6 >> r2
            r14 = r3 | r6
            r3 = r5 & 15
            int r3 = r3 << 8
            r15 = r3 | r7
            r3 = 7
            r5 = r1[r3]
            r5 = r5 & 240(0xf0, float:3.36E-43)
            int r5 = r5 >> r2
            r6 = 2
            if (r5 == r6) goto L44
            r6 = 3
            if (r5 == r6) goto L3e
            if (r5 == r2) goto L36
            r2 = 1065353216(0x3f800000, float:1.0)
        L33:
            r18 = r2
            goto L4a
        L36:
            int r2 = r15 * 121
            float r2 = (float) r2
            int r5 = r14 * 100
        L3b:
            float r5 = (float) r5
            float r2 = r2 / r5
            goto L33
        L3e:
            int r2 = r15 * 16
            float r2 = (float) r2
            int r5 = r14 * 9
            goto L3b
        L44:
            int r2 = r15 * 4
            float r2 = (float) r2
            int r5 = r14 * 3
            goto L3b
        L4a:
            java.util.List r16 = java.util.Collections.singletonList(r1)
            r17 = -1
            r8 = 0
            java.lang.String r9 = "video/mpeg2"
            r10 = -1
            r11 = -1
            r12 = -1
            n.x r2 = n.x.p(r8, r9, r10, r11, r12, r14, r15, r16, r17, r18)
            r3 = r1[r3]
            r3 = r3 & 15
            int r3 = r3 + (-1)
            if (r3 < 0) goto L89
            double[] r5 = A.f.f39m
            int r6 = r5.length
            if (r3 >= r6) goto L89
            r6 = r5[r3]
            int r0 = r0.f53c
            int r0 = r0 + 9
            r0 = r1[r0]
            r1 = r0 & 96
            int r1 = r1 >> r4
            r0 = r0 & 31
            if (r1 == r0) goto L81
            double r3 = (double) r1
            r8 = 4607182418800017408(0x3ff0000000000000, double:1.0)
            double r3 = r3 + r8
            int r0 = r0 + 1
            double r0 = (double) r0
            double r3 = r3 / r0
            double r6 = r6 * r3
        L81:
            r0 = 4696837146684686336(0x412e848000000000, double:1000000.0)
            double r0 = r0 / r6
            long r0 = (long) r0
            goto L8b
        L89:
            r0 = 0
        L8b:
            java.lang.Long r0 = java.lang.Long.valueOf(r0)
            android.util.Pair r0 = android.util.Pair.create(r2, r0)
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: A.f.e(A.f$a):android.util.Pair");
    }

    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    @Override // A.e
    public void a(t tVar) {
        int i2;
        int i3;
        if (tVar.a() > 0) {
            int iC = tVar.c();
            int iD = tVar.d();
            byte[] bArr = tVar.f3092a;
            this.f45g += (long) tVar.a();
            this.f38a.a(tVar, tVar.a());
            int i4 = iC;
            while (true) {
                int iC2 = r.c(bArr, iC, iD, this.f42d);
                if (iC2 == iD) {
                    break;
                }
                int i5 = iC2 + 3;
                int i6 = tVar.f3092a[i5] & 255;
                if (!this.f40b) {
                    int i7 = iC2 - i4;
                    if (i7 > 0) {
                        this.f43e.a(bArr, i4, iC2);
                    }
                    if (this.f43e.b(i6, i7 < 0 ? -i7 : 0)) {
                        Pair pairE = e(this.f43e);
                        this.f38a.c((x) pairE.first);
                        this.f41c = ((Long) pairE.second).longValue();
                        this.f40b = true;
                    }
                }
                if (this.f40b && (i6 == 184 || i6 == 0)) {
                    int i8 = iD - iC2;
                    if (this.f44f) {
                        this.f38a.e(this.f50l, this.f48j ? 1 : 0, ((int) (this.f45g - this.f49k)) - i8, i8, null);
                        this.f48j = false;
                        i3 = i6;
                        i2 = TvLanguage.GA;
                    } else {
                        i2 = 184;
                        i3 = i6;
                    }
                    if (i3 == i2) {
                        this.f44f = false;
                        this.f48j = true;
                    } else {
                        this.f50l = this.f47i ? this.f46h : this.f50l + this.f41c;
                        this.f49k = this.f45g - ((long) i8);
                        this.f47i = false;
                        this.f44f = true;
                    }
                }
                i4 = iC2;
                iC = i5;
            }
            if (this.f40b) {
                return;
            }
            this.f43e.a(bArr, i4, iD);
        }
    }

    @Override // A.e
    public void b() {
    }

    @Override // A.e
    public void c(long j2, boolean z2) {
        boolean z3 = j2 != -1;
        this.f47i = z3;
        if (z3) {
            this.f46h = j2;
        }
    }

    @Override // A.e
    public void d() {
        r.a(this.f42d);
        this.f43e.c();
        this.f47i = false;
        this.f44f = false;
        this.f45g = 0L;
    }
}
