package defpackage;

import android.util.Pair;
import androidx.media3.common.ParserException;
import java.nio.ByteOrder;
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 C2224 implements InterfaceC4291 {

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public InterfaceC5226 f8824;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public int f8825;

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

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public InterfaceC4550 f8827;

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public long f8828;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public long f8829;

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

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ʽˈˋ */
    public final void mo1252(long j, long j2) {
        this.f8825 = j == 0 ? 0 : 4;
        InterfaceC3802 interfaceC3802 = this.f8826;
        if (interfaceC3802 != null) {
            interfaceC3802.mo5206(j2);
        }
    }

    @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) {
        return ˋˀᵧ.ᵵᵽ(interfaceC5206);
    }

    @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.f8827 = interfaceC4550;
        this.f8824 = interfaceC4550.mo2743(0, 1);
        interfaceC4550.mo2740();
    }

    /* JADX WARN: Code restructure failed: missing block: B:77:0x020f, code lost:
    
        if (r9 != 65534) goto L78;
     */
    /* JADX WARN: Removed duplicated region for block: B:84:0x0224  */
    /* JADX WARN: Removed duplicated region for block: B:87:0x0236  */
    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ᵷᵺʾᵖ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final int mo1258(InterfaceC5206 interfaceC5206, C2669 c2669) throws ParserException {
        byte[] bArr;
        int i;
        this.f8824.getClass();
        String str = AbstractC0956.f4222;
        int i2 = this.f8825;
        int iM3212 = 4;
        if (i2 == 0) {
            ᵻᵪ.ˌᴵ(interfaceC5206.getPosition() == 0);
            int i3 = this.f8830;
            if (i3 != -1) {
                interfaceC5206.mo4700(i3);
                this.f8825 = 4;
                return 0;
            }
            if (!ˋˀᵧ.ᵵᵽ(interfaceC5206)) {
                throw ParserException.m357("Unsupported or unrecognized wav file type.", null);
            }
            interfaceC5206.mo4700((int) (interfaceC5206.mo4706() - interfaceC5206.getPosition()));
            this.f8825 = 1;
            return 0;
        }
        long jM9615 = -1;
        if (i2 == 1) {
            C4545 c4545 = new C4545(8);
            C0655 c0655M2395 = C0655.m2395(interfaceC5206, c4545);
            if (c0655M2395.f3092 != 1685272116) {
                interfaceC5206.mo4698();
            } else {
                interfaceC5206.mo4705(8);
                c4545.m9624(0);
                interfaceC5206.mo4701(c4545.f17284, 0, 8);
                jM9615 = c4545.m9615();
                interfaceC5206.mo4700(((int) c0655M2395.f3093) + 8);
            }
            this.f8829 = jM9615;
            this.f8825 = 2;
            return 0;
        }
        if (i2 != 2) {
            if (i2 != 3) {
                if (i2 != 4) {
                    ᵷᵝˎ.ᵱʡˏ();
                    return 0;
                }
                ᵻᵪ.ˌᴵ(this.f8828 != -1);
                long position = this.f8828 - interfaceC5206.getPosition();
                InterfaceC3802 interfaceC3802 = this.f8826;
                interfaceC3802.getClass();
                return interfaceC3802.mo5204(interfaceC5206, position) ? -1 : 0;
            }
            interfaceC5206.mo4698();
            C0655 c0655 = ˋˀᵧ.ˈᵲᵢ(1684108385, interfaceC5206, new C4545(8));
            interfaceC5206.mo4700(8);
            Pair pairCreate = Pair.create(Long.valueOf(interfaceC5206.getPosition()), Long.valueOf(c0655.f3093));
            this.f8830 = ((Long) pairCreate.first).intValue();
            long jLongValue = ((Long) pairCreate.second).longValue();
            long j = this.f8829;
            if (j != -1 && jLongValue == 4294967295L) {
                jLongValue = j;
            }
            this.f8828 = ((long) this.f8830) + jLongValue;
            long length = interfaceC5206.getLength();
            if (length != -1 && this.f8828 > length) {
                ˋˀᵧ.ʿٴˇ("Data exceeds input length: " + this.f8828 + ", " + length);
                this.f8828 = length;
            }
            InterfaceC3802 interfaceC38022 = this.f8826;
            interfaceC38022.getClass();
            interfaceC38022.mo5205(this.f8828, this.f8830);
            this.f8825 = 4;
            return 0;
        }
        C4545 c45452 = new C4545(16);
        long j2 = ˋˀᵧ.ˈᵲᵢ(1718449184, interfaceC5206, c45452).f3093;
        ᵻᵪ.ˌᴵ(j2 >= 16);
        interfaceC5206.mo4701(c45452.f17284, 0, 16);
        c45452.m9624(0);
        int iM9607 = c45452.m9607();
        int iM96072 = c45452.m9607();
        int iM9597 = c45452.m9597();
        c45452.m9597();
        int iM96073 = c45452.m9607();
        int iM96074 = c45452.m9607();
        int i4 = ((int) j2) - 16;
        if (i4 > 0) {
            bArr = new byte[i4];
            interfaceC5206.mo4701(bArr, 0, i4);
            if (iM9607 == 65534 && i4 == 24) {
                C4545 c45453 = new C4545(bArr);
                c45453.m9607();
                int iM96075 = c45453.m9607();
                if (iM96075 != 0 && iM96075 != iM96074) {
                    throw ParserException.m356("validBits ( " + iM96075 + ")  != bitsPerSample( " + iM96074 + ") are not supported");
                }
                int iM95972 = c45453.m9597();
                if ((iM95972 >> 18) != 0) {
                    throw ParserException.m356("invalid channel mask " + iM95972);
                }
                if (iM95972 != 0 && Integer.bitCount(iM95972) != iM96072) {
                    throw ParserException.m356("invalid number of channels (" + Integer.bitCount(iM95972) + ") in channel mask " + iM95972);
                }
                iM9607 = c45453.m9607();
                byte[] bArr2 = new byte[14];
                c45453.m9627(bArr2, 0, 14);
                if (!Arrays.equals(bArr2, ˋˀᵧ.ʽˈˋ) && !Arrays.equals(bArr2, ˋˀᵧ.ːˏᵟᵯ)) {
                    throw ParserException.m356("invalid wav format extension guid");
                }
            }
        } else {
            bArr = AbstractC0956.f4216;
        }
        interfaceC5206.mo4700((int) (interfaceC5206.mo4706() - interfaceC5206.getPosition()));
        C1597 c1597 = new C1597();
        c1597.f6411 = iM96072;
        c1597.f6408 = iM9597;
        c1597.f6409 = iM96073;
        c1597.f6412 = iM96074;
        c1597.f6410 = bArr;
        if (iM9607 == 17) {
            this.f8826 = new C3458(this.f8827, this.f8824, c1597);
        } else if (iM9607 == 6) {
            this.f8826 = new C1943(this.f8827, this.f8824, c1597, "audio/g711-alaw", -1);
        } else if (iM9607 == 7) {
            this.f8826 = new C1943(this.f8827, this.f8824, c1597, "audio/g711-mlaw", -1);
        } else if (iM9607 == 1) {
            iM3212 = AbstractC0956.m3212(iM96074, ByteOrder.LITTLE_ENDIAN);
            i = iM3212;
            if (i == 0) {
                throw ParserException.m356("Unsupported WAV format type: " + iM9607);
            }
            this.f8826 = new C1943(this.f8827, this.f8824, c1597, "audio/raw", i);
        } else {
            if (iM9607 == 3) {
                if (iM96074 == 32) {
                    i = iM3212;
                }
                if (i == 0) {
                }
            }
            i = 0;
            if (i == 0) {
            }
        }
        this.f8825 = 3;
        return 0;
    }

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