package o; import java.io.IOException; import java.io.OutputStream; /* loaded from: classes6.dex */ public class gnG { public OutputStream a; public gnG(OutputStream outputStream) { this.a = outputStream; } public final void d(int i) throws IOException { if (i > 127) { int i2 = i; int i3 = 1; while (true) { i2 >>>= 8; if (i2 == 0) { break; } else { i3++; } } a((byte) (i3 | 128)); for (int i4 = (i3 - 1) << 3; i4 >= 0; i4 -= 8) { a((byte) (i >> i4)); } return; } a((byte) i); } public void a(int i) throws IOException { this.a.write(i); } /* JADX INFO: Access modifiers changed from: package-private */ public final void b(int i, int i2) throws IOException { if (i2 < 31) { a(i | i2); return; } a(i | 31); if (i2 < 128) { a(i2); return; } byte[] bArr = new byte[5]; int i3 = 4; bArr[4] = (byte) (i2 & 127); do { i2 >>= 7; i3--; bArr[i3] = (byte) ((i2 & 127) | 128); } while (i2 > 127); this.a.write(bArr, i3, 5 - i3); } public void d(InterfaceC15342gnr interfaceC15342gnr) throws IOException { if (interfaceC15342gnr != null) { interfaceC15342gnr.i().c(this); return; } throw new IOException("null object detected"); } /* JADX INFO: Access modifiers changed from: package-private */ public gnG d() { return new C15383gow(this.a); } /* JADX INFO: Access modifiers changed from: package-private */ public gnG e() { return new goK(this.a); } /* loaded from: classes6.dex */ class LWm extends gnG { private boolean c; private gnG e; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ public LWm(gnG gng, OutputStream outputStream) { super(outputStream); this.e = gng; this.c = true; } @Override // o.gnG public final void a(int i) throws IOException { if (this.c) { this.c = false; } else { super.a(i); } } } }