package p138.p145.p146.p151.p160.p165;

import android.util.Log;
import com.bumptech.glide.load.ImageHeaderParser;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.List;
import p000.p001.p002.p003.p004.C0567;
import p138.p145.p146.p151.C2848;
import p138.p145.p146.p151.InterfaceC2850;
import p138.p145.p146.p151.p154.InterfaceC2932;
import p138.p145.p146.p151.p154.p155.InterfaceC2940;

/* JADX INFO: renamed from: ދ.ؠ.֏.ތ.ތ.ބ.އ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C3153 implements InterfaceC2850<InputStream, C3142> {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final List<ImageHeaderParser> f9415;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final InterfaceC2850<ByteBuffer, C3142> f9416;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final InterfaceC2940 f9417;

    public C3153(List<ImageHeaderParser> list, InterfaceC2850<ByteBuffer, C3142> interfaceC2850, InterfaceC2940 interfaceC2940) {
        this.f9415 = list;
        this.f9416 = interfaceC2850;
        this.f9417 = interfaceC2940;
    }

    /* JADX WARN: Removed duplicated region for block: B:16:0x0033  */
    /* JADX WARN: Removed duplicated region for block: B:21:? A[RETURN, SYNTHETIC] */
    @Override // p138.p145.p146.p151.InterfaceC2850
    /* JADX INFO: renamed from: ֏ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public InterfaceC2932<C3142> mo4981(InputStream inputStream, int i, int i2, C2848 c2848) {
        byte[] byteArray;
        byte[] bArr;
        InputStream inputStream2 = inputStream;
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(16384);
        try {
            bArr = new byte[16384];
        } catch (IOException e) {
            if (Log.isLoggable("StreamGifDecoder", 5)) {
                Log.w("StreamGifDecoder", "Error reading data from stream", e);
            }
            byteArray = null;
        }
        while (true) {
            int i3 = inputStream2.read(bArr);
            if (i3 == -1) {
                break;
            }
            byteArrayOutputStream.write(bArr, 0, i3);
            if (byteArray != null) {
                return null;
            }
            return this.f9416.mo4981(ByteBuffer.wrap(byteArray), i, i2, c2848);
        }
        byteArrayOutputStream.flush();
        byteArray = byteArrayOutputStream.toByteArray();
        if (byteArray != null) {
        }
    }

    @Override // p138.p145.p146.p151.InterfaceC2850
    /* JADX INFO: renamed from: ֏ */
    public boolean mo4982(InputStream inputStream, C2848 c2848) {
        return !((Boolean) c2848.m4979(C3152.f9414)).booleanValue() && C0567.m1909(this.f9415, inputStream, this.f9417) == ImageHeaderParser.ImageType.GIF;
    }
}
