package o; import java.io.ByteArrayInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.channels.FileChannel; /* loaded from: classes6.dex */ public final class goV { private static final long e = Runtime.getRuntime().maxMemory(); public static int d(int i) { int i2 = 1; if (i > 127) { int i3 = 1; while (true) { i >>>= 8; if (i == 0) { break; } i3++; } for (int i4 = (i3 - 1) << 3; i4 >= 0; i4 -= 8) { i2++; } } return i2; } goV() { } /* JADX INFO: Access modifiers changed from: package-private */ public static int c(InputStream inputStream) { if (inputStream instanceof goU) { return ((goU) inputStream).d(); } if (!(inputStream instanceof C15348gnx)) { if (inputStream instanceof ByteArrayInputStream) { return ((ByteArrayInputStream) inputStream).available(); } if (inputStream instanceof FileInputStream) { try { FileChannel channel = ((FileInputStream) inputStream).getChannel(); long size = channel != null ? channel.size() : 2147483647L; if (size < 2147483647L) { return (int) size; } } catch (IOException unused) { } } long j = e; if (j > 2147483647L) { return Integer.MAX_VALUE; } return (int) j; } return ((C15348gnx) inputStream).a; } /* JADX INFO: Access modifiers changed from: package-private */ public static int a(int i) throws IOException { if (i < 31) { return 1; } if (i < 128) { return 2; } byte[] bArr = new byte[5]; int i2 = 4; bArr[4] = (byte) (i & 127); do { i >>= 7; i2--; bArr[i2] = (byte) ((i & 127) | 128); } while (i > 127); return 6 - i2; } }