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

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

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final p01 f10355b = new p01(32);

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

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

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

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

    public db(cb cbVar) {
        this.f10354a = cbVar;
    }

    @Override // com.google.android.gms.internal.ads.jb
    public final void a(p01 p01Var, int i10) {
        int i11 = i10 & 1;
        int I = i11 != 0 ? p01Var.f15226b + p01Var.I() : -1;
        if (this.f10359f) {
            if (i11 == 0) {
                return;
            }
            this.f10359f = false;
            p01Var.C(I);
            this.f10357d = 0;
        }
        while (p01Var.y() > 0) {
            int i12 = this.f10357d;
            p01 p01Var2 = this.f10355b;
            if (i12 < 3) {
                if (i12 == 0) {
                    int I2 = p01Var.I();
                    p01Var.C(p01Var.f15226b - 1);
                    if (I2 == 255) {
                        this.f10359f = true;
                        return;
                    }
                }
                int iMin = Math.min(p01Var.y(), 3 - this.f10357d);
                p01Var.F(this.f10357d, iMin, p01Var2.f15225a);
                int i13 = this.f10357d + iMin;
                this.f10357d = i13;
                if (i13 == 3) {
                    p01Var2.C(0);
                    p01Var2.A(3);
                    p01Var2.E(1);
                    int I3 = p01Var2.I();
                    boolean z10 = (I3 & 128) != 0;
                    int I4 = p01Var2.I();
                    this.f10358e = z10;
                    int i14 = (((I3 & 15) << 8) | I4) + 3;
                    this.f10356c = i14;
                    byte[] bArr = p01Var2.f15225a;
                    if (bArr.length < i14) {
                        int length = bArr.length;
                        p01Var2.x(Math.min(4098, Math.max(i14, length + length)));
                    }
                }
            } else {
                int iMin2 = Math.min(p01Var.y(), this.f10356c - this.f10357d);
                p01Var.F(this.f10357d, iMin2, p01Var2.f15225a);
                int i15 = this.f10357d + iMin2;
                this.f10357d = i15;
                int i16 = this.f10356c;
                if (i15 != i16) {
                    continue;
                } else {
                    if (!this.f10358e) {
                        p01Var2.A(i16);
                    } else {
                        if (bb1.f(0, i16, -1, p01Var2.f15225a) != 0) {
                            this.f10359f = true;
                            return;
                        }
                        p01Var2.A(this.f10356c - 4);
                    }
                    p01Var2.C(0);
                    this.f10354a.e(p01Var2);
                    this.f10357d = 0;
                }
            }
        }
    }

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

    @Override // com.google.android.gms.internal.ads.jb
    public final void zzb() {
        this.f10359f = true;
    }
}
