package A1;

import u0.C1578n;
import u0.C1579o;
import x0.AbstractC1709a;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    public u(int i, String str, String str2) {
        x0.o oVar = new x0.o(4);
        this.f320a = oVar;
        oVar.f18539a[0] = -1;
        this.f321b = new T0.x();
        this.f332n = -9223372036854775807L;
        this.f322c = str;
        this.f323d = i;
        this.f324e = str2;
    }

    @Override // A1.InterfaceC0008i
    public final void a() {
        this.f327h = 0;
        this.i = 0;
        this.f329k = false;
        this.f332n = -9223372036854775807L;
    }

    @Override // A1.InterfaceC0008i
    public final void e(x0.o oVar) {
        AbstractC1709a.k(this.f325f);
        while (oVar.a() > 0) {
            int i = this.f327h;
            x0.o oVar2 = this.f320a;
            if (i == 0) {
                byte[] bArr = oVar.f18539a;
                int i5 = oVar.f18540b;
                int i8 = oVar.f18541c;
                while (true) {
                    if (i5 >= i8) {
                        oVar.F(i8);
                        break;
                    }
                    byte b8 = bArr[i5];
                    boolean z8 = (b8 & 255) == 255;
                    boolean z9 = this.f329k && (b8 & 224) == 224;
                    this.f329k = z8;
                    if (z9) {
                        oVar.F(i5 + 1);
                        this.f329k = false;
                        oVar2.f18539a[1] = bArr[i5];
                        this.i = 2;
                        this.f327h = 1;
                        break;
                    }
                    i5++;
                }
            } else if (i == 1) {
                int iMin = Math.min(oVar.a(), 4 - this.i);
                oVar.e(oVar2.f18539a, this.i, iMin);
                int i9 = this.i + iMin;
                this.i = i9;
                if (i9 >= 4) {
                    oVar2.F(0);
                    int iG = oVar2.g();
                    T0.x xVar = this.f321b;
                    if (xVar.b(iG)) {
                        this.f331m = xVar.f6476b;
                        if (!this.f328j) {
                            this.f330l = (((long) xVar.f6480f) * 1000000) / ((long) xVar.f6477c);
                            C1578n c1578n = new C1578n();
                            c1578n.f17309a = this.f326g;
                            c1578n.f17319l = u0.E.m(this.f324e);
                            c1578n.f17320m = u0.E.m((String) xVar.f6481g);
                            c1578n.f17321n = 4096;
                            c1578n.f17301C = xVar.f6478d;
                            c1578n.D = xVar.f6477c;
                            c1578n.f17312d = this.f322c;
                            c1578n.f17314f = this.f323d;
                            this.f325f.e(new C1579o(c1578n));
                            this.f328j = true;
                        }
                        oVar2.F(0);
                        this.f325f.c(4, oVar2);
                        this.f327h = 2;
                    } else {
                        this.i = 0;
                        this.f327h = 1;
                    }
                }
            } else {
                if (i != 2) {
                    throw new IllegalStateException();
                }
                int iMin2 = Math.min(oVar.a(), this.f331m - this.i);
                this.f325f.c(iMin2, oVar);
                int i10 = this.i + iMin2;
                this.i = i10;
                if (i10 >= this.f331m) {
                    AbstractC1709a.j(this.f332n != -9223372036854775807L);
                    this.f325f.a(this.f332n, 1, this.f331m, 0, null);
                    this.f332n += this.f330l;
                    this.i = 0;
                    this.f327h = 0;
                }
            }
        }
    }

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

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

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