package com.applovin.impl; import com.applovin.impl.i2; import com.mbridge.msdk.playercommon.exoplayer2.C; /* loaded from: classes.dex */ final class gi extends i2 { public gi(ho hoVar, long j, long j2) { super(new i2.b(), new b(hoVar), j, 0L, j + 1, 0L, j2, 188L, 1000); } public static final class b implements i2.f { private final ho a; private final bh b; private b(ho hoVar) { this.a = hoVar; this.b = new bh(); } @Override // com.applovin.impl.i2.f public void a() { this.b.a(xp.f); } private i2.e a(bh bhVar, long j, long j2) { int i = -1; int i2 = -1; long j3 = -9223372036854775807L; while (bhVar.a() >= 4) { if (gi.b(bhVar.c(), bhVar.d()) != 442) { bhVar.g(1); } else { bhVar.g(4); long c = hi.c(bhVar); if (c != C.TIME_UNSET) { long b = this.a.b(c); if (b > j) { if (j3 == C.TIME_UNSET) { return i2.e.a(b, j2); } return i2.e.a(j2 + i2); } if (100000 + b > j) { return i2.e.a(j2 + bhVar.d()); } i2 = bhVar.d(); j3 = b; } a(bhVar); i = bhVar.d(); } } if (j3 != C.TIME_UNSET) { return i2.e.b(j3, j2 + i); } return i2.e.d; } @Override // com.applovin.impl.i2.f public i2.e a(l8 l8Var, long j) { long f = l8Var.f(); int min = (int) Math.min(20000L, l8Var.a() - f); this.b.d(min); l8Var.c(this.b.c(), 0, min); return a(this.b, j, f); } private static void a(bh bhVar) { int b; int e = bhVar.e(); if (bhVar.a() < 10) { bhVar.f(e); return; } bhVar.g(9); int w = bhVar.w() & 7; if (bhVar.a() < w) { bhVar.f(e); return; } bhVar.g(w); if (bhVar.a() >= 4) { if (gi.b(bhVar.c(), bhVar.d()) == 443) { bhVar.g(4); int C = bhVar.C(); if (bhVar.a() < C) { bhVar.f(e); return; } bhVar.g(C); } while (bhVar.a() >= 4 && (b = gi.b(bhVar.c(), bhVar.d())) != 442 && b != 441 && (b >>> 8) == 1) { bhVar.g(4); if (bhVar.a() < 2) { bhVar.f(e); return; } bhVar.f(Math.min(bhVar.e(), bhVar.d() + bhVar.C())); } return; } bhVar.f(e); } } /* JADX INFO: Access modifiers changed from: private */ public static int b(byte[] bArr, int i) { return (bArr[i + 3] & 255) | ((bArr[i] & 255) << 24) | ((bArr[i + 1] & 255) << 16) | ((bArr[i + 2] & 255) << 8); } }