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

import androidx.media3.common.MimeTypes;
import java.math.RoundingMode;

/* JADX INFO: loaded from: classes2.dex */
public final class nb implements mb {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final u3 f14515b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final pb f14516c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final zn2 f14517d;

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

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

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

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

    public nb(q2 q2Var, u3 u3Var, pb pbVar, String str, int i10) throws zzat {
        this.f14514a = q2Var;
        this.f14515b = u3Var;
        this.f14516c = pbVar;
        int i11 = pbVar.f15352b * pbVar.f15355e;
        int i12 = pbVar.f15354d;
        int i13 = i11 / 8;
        if (i12 != i13) {
            throw zzat.zzb(com.google.android.gms.measurement.internal.u1.m(new StringBuilder(String.valueOf(i13).length() + 28 + String.valueOf(i12).length()), "Expected block size: ", i13, "; got: ", i12), null);
        }
        int i14 = pbVar.f15353c * i13;
        int i15 = i14 * 8;
        int iMax = Math.max(i13, i14 / 10);
        this.f14518e = iMax;
        sm2 sm2Var = new sm2();
        sm2Var.zzl(MimeTypes.AUDIO_WAV);
        sm2Var.zzm(str);
        sm2Var.f16481d = i15;
        sm2Var.f16482e = i15;
        sm2Var.f16483f = iMax;
        sm2Var.f16496s = pbVar.f15352b;
        sm2Var.f16497t = pbVar.f15353c;
        sm2Var.f16498u = i10;
        this.f14517d = new zn2(sm2Var);
    }

    @Override // com.google.android.gms.internal.ads.mb
    public final void a(long j10) {
        this.f14519f = j10;
        this.f14520g = 0;
        this.f14521h = 0L;
    }

    @Override // com.google.android.gms.internal.ads.mb
    public final void b(int i10, long j10) {
        this.f14514a.k(new qb(this.f14516c, 1, i10, j10));
        u3 u3Var = this.f14515b;
        u3Var.d(this.f14517d);
        u3Var.zzN();
    }

    @Override // com.google.android.gms.internal.ads.mb
    public final boolean c(p2 p2Var, long j10) {
        int i10;
        int i11;
        long j11 = j10;
        while (j11 > 0 && (i10 = this.f14520g) < (i11 = this.f14518e)) {
            int iE = this.f14515b.e(p2Var, (int) Math.min(i11 - i10, j11), true);
            if (iE == -1) {
                j11 = 0;
            } else {
                this.f14520g += iE;
                j11 -= (long) iE;
            }
        }
        int i12 = this.f14520g;
        int i13 = this.f14516c.f15354d;
        int i14 = i12 / i13;
        if (i14 > 0) {
            long jR = this.f14519f + bb1.r(this.f14521h, 1000000L, r2.f15353c, RoundingMode.DOWN);
            int i15 = i14 * i13;
            int i16 = this.f14520g - i15;
            this.f14515b.zze(jR, 1, i15, i16, null);
            this.f14521h += (long) i14;
            this.f14520g = i16;
        }
        return j11 <= 0;
    }
}
