package l2;

import androidx.media3.common.ParserException;
import androidx.media3.common.util.ParsableByteArray;
import com.google.android.gms.internal.ads.p01;
import com.google.android.gms.internal.ads.r2;
import com.google.android.gms.internal.ads.zzat;

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

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

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

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

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

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

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

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

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

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

    public b(p01 p01Var, p01 p01Var2, boolean z10) throws zzat {
        this.f29948i = p01Var;
        this.f29947h = p01Var2;
        this.f29944e = z10;
        p01Var2.C(12);
        this.f29940a = p01Var2.h();
        p01Var.C(12);
        this.f29946g = p01Var.h();
        r2.zza(p01Var.b() == 1, "first_chunk must be 1");
        this.f29941b = -1;
    }

    public final boolean a() {
        int i10 = this.f29941b + 1;
        this.f29941b = i10;
        if (i10 == this.f29940a) {
            return false;
        }
        boolean z10 = this.f29944e;
        Object obj = this.f29947h;
        this.f29943d = z10 ? ((ParsableByteArray) obj).readUnsignedLongToLong() : ((ParsableByteArray) obj).readUnsignedInt();
        if (this.f29941b == this.f29945f) {
            Object obj2 = this.f29948i;
            this.f29942c = ((ParsableByteArray) obj2).readUnsignedIntToInt();
            ((ParsableByteArray) obj2).skipBytes(4);
            int i11 = this.f29946g - 1;
            this.f29946g = i11;
            this.f29945f = i11 > 0 ? ((ParsableByteArray) obj2).readUnsignedIntToInt() - 1 : -1;
        }
        return true;
    }

    public final boolean b() {
        int i10 = this.f29941b + 1;
        this.f29941b = i10;
        if (i10 == this.f29940a) {
            return false;
        }
        boolean z10 = this.f29944e;
        Object obj = this.f29947h;
        this.f29943d = z10 ? ((p01) obj).j() : ((p01) obj).N();
        if (this.f29941b == this.f29945f) {
            p01 p01Var = (p01) this.f29948i;
            this.f29942c = p01Var.h();
            p01Var.E(4);
            int i11 = this.f29946g - 1;
            this.f29946g = i11;
            this.f29945f = i11 > 0 ? (-1) + p01Var.h() : -1;
        }
        return true;
    }

    public b(ParsableByteArray parsableByteArray, ParsableByteArray parsableByteArray2, boolean z10) throws ParserException {
        this.f29948i = parsableByteArray;
        this.f29947h = parsableByteArray2;
        this.f29944e = z10;
        parsableByteArray2.setPosition(12);
        this.f29940a = parsableByteArray2.readUnsignedIntToInt();
        parsableByteArray.setPosition(12);
        this.f29946g = parsableByteArray.readUnsignedIntToInt();
        androidx.media3.extractor.c0.checkContainerInput(parsableByteArray.readInt() == 1, "first_chunk must be 1");
        this.f29941b = -1;
    }
}
