package androidx.media3.extractor;

/* JADX INFO: loaded from: classes.dex */
public class q implements t0 {

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

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

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

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

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

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

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

    public q(int i10, int i11, long j10, long j11, boolean z10) {
        this.f3443a = j10;
        this.f3444b = j11;
        this.f3445c = i11 == -1 ? 1 : i11;
        this.f3447e = i10;
        this.f3449g = z10;
        if (j10 == -1) {
            this.f3446d = -1L;
            this.f3448f = -9223372036854775807L;
        } else {
            long j12 = j10 - j11;
            this.f3446d = j12;
            this.f3448f = (Math.max(0L, j12) * 8000000) / ((long) i10);
        }
    }

    @Override // androidx.media3.extractor.t0
    public final long getDurationUs() {
        return this.f3448f;
    }

    @Override // androidx.media3.extractor.t0
    public final s0 getSeekPoints(long j10) {
        long j11 = this.f3446d;
        long j12 = this.f3444b;
        if (j11 == -1 && !this.f3449g) {
            u0 u0Var = new u0(0L, j12);
            return new s0(u0Var, u0Var);
        }
        int i10 = this.f3447e;
        long j13 = this.f3445c;
        long jMin = (((((long) i10) * j10) / 8000000) / j13) * j13;
        if (j11 != -1) {
            jMin = Math.min(jMin, j11 - j13);
        }
        long jMax = Math.max(jMin, 0L) + j12;
        long jMax2 = (Math.max(0L, jMax - j12) * 8000000) / ((long) i10);
        u0 u0Var2 = new u0(jMax2, jMax);
        if (j11 != -1 && jMax2 < j10) {
            long j14 = jMax + j13;
            if (j14 < this.f3443a) {
                return new s0(u0Var2, new u0((Math.max(0L, j14 - j12) * 8000000) / ((long) i10), j14));
            }
        }
        return new s0(u0Var2, u0Var2);
    }

    @Override // androidx.media3.extractor.t0
    public final boolean isSeekable() {
        return this.f3446d != -1 || this.f3449g;
    }
}
