package L0;

import u0.C1566b;

/* JADX INFO: renamed from: L0.f, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0151f extends r {

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

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

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

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

    public C0151f(u0.S s8, long j8, long j9) throws C0152g {
        super(s8);
        if (j9 != Long.MIN_VALUE && j9 < j8) {
            throw new C0152g(2, j8, j9);
        }
        boolean z8 = false;
        if (s8.h() != 1) {
            throw new C0152g(0);
        }
        u0.Q qM = s8.m(0, new u0.Q(), 0L);
        long jMax = Math.max(0L, j8);
        if (!qM.f17193k && jMax != 0 && !qM.f17191h) {
            throw new C0152g(1);
        }
        long jMax2 = j9 == Long.MIN_VALUE ? qM.f17195m : Math.max(0L, j9);
        long j10 = qM.f17195m;
        if (j10 != -9223372036854775807L) {
            jMax2 = jMax2 > j10 ? j10 : jMax2;
            if (jMax > jMax2) {
                jMax = jMax2;
            }
        }
        this.f3808c = jMax;
        this.f3809d = jMax2;
        this.f3810e = jMax2 != -9223372036854775807L ? jMax2 - jMax : -9223372036854775807L;
        if (qM.i && (jMax2 == -9223372036854775807L || (j10 != -9223372036854775807L && jMax2 == j10))) {
            z8 = true;
        }
        this.f3811f = z8;
    }

    @Override // L0.r, u0.S
    public final u0.P f(int i, u0.P p3, boolean z8) {
        this.f3900b.f(0, p3, z8);
        long j8 = p3.f17179e - this.f3808c;
        long j9 = this.f3810e;
        p3.h(p3.f17175a, p3.f17176b, 0, j9 != -9223372036854775807L ? j9 - j8 : -9223372036854775807L, j8, C1566b.f17261c, false);
        return p3;
    }

    @Override // L0.r, u0.S
    public final u0.Q m(int i, u0.Q q8, long j8) {
        this.f3900b.m(0, q8, 0L);
        long j9 = q8.f17198p;
        long j10 = this.f3808c;
        q8.f17198p = j9 + j10;
        q8.f17195m = this.f3810e;
        q8.i = this.f3811f;
        long j11 = q8.f17194l;
        if (j11 != -9223372036854775807L) {
            long jMax = Math.max(j11, j10);
            q8.f17194l = jMax;
            long j12 = this.f3809d;
            if (j12 != -9223372036854775807L) {
                jMax = Math.min(jMax, j12);
            }
            q8.f17194l = jMax - j10;
        }
        long jW = x0.v.W(j10);
        long j13 = q8.f17188e;
        if (j13 != -9223372036854775807L) {
            q8.f17188e = j13 + jW;
        }
        long j14 = q8.f17189f;
        if (j14 != -9223372036854775807L) {
            q8.f17189f = j14 + jW;
        }
        return q8;
    }
}
