package A1;

import T0.AbstractC0302b;
import java.util.Objects;
import n4.u0;
import u0.C1578n;
import u0.C1579o;
import x0.AbstractC1709a;

/* JADX INFO: renamed from: A1.b, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0001b implements InterfaceC0008i {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f107a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final T0.H f108b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final x0.o f109c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final String f110d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final int f111e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final String f112f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public String f113g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public T0.F f114h;
    public int i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public int f115j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public boolean f116k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public long f117l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public C1579o f118m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public int f119n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public long f120o;

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public C0001b(String str) {
        this(null, 0, 0, str);
        this.f107a = 0;
    }

    @Override // A1.InterfaceC0008i
    public final void a() {
        switch (this.f107a) {
            case u0.f15495q /* 0 */:
                this.i = 0;
                this.f115j = 0;
                this.f116k = false;
                this.f120o = -9223372036854775807L;
                break;
            default:
                this.i = 0;
                this.f115j = 0;
                this.f116k = false;
                this.f120o = -9223372036854775807L;
                break;
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:181:0x0340  */
    /* JADX WARN: Removed duplicated region for block: B:203:0x0382  */
    /* JADX WARN: Removed duplicated region for block: B:206:0x038a  */
    /* JADX WARN: Removed duplicated region for block: B:223:0x03bb  */
    /* JADX WARN: Removed duplicated region for block: B:233:0x03d0  */
    /* JADX WARN: Removed duplicated region for block: B:242:0x03ed  */
    @Override // A1.InterfaceC0008i
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void e(x0.o oVar) {
        int i;
        int iF;
        int i5;
        int i8;
        int i9;
        String str;
        int i10;
        int i11;
        int i12;
        int i13;
        int i14;
        int i15;
        int i16;
        int i17;
        int i18;
        int i19;
        int i20;
        int i21;
        switch (this.f107a) {
            case u0.f15495q /* 0 */:
                AbstractC1709a.k(this.f114h);
                while (oVar.a() > 0) {
                    int i22 = this.i;
                    x0.o oVar2 = this.f109c;
                    if (i22 == 0) {
                        while (true) {
                            if (oVar.a() <= 0) {
                            }
                            if (this.f116k) {
                                int iT = oVar.t();
                                if (iT == 119) {
                                    this.f116k = false;
                                    this.i = 1;
                                    byte[] bArr = oVar2.f18539a;
                                    bArr[0] = 11;
                                    bArr[1] = 119;
                                    this.f115j = 2;
                                } else {
                                    this.f116k = iT == 11;
                                }
                            } else {
                                this.f116k = oVar.t() == 11;
                            }
                            break;
                        }
                    } else if (i22 == 1) {
                        byte[] bArr2 = oVar2.f18539a;
                        int iMin = Math.min(oVar.a(), 128 - this.f115j);
                        oVar.e(bArr2, this.f115j, iMin);
                        int i23 = this.f115j + iMin;
                        this.f115j = i23;
                        if (i23 == 128) {
                            T0.H h8 = this.f108b;
                            h8.q(0);
                            int iG = h8.g();
                            h8.t(40);
                            Object[] objArr = h8.i(5) > 10;
                            h8.q(iG);
                            int[] iArr = AbstractC0302b.f6371f;
                            int[] iArr2 = AbstractC0302b.f6369d;
                            if (objArr == true) {
                                h8.t(16);
                                int i24 = h8.i(2);
                                byte b8 = i24 != 0 ? i24 != 1 ? i24 != 2 ? (byte) -1 : (byte) 2 : (byte) 1 : (byte) 0;
                                h8.t(3);
                                iF = (h8.i(11) + 1) * 2;
                                int i25 = h8.i(2);
                                if (i25 == 3) {
                                    i10 = AbstractC0302b.f6370e[h8.i(2)];
                                    i11 = 3;
                                    i12 = 6;
                                } else {
                                    int i26 = h8.i(2);
                                    int i27 = AbstractC0302b.f6368c[i26];
                                    i10 = iArr2[i25];
                                    i11 = i26;
                                    i12 = i27;
                                }
                                i9 = i12 * 256;
                                int i28 = (iF * i10) / (i12 * 32);
                                int i29 = h8.i(3);
                                boolean zH = h8.h();
                                i8 = iArr[i29] + (zH ? 1 : 0);
                                h8.t(10);
                                if (h8.h()) {
                                    h8.t(8);
                                }
                                if (i29 == 0) {
                                    h8.t(5);
                                    if (h8.h()) {
                                        h8.t(8);
                                    }
                                }
                                if (b8 == 1 && h8.h()) {
                                    h8.t(16);
                                }
                                if (h8.h()) {
                                    if (i29 > 2) {
                                        h8.t(2);
                                    }
                                    if ((i29 & 1) == 0 || i29 <= 2) {
                                        i17 = 6;
                                    } else {
                                        i17 = 6;
                                        h8.t(6);
                                    }
                                    if ((i29 & 4) != 0) {
                                        h8.t(i17);
                                    }
                                    if (zH && h8.h()) {
                                        h8.t(5);
                                    }
                                    if (b8 == 0) {
                                        if (h8.h()) {
                                            i18 = 6;
                                            h8.t(6);
                                        } else {
                                            i18 = 6;
                                        }
                                        if (i29 == 0 && h8.h()) {
                                            h8.t(i18);
                                        }
                                        if (h8.h()) {
                                            h8.t(i18);
                                        }
                                        int i30 = h8.i(2);
                                        if (i30 == 1) {
                                            h8.t(5);
                                            i20 = 2;
                                        } else {
                                            if (i30 == 2) {
                                                h8.t(12);
                                            } else if (i30 == 3) {
                                                int i31 = h8.i(5);
                                                if (h8.h()) {
                                                    h8.t(5);
                                                    if (h8.h()) {
                                                        i21 = 4;
                                                        h8.t(4);
                                                    } else {
                                                        i21 = 4;
                                                    }
                                                    if (h8.h()) {
                                                        h8.t(i21);
                                                    }
                                                    if (h8.h()) {
                                                        h8.t(i21);
                                                    }
                                                    if (h8.h()) {
                                                        h8.t(i21);
                                                    }
                                                    if (h8.h()) {
                                                        h8.t(i21);
                                                    }
                                                    if (h8.h()) {
                                                        h8.t(i21);
                                                    }
                                                    if (h8.h()) {
                                                        h8.t(i21);
                                                    }
                                                    if (h8.h()) {
                                                        if (h8.h()) {
                                                            h8.t(i21);
                                                        }
                                                        if (h8.h()) {
                                                            h8.t(i21);
                                                        }
                                                    }
                                                }
                                                if (h8.h()) {
                                                    h8.t(5);
                                                    if (h8.h()) {
                                                        h8.t(7);
                                                        if (h8.h()) {
                                                            i19 = 8;
                                                            h8.t(8);
                                                        } else {
                                                            i19 = 8;
                                                        }
                                                        i20 = 2;
                                                        h8.t((i31 + 2) * i19);
                                                        h8.c();
                                                    }
                                                }
                                            }
                                            i20 = 2;
                                        }
                                        if (i29 < i20) {
                                            if (h8.h()) {
                                                h8.t(14);
                                            }
                                            if (i29 == 0 && h8.h()) {
                                                h8.t(14);
                                            }
                                        }
                                        if (h8.h()) {
                                            i13 = i11;
                                            if (i13 == 0) {
                                                h8.t(5);
                                            } else {
                                                for (int i32 = 0; i32 < i12; i32++) {
                                                    if (h8.h()) {
                                                        h8.t(5);
                                                    }
                                                }
                                            }
                                        }
                                        if (h8.h()) {
                                        }
                                        if (b8 == 0) {
                                            h8.s();
                                        }
                                        if (b8 == 2) {
                                            i15 = 6;
                                            if (!h8.h()) {
                                                i = i28;
                                            }
                                        }
                                    }
                                } else {
                                    i13 = i11;
                                    if (h8.h()) {
                                        i14 = 3;
                                    } else {
                                        h8.t(5);
                                        if (i29 == 2) {
                                            h8.t(4);
                                        }
                                        if (i29 >= 6) {
                                            h8.t(2);
                                        }
                                        if (h8.h()) {
                                            i16 = 8;
                                            h8.t(8);
                                        } else {
                                            i16 = 8;
                                        }
                                        if (i29 == 0 && h8.h()) {
                                            h8.t(i16);
                                        }
                                        i14 = 3;
                                        if (i25 < 3) {
                                            h8.s();
                                        }
                                    }
                                    if (b8 == 0 && i13 != i14) {
                                        h8.s();
                                    }
                                    if (b8 == 2 || !(i13 == i14 || h8.h())) {
                                        i15 = 6;
                                    } else {
                                        i15 = 6;
                                        h8.t(6);
                                    }
                                    str = (!h8.h() && h8.i(i15) == 1 && h8.i(8) == 1) ? "audio/eac3-joc" : "audio/eac3";
                                    i = i28;
                                }
                            } else {
                                h8.t(32);
                                int i33 = h8.i(2);
                                String str2 = i33 == 3 ? null : "audio/ac3";
                                int i34 = h8.i(6);
                                i = AbstractC0302b.f6372g[i34 / 2] * 1000;
                                iF = AbstractC0302b.f(i33, i34);
                                h8.t(8);
                                int i35 = h8.i(3);
                                if ((i35 & 1) == 0 || i35 == 1) {
                                    i5 = 2;
                                } else {
                                    i5 = 2;
                                    h8.t(2);
                                }
                                if ((i35 & 4) != 0) {
                                    h8.t(i5);
                                }
                                if (i35 == i5) {
                                    h8.t(i5);
                                }
                                int i36 = i33 < 3 ? iArr2[i33] : -1;
                                i8 = iArr[i35] + (h8.h() ? 1 : 0);
                                String str3 = str2;
                                i9 = 1536;
                                str = str3;
                                i10 = i36;
                            }
                            C1579o c1579o = this.f118m;
                            if (c1579o == null || i8 != c1579o.D || i10 != c1579o.f17337E || !Objects.equals(str, c1579o.f17358n)) {
                                C1578n c1578n = new C1578n();
                                c1578n.f17309a = this.f113g;
                                c1578n.f17319l = u0.E.m(this.f112f);
                                c1578n.f17320m = u0.E.m(str);
                                c1578n.f17301C = i8;
                                c1578n.D = i10;
                                c1578n.f17312d = this.f110d;
                                c1578n.f17314f = this.f111e;
                                c1578n.i = i;
                                if ("audio/ac3".equals(str)) {
                                    c1578n.f17316h = i;
                                }
                                C1579o c1579o2 = new C1579o(c1578n);
                                this.f118m = c1579o2;
                                this.f114h.e(c1579o2);
                            }
                            this.f119n = iF;
                            this.f117l = (((long) i9) * 1000000) / ((long) this.f118m.f17337E);
                            oVar2.F(0);
                            this.f114h.c(128, oVar2);
                            this.i = 2;
                        }
                    } else if (i22 == 2) {
                        int iMin2 = Math.min(oVar.a(), this.f119n - this.f115j);
                        this.f114h.c(iMin2, oVar);
                        int i37 = this.f115j + iMin2;
                        this.f115j = i37;
                        if (i37 == this.f119n) {
                            AbstractC1709a.j(this.f120o != -9223372036854775807L);
                            this.f114h.a(this.f120o, 1, this.f119n, 0, null);
                            this.f120o += this.f117l;
                            this.i = 0;
                        }
                    }
                }
                break;
            default:
                AbstractC1709a.k(this.f114h);
                while (oVar.a() > 0) {
                    int i38 = this.i;
                    x0.o oVar3 = this.f109c;
                    if (i38 == 0) {
                        while (oVar.a() > 0) {
                            if (this.f116k) {
                                int iT2 = oVar.t();
                                this.f116k = iT2 == 172;
                                if (iT2 == 64 || iT2 == 65) {
                                    Object[] objArr2 = iT2 == 65;
                                    this.i = 1;
                                    byte[] bArr3 = oVar3.f18539a;
                                    bArr3[0] = -84;
                                    bArr3[1] = (byte) (objArr2 == true ? 65 : 64);
                                    this.f115j = 2;
                                }
                            } else {
                                this.f116k = oVar.t() == 172;
                            }
                        }
                    } else if (i38 == 1) {
                        byte[] bArr4 = oVar3.f18539a;
                        int iMin3 = Math.min(oVar.a(), 16 - this.f115j);
                        oVar.e(bArr4, this.f115j, iMin3);
                        int i39 = this.f115j + iMin3;
                        this.f115j = i39;
                        if (i39 == 16) {
                            T0.H h9 = this.f108b;
                            h9.q(0);
                            R0.h hVarM = AbstractC0302b.m(h9);
                            C1579o c1579o3 = this.f118m;
                            int i40 = hVarM.f5896a;
                            if (c1579o3 == null || 2 != c1579o3.D || i40 != c1579o3.f17337E || !"audio/ac4".equals(c1579o3.f17358n)) {
                                C1578n c1578n2 = new C1578n();
                                c1578n2.f17309a = this.f113g;
                                c1578n2.f17319l = u0.E.m(this.f112f);
                                c1578n2.f17320m = u0.E.m("audio/ac4");
                                c1578n2.f17301C = 2;
                                c1578n2.D = i40;
                                c1578n2.f17312d = this.f110d;
                                c1578n2.f17314f = this.f111e;
                                C1579o c1579o4 = new C1579o(c1578n2);
                                this.f118m = c1579o4;
                                this.f114h.e(c1579o4);
                            }
                            this.f119n = hVarM.f5897b;
                            this.f117l = (((long) hVarM.f5898c) * 1000000) / ((long) this.f118m.f17337E);
                            oVar3.F(0);
                            this.f114h.c(16, oVar3);
                            this.i = 2;
                        }
                    } else if (i38 == 2) {
                        int iMin4 = Math.min(oVar.a(), this.f119n - this.f115j);
                        this.f114h.c(iMin4, oVar);
                        int i41 = this.f115j + iMin4;
                        this.f115j = i41;
                        if (i41 == this.f119n) {
                            AbstractC1709a.j(this.f120o != -9223372036854775807L);
                            this.f114h.a(this.f120o, 1, this.f119n, 0, null);
                            this.f120o += this.f117l;
                            this.i = 0;
                        }
                    }
                }
                break;
        }
    }

    @Override // A1.InterfaceC0008i
    public final void f(boolean z8) {
        int i = this.f107a;
    }

    @Override // A1.InterfaceC0008i
    public final void g(T0.o oVar, M m8) {
        switch (this.f107a) {
            case u0.f15495q /* 0 */:
                m8.a();
                m8.b();
                this.f113g = m8.f103e;
                m8.b();
                this.f114h = oVar.j(m8.f102d, 1);
                break;
            default:
                m8.a();
                m8.b();
                this.f113g = m8.f103e;
                m8.b();
                this.f114h = oVar.j(m8.f102d, 1);
                break;
        }
    }

    @Override // A1.InterfaceC0008i
    public final void h(long j8, int i) {
        switch (this.f107a) {
            case u0.f15495q /* 0 */:
                this.f120o = j8;
                break;
            default:
                this.f120o = j8;
                break;
        }
    }

    public C0001b(String str, int i, int i5, String str2) {
        this.f107a = i5;
        switch (i5) {
            case 1:
                T0.H h8 = new T0.H(16, new byte[16]);
                this.f108b = h8;
                this.f109c = new x0.o(h8.f6361d);
                this.i = 0;
                this.f115j = 0;
                this.f116k = false;
                this.f120o = -9223372036854775807L;
                this.f110d = str;
                this.f111e = i;
                this.f112f = str2;
                break;
            default:
                T0.H h9 = new T0.H(128, new byte[128]);
                this.f108b = h9;
                this.f109c = new x0.o(h9.f6361d);
                this.i = 0;
                this.f120o = -9223372036854775807L;
                this.f110d = str;
                this.f111e = i;
                this.f112f = str2;
                break;
        }
    }

    private final void b(boolean z8) {
    }

    private final void c(boolean z8) {
    }
}
