package com.applovin.impl; import com.applovin.impl.dp; import com.mbridge.msdk.playercommon.exoplayer2.C; /* loaded from: classes.dex */ public final class e7 implements q7 { private final String b; private String c; private qo d; private int f; private int g; private long h; private f9 i; private int j; private final bh a = new bh(new byte[18]); private int e = 0; private long k = C.TIME_UNSET; @Override // com.applovin.impl.q7 public void a() { this.e = 0; this.f = 0; this.g = 0; this.k = C.TIME_UNSET; } @Override // com.applovin.impl.q7 public void a(long j, int i) { if (j != C.TIME_UNSET) { this.k = j; } } @Override // com.applovin.impl.q7 public void b() { } public e7(String str) { this.b = str; } @Override // com.applovin.impl.q7 public void a(bh bhVar) { b1.b(this.d); while (bhVar.a() > 0) { int i = this.e; if (i != 0) { if (i != 1) { if (i == 2) { int min = Math.min(bhVar.a(), this.j - this.f); this.d.a(bhVar, min); int i2 = this.f + min; this.f = i2; int i3 = this.j; if (i2 == i3) { long j = this.k; if (j != C.TIME_UNSET) { this.d.a(j, 1, i3, 0, null); this.k += this.h; } this.e = 0; } } else { throw new IllegalStateException(); } } else if (a(bhVar, this.a.c(), 18)) { c(); this.a.f(0); this.d.a(this.a, 18); this.e = 2; } } else if (b(bhVar)) { this.e = 1; } } } private boolean b(bh bhVar) { while (bhVar.a() > 0) { int i = this.g << 8; this.g = i; int w = i | bhVar.w(); this.g = w; if (f7.a(w)) { byte[] c = this.a.c(); int i2 = this.g; c[0] = (byte) ((i2 >> 24) & 255); c[1] = (byte) ((i2 >> 16) & 255); c[2] = (byte) ((i2 >> 8) & 255); c[3] = (byte) (i2 & 255); this.f = 4; this.g = 0; return true; } } return false; } private void c() { byte[] c = this.a.c(); if (this.i == null) { f9 a = f7.a(c, this.c, this.b, null); this.i = a; this.d.a(a); } this.j = f7.a(c); this.h = (int) ((f7.d(c) * 1000000) / this.i.A); } private boolean a(bh bhVar, byte[] bArr, int i) { int min = Math.min(bhVar.a(), i - this.f); bhVar.a(bArr, this.f, min); int i2 = this.f + min; this.f = i2; return i2 == i; } @Override // com.applovin.impl.q7 public void a(m8 m8Var, dp.d dVar) { dVar.a(); this.c = dVar.b(); this.d = m8Var.a(dVar.c(), 1); } }