package o; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.ParcelFileDescriptor; import com.bumptech.glide.load.ImageHeaderParser; import com.bumptech.glide.load.data.ParcelFileDescriptorRewinder; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.util.List; import o.hKF; /* loaded from: classes.dex */ interface zSt { Bitmap EU_(BitmapFactory.Options options) throws IOException; int a() throws IOException; ImageHeaderParser.ImageType b() throws IOException; void c(); /* loaded from: classes.dex */ public static final class LWm implements zSt { private final ByteBuffer a; private final List c; private final Opg e; @Override // o.zSt public final void c() { } /* JADX INFO: Access modifiers changed from: package-private */ public LWm(ByteBuffer byteBuffer, List list, Opg opg) { this.a = byteBuffer; this.c = list; this.e = opg; } @Override // o.zSt public final Bitmap EU_(BitmapFactory.Options options) { return BitmapFactory.decodeStream(Qeb.a(Qeb.e(this.a)), null, options); } @Override // o.zSt public final ImageHeaderParser.ImageType b() throws IOException { List list = this.c; ByteBuffer e = Qeb.e(this.a); if (e == null) { return ImageHeaderParser.ImageType.UNKNOWN; } return hKF.e(list, new hKF.AnonymousClass2(e)); } @Override // o.zSt public final int a() throws IOException { List list = this.c; ByteBuffer e = Qeb.e(this.a); Opg opg = this.e; if (e == null) { return -1; } return hKF.b(list, new hKF.Sts(e, opg) { // from class: o.hKF.5 private ByteBuffer a; private Opg b; public AnonymousClass5(ByteBuffer e2, Opg opg2) { this.a = e2; this.b = opg2; } @Override // o.hKF.Sts public final int a(ImageHeaderParser imageHeaderParser) throws IOException { try { return imageHeaderParser.d(this.a, this.b); } finally { Qeb.e(this.a); } } }); } } /* loaded from: classes.dex */ public static final class Sts implements zSt { private final Opg a; private final Hwg b; private final List d; /* JADX INFO: Access modifiers changed from: package-private */ public Sts(InputStream inputStream, List list, Opg opg) { if (opg == null) { throw new NullPointerException("Argument must not be null"); } this.a = opg; if (list != null) { this.d = list; this.b = new Hwg(inputStream, opg); return; } throw new NullPointerException("Argument must not be null"); } @Override // o.zSt public final Bitmap EU_(BitmapFactory.Options options) throws IOException { Hwg hwg = this.b; hwg.a.reset(); return BitmapFactory.decodeStream(hwg.a, null, options); } @Override // o.zSt public final ImageHeaderParser.ImageType b() throws IOException { List list = this.d; Hwg hwg = this.b; hwg.a.reset(); return hKF.a(list, hwg.a, this.a); } @Override // o.zSt public final int a() throws IOException { List list = this.d; Hwg hwg = this.b; hwg.a.reset(); return hKF.c(list, hwg.a, this.a); } @Override // o.zSt public final void c() { C16158ljW c16158ljW = this.b.a; synchronized (c16158ljW) { c16158ljW.e = c16158ljW.c.length; } } } /* loaded from: classes.dex */ public static final class RVV implements zSt { private final ParcelFileDescriptorRewinder c; private final Opg d; private final List e; @Override // o.zSt public final void c() { } /* JADX INFO: Access modifiers changed from: package-private */ public RVV(ParcelFileDescriptor parcelFileDescriptor, List list, Opg opg) { if (opg == null) { throw new NullPointerException("Argument must not be null"); } this.d = opg; if (list != null) { this.e = list; this.c = new ParcelFileDescriptorRewinder(parcelFileDescriptor); return; } throw new NullPointerException("Argument must not be null"); } @Override // o.zSt public final Bitmap EU_(BitmapFactory.Options options) throws IOException { return BitmapFactory.decodeFileDescriptor(this.c.d.rewind().getFileDescriptor(), null, options); } @Override // o.zSt public final int a() throws IOException { return hKF.b(this.e, new hKF.Sts(this.c, this.d) { // from class: o.hKF.9 private ParcelFileDescriptorRewinder a; private Opg d; public AnonymousClass9(ParcelFileDescriptorRewinder parcelFileDescriptorRewinder, Opg opg) { this.a = parcelFileDescriptorRewinder; this.d = opg; } @Override // o.hKF.Sts public final int a(ImageHeaderParser imageHeaderParser) throws IOException { C16158ljW c16158ljW; try { c16158ljW = new C16158ljW(new FileInputStream(this.a.d.rewind().getFileDescriptor()), this.d); try { int a = imageHeaderParser.a(c16158ljW, this.d); c16158ljW.a(); this.a.d.rewind(); return a; } catch (Throwable th) { th = th; if (c16158ljW != null) { c16158ljW.a(); } this.a.d.rewind(); throw th; } } catch (Throwable th2) { th = th2; c16158ljW = null; } } }); } @Override // o.zSt public final ImageHeaderParser.ImageType b() throws IOException { return hKF.e(this.e, new hKF.RVV(this.c, this.d) { // from class: o.hKF.3 private ParcelFileDescriptorRewinder a; private Opg d; public AnonymousClass3(ParcelFileDescriptorRewinder parcelFileDescriptorRewinder, Opg opg) { this.a = parcelFileDescriptorRewinder; this.d = opg; } @Override // o.hKF.RVV public final ImageHeaderParser.ImageType b(ImageHeaderParser imageHeaderParser) throws IOException { C16158ljW c16158ljW; try { c16158ljW = new C16158ljW(new FileInputStream(this.a.d.rewind().getFileDescriptor()), this.d); try { ImageHeaderParser.ImageType b = imageHeaderParser.b(c16158ljW); c16158ljW.a(); this.a.d.rewind(); return b; } catch (Throwable th) { th = th; if (c16158ljW != null) { c16158ljW.a(); } this.a.d.rewind(); throw th; } } catch (Throwable th2) { th = th2; c16158ljW = null; } } }); } } }