package D0;

import java.nio.ByteBuffer;
import v0.AbstractC1669h;
import v0.C1666e;
import v0.C1667f;

/* JADX INFO: loaded from: classes.dex */
public final class L extends AbstractC1669h {
    public int i;

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

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

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

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

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

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

    @Override // v0.AbstractC1669h, v0.InterfaceC1668g
    public final ByteBuffer b() {
        int i;
        if (super.d() && (i = this.f1531n) > 0) {
            k(i).put(this.f1530m, 0, this.f1531n).flip();
            this.f1531n = 0;
        }
        return super.b();
    }

    @Override // v0.AbstractC1669h, v0.InterfaceC1668g
    public final boolean d() {
        return super.d() && this.f1531n == 0;
    }

    @Override // v0.InterfaceC1668g
    public final void e(ByteBuffer byteBuffer) {
        int iPosition = byteBuffer.position();
        int iLimit = byteBuffer.limit();
        int i = iLimit - iPosition;
        if (i == 0) {
            return;
        }
        int iMin = Math.min(i, this.f1529l);
        this.f1532o += (long) (iMin / this.f18021b.f18019d);
        this.f1529l -= iMin;
        byteBuffer.position(iPosition + iMin);
        if (this.f1529l > 0) {
            return;
        }
        int i5 = i - iMin;
        int length = (this.f1531n + i5) - this.f1530m.length;
        ByteBuffer byteBufferK = k(length);
        int i8 = x0.v.i(length, 0, this.f1531n);
        byteBufferK.put(this.f1530m, 0, i8);
        int i9 = x0.v.i(length - i8, 0, i5);
        byteBuffer.limit(byteBuffer.position() + i9);
        byteBufferK.put(byteBuffer);
        byteBuffer.limit(iLimit);
        int i10 = i5 - i9;
        int i11 = this.f1531n - i8;
        this.f1531n = i11;
        byte[] bArr = this.f1530m;
        System.arraycopy(bArr, i8, bArr, 0, i11);
        byteBuffer.get(this.f1530m, this.f1531n, i10);
        this.f1531n += i10;
        byteBufferK.flip();
    }

    @Override // v0.AbstractC1669h
    public final C1666e g(C1666e c1666e) throws C1667f {
        int i = c1666e.f18018c;
        if (i != 2 && i != 4) {
            throw new C1667f(c1666e);
        }
        this.f1528k = true;
        return (this.i == 0 && this.f1527j == 0) ? C1666e.f18015e : c1666e;
    }

    @Override // v0.AbstractC1669h
    public final void h() {
        if (this.f1528k) {
            this.f1528k = false;
            int i = this.f1527j;
            int i5 = this.f18021b.f18019d;
            this.f1530m = new byte[i * i5];
            this.f1529l = this.i * i5;
        }
        this.f1531n = 0;
    }

    @Override // v0.AbstractC1669h
    public final void i() {
        if (this.f1528k) {
            int i = this.f1531n;
            if (i > 0) {
                this.f1532o += (long) (i / this.f18021b.f18019d);
            }
            this.f1531n = 0;
        }
    }

    @Override // v0.AbstractC1669h
    public final void j() {
        this.f1530m = x0.v.f18555c;
    }
}
