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

import android.util.SparseArray;
import java.io.EOFException;
import p138.p176.p177.p190.p198.C3558;
import p138.p176.p177.p190.p198.C3570;
import p138.p176.p177.p190.p198.InterfaceC3561;
import p138.p176.p177.p190.p198.InterfaceC3562;
import p138.p176.p177.p190.p198.InterfaceC3571;
import p138.p176.p177.p190.p198.p207.InterfaceC3690;
import p138.p176.p177.p190.p239.C4139;
import p138.p176.p177.p190.p239.C4140;
import p138.p176.p177.p190.p239.C4149;

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

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

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

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

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

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public C3674 f11316;

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

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

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C4149 f11308 = new C4149(0);

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final C4140 f11310 = new C4140(4096);

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final SparseArray<C3679> f11309 = new SparseArray<>();

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final C3677 f11311 = new C3677();

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

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final InterfaceC3660 f11319;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final C4149 f11320;

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public final C4139 f11321 = new C4139(new byte[64]);

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

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

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

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

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

        public C3679(InterfaceC3660 interfaceC3660, C4149 c4149) {
            this.f11319 = interfaceC3660;
            this.f11320 = c4149;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:101:0x01f5  */
    @Override // p138.p176.p177.p190.p198.InterfaceC3561
    /* JADX INFO: renamed from: ֏ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public int mo5886(C3558 c3558, C3570 c3570) throws InterruptedException, EOFException {
        InterfaceC3660 c3661;
        long j = c3558.f10562;
        long j2 = -9223372036854775807L;
        if (j != -1) {
            C3677 c3677 = this.f11311;
            if (!c3677.f11302) {
                if (!c3677.f11304) {
                    long j3 = c3558.f10562;
                    int iMin = (int) Math.min(20000L, j3);
                    long j4 = j3 - ((long) iMin);
                    if (c3558.f10563 == j4) {
                        c3677.f11301.m6689(iMin);
                        c3558.f10565 = 0;
                        c3558.m5875(c3677.f11301.f13227, 0, iMin, false);
                        C4140 c4140 = c3677.f11301;
                        int i = c4140.f13228;
                        int i2 = c4140.f13229 - 4;
                        while (true) {
                            if (i2 < i) {
                                break;
                            }
                            if (c3677.m6030(c4140.f13227, i2) == 442) {
                                c4140.m6693(i2 + 4);
                                long jM6028 = C3677.m6028(c4140);
                                if (jM6028 != -9223372036854775807L) {
                                    j2 = jM6028;
                                    break;
                                }
                            }
                            i2--;
                        }
                        c3677.f11306 = j2;
                        c3677.f11304 = true;
                        return 0;
                    }
                    c3570.f10591 = j4;
                } else {
                    if (c3677.f11306 == -9223372036854775807L) {
                        c3677.m6029(c3558);
                        return 0;
                    }
                    if (c3677.f11303) {
                        long j5 = c3677.f11305;
                        if (j5 == -9223372036854775807L) {
                            c3677.m6029(c3558);
                            return 0;
                        }
                        c3677.f11307 = c3677.f11300.m6737(c3677.f11306) - c3677.f11300.m6737(j5);
                        c3677.m6029(c3558);
                        return 0;
                    }
                    int iMin2 = (int) Math.min(20000L, c3558.f10562);
                    long j6 = 0;
                    if (c3558.f10563 == j6) {
                        c3677.f11301.m6689(iMin2);
                        c3558.f10565 = 0;
                        c3558.m5875(c3677.f11301.f13227, 0, iMin2, false);
                        C4140 c41402 = c3677.f11301;
                        int i3 = c41402.f13228;
                        int i4 = c41402.f13229;
                        while (true) {
                            if (i3 >= i4 - 3) {
                                break;
                            }
                            if (c3677.m6030(c41402.f13227, i3) == 442) {
                                c41402.m6693(i3 + 4);
                                long jM60282 = C3677.m6028(c41402);
                                if (jM60282 != -9223372036854775807L) {
                                    j2 = jM60282;
                                    break;
                                }
                            }
                            i3++;
                        }
                        c3677.f11305 = j2;
                        c3677.f11303 = true;
                        return 0;
                    }
                    c3570.f10591 = j6;
                }
                return 1;
            }
        }
        if (!this.f11318) {
            this.f11318 = true;
            C3677 c36772 = this.f11311;
            long j7 = c36772.f11307;
            if (j7 != -9223372036854775807L) {
                C3674 c3674 = new C3674(c36772.f11300, j7, j);
                this.f11316 = c3674;
                this.f11317.mo5893(c3674.f10525);
            } else {
                this.f11317.mo5893(new InterfaceC3571.C3573(j7, 0L));
            }
        }
        C3674 c36742 = this.f11316;
        if (c36742 != null && c36742.m5855()) {
            return this.f11316.m5852(c3558, c3570);
        }
        c3558.f10565 = 0;
        long jM5872 = j != -1 ? j - c3558.m5872() : -1L;
        if ((jM5872 != -1 && jM5872 < 4) || !c3558.m5875(this.f11310.f13227, 0, 4, true)) {
            return -1;
        }
        this.f11310.m6693(0);
        int iM6688 = this.f11310.m6688();
        if (iM6688 == 441) {
            return -1;
        }
        if (iM6688 == 442) {
            c3558.m5875(this.f11310.f13227, 0, 10, false);
            this.f11310.m6693(9);
            c3558.m5878((this.f11310.m6702() & 7) + 14);
            return 0;
        }
        if (iM6688 == 443) {
            c3558.m5875(this.f11310.f13227, 0, 2, false);
            this.f11310.m6693(0);
            c3558.m5878(this.f11310.m6707() + 6);
            return 0;
        }
        if (((iM6688 & (-256)) >> 8) != 1) {
            c3558.m5878(1);
            return 0;
        }
        int i5 = iM6688 & 255;
        C3679 c3679 = this.f11309.get(i5);
        if (!this.f11312) {
            if (c3679 == null) {
                InterfaceC3660 interfaceC3660 = null;
                if (i5 == 189) {
                    c3661 = new C3652(null);
                    this.f11313 = true;
                    this.f11315 = c3558.f10563;
                } else if ((i5 & 224) == 192) {
                    c3661 = new C3671(null);
                    this.f11313 = true;
                    this.f11315 = c3558.f10563;
                } else {
                    if ((i5 & 240) == 224) {
                        c3661 = new C3661(null);
                        this.f11314 = true;
                        this.f11315 = c3558.f10563;
                    }
                    if (interfaceC3660 != null) {
                        interfaceC3660.mo5999(this.f11317, new InterfaceC3690.C3694(Integer.MIN_VALUE, i5, 256));
                        c3679 = new C3679(interfaceC3660, this.f11308);
                        this.f11309.put(i5, c3679);
                    }
                }
                interfaceC3660 = c3661;
                if (interfaceC3660 != null) {
                }
            }
            if (c3558.f10563 > ((this.f11313 && this.f11314) ? this.f11315 + 8192 : 1048576L)) {
                this.f11312 = true;
                this.f11317.mo5892();
            }
        }
        c3558.m5875(this.f11310.f13227, 0, 2, false);
        this.f11310.m6693(0);
        int iM6707 = this.f11310.m6707() + 6;
        if (c3679 == null) {
            c3558.m5878(iM6707);
        } else {
            this.f11310.m6689(iM6707);
            c3558.m5877(this.f11310.f13227, 0, iM6707, false);
            this.f11310.m6693(6);
            C4140 c41403 = this.f11310;
            c41403.m6685(c3679.f11321.f13223, 0, 3);
            c3679.f11321.m6672(0);
            c3679.f11321.m6675(8);
            c3679.f11322 = c3679.f11321.m6677();
            c3679.f11323 = c3679.f11321.m6677();
            c3679.f11321.m6675(6);
            int iM6667 = c3679.f11321.m6667(8);
            c3679.f11325 = iM6667;
            c41403.m6685(c3679.f11321.f13223, 0, iM6667);
            c3679.f11321.m6672(0);
            c3679.f11326 = 0L;
            if (c3679.f11322) {
                c3679.f11321.m6675(4);
                long jM6667 = ((long) c3679.f11321.m6667(3)) << 30;
                c3679.f11321.m6675(1);
                long jM66672 = jM6667 | ((long) (c3679.f11321.m6667(15) << 15));
                c3679.f11321.m6675(1);
                long jM66673 = jM66672 | ((long) c3679.f11321.m6667(15));
                c3679.f11321.m6675(1);
                if (!c3679.f11324 && c3679.f11323) {
                    c3679.f11321.m6675(4);
                    long jM66674 = ((long) c3679.f11321.m6667(3)) << 30;
                    c3679.f11321.m6675(1);
                    long jM66675 = jM66674 | ((long) (c3679.f11321.m6667(15) << 15));
                    c3679.f11321.m6675(1);
                    long jM66676 = jM66675 | ((long) c3679.f11321.m6667(15));
                    c3679.f11321.m6675(1);
                    c3679.f11320.m6737(jM66676);
                    c3679.f11324 = true;
                }
                c3679.f11326 = c3679.f11320.m6737(jM66673);
            }
            c3679.f11319.mo5998(c3679.f11326, 4);
            c3679.f11319.mo6000(c41403);
            c3679.f11319.mo6001();
            C4140 c41404 = this.f11310;
            c41404.m6691(c41404.f13227.length);
        }
        return 0;
    }

    @Override // p138.p176.p177.p190.p198.InterfaceC3561
    /* JADX INFO: renamed from: ֏ */
    public void mo5887() {
    }

    /* JADX WARN: Removed duplicated region for block: B:11:0x0023  */
    @Override // p138.p176.p177.p190.p198.InterfaceC3561
    /* JADX INFO: renamed from: ֏ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void mo5888(long j, long j2) {
        if (!(this.f11308.m6735() == -9223372036854775807L)) {
            long j3 = this.f11308.f13256;
            if (j3 != 0 && j3 != j2) {
                this.f11308.f13258 = -9223372036854775807L;
                this.f11308.m6739(j2);
            }
        }
        C3674 c3674 = this.f11316;
        if (c3674 != null) {
            c3674.m5853(j2);
        }
        for (int i = 0; i < this.f11309.size(); i++) {
            C3679 c3679ValueAt = this.f11309.valueAt(i);
            c3679ValueAt.f11324 = false;
            c3679ValueAt.f11319.mo5997();
        }
    }

    @Override // p138.p176.p177.p190.p198.InterfaceC3561
    /* JADX INFO: renamed from: ֏ */
    public void mo5889(InterfaceC3562 interfaceC3562) {
        this.f11317 = interfaceC3562;
    }

    @Override // p138.p176.p177.p190.p198.InterfaceC3561
    /* JADX INFO: renamed from: ֏ */
    public boolean mo5890(C3558 c3558) throws InterruptedException, EOFException {
        byte[] bArr = new byte[14];
        c3558.m5875(bArr, 0, 14, false);
        if (442 != (((bArr[0] & 255) << 24) | ((bArr[1] & 255) << 16) | ((bArr[2] & 255) << 8) | (bArr[3] & 255)) || (bArr[4] & 196) != 68 || (bArr[6] & 4) != 4 || (bArr[8] & 4) != 4 || (bArr[9] & 1) != 1 || (bArr[12] & 3) != 3) {
            return false;
        }
        c3558.m5874(bArr[13] & 7, false);
        c3558.m5875(bArr, 0, 3, false);
        return 1 == ((((bArr[0] & 255) << 16) | ((bArr[1] & 255) << 8)) | (bArr[2] & 255));
    }
}
