package com.google.android.gms.internal.ads;

import androidx.annotation.Nullable;

/* JADX INFO: loaded from: classes2.dex */
public final class xa implements jb {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final androidx.media3.extractor.b1 f18376b = new androidx.media3.extractor.b1(new byte[10], 10);

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

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

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

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

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

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

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

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

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

    public xa(ja jaVar) {
        this.f18375a = jaVar;
    }

    private final boolean zzf(p01 p01Var, @Nullable byte[] bArr, int i10) {
        int iMin = Math.min(p01Var.y(), i10 - this.f18378d);
        if (iMin <= 0) {
            return true;
        }
        if (bArr == null) {
            p01Var.E(iMin);
        } else {
            p01Var.F(this.f18378d, iMin, bArr);
        }
        int i11 = this.f18378d + iMin;
        this.f18378d = i11;
        return i11 == i10;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r19v0 */
    /* JADX WARN: Type inference failed for: r19v2 */
    /* JADX WARN: Type inference failed for: r3v6 */
    /* JADX WARN: Type inference failed for: r4v0 */
    /* JADX WARN: Type inference failed for: r4v1, types: [boolean, int] */
    /* JADX WARN: Type inference failed for: r4v12 */
    /* JADX WARN: Type inference failed for: r4v4 */
    /* JADX WARN: Type inference failed for: r4v5 */
    /* JADX WARN: Type inference failed for: r5v0, types: [com.google.android.gms.internal.ads.ja] */
    /* JADX WARN: Type inference failed for: r9v0, types: [androidx.media3.extractor.b1] */
    /* JADX WARN: Type inference failed for: r9v10 */
    /* JADX WARN: Type inference failed for: r9v3, types: [int] */
    /* JADX WARN: Type inference failed for: r9v8 */
    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$UnknownArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    @Override // com.google.android.gms.internal.ads.jb
    public final void a(p01 p01Var, int i10) {
        int i11;
        int i12;
        boolean z10;
        int i13;
        long jC;
        char c6;
        this.f18379e.getClass();
        int i14 = i10 & 1;
        int i15 = 1;
        ?? r42 = 0;
        ?? r52 = this.f18375a;
        int i16 = -1;
        int i17 = 2;
        if (i14 != 0) {
            int i18 = this.f18377c;
            if (i18 != 0 && i18 != 1) {
                if (i18 != 2) {
                    int i19 = this.f18384j;
                    if (i19 != -1) {
                        StringBuilder sb = new StringBuilder(String.valueOf(i19).length() + 48);
                        sb.append("Unexpected start indicator: expected ");
                        sb.append(i19);
                        sb.append(" more bytes");
                        vt0.c(sb.toString());
                    }
                    r52.b(p01Var.f15227c == 0);
                } else {
                    vt0.c("Unexpected start indicator reading extended header");
                }
            }
            this.f18377c = 1;
            this.f18378d = 0;
        }
        int i20 = i10;
        while (p01Var.y() > 0) {
            int i21 = this.f18377c;
            if (i21 != 0) {
                ?? r92 = this.f18376b;
                if (i21 != i15) {
                    if (i21 != i17) {
                        int iY = p01Var.y();
                        int i22 = this.f18384j;
                        ?? r93 = i22 == i16 ? r42 : iY - i22;
                        if (r93 > 0) {
                            iY -= r93;
                            p01Var.A(p01Var.f15226b + iY);
                        }
                        r52.d(p01Var);
                        int i23 = this.f18384j;
                        if (i23 != i16) {
                            int i24 = i23 - iY;
                            this.f18384j = i24;
                            if (i24 == 0) {
                                r52.b(r42);
                                this.f18377c = i15;
                                this.f18378d = r42;
                            }
                        }
                    } else {
                        if (zzf(p01Var, (byte[]) r92.f3327b, Math.min(10, this.f18383i)) && zzf(p01Var, null, this.f18383i)) {
                            r92.l(r42);
                            if (this.f18380f) {
                                r92.n(4);
                                long jP = r92.p(3);
                                r92.n(i15);
                                int iP = r92.p(15) << 15;
                                r92.n(i15);
                                long jP2 = r92.p(15);
                                r92.n(i15);
                                if (this.f18382h || !this.f18381g) {
                                    c6 = 30;
                                } else {
                                    r92.n(4);
                                    long jP3 = ((long) r92.p(3)) << 30;
                                    r92.n(i15);
                                    int iP2 = r92.p(15) << 15;
                                    r92.n(i15);
                                    long jP4 = r92.p(15);
                                    r92.n(i15);
                                    this.f18379e.c(jP3 | ((long) iP2) | jP4);
                                    this.f18382h = true;
                                    c6 = 30;
                                }
                                jC = this.f18379e.c((jP << c6) | ((long) iP) | jP2);
                            } else {
                                jC = -9223372036854775807L;
                            }
                            i20 |= true != this.f18385k ? 0 : 4;
                            r52.c(i20, jC);
                            this.f18377c = 3;
                            this.f18378d = 0;
                            r42 = 0;
                            i15 = 1;
                            i16 = -1;
                            i17 = 2;
                        }
                    }
                    ?? r19 = r42;
                    i11 = i15;
                    i12 = i16;
                    z10 = r19 == true ? 1 : 0;
                } else {
                    ?? r32 = r42;
                    if (zzf(p01Var, (byte[]) r92.f3327b, 9)) {
                        r92.l(r32 == true ? 1 : 0);
                        int iP3 = r92.p(24);
                        i11 = 1;
                        if (iP3 != 1) {
                            com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.q(new StringBuilder(String.valueOf(iP3).length() + 30), "Unexpected start code prefix: ", iP3);
                            i12 = -1;
                            this.f18384j = -1;
                            i13 = 0;
                            i17 = 2;
                        } else {
                            r92.n(8);
                            int iP4 = r92.p(16);
                            r92.n(5);
                            this.f18385k = r92.o();
                            i17 = 2;
                            r92.n(2);
                            this.f18380f = r92.o();
                            this.f18381g = r92.o();
                            r92.n(6);
                            int iP5 = r92.p(8);
                            this.f18383i = iP5;
                            if (iP4 == 0) {
                                this.f18384j = -1;
                                i13 = 2;
                                i12 = -1;
                            } else {
                                int i25 = (iP4 - 3) - iP5;
                                this.f18384j = i25;
                                if (i25 < 0) {
                                    com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.q(new StringBuilder(String.valueOf(i25).length() + 36), "Found negative packet payload size: ", i25);
                                    i12 = -1;
                                    this.f18384j = -1;
                                } else {
                                    i12 = -1;
                                }
                                i13 = 2;
                            }
                        }
                        this.f18377c = i13;
                        z10 = false;
                        this.f18378d = 0;
                    } else {
                        z10 = r32 == true ? 1 : 0;
                        i12 = -1;
                        i11 = 1;
                        i17 = 2;
                    }
                }
            } else {
                ?? r192 = r42;
                i11 = i15;
                i12 = i16;
                z10 = r192 == true ? 1 : 0;
                p01Var.E(p01Var.y());
            }
            boolean z11 = z10;
            i16 = i12;
            i15 = i11;
            r42 = z11 ? 1 : 0;
        }
    }

    @Override // com.google.android.gms.internal.ads.jb
    public final void d(g91 g91Var, q2 q2Var, x2.o0 o0Var) {
        this.f18379e = g91Var;
        this.f18375a.a(q2Var, o0Var);
    }

    @Override // com.google.android.gms.internal.ads.jb
    public final void zzb() {
        this.f18377c = 0;
        this.f18378d = 0;
        this.f18382h = false;
        this.f18375a.zza();
    }
}
