package A1;

import T0.AbstractC0302b;
import T0.C0301a;
import java.util.Collections;
import u0.C1578n;
import u0.C1579o;
import x0.AbstractC1709a;

/* JADX INFO: loaded from: classes.dex */
public final class t implements InterfaceC0008i {

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

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

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

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public T0.F f303e;

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

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

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f306h;
    public int i;

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

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

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

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

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

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

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

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

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

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

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

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

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

    public t(int i, String str) {
        this.f299a = str;
        this.f300b = i;
        x0.o oVar = new x0.o(1024);
        this.f301c = oVar;
        byte[] bArr = oVar.f18539a;
        this.f302d = new T0.H(bArr.length, bArr);
        this.f309l = -9223372036854775807L;
    }

    @Override // A1.InterfaceC0008i
    public final void a() {
        this.f306h = 0;
        this.f309l = -9223372036854775807L;
        this.f310m = false;
    }

    @Override // A1.InterfaceC0008i
    public final void e(x0.o oVar) throws u0.F {
        int i;
        boolean zH;
        AbstractC1709a.k(this.f303e);
        while (oVar.a() > 0) {
            int i5 = this.f306h;
            if (i5 != 0) {
                if (i5 != 1) {
                    x0.o oVar2 = this.f301c;
                    T0.H h8 = this.f302d;
                    if (i5 == 2) {
                        int iT = ((this.f308k & (-225)) << 8) | oVar.t();
                        this.f307j = iT;
                        if (iT > oVar2.f18539a.length) {
                            oVar2.C(iT);
                            byte[] bArr = oVar2.f18539a;
                            h8.getClass();
                            h8.o(bArr.length, bArr);
                        }
                        this.i = 0;
                        this.f306h = 3;
                    } else {
                        if (i5 != 3) {
                            throw new IllegalStateException();
                        }
                        int iMin = Math.min(oVar.a(), this.f307j - this.i);
                        oVar.e(h8.f6361d, this.i, iMin);
                        int i8 = this.i + iMin;
                        this.i = i8;
                        if (i8 == this.f307j) {
                            h8.q(0);
                            if (h8.h()) {
                                if (this.f310m) {
                                }
                                this.f306h = 0;
                            } else {
                                this.f310m = true;
                                int i9 = h8.i(1);
                                int i10 = i9 == 1 ? h8.i(1) : 0;
                                this.f311n = i10;
                                if (i10 != 0) {
                                    throw u0.F.a(null, null);
                                }
                                if (i9 == 1) {
                                    h8.i((h8.i(2) + 1) * 8);
                                }
                                if (!h8.h()) {
                                    throw u0.F.a(null, null);
                                }
                                this.f312o = h8.i(6);
                                int i11 = h8.i(4);
                                int i12 = h8.i(3);
                                if (i11 != 0 || i12 != 0) {
                                    throw u0.F.a(null, null);
                                }
                                if (i9 == 0) {
                                    int iG = h8.g();
                                    int iB = h8.b();
                                    C0301a c0301aN = AbstractC0302b.n(h8, true);
                                    this.f319v = c0301aN.f6363a;
                                    this.f316s = c0301aN.f6364b;
                                    this.f318u = c0301aN.f6365c;
                                    int iB2 = iB - h8.b();
                                    h8.q(iG);
                                    byte[] bArr2 = new byte[(iB2 + 7) / 8];
                                    h8.j(iB2, bArr2);
                                    C1578n c1578n = new C1578n();
                                    c1578n.f17309a = this.f304f;
                                    c1578n.f17319l = u0.E.m("video/mp2t");
                                    c1578n.f17320m = u0.E.m("audio/mp4a-latm");
                                    c1578n.f17317j = this.f319v;
                                    c1578n.f17301C = this.f318u;
                                    c1578n.D = this.f316s;
                                    c1578n.f17323p = Collections.singletonList(bArr2);
                                    c1578n.f17312d = this.f299a;
                                    c1578n.f17314f = this.f300b;
                                    C1579o c1579o = new C1579o(c1578n);
                                    if (!c1579o.equals(this.f305g)) {
                                        this.f305g = c1579o;
                                        this.f317t = 1024000000 / ((long) c1579o.f17337E);
                                        this.f303e.e(c1579o);
                                    }
                                } else {
                                    int iB3 = h8.b();
                                    C0301a c0301aN2 = AbstractC0302b.n(h8, true);
                                    this.f319v = c0301aN2.f6363a;
                                    this.f316s = c0301aN2.f6364b;
                                    this.f318u = c0301aN2.f6365c;
                                    h8.t(h8.i((h8.i(2) + 1) * 8) - (iB3 - h8.b()));
                                }
                                int i13 = h8.i(3);
                                this.f313p = i13;
                                if (i13 == 0) {
                                    h8.t(8);
                                } else if (i13 == 1) {
                                    h8.t(9);
                                } else if (i13 == 3 || i13 == 4 || i13 == 5) {
                                    h8.t(6);
                                } else {
                                    if (i13 != 6 && i13 != 7) {
                                        throw new IllegalStateException();
                                    }
                                    h8.t(1);
                                }
                                boolean zH2 = h8.h();
                                this.f314q = zH2;
                                this.f315r = 0L;
                                if (zH2) {
                                    if (i9 == 1) {
                                        this.f315r = h8.i((h8.i(2) + 1) * 8);
                                    } else {
                                        do {
                                            zH = h8.h();
                                            this.f315r = (this.f315r << 8) + ((long) h8.i(8));
                                        } while (zH);
                                    }
                                }
                                if (h8.h()) {
                                    h8.t(8);
                                }
                            }
                            if (this.f311n != 0) {
                                throw u0.F.a(null, null);
                            }
                            if (this.f312o != 0) {
                                throw u0.F.a(null, null);
                            }
                            if (this.f313p != 0) {
                                throw u0.F.a(null, null);
                            }
                            int i14 = 0;
                            do {
                                i = h8.i(8);
                                i14 += i;
                            } while (i == 255);
                            int iG2 = h8.g();
                            if ((iG2 & 7) == 0) {
                                oVar2.F(iG2 >> 3);
                            } else {
                                h8.j(i14 * 8, oVar2.f18539a);
                                oVar2.F(0);
                            }
                            this.f303e.c(i14, oVar2);
                            AbstractC1709a.j(this.f309l != -9223372036854775807L);
                            this.f303e.a(this.f309l, 1, i14, 0, null);
                            this.f309l += this.f317t;
                            if (this.f314q) {
                                h8.t((int) this.f315r);
                            }
                            this.f306h = 0;
                        } else {
                            continue;
                        }
                    }
                } else {
                    int iT2 = oVar.t();
                    if ((iT2 & 224) == 224) {
                        this.f308k = iT2;
                        this.f306h = 2;
                    } else if (iT2 != 86) {
                        this.f306h = 0;
                    }
                }
            } else if (oVar.t() == 86) {
                this.f306h = 1;
            }
        }
    }

    @Override // A1.InterfaceC0008i
    public final void g(T0.o oVar, M m8) {
        m8.a();
        m8.b();
        this.f303e = oVar.j(m8.f102d, 1);
        m8.b();
        this.f304f = m8.f103e;
    }

    @Override // A1.InterfaceC0008i
    public final void h(long j8, int i) {
        this.f309l = j8;
    }

    @Override // A1.InterfaceC0008i
    public final void f(boolean z8) {
    }
}
