package q;

/* JADX INFO: loaded from: classes.dex */
public final class N0 implements I0 {

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

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

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

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

    public N0(K0 k02, X x6, long j4) {
        this.f23203a = k02;
        this.f23204b = x6;
        this.f23205c = ((long) (k02.f() + k02.e())) * 1000000;
        this.f23206d = j4 * 1000000;
    }

    @Override // q.I0
    public final boolean a() {
        return true;
    }

    @Override // q.I0
    public final long b(AbstractC2798s abstractC2798s, AbstractC2798s abstractC2798s2, AbstractC2798s abstractC2798s3) {
        return Long.MAX_VALUE;
    }

    @Override // q.I0
    public final AbstractC2798s c(long j4, AbstractC2798s abstractC2798s, AbstractC2798s abstractC2798s2, AbstractC2798s abstractC2798s3) {
        return this.f23203a.c(h(j4), abstractC2798s, abstractC2798s2, i(j4, abstractC2798s, abstractC2798s3, abstractC2798s2));
    }

    @Override // q.I0
    public final AbstractC2798s d(long j4, AbstractC2798s abstractC2798s, AbstractC2798s abstractC2798s2, AbstractC2798s abstractC2798s3) {
        return this.f23203a.d(h(j4), abstractC2798s, abstractC2798s2, i(j4, abstractC2798s, abstractC2798s3, abstractC2798s2));
    }

    public final long h(long j4) {
        long j6 = this.f23206d;
        if (j4 + j6 <= 0) {
            return 0L;
        }
        long j7 = j4 + j6;
        long j8 = this.f23205c;
        long j9 = j7 / j8;
        return (this.f23204b == X.f23246a || j9 % ((long) 2) == 0) ? j7 - (j9 * j8) : ((j9 + 1) * j8) - j7;
    }

    public final AbstractC2798s i(long j4, AbstractC2798s abstractC2798s, AbstractC2798s abstractC2798s2, AbstractC2798s abstractC2798s3) {
        long j6 = this.f23206d;
        long j7 = j4 + j6;
        long j8 = this.f23205c;
        return j7 > j8 ? this.f23203a.d(j8 - j6, abstractC2798s, abstractC2798s3, abstractC2798s2) : abstractC2798s2;
    }
}
