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

import java.io.EOFException;

/* JADX INFO: loaded from: classes2.dex */
public final class a8 {

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

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

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

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

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final int[] f8520f = new int[255];

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final p01 f8521g = new p01(255);

    public final boolean a(p2 p2Var, long j10) {
        ih1.x(p2Var.zzn() == p2Var.zzm());
        p01 p01Var = this.f8521g;
        p01Var.v(4);
        while (true) {
            if (j10 != -1 && p2Var.zzn() + 4 >= j10) {
                break;
            }
            try {
                if (!p2Var.j(p01Var.f15225a, 0, 4, true)) {
                    break;
                }
                p01Var.C(0);
                if (p01Var.N() == 1332176723) {
                    p2Var.zzl();
                    return true;
                }
                p2Var.e(1);
            } catch (EOFException unused) {
            }
        }
        do {
            if (j10 != -1 && p2Var.zzn() >= j10) {
                break;
            }
        } while (p2Var.zzd() != -1);
        return false;
    }

    public final boolean b(p2 p2Var, boolean z10) throws zzat, EOFException {
        this.f8515a = 0;
        this.f8516b = 0L;
        this.f8517c = 0;
        this.f8518d = 0;
        this.f8519e = 0;
        p01 p01Var = this.f8521g;
        p01Var.v(27);
        try {
            if (p2Var.j(p01Var.f15225a, 0, 27, z10) && p01Var.N() == 1332176723) {
                if (p01Var.I() != 0) {
                    if (z10) {
                        return false;
                    }
                    throw zzat.zzc("unsupported bit stream revision");
                }
                this.f8515a = p01Var.I();
                this.f8516b = p01Var.e();
                p01Var.a();
                p01Var.a();
                p01Var.a();
                int I = p01Var.I();
                this.f8517c = I;
                this.f8518d = I + 27;
                p01Var.v(I);
                try {
                    if (p2Var.j(p01Var.f15225a, 0, this.f8517c, z10)) {
                        for (int i10 = 0; i10 < this.f8517c; i10++) {
                            int I2 = p01Var.I();
                            this.f8520f[i10] = I2;
                            this.f8519e += I2;
                        }
                        return true;
                    }
                } catch (EOFException e10) {
                    if (!z10) {
                        throw e10;
                    }
                }
                return false;
            }
        } catch (EOFException e11) {
            if (!z10) {
                throw e11;
            }
        }
        return false;
    }
}
