package o; import com.bumptech.glide.load.ImageHeaderParser; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.util.List; /* loaded from: classes.dex */ public final class hKF { /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public interface RVV { ImageHeaderParser.ImageType b(ImageHeaderParser imageHeaderParser) throws IOException; } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public interface Sts { int a(ImageHeaderParser imageHeaderParser) throws IOException; } public static ImageHeaderParser.ImageType a(List list, InputStream inputStream, Opg opg) throws IOException { if (inputStream == null) { return ImageHeaderParser.ImageType.UNKNOWN; } if (!inputStream.markSupported()) { inputStream = new C16158ljW(inputStream, opg); } inputStream.mark(5242880); return e(list, new RVV(inputStream) { // from class: o.hKF.1 private InputStream a; { this.a = inputStream; } @Override // o.hKF.RVV public final ImageHeaderParser.ImageType b(ImageHeaderParser imageHeaderParser) throws IOException { try { return imageHeaderParser.b(this.a); } finally { this.a.reset(); } } }); } /* renamed from: o.hKF$2, reason: invalid class name */ /* loaded from: classes.dex */ public class AnonymousClass2 implements RVV { private ByteBuffer e; public AnonymousClass2(ByteBuffer byteBuffer) { this.e = byteBuffer; } @Override // o.hKF.RVV public final ImageHeaderParser.ImageType b(ImageHeaderParser imageHeaderParser) throws IOException { try { return imageHeaderParser.a(this.e); } finally { Qeb.e(this.e); } } } public static ImageHeaderParser.ImageType e(List list, RVV rvv) throws IOException { int size = list.size(); for (int i = 0; i < size; i++) { ImageHeaderParser.ImageType b = rvv.b(list.get(i)); if (b != ImageHeaderParser.ImageType.UNKNOWN) { return b; } } return ImageHeaderParser.ImageType.UNKNOWN; } public static int c(List list, InputStream inputStream, Opg opg) throws IOException { if (inputStream == null) { return -1; } if (!inputStream.markSupported()) { inputStream = new C16158ljW(inputStream, opg); } inputStream.mark(5242880); return b(list, new Sts(inputStream, opg) { // from class: o.hKF.4 private Opg d; private InputStream e; { this.e = inputStream; this.d = opg; } @Override // o.hKF.Sts public final int a(ImageHeaderParser imageHeaderParser) throws IOException { try { return imageHeaderParser.a(this.e, this.d); } finally { this.e.reset(); } } }); } public static int b(List list, Sts sts) throws IOException { int size = list.size(); for (int i = 0; i < size; i++) { int a = sts.a(list.get(i)); if (a != -1) { return a; } } return -1; } }