package defpackage;

import androidx.media3.common.ParserException;
import java.util.Arrays;
import java.util.List;

/* JADX INFO: renamed from: ᵞᵔ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C3000 implements InterfaceC4291 {

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public C1956 f11548;

    /* JADX INFO: renamed from: ˋˈ, reason: contains not printable characters */
    public long f11549;

    /* JADX INFO: renamed from: ᵝᵶ, reason: contains not printable characters */
    public int f11551;

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public InterfaceC4550 f11552;

    /* JADX INFO: renamed from: ᵮᵣᵗˈ, reason: contains not printable characters */
    public C5052 f11553;

    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    public int f11554;

    /* JADX INFO: renamed from: ᵶᵥᵝ, reason: contains not printable characters */
    public int f11557;

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public C0063 f11559;

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public InterfaceC5226 f11560;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final byte[] f11555 = new byte[42];

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final C4545 f11547 = new C4545(0, new byte[32768]);

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final boolean f11550 = false;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final C2669 f11558 = new C2669();

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public int f11556 = 0;

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ʽˈˋ */
    public final void mo1252(long j, long j2) {
        if (j == 0) {
            this.f11556 = 0;
        } else {
            C5052 c5052 = this.f11553;
            if (c5052 != null) {
                c5052.m10391(j2);
            }
        }
        this.f11549 = j2 != 0 ? -1L : 0L;
        this.f11551 = 0;
        this.f11547.m9603(0);
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ːˏᵟᵯ */
    public final InterfaceC4291 mo1254() {
        return this;
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ᵨᵣ */
    public final boolean mo1255(InterfaceC5206 interfaceC5206) {
        C1956 c1956M10740 = new C5195(0).m10740(interfaceC5206, C3118.f11897, 0);
        if (c1956M10740 != null) {
            int length = c1956M10740.f7784.length;
        }
        C4545 c4545 = new C4545(4);
        ((C2373) interfaceC5206).mo4708(c4545.f17284, 0, 4, false);
        return c4545.m9606() == 1716281667;
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ᵲᵶᵳˈ */
    public final void mo1256() {
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ᵵᵽ */
    public final void mo1257(InterfaceC4550 interfaceC4550) {
        this.f11552 = interfaceC4550;
        this.f11560 = interfaceC4550.mo2743(0, 1);
        interfaceC4550.mo2740();
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ᵷᵺʾᵖ */
    public final int mo1258(InterfaceC5206 interfaceC5206, C2669 c2669) throws ParserException {
        C0063 c0063;
        int i;
        InterfaceC5517 c3782;
        long j;
        long j2;
        boolean z;
        long jM9595;
        long j3;
        int i2 = this.f11556;
        C1956 c1956 = null;
        if (i2 == 0) {
            interfaceC5206.mo4698();
            long jMo4706 = interfaceC5206.mo4706();
            C1956 c1956M10740 = new C5195(0).m10740(interfaceC5206, !this.f11550 ? null : C3118.f11897, 0);
            if (c1956M10740 != null && c1956M10740.f7784.length != 0) {
                c1956 = c1956M10740;
            }
            interfaceC5206.mo4700((int) (interfaceC5206.mo4706() - jMo4706));
            this.f11548 = c1956;
            this.f11556 = 1;
            return 0;
        }
        byte[] bArr = this.f11555;
        if (i2 == 1) {
            interfaceC5206.mo4701(bArr, 0, bArr.length);
            interfaceC5206.mo4698();
            this.f11556 = 2;
            return 0;
        }
        int i3 = 4;
        int i4 = 3;
        if (i2 == 2) {
            C4545 c4545 = new C4545(4);
            interfaceC5206.readFully(c4545.f17284, 0, 4);
            if (c4545.m9606() != 1716281667) {
                throw ParserException.m357("Failed to read FLAC stream marker.", null);
            }
            this.f11556 = 3;
            return 0;
        }
        int i5 = 6;
        if (i2 == 3) {
            int i6 = 0;
            C0063 c00632 = this.f11559;
            boolean z2 = false;
            while (!z2) {
                interfaceC5206.mo4698();
                byte[] bArr2 = new byte[i3];
                C3180 c3180 = new C3180(i3, bArr2);
                int i7 = i6;
                interfaceC5206.mo4701(bArr2, i7, i3);
                boolean zM7299 = c3180.m7299();
                int iM7302 = c3180.m7302(i);
                int iM73022 = c3180.m7302(24) + i3;
                if (iM7302 == 0) {
                    byte[] bArr3 = new byte[38];
                    interfaceC5206.readFully(bArr3, i7, 38);
                    c00632 = new C0063(i3, bArr3);
                } else {
                    if (c00632 == null) {
                        ᵷᵝˎ.ᵷᵺʾᵖ();
                        return 0;
                    }
                    C1956 c19562 = c00632.f1249;
                    if (iM7302 == i4) {
                        C4545 c45452 = new C4545(iM73022);
                        interfaceC5206.readFully(c45452.f17284, i7, iM73022);
                        c00632 = new C0063(c00632.f1251, c00632.f1245, c00632.f1247, c00632.f1254, c00632.f1248, c00632.f1252, c00632.f1246, c00632.f1250, ᵫﾞˌ.ˌᴵ(c45452), c00632.f1249);
                    } else {
                        if (iM7302 == i3) {
                            C4545 c45453 = new C4545(iM73022);
                            interfaceC5206.readFully(c45453.f17284, 0, iM73022);
                            c45453.m9609(i3);
                            C1956 c1956M5238 = ᵟˌᵫ.ˀᵭ(Arrays.asList((String[]) ᵟˌᵫ.ᵵᵬᵽ(c45453, false, false).ᵜᵪʾ));
                            if (c19562 != null) {
                                c1956M5238 = c19562.m5238(c1956M5238);
                            }
                            c0063 = new C0063(c00632.f1251, c00632.f1245, c00632.f1247, c00632.f1254, c00632.f1248, c00632.f1252, c00632.f1246, c00632.f1250, c00632.f1253, c1956M5238);
                        } else if (iM7302 == i5) {
                            C4545 c45454 = new C4545(iM73022);
                            interfaceC5206.readFully(c45454.f17284, 0, iM73022);
                            c45454.m9609(4);
                            C1956 c19563 = new C1956(AbstractC4509.m9553(C3018.m7103(c45454)));
                            if (c19562 != null) {
                                c19563 = c19562.m5238(c19563);
                            }
                            c0063 = new C0063(c00632.f1251, c00632.f1245, c00632.f1247, c00632.f1254, c00632.f1248, c00632.f1252, c00632.f1246, c00632.f1250, c00632.f1253, c19563);
                        } else {
                            interfaceC5206.mo4700(iM73022);
                        }
                        c00632 = c0063;
                    }
                }
                String str = AbstractC0956.f4222;
                this.f11559 = c00632;
                z2 = zM7299;
                i3 = 4;
                i4 = 3;
                i = 7;
                i5 = 6;
                i6 = 0;
            }
            this.f11559.getClass();
            this.f11554 = Math.max(this.f11559.f1247, 6);
            C5286 c5286M1077 = this.f11559.m1077(bArr, this.f11548);
            InterfaceC5226 interfaceC5226 = this.f11560;
            C4753 c4753M10878 = c5286M1077.m10878();
            c4753M10878.f18111 = AbstractC4208.m9132("audio/flac");
            AbstractC0659.m2415(c4753M10878, interfaceC5226);
            this.f11560.mo1743(this.f11559.m1076());
            this.f11556 = 4;
            return 0;
        }
        long j4 = 0;
        if (i2 == 4) {
            interfaceC5206.mo4698();
            C4545 c45455 = new C4545(2);
            interfaceC5206.mo4701(c45455.f17284, 0, 2);
            int iM9598 = c45455.m9598();
            if ((iM9598 >> 2) != 16382) {
                interfaceC5206.mo4698();
                throw ParserException.m357("First frame does not start with sync code.", null);
            }
            interfaceC5206.mo4698();
            this.f11557 = iM9598;
            InterfaceC4550 interfaceC4550 = this.f11552;
            String str2 = AbstractC0956.f4222;
            long position = interfaceC5206.getPosition();
            long length = interfaceC5206.getLength();
            this.f11559.getClass();
            C0063 c00633 = this.f11559;
            ˊˊᵞᵽ r3 = c00633.f1253;
            if (r3 != null && ((long[]) r3.ᵜᵪʾ).length > 0) {
                c3782 = new C3782(c00633, position, 1);
                i = 0;
            } else if (length == -1 || c00633.f1250 <= 0) {
                i = 0;
                c3782 = new C3782(c00633.m1076());
            } else {
                int i8 = this.f11557;
                int i9 = c00633.f1247;
                ᵳᵢᵺ r9 = new ᵳᵢᵺ(27, c00633);
                C1404 c1404 = new C1404(c00633, i8);
                long jM1076 = c00633.m1076();
                long j5 = c00633.f1250;
                int i10 = c00633.f1254;
                if (i10 > 0) {
                    i = 0;
                    j = ((((long) i10) + ((long) i9)) / 2) + 1;
                } else {
                    i = 0;
                    int i11 = c00633.f1251;
                    j = 64 + (((((i11 != c00633.f1245 || i11 <= 0) ? 4096L : i11) * ((long) c00633.f1252)) * ((long) c00633.f1246)) / 8);
                }
                C5052 c5052 = new C5052(r9, c1404, jM1076, j5, position, length, j, Math.max(6, i9));
                this.f11553 = c5052;
                c3782 = c5052.f19096;
            }
            interfaceC4550.mo2739(c3782);
            this.f11556 = 5;
            return i;
        }
        if (i2 != 5) {
            ᵷᵝˎ.ᵱʡˏ();
            return 0;
        }
        this.f11560.getClass();
        this.f11559.getClass();
        C5052 c50522 = this.f11553;
        if (c50522 != null && c50522.f19095 != null) {
            return c50522.m10390(interfaceC5206, c2669);
        }
        if (this.f11549 == -1) {
            C0063 c00634 = this.f11559;
            interfaceC5206.mo4698();
            interfaceC5206.mo4705(1);
            byte[] bArr4 = new byte[1];
            interfaceC5206.mo4701(bArr4, 0, 1);
            boolean z3 = (bArr4[0] & 1) == 1;
            interfaceC5206.mo4705(2);
            i = z3 ? 7 : 6;
            C4545 c45456 = new C4545(i);
            byte[] bArr5 = c45456.f17284;
            int i12 = 0;
            while (i12 < i) {
                int iMo4707 = interfaceC5206.mo4707(bArr5, i12, i - i12);
                if (iMo4707 == -1) {
                    break;
                }
                i12 += iMo4707;
            }
            c45456.m9612(i12);
            interfaceC5206.mo4698();
            try {
                jM9595 = c45456.m9595();
                if (!z3) {
                    jM9595 *= (long) c00634.f1245;
                }
                j3 = c00634.f1250;
            } catch (NumberFormatException unused) {
            }
            if (j3 == 0 || jM9595 <= j3) {
                j4 = jM9595;
            } else {
                z = false;
            }
            if (!z) {
                throw ParserException.m357(null, null);
            }
            this.f11549 = j4;
        } else {
            C4545 c45457 = this.f11547;
            int i13 = c45457.f17283;
            if (i13 < 32768) {
                int i14 = interfaceC5206.read(c45457.f17284, i13, 32768 - i13);
                z = i14 == -1;
                if (!z) {
                    c45457.m9612(i13 + i14);
                } else if (c45457.m9623() == 0) {
                    long j6 = this.f11549 * 1000000;
                    C0063 c00635 = this.f11559;
                    String str3 = AbstractC0956.f4222;
                    this.f11560.mo1741(j6 / ((long) c00635.f1248), 1, this.f11551, 0, null);
                    return -1;
                }
            } else {
                z = false;
            }
            int i15 = c45457.f17282;
            int i16 = this.f11551;
            int i17 = this.f11554;
            if (i16 < i17) {
                c45457.m9609(Math.min(i17 - i16, c45457.m9623()));
            }
            this.f11559.getClass();
            int i18 = c45457.f17282;
            while (true) {
                int i19 = c45457.f17283 - 16;
                C2669 c26692 = this.f11558;
                if (i18 <= i19) {
                    c45457.m9624(i18);
                    if (ᵣˉ.ᵱᵽʡᵚ(c45457, this.f11559, this.f11557, c26692)) {
                        c45457.m9624(i18);
                        j2 = c26692.f10317;
                        break;
                    }
                    i18++;
                } else {
                    if (z) {
                        while (true) {
                            int i20 = c45457.f17283;
                            if (i18 > i20 - this.f11554) {
                                c45457.m9624(i20);
                                break;
                            }
                            c45457.m9624(i18);
                            try {
                                z = ᵣˉ.ᵱᵽʡᵚ(c45457, this.f11559, this.f11557, c26692);
                            } catch (IndexOutOfBoundsException unused2) {
                                z = false;
                            }
                            if (c45457.f17282 > c45457.f17283) {
                                z = false;
                            }
                            if (z) {
                                c45457.m9624(i18);
                                j2 = c26692.f10317;
                                break;
                            }
                            i18++;
                        }
                    } else {
                        c45457.m9624(i18);
                    }
                    j2 = -1;
                }
            }
            int i21 = c45457.f17282 - i15;
            c45457.m9624(i15);
            this.f11560.mo1740(i21, c45457);
            int i22 = this.f11551 + i21;
            this.f11551 = i22;
            if (j2 != -1) {
                long j7 = this.f11549 * 1000000;
                C0063 c00636 = this.f11559;
                String str4 = AbstractC0956.f4222;
                this.f11560.mo1741(j7 / ((long) c00636.f1248), 1, i22, 0, null);
                this.f11551 = 0;
                this.f11549 = j2;
            }
            int length2 = c45457.f17284.length - c45457.f17283;
            if (c45457.m9623() < 16 && length2 < 16) {
                int iM9623 = c45457.m9623();
                byte[] bArr6 = c45457.f17284;
                System.arraycopy(bArr6, c45457.f17282, bArr6, 0, iM9623);
                c45457.m9624(0);
                c45457.m9612(iM9623);
            }
        }
        return 0;
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ᵻˈᵦʼ */
    public final List mo1259() {
        C2822 c2822 = AbstractC4509.f17159;
        return C2598.f10048;
    }
}
