package defpackage;

import androidx.media3.common.ParserException;
import java.io.EOFException;

/* JADX INFO: renamed from: ᵳᵵᵜ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C4612 implements InterfaceC2025 {

    /* JADX INFO: renamed from: ʿٴˇ, reason: contains not printable characters */
    public long f17533;

    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public long f17534;

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final C1724 f17535;

    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    public long f17536;

    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public long f17537;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public final long f17538;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public final long f17539;

    /* JADX INFO: renamed from: ᵠˏˏ, reason: contains not printable characters */
    public long f17540;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public final AbstractC4258 f17541;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public int f17542;

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public long f17543;

    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    public long f17544;

    public C4612(AbstractC4258 abstractC4258, long j, long j2, long j3, long j4, boolean z) {
        ᵻᵪ.ᵱᵽʡᵚ(j >= 0 && j2 > j);
        this.f17541 = abstractC4258;
        this.f17539 = j;
        this.f17538 = j2;
        if (j3 == j2 - j || z) {
            this.f17543 = j4;
            this.f17542 = 4;
        } else {
            this.f17542 = 0;
        }
        this.f17535 = new C1724();
    }

    /* JADX WARN: Removed duplicated region for block: B:43:0x00c1 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:44:0x00c2  */
    @Override // defpackage.InterfaceC2025
    /* JADX INFO: renamed from: ʽˈˋ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final long mo5130(InterfaceC5206 interfaceC5206) throws ParserException, EOFException {
        long j;
        long j2;
        long jM3267;
        int i = this.f17542;
        long j3 = this.f17538;
        C1724 c1724 = this.f17535;
        if (i == 0) {
            j = 0;
            long position = interfaceC5206.getPosition();
            this.f17534 = position;
            this.f17542 = 1;
            long j4 = j3 - 65307;
            if (j4 > position) {
                return j4;
            }
        } else if (i != 1) {
            if (i == 2) {
                if (this.f17544 == this.f17537) {
                    jM3267 = -1;
                } else {
                    long position2 = interfaceC5206.getPosition();
                    if (c1724.m4768(interfaceC5206, this.f17537)) {
                        c1724.m4770(interfaceC5206, false);
                        interfaceC5206.mo4698();
                        long j5 = this.f17536;
                        long j6 = c1724.f6912;
                        long j7 = j5 - j6;
                        j2 = 2;
                        int i2 = c1724.f6917 + c1724.f6914;
                        if (0 > j7 || j7 >= 72000) {
                            if (j7 < 0) {
                                this.f17537 = position2;
                                this.f17540 = j6;
                            } else {
                                this.f17544 = interfaceC5206.getPosition() + ((long) i2);
                                this.f17533 = c1724.f6912;
                            }
                            long j8 = this.f17537;
                            long j9 = this.f17544;
                            if (j8 - j9 < 100000) {
                                this.f17537 = j9;
                                jM3267 = j9;
                            } else {
                                long position3 = interfaceC5206.getPosition() - (((long) i2) * (j7 <= 0 ? 2L : 1L));
                                long j10 = this.f17537;
                                long j11 = this.f17544;
                                jM3267 = AbstractC0956.m3267((((j10 - j11) * j7) / (this.f17540 - this.f17533)) + position3, j11, j10 - 1);
                            }
                        } else {
                            jM3267 = -1;
                        }
                        if (jM3267 == -1) {
                            return jM3267;
                        }
                        this.f17542 = 3;
                    } else {
                        jM3267 = this.f17544;
                        if (jM3267 == position2) {
                            C1685.m4568("No ogg page can be found.");
                            return 0L;
                        }
                    }
                }
                j2 = 2;
                if (jM3267 == -1) {
                }
            } else {
                if (i != 3) {
                    if (i == 4) {
                        return -1L;
                    }
                    ᵷᵝˎ.ᵱʡˏ();
                    return 0L;
                }
                j2 = 2;
            }
            while (true) {
                c1724.m4768(interfaceC5206, -1L);
                c1724.m4770(interfaceC5206, false);
                if (c1724.f6912 > this.f17536) {
                    interfaceC5206.mo4698();
                    this.f17542 = 4;
                    return -(this.f17533 + j2);
                }
                interfaceC5206.mo4700(c1724.f6917 + c1724.f6914);
                this.f17544 = interfaceC5206.getPosition();
                this.f17533 = c1724.f6912;
            }
        } else {
            j = 0;
        }
        c1724.f6915 = 0;
        c1724.f6912 = j;
        c1724.f6913 = 0;
        c1724.f6917 = 0;
        c1724.f6914 = 0;
        if (!c1724.m4768(interfaceC5206, -1L)) {
            throw new EOFException();
        }
        c1724.m4770(interfaceC5206, false);
        interfaceC5206.mo4700(c1724.f6917 + c1724.f6914);
        long j12 = c1724.f6912;
        while ((c1724.f6915 & 4) != 4 && c1724.m4768(interfaceC5206, -1L) && interfaceC5206.getPosition() < j3 && c1724.m4770(interfaceC5206, true)) {
            try {
                interfaceC5206.mo4700(c1724.f6917 + c1724.f6914);
                j12 = c1724.f6912;
            } catch (EOFException unused) {
            }
        }
        this.f17543 = j12;
        this.f17542 = 4;
        return this.f17534;
    }

    @Override // defpackage.InterfaceC2025
    /* JADX INFO: renamed from: ᵝᵶ */
    public final void mo5131(long j) {
        this.f17536 = AbstractC0956.m3267(j, 0L, this.f17543 - 1);
        this.f17542 = 2;
        this.f17544 = this.f17539;
        this.f17537 = this.f17538;
        this.f17533 = 0L;
        this.f17540 = this.f17543;
    }

    @Override // defpackage.InterfaceC2025
    /* JADX INFO: renamed from: ᵻʽᵯ */
    public final InterfaceC5517 mo5133() {
        if (this.f17543 != 0) {
            return new C2249(this);
        }
        return null;
    }
}
