package p138.p176.p177.p190.p198.p207;

import android.util.Pair;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import p000.p001.p002.p003.p004.C0567;
import p138.p176.p177.p190.C3431;
import p138.p176.p177.p190.p194.C3526;
import p138.p176.p177.p190.p198.InterfaceC3562;
import p138.p176.p177.p190.p198.InterfaceC3575;
import p138.p176.p177.p190.p198.p207.InterfaceC3690;
import p138.p176.p177.p190.p239.C4136;
import p138.p176.p177.p190.p239.C4140;

/* JADX INFO: renamed from: ދ.ހ.֏.ؠ.ೲ.ޝ.ވ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C3661 implements InterfaceC3660 {

    /* JADX INFO: renamed from: ގ, reason: contains not printable characters */
    public static final double[] f11145 = {23.976023976023978d, 24.0d, 25.0d, 29.97002997002997d, 30.0d, 50.0d, 59.94005994005994d, 60.0d};

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public String f11146;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public InterfaceC3575 f11147;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public boolean f11148;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public long f11149;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public final C3695 f11150;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final C4140 f11151;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final boolean[] f11152 = new boolean[4];

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public final C3662 f11153 = new C3662(128);

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public final C3672 f11154;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public long f11155;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public boolean f11156;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public long f11157;

    /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
    public long f11158;

    /* JADX INFO: renamed from: ދ, reason: contains not printable characters */
    public long f11159;

    /* JADX INFO: renamed from: ތ, reason: contains not printable characters */
    public boolean f11160;

    /* JADX INFO: renamed from: ލ, reason: contains not printable characters */
    public boolean f11161;

    /* JADX INFO: renamed from: ދ.ހ.֏.ؠ.ೲ.ޝ.ވ$֏, reason: contains not printable characters */
    public static final class C3662 {

        /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
        public static final byte[] f11162 = {0, 0, 1};

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public boolean f11163;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public int f11164;

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public int f11165;

        /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
        public byte[] f11166;

        public C3662(int i) {
            this.f11166 = new byte[i];
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public void m6012(byte[] bArr, int i, int i2) {
            if (this.f11163) {
                int i3 = i2 - i;
                byte[] bArr2 = this.f11166;
                int length = bArr2.length;
                int i4 = this.f11164;
                if (length < i4 + i3) {
                    this.f11166 = Arrays.copyOf(bArr2, (i4 + i3) * 2);
                }
                System.arraycopy(bArr, i, this.f11166, this.f11164, i3);
                this.f11164 += i3;
            }
        }
    }

    public C3661(C3695 c3695) {
        this.f11150 = c3695;
        if (c3695 != null) {
            this.f11154 = new C3672(178, 128);
            this.f11151 = new C4140();
        } else {
            this.f11154 = null;
            this.f11151 = null;
        }
    }

    @Override // p138.p176.p177.p190.p198.p207.InterfaceC3660
    /* JADX INFO: renamed from: ֏ */
    public void mo5997() {
        C4136.m6664(this.f11152);
        C3662 c3662 = this.f11153;
        c3662.f11163 = false;
        c3662.f11164 = 0;
        c3662.f11165 = 0;
        if (this.f11150 != null) {
            this.f11154.m6018();
        }
        this.f11155 = 0L;
        this.f11156 = false;
    }

    @Override // p138.p176.p177.p190.p198.p207.InterfaceC3660
    /* JADX INFO: renamed from: ֏ */
    public void mo5998(long j, int i) {
        this.f11157 = j;
    }

    @Override // p138.p176.p177.p190.p198.p207.InterfaceC3660
    /* JADX INFO: renamed from: ֏ */
    public void mo5999(InterfaceC3562 interfaceC3562, InterfaceC3690.C3694 c3694) {
        c3694.m6035();
        this.f11146 = c3694.m6036();
        this.f11147 = interfaceC3562.mo5891(c3694.m6037(), 2);
        C3695 c3695 = this.f11150;
        if (c3695 != null) {
            for (int i = 0; i < c3695.f11386.length; i++) {
                c3694.m6035();
                InterfaceC3575 interfaceC3575Mo5891 = interfaceC3562.mo5891(c3694.m6037(), 3);
                C3431 c3431 = c3695.f11385.get(i);
                String str = c3431.f10090;
                C0567.m1897("application/cea-608".equals(str) || "application/cea-708".equals(str), (Object) ("Invalid closed caption mime type provided: " + str));
                interfaceC3575Mo5891.mo5884(C3431.m5586(c3694.m6036(), str, (String) null, -1, c3431.f10084, c3431.f10108, c3431.f10109, (C3526) null, Long.MAX_VALUE, c3431.f10092));
                c3695.f11386[i] = interfaceC3575Mo5891;
            }
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:31:0x007d  */
    /* JADX WARN: Removed duplicated region for block: B:43:0x00ed  */
    /* JADX WARN: Removed duplicated region for block: B:49:0x0118  */
    /* 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 // p138.p176.p177.p190.p198.p207.InterfaceC3660
    /* JADX INFO: renamed from: ֏ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void mo6000(C4140 c4140) {
        int i;
        boolean z;
        float f;
        int i2;
        float f2;
        int i3;
        long j;
        int i4 = c4140.f13228;
        int i5 = c4140.f13229;
        byte[] bArr = c4140.f13227;
        this.f11155 += (long) c4140.m6679();
        this.f11147.mo5885(c4140, c4140.m6679());
        while (true) {
            int iM6661 = C4136.m6661(bArr, i4, i5, this.f11152);
            if (iM6661 == i5) {
                if (!this.f11148) {
                    this.f11153.m6012(bArr, i4, i5);
                }
                if (this.f11150 != null) {
                    this.f11154.m6019(bArr, i4, i5);
                    return;
                }
                return;
            }
            int i6 = iM6661 + 3;
            int i7 = c4140.f13227[i6] & 255;
            int i8 = iM6661 - i4;
            if (!this.f11148) {
                if (i8 > 0) {
                    this.f11153.m6012(bArr, i4, iM6661);
                }
                int i9 = i8 < 0 ? -i8 : 0;
                C3662 c3662 = this.f11153;
                if (c3662.f11163) {
                    int i10 = c3662.f11164 - i9;
                    c3662.f11164 = i10;
                    if (c3662.f11165 == 0 && i7 == 181) {
                        c3662.f11165 = i10;
                    } else {
                        c3662.f11163 = false;
                        z = true;
                        if (z) {
                            C3662 c36622 = this.f11153;
                            String str = this.f11146;
                            byte[] bArrCopyOf = Arrays.copyOf(c36622.f11166, c36622.f11164);
                            int i11 = bArrCopyOf[4] & 255;
                            int i12 = bArrCopyOf[5] & 255;
                            int i13 = (i11 << 4) | (i12 >> 4);
                            int i14 = ((i12 & 15) << 8) | (bArrCopyOf[6] & 255);
                            int i15 = (bArrCopyOf[7] & 240) >> 4;
                            if (i15 == 2) {
                                f = i14 * 4;
                                i2 = i13 * 3;
                            } else if (i15 == 3) {
                                f = i14 * 16;
                                i2 = i13 * 9;
                            } else if (i15 != 4) {
                                f2 = 1.0f;
                                C3431 c3431M5581 = C3431.m5581(str, "video/mpeg2", (String) null, -1, -1, i13, i14, -1.0f, (List<byte[]>) Collections.singletonList(bArrCopyOf), -1, f2, (C3526) null);
                                i3 = (bArrCopyOf[7] & 15) - 1;
                                if (i3 < 0) {
                                    double[] dArr = f11145;
                                    if (i3 < dArr.length) {
                                        double d = dArr[i3];
                                        int i16 = c36622.f11165 + 9;
                                        int i17 = (bArrCopyOf[i16] & 96) >> 5;
                                        int i18 = bArrCopyOf[i16] & 31;
                                        if (i17 != i18) {
                                            d *= (((double) i17) + 1.0d) / ((double) (i18 + 1));
                                        }
                                        j = (long) (1000000.0d / d);
                                    } else {
                                        j = 0;
                                    }
                                    Pair pairCreate = Pair.create(c3431M5581, Long.valueOf(j));
                                    this.f11147.mo5884((C3431) pairCreate.first);
                                    this.f11149 = ((Long) pairCreate.second).longValue();
                                    this.f11148 = true;
                                }
                            } else {
                                f = i14 * 121;
                                i2 = i13 * 100;
                            }
                            f2 = f / i2;
                            C3431 c3431M55812 = C3431.m5581(str, "video/mpeg2", (String) null, -1, -1, i13, i14, -1.0f, (List<byte[]>) Collections.singletonList(bArrCopyOf), -1, f2, (C3526) null);
                            i3 = (bArrCopyOf[7] & 15) - 1;
                            if (i3 < 0) {
                            }
                        }
                    }
                } else if (i7 == 179) {
                    c3662.f11163 = true;
                }
                byte[] bArr2 = C3662.f11162;
                c3662.m6012(bArr2, 0, bArr2.length);
                z = false;
                if (z) {
                }
            }
            if (this.f11150 != null) {
                if (i8 > 0) {
                    this.f11154.m6019(bArr, i4, iM6661);
                    i = 0;
                } else {
                    i = -i8;
                }
                if (this.f11154.m6020(i)) {
                    C3672 c3672 = this.f11154;
                    this.f11151.m6684(this.f11154.f11284, C4136.m6660(c3672.f11284, c3672.f11285));
                    C3695 c3695 = this.f11150;
                    long j2 = this.f11159;
                    C4140 c41402 = this.f11151;
                    if (c3695 == null) {
                        throw null;
                    }
                    if (c41402.m6679() >= 9) {
                        int iM6688 = c41402.m6688();
                        int iM66882 = c41402.m6688();
                        int iM6702 = c41402.m6702();
                        if (iM6688 == 434 && iM66882 == 1195456820 && iM6702 == 3) {
                            C0567.m1914(j2, c41402, c3695.f11386);
                        }
                    }
                }
                if (i7 == 178 && c4140.f13227[iM6661 + 2] == 1) {
                    this.f11154.m6021(i7);
                }
            }
            if (i7 == 0 || i7 == 179) {
                int i19 = i5 - iM6661;
                if (this.f11156 && this.f11161 && this.f11148) {
                    this.f11147.mo5883(this.f11159, this.f11160 ? 1 : 0, ((int) (this.f11155 - this.f11158)) - i19, i19, null);
                }
                if (!this.f11156 || this.f11161) {
                    this.f11158 = this.f11155 - ((long) i19);
                    long j3 = this.f11157;
                    if (j3 == -9223372036854775807L) {
                        j3 = this.f11156 ? this.f11159 + this.f11149 : 0L;
                    }
                    this.f11159 = j3;
                    this.f11160 = false;
                    this.f11157 = -9223372036854775807L;
                    this.f11156 = true;
                }
                this.f11161 = i7 == 0;
            } else if (i7 == 184) {
                this.f11160 = true;
            }
            i4 = i6;
        }
    }

    @Override // p138.p176.p177.p190.p198.p207.InterfaceC3660
    /* JADX INFO: renamed from: ؠ */
    public void mo6001() {
    }
}
