package x2;

import androidx.media3.common.util.Assertions;
import java.util.Arrays;

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

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

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public byte[] f34708d;

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

    public z(int i10) {
        this.f34705a = i10;
        byte[] bArr = new byte[131];
        this.f34708d = bArr;
        bArr[2] = 1;
    }

    public final void a(int i10, int i11, byte[] bArr) {
        if (this.f34706b) {
            int i12 = i11 - i10;
            byte[] bArr2 = this.f34708d;
            int length = bArr2.length;
            int i13 = this.f34709e;
            if (length < i13 + i12) {
                this.f34708d = Arrays.copyOf(bArr2, (i13 + i12) * 2);
            }
            System.arraycopy(bArr, i10, this.f34708d, this.f34709e, i12);
            this.f34709e += i12;
        }
    }

    public final boolean b(int i10) {
        if (!this.f34706b) {
            return false;
        }
        this.f34709e -= i10;
        this.f34706b = false;
        this.f34707c = true;
        return true;
    }

    public final void c() {
        this.f34706b = false;
        this.f34707c = false;
    }

    public final void d(int i10) {
        Assertions.checkState(!this.f34706b);
        boolean z10 = i10 == this.f34705a;
        this.f34706b = z10;
        if (z10) {
            this.f34709e = 3;
            this.f34707c = false;
        }
    }
}
