package sh;

import android.graphics.Bitmap;
import java.io.IOException;
import java.io.InputStream;
import sh.m;

/* loaded from: classes4.dex */
public class y implements jh.j {

    /* renamed from: a, reason: collision with root package name */
    private final m f35783a;

    /* renamed from: b, reason: collision with root package name */
    private final mh.b f35784b;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static class a implements m.b {

        /* renamed from: a, reason: collision with root package name */
        private final w f35785a;

        /* renamed from: b, reason: collision with root package name */
        private final ei.d f35786b;

        a(w wVar, ei.d dVar) {
            this.f35785a = wVar;
            this.f35786b = dVar;
        }

        @Override // sh.m.b
        public void a(mh.d dVar, Bitmap bitmap) {
            IOException a10 = this.f35786b.a();
            if (a10 != null) {
                if (bitmap == null) {
                    throw a10;
                }
                dVar.c(bitmap);
                throw a10;
            }
        }

        @Override // sh.m.b
        public void b() {
            this.f35785a.b();
        }
    }

    public y(m mVar, mh.b bVar) {
        this.f35783a = mVar;
        this.f35784b = bVar;
    }

    @Override // jh.j
    /* renamed from: c, reason: merged with bridge method [inline-methods] */
    public lh.v a(InputStream inputStream, int i10, int i11, jh.h hVar) {
        boolean z10;
        w wVar;
        if (inputStream instanceof w) {
            wVar = (w) inputStream;
            z10 = false;
        } else {
            z10 = true;
            wVar = new w(inputStream, this.f35784b);
        }
        ei.d b10 = ei.d.b(wVar);
        try {
            return this.f35783a.e(new ei.i(b10), i10, i11, hVar, new a(wVar, b10));
        } finally {
            b10.release();
            if (z10) {
                wVar.release();
            }
        }
    }

    @Override // jh.j
    /* renamed from: d, reason: merged with bridge method [inline-methods] */
    public boolean b(InputStream inputStream, jh.h hVar) {
        return this.f35783a.p(inputStream);
    }
}
