package A1;

import C3.W;
import java.io.EOFException;
import java.io.InterruptedIOException;
import java.util.List;
import x0.AbstractC1709a;

/* JADX INFO: renamed from: A1.d, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0003d implements T0.m {

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

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

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

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

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final C0004e f124a = new C0004e(null, "audio/mp4a-latm", 0, true);

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final x0.o f125b = new x0.o(2048);

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public long f130g = -1;

    public C0003d() {
        x0.o oVar = new x0.o(10);
        this.f126c = oVar;
        byte[] bArr = oVar.f18539a;
        this.f127d = new T0.H(bArr.length, bArr);
    }

    @Override // T0.m
    public final T0.m c() {
        return this;
    }

    @Override // T0.m
    public final int e(T0.n nVar, L4.h hVar) throws u0.F, EOFException, InterruptedIOException {
        AbstractC1709a.k(this.f128e);
        long j8 = ((T0.j) nVar).f6427s;
        x0.o oVar = this.f125b;
        int iP = ((T0.j) nVar).p(oVar.f18539a, 0, 2048);
        boolean z8 = iP == -1;
        if (!this.i) {
            this.f128e.v(new T0.q(-9223372036854775807L));
            this.i = true;
        }
        if (z8) {
            return -1;
        }
        oVar.F(0);
        oVar.E(iP);
        boolean z9 = this.f131h;
        C0004e c0004e = this.f124a;
        if (!z9) {
            c0004e.f152u = this.f129f;
            this.f131h = true;
        }
        c0004e.e(oVar);
        return 0;
    }

    @Override // T0.m
    public final boolean f(T0.n nVar) throws EOFException, InterruptedIOException {
        T0.j jVar = (T0.j) nVar;
        int i = 0;
        while (true) {
            x0.o oVar = this.f126c;
            jVar.f(oVar.f18539a, 0, 10, false);
            oVar.F(0);
            if (oVar.w() != 4801587) {
                break;
            }
            oVar.G(3);
            int iS = oVar.s();
            i += iS + 10;
            jVar.h(iS, false);
        }
        jVar.f6430v = 0;
        jVar.h(i, false);
        if (this.f130g == -1) {
            this.f130g = i;
        }
        int i5 = i;
        int i8 = 0;
        int i9 = 0;
        do {
            x0.o oVar2 = this.f126c;
            jVar.f(oVar2.f18539a, 0, 2, false);
            oVar2.F(0);
            if ((oVar2.z() & 65526) == 65520) {
                i8++;
                if (i8 >= 4 && i9 > 188) {
                    return true;
                }
                jVar.f(oVar2.f18539a, 0, 4, false);
                T0.H h8 = this.f127d;
                h8.q(14);
                int i10 = h8.i(13);
                if (i10 <= 6) {
                    i5++;
                    jVar.f6430v = 0;
                    jVar.h(i5, false);
                } else {
                    jVar.h(i10 - 6, false);
                    i9 += i10;
                }
            } else {
                i5++;
                jVar.f6430v = 0;
                jVar.h(i5, false);
            }
            i8 = 0;
            i9 = 0;
        } while (i5 - i < 8192);
        return false;
    }

    @Override // T0.m
    public final void i(long j8, long j9) {
        this.f131h = false;
        this.f124a.a();
        this.f129f = j9;
    }

    @Override // T0.m
    public final void l(T0.o oVar) {
        this.f128e = oVar;
        this.f124a.g(oVar, new M(0, 1));
        oVar.h();
    }

    @Override // T0.m
    public final List m() {
        C3.E e8 = C3.G.f1197r;
        return W.f1225u;
    }

    @Override // T0.m
    public final void a() {
    }
}
