package com.applovin.impl; import android.os.SystemClock; import com.applovin.impl.td; import com.mbridge.msdk.playercommon.exoplayer2.C; /* loaded from: classes.dex */ public final class e6 implements kc { private final float a; private final float b; private final long c; private final float d; private final long e; private final long f; private final float g; private long h; private long i; private long j; private long k; private long l; private long m; private float n; private float o; private float p; private long q; private long r; private long s; public static final class b { private float a = 0.97f; private float b = 1.03f; private long c = 1000; private float d = 1.0E-7f; private long e = t2.a(20L); private long f = t2.a(500L); private float g = 0.999f; public e6 a() { return new e6(this.a, this.b, this.c, this.d, this.e, this.f, this.g); } } private static long a(long j, long j2, float f) { return (long) ((j * f) + ((1.0f - f) * j2)); } private void c() { long j = this.h; if (j != C.TIME_UNSET) { long j2 = this.i; if (j2 != C.TIME_UNSET) { j = j2; } long j3 = this.k; if (j3 != C.TIME_UNSET && j < j3) { j = j3; } long j4 = this.l; if (j4 != C.TIME_UNSET && j > j4) { j = j4; } } else { j = -9223372036854775807L; } if (this.j == j) { return; } this.j = j; this.m = j; this.r = C.TIME_UNSET; this.s = C.TIME_UNSET; this.q = C.TIME_UNSET; } @Override // com.applovin.impl.kc public void a() { long j = this.m; if (j == C.TIME_UNSET) { return; } long j2 = j + this.f; this.m = j2; long j3 = this.l; if (j3 != C.TIME_UNSET && j2 > j3) { this.m = j3; } this.q = C.TIME_UNSET; } @Override // com.applovin.impl.kc public long b() { return this.m; } private e6(float f, float f2, long j, float f3, long j2, long j3, float f4) { this.a = f; this.b = f2; this.c = j; this.d = f3; this.e = j2; this.f = j3; this.g = f4; this.h = C.TIME_UNSET; this.i = C.TIME_UNSET; this.k = C.TIME_UNSET; this.l = C.TIME_UNSET; this.o = f; this.n = f2; this.p = 1.0f; this.q = C.TIME_UNSET; this.j = C.TIME_UNSET; this.m = C.TIME_UNSET; this.r = C.TIME_UNSET; this.s = C.TIME_UNSET; } @Override // com.applovin.impl.kc public float a(long j, long j2) { if (this.h == C.TIME_UNSET) { return 1.0f; } b(j, j2); if (this.q != C.TIME_UNSET && SystemClock.elapsedRealtime() - this.q < this.c) { return this.p; } this.q = SystemClock.elapsedRealtime(); b(j); long j3 = j - this.m; if (Math.abs(j3) < this.e) { this.p = 1.0f; } else { this.p = xp.a((this.d * j3) + 1.0f, this.o, this.n); } return this.p; } private void b(long j) { long j2 = this.r + (this.s * 3); if (this.m > j2) { float a2 = t2.a(this.c); this.m = sc.a(j2, this.j, this.m - (((long) ((this.p - 1.0f) * a2)) + ((long) ((this.n - 1.0f) * a2)))); return; } long b2 = xp.b(j - ((long) (Math.max(0.0f, this.p - 1.0f) / this.d)), this.m, j2); this.m = b2; long j3 = this.l; if (j3 == C.TIME_UNSET || b2 <= j3) { return; } this.m = j3; } @Override // com.applovin.impl.kc public void a(td.f fVar) { this.h = t2.a(fVar.a); this.k = t2.a(fVar.b); this.l = t2.a(fVar.c); float f = fVar.d; if (f == -3.4028235E38f) { f = this.a; } this.o = f; float f2 = fVar.f; if (f2 == -3.4028235E38f) { f2 = this.b; } this.n = f2; c(); } private void b(long j, long j2) { long j3 = j - j2; long j4 = this.r; if (j4 == C.TIME_UNSET) { this.r = j3; this.s = 0L; } else { long max = Math.max(j3, a(j4, j3, this.g)); this.r = max; this.s = a(this.s, Math.abs(j3 - max), this.g); } } @Override // com.applovin.impl.kc public void a(long j) { this.i = j; c(); } }