package c0;

import android.util.SparseArray;
import d0.C0760a;
import h6.EnumC1035b;
import java.nio.ByteBuffer;

/* JADX INFO: loaded from: classes.dex */
public final class m {

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

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

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

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

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

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

    public m(i6.c cVar) {
        this.f9308d = cVar;
        this.f9306b = 1;
        this.f9310f = EnumC1035b.f13428s;
        this.f9307c = -1;
    }

    public int a(int i) {
        SparseArray sparseArray = ((p) this.f9309e).f9320a;
        p pVar = sparseArray == null ? null : (p) sparseArray.get(i);
        int i5 = 1;
        int i8 = 2;
        if (this.f9305a == 2) {
            if (pVar != null) {
                this.f9309e = pVar;
                this.f9307c++;
            } else if (i == 65038) {
                b();
            } else if (i != 65039) {
                p pVar2 = (p) this.f9309e;
                if (pVar2.f9321b != null) {
                    i8 = 3;
                    if (this.f9307c != 1) {
                        this.f9310f = pVar2;
                        b();
                    } else if (c()) {
                        this.f9310f = (p) this.f9309e;
                        b();
                    } else {
                        b();
                    }
                } else {
                    b();
                }
            }
            i5 = i8;
        } else if (pVar == null) {
            b();
        } else {
            this.f9305a = 2;
            this.f9309e = pVar;
            this.f9307c = 1;
            i5 = i8;
        }
        this.f9306b = i;
        return i5;
    }

    public void b() {
        this.f9305a = 1;
        this.f9309e = (p) this.f9308d;
        this.f9307c = 0;
    }

    public boolean c() {
        C0760a c0760aB = ((p) this.f9309e).f9321b.b();
        int iA = c0760aB.a(6);
        return !(iA == 0 || ((ByteBuffer) c0760aB.f1393t).get(iA + c0760aB.f1390q) == 0) || this.f9306b == 65039;
    }

    public m(p pVar) {
        this.f9305a = 1;
        this.f9308d = pVar;
        this.f9309e = pVar;
    }
}
