package com.applovin.impl; import com.mbridge.msdk.playercommon.exoplayer2.extractor.ogg.OggPageHeader; import java.util.Arrays; /* loaded from: classes.dex */ final class ig { private final jg a = new jg(); private final bh b = new bh(new byte[OggPageHeader.MAX_PAGE_PAYLOAD], 0); private int c = -1; private int d; private boolean e; public jg a() { return this.a; } public bh b() { return this.b; } public void c() { this.a.a(); this.b.d(0); this.c = -1; this.e = false; } public void d() { if (this.b.c().length == 65025) { return; } bh bhVar = this.b; bhVar.a(Arrays.copyOf(bhVar.c(), Math.max(OggPageHeader.MAX_PAGE_PAYLOAD, this.b.e())), this.b.e()); } private int a(int i) { int i2; int i3 = 0; this.d = 0; do { int i4 = this.d; int i5 = i + i4; jg jgVar = this.a; if (i5 >= jgVar.g) { break; } int[] iArr = jgVar.j; this.d = i4 + 1; i2 = iArr[i5]; i3 += i2; } while (i2 == 255); return i3; } public boolean a(l8 l8Var) { int i; b1.b(l8Var != null); if (this.e) { this.e = false; this.b.d(0); } while (!this.e) { if (this.c < 0) { if (!this.a.a(l8Var) || !this.a.a(l8Var, true)) { return false; } jg jgVar = this.a; int i2 = jgVar.h; if ((jgVar.b & 1) == 1 && this.b.e() == 0) { i2 += a(0); i = this.d; } else { i = 0; } if (!n8.a(l8Var, i2)) { return false; } this.c = i; } int a = a(this.c); int i3 = this.c + this.d; if (a > 0) { bh bhVar = this.b; bhVar.a(bhVar.e() + a); if (!n8.b(l8Var, this.b.c(), this.b.e(), a)) { return false; } bh bhVar2 = this.b; bhVar2.e(bhVar2.e() + a); this.e = this.a.j[i3 + (-1)] != 255; } if (i3 == this.a.g) { i3 = -1; } this.c = i3; } return true; } }