package A1;

import java.util.Collections;
import java.util.List;
import n4.u0;
import u0.C1578n;
import x0.AbstractC1709a;

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

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

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

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

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

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

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

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

    public C0007h(List list) {
        this.f173a = 0;
        this.f178f = list;
        this.f179g = new T0.F[list.size()];
        this.f175c = -9223372036854775807L;
    }

    @Override // A1.InterfaceC0008i
    public final void a() {
        switch (this.f173a) {
            case u0.f15495q /* 0 */:
                this.f174b = false;
                this.f175c = -9223372036854775807L;
                break;
            default:
                this.f174b = false;
                this.f175c = -9223372036854775807L;
                break;
        }
    }

    @Override // A1.InterfaceC0008i
    public final void e(x0.o oVar) {
        boolean z8;
        boolean z9;
        switch (this.f173a) {
            case u0.f15495q /* 0 */:
                if (this.f174b) {
                    if (this.f176d == 2) {
                        if (oVar.a() == 0) {
                            z9 = false;
                        } else {
                            if (oVar.t() != 32) {
                                this.f174b = false;
                            }
                            this.f176d--;
                            z9 = this.f174b;
                        }
                        if (!z9) {
                        }
                    }
                    if (this.f176d == 1) {
                        if (oVar.a() == 0) {
                            z8 = false;
                        } else {
                            if (oVar.t() != 0) {
                                this.f174b = false;
                            }
                            this.f176d--;
                            z8 = this.f174b;
                        }
                        if (!z8) {
                        }
                    }
                    int i = oVar.f18540b;
                    int iA = oVar.a();
                    for (T0.F f3 : (T0.F[]) this.f179g) {
                        oVar.F(i);
                        f3.c(iA, oVar);
                    }
                    this.f177e += iA;
                }
                break;
            default:
                AbstractC1709a.k((T0.F) this.f179g);
                if (this.f174b) {
                    int iA2 = oVar.a();
                    int i5 = this.f177e;
                    if (i5 < 10) {
                        int iMin = Math.min(iA2, 10 - i5);
                        byte[] bArr = oVar.f18539a;
                        int i8 = oVar.f18540b;
                        x0.o oVar2 = (x0.o) this.f178f;
                        System.arraycopy(bArr, i8, oVar2.f18539a, this.f177e, iMin);
                        if (this.f177e + iMin == 10) {
                            oVar2.F(0);
                            if (73 == oVar2.t() && 68 == oVar2.t() && 51 == oVar2.t()) {
                                oVar2.G(3);
                                this.f176d = oVar2.s() + 10;
                            } else {
                                AbstractC1709a.B("Id3Reader", "Discarding invalid ID3 tag");
                                this.f174b = false;
                            }
                        }
                    }
                    int iMin2 = Math.min(iA2, this.f176d - this.f177e);
                    ((T0.F) this.f179g).c(iMin2, oVar);
                    this.f177e += iMin2;
                    break;
                }
                break;
        }
    }

    @Override // A1.InterfaceC0008i
    public final void f(boolean z8) {
        int i;
        switch (this.f173a) {
            case u0.f15495q /* 0 */:
                if (this.f174b) {
                    AbstractC1709a.j(this.f175c != -9223372036854775807L);
                    for (T0.F f3 : (T0.F[]) this.f179g) {
                        f3.a(this.f175c, 1, this.f177e, 0, null);
                    }
                    this.f174b = false;
                }
                break;
            default:
                AbstractC1709a.k((T0.F) this.f179g);
                if (this.f174b && (i = this.f176d) != 0 && this.f177e == i) {
                    AbstractC1709a.j(this.f175c != -9223372036854775807L);
                    ((T0.F) this.f179g).a(this.f175c, 1, this.f176d, 0, null);
                    this.f174b = false;
                    break;
                }
                break;
        }
    }

    @Override // A1.InterfaceC0008i
    public final void g(T0.o oVar, M m8) {
        switch (this.f173a) {
            case u0.f15495q /* 0 */:
                int i = 0;
                while (true) {
                    T0.F[] fArr = (T0.F[]) this.f179g;
                    if (i < fArr.length) {
                        K k8 = (K) ((List) this.f178f).get(i);
                        m8.a();
                        m8.b();
                        T0.F fJ = oVar.j(m8.f102d, 3);
                        C1578n c1578n = new C1578n();
                        m8.b();
                        c1578n.f17309a = m8.f103e;
                        c1578n.f17319l = u0.E.m("video/mp2t");
                        c1578n.f17320m = u0.E.m("application/dvbsubs");
                        c1578n.f17323p = Collections.singletonList(k8.f94b);
                        c1578n.f17312d = k8.f93a;
                        I1.a.w(c1578n, fJ);
                        fArr[i] = fJ;
                        i++;
                    }
                    break;
                }
                break;
            default:
                m8.a();
                m8.b();
                T0.F fJ2 = oVar.j(m8.f102d, 5);
                this.f179g = fJ2;
                C1578n c1578n2 = new C1578n();
                m8.b();
                c1578n2.f17309a = m8.f103e;
                c1578n2.f17319l = u0.E.m("video/mp2t");
                c1578n2.f17320m = u0.E.m("application/id3");
                I1.a.w(c1578n2, fJ2);
                break;
        }
    }

    @Override // A1.InterfaceC0008i
    public final void h(long j8, int i) {
        switch (this.f173a) {
            case u0.f15495q /* 0 */:
                if ((i & 4) != 0) {
                    this.f174b = true;
                    this.f175c = j8;
                    this.f177e = 0;
                    this.f176d = 2;
                    break;
                }
                break;
            default:
                if ((i & 4) != 0) {
                    this.f174b = true;
                    this.f175c = j8;
                    this.f176d = 0;
                    this.f177e = 0;
                    break;
                }
                break;
        }
    }

    public C0007h() {
        this.f173a = 1;
        this.f178f = new x0.o(10);
        this.f175c = -9223372036854775807L;
    }
}
