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

import android.annotation.TargetApi;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.ColorSpace;
import android.graphics.Matrix;
import android.graphics.RectF;
import android.os.Build;
import android.util.DisplayMetrics;
import android.util.Log;
import com.bumptech.glide.load.ImageHeaderParser;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Queue;
import java.util.Set;
import p000.p001.p002.p003.p004.C0567;
import p138.p139.p143.p144.C2803;
import p138.p145.p146.p151.C2845;
import p138.p145.p146.p151.C2848;
import p138.p145.p146.p151.EnumC2841;
import p138.p145.p146.p151.EnumC2849;
import p138.p145.p146.p151.p154.InterfaceC2932;
import p138.p145.p146.p151.p154.p155.InterfaceC2940;
import p138.p145.p146.p151.p154.p155.InterfaceC2942;
import p138.p145.p146.p151.p160.p161.AbstractC3089;
import p138.p145.p146.p151.p160.p161.InterfaceC3104;
import p138.p145.p146.p174.C3236;
import p138.p145.p146.p174.C3240;

/* JADX INFO: renamed from: ދ.ؠ.֏.ތ.ތ.ހ.މ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C3095 {

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public static final C2845<EnumC2841> f9302 = C2845.m4977("com.bumptech.glide.load.resource.bitmap.Downsampler.DecodeFormat", EnumC2841.f8804);

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public static final C2845<EnumC2849> f9303 = C2845.m4977("com.bumptech.glide.load.resource.bitmap.Downsampler.PreferredColorSpace", EnumC2849.SRGB);

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public static final C2845<Boolean> f9304;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public static final C2845<Boolean> f9305;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public static final Set<String> f9306;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public static final InterfaceC3097 f9307;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public static final Set<ImageHeaderParser.ImageType> f9308;

    /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
    public static final Queue<BitmapFactory.Options> f9309;

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final InterfaceC2942 f9310;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final DisplayMetrics f9311;

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

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

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public final C3103 f9314 = C3103.m5185();

    /* JADX INFO: renamed from: ދ.ؠ.֏.ތ.ތ.ހ.މ$֏, reason: contains not printable characters */
    public class C3096 implements InterfaceC3097 {
        @Override // p138.p145.p146.p151.p160.p161.C3095.InterfaceC3097
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public void mo5182() {
        }

        @Override // p138.p145.p146.p151.p160.p161.C3095.InterfaceC3097
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public void mo5183(InterfaceC2942 interfaceC2942, Bitmap bitmap) {
        }
    }

    /* JADX INFO: renamed from: ދ.ؠ.֏.ތ.ތ.ހ.މ$ؠ, reason: contains not printable characters */
    public interface InterfaceC3097 {
        /* JADX INFO: renamed from: ֏ */
        void mo5182();

        /* JADX INFO: renamed from: ֏ */
        void mo5183(InterfaceC2942 interfaceC2942, Bitmap bitmap);
    }

    static {
        C2845<AbstractC3089> c2845 = AbstractC3089.f9297;
        f9304 = C2845.m4977("com.bumptech.glide.load.resource.bitmap.Downsampler.FixBitmapSize", false);
        f9305 = C2845.m4977("com.bumptech.glide.load.resource.bitmap.Downsampler.AllowHardwareDecode", false);
        f9306 = Collections.unmodifiableSet(new HashSet(Arrays.asList("image/vnd.wap.wbmp", "image/x-ico")));
        f9307 = new C3096();
        f9308 = Collections.unmodifiableSet(EnumSet.of(ImageHeaderParser.ImageType.JPEG, ImageHeaderParser.ImageType.PNG_A, ImageHeaderParser.ImageType.PNG));
        f9309 = C3240.m5334(0);
    }

    public C3095(List<ImageHeaderParser> list, DisplayMetrics displayMetrics, InterfaceC2942 interfaceC2942, InterfaceC2940 interfaceC2940) {
        this.f9313 = list;
        C0567.m1858(displayMetrics, "Argument must not be null");
        this.f9311 = displayMetrics;
        C0567.m1858(interfaceC2942, "Argument must not be null");
        this.f9310 = interfaceC2942;
        C0567.m1858(interfaceC2940, "Argument must not be null");
        this.f9312 = interfaceC2940;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static int m5169(double d) {
        if (d > 1.0d) {
            d = 1.0d / d;
        }
        return (int) Math.round(d * 2.147483647E9d);
    }

    /* JADX WARN: Code restructure failed: missing block: B:28:?, code lost:
    
        throw r1;
     */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static Bitmap m5170(InterfaceC3104 interfaceC3104, BitmapFactory.Options options, InterfaceC3097 interfaceC3097, InterfaceC2942 interfaceC2942) {
        if (!options.inJustDecodeBounds) {
            interfaceC3097.mo5182();
            interfaceC3104.mo5189();
        }
        int i = options.outWidth;
        int i2 = options.outHeight;
        String str = options.outMimeType;
        C3115.f9351.lock();
        try {
            try {
                Bitmap bitmapMo5188 = interfaceC3104.mo5188(options);
                C3115.f9351.unlock();
                return bitmapMo5188;
            } catch (IllegalArgumentException e) {
                IOException iOExceptionM5172 = m5172(e, i, i2, str, options);
                if (Log.isLoggable("Downsampler", 3)) {
                    Log.d("Downsampler", "Failed to decode with inBitmap, trying again without Bitmap re-use", iOExceptionM5172);
                }
                if (options.inBitmap == null) {
                    throw iOExceptionM5172;
                }
                try {
                    interfaceC2942.mo5088(options.inBitmap);
                    options.inBitmap = null;
                    Bitmap bitmapM5170 = m5170(interfaceC3104, options, interfaceC3097, interfaceC2942);
                    C3115.f9351.unlock();
                    return bitmapM5170;
                } catch (IOException unused) {
                    throw iOExceptionM5172;
                }
            }
        } catch (Throwable th) {
            C3115.f9351.unlock();
            throw th;
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static synchronized BitmapFactory.Options m5171() {
        BitmapFactory.Options optionsPoll;
        synchronized (f9309) {
            optionsPoll = f9309.poll();
        }
        if (optionsPoll == null) {
            optionsPoll = new BitmapFactory.Options();
            m5177(optionsPoll);
        }
        return optionsPoll;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static IOException m5172(IllegalArgumentException illegalArgumentException, int i, int i2, String str, BitmapFactory.Options options) {
        StringBuilder sbM4890 = C2803.m4890("Exception decoding bitmap, outWidth: ", i, ", outHeight: ", i2, ", outMimeType: ");
        sbM4890.append(str);
        sbM4890.append(", inBitmap: ");
        sbM4890.append(m5173(options.inBitmap));
        return new IOException(sbM4890.toString(), illegalArgumentException);
    }

    @TargetApi(19)
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static String m5173(Bitmap bitmap) {
        if (bitmap == null) {
            return null;
        }
        StringBuilder sbM4889 = C2803.m4889(" (");
        sbM4889.append(bitmap.getAllocationByteCount());
        sbM4889.append(")");
        String string = sbM4889.toString();
        StringBuilder sbM48892 = C2803.m4889("[");
        sbM48892.append(bitmap.getWidth());
        sbM48892.append("x");
        sbM48892.append(bitmap.getHeight());
        sbM48892.append("] ");
        sbM48892.append(bitmap.getConfig());
        sbM48892.append(string);
        return sbM48892.toString();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static void m5174(BitmapFactory.Options options) {
        m5177(options);
        synchronized (f9309) {
            f9309.offer(options);
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static boolean m5175(int i) {
        return i == 90 || i == 270;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static int m5176(double d) {
        return (int) (d + 0.5d);
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static void m5177(BitmapFactory.Options options) {
        options.inTempStorage = null;
        options.inDither = false;
        options.inScaled = false;
        options.inSampleSize = 1;
        options.inPreferredConfig = null;
        options.inJustDecodeBounds = false;
        options.inDensity = 0;
        options.inTargetDensity = 0;
        if (Build.VERSION.SDK_INT >= 26) {
            options.inPreferredColorSpace = null;
            options.outColorSpace = null;
            options.outConfig = null;
        }
        options.outWidth = 0;
        options.outHeight = 0;
        options.outMimeType = null;
        options.inBitmap = null;
        options.inMutable = true;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static int[] m5178(InterfaceC3104 interfaceC3104, BitmapFactory.Options options, InterfaceC3097 interfaceC3097, InterfaceC2942 interfaceC2942) {
        options.inJustDecodeBounds = true;
        m5170(interfaceC3104, options, interfaceC3097, interfaceC2942);
        options.inJustDecodeBounds = false;
        return new int[]{options.outWidth, options.outHeight};
    }

    /* JADX WARN: Removed duplicated region for block: B:108:0x02d4  */
    /* JADX WARN: Removed duplicated region for block: B:110:0x02dd  */
    /* JADX WARN: Removed duplicated region for block: B:111:0x02df  */
    /* JADX WARN: Removed duplicated region for block: B:132:0x032c  */
    /* JADX WARN: Removed duplicated region for block: B:138:0x0338  */
    /* JADX WARN: Removed duplicated region for block: B:140:0x033b  */
    /* JADX WARN: Removed duplicated region for block: B:141:0x0343  */
    /* JADX WARN: Removed duplicated region for block: B:144:0x036d  */
    /* JADX WARN: Removed duplicated region for block: B:150:0x03b3  */
    /* JADX WARN: Removed duplicated region for block: B:154:0x03bd  */
    /* JADX WARN: Removed duplicated region for block: B:156:0x03c0  */
    /* JADX WARN: Removed duplicated region for block: B:160:0x03ce  */
    /* JADX WARN: Removed duplicated region for block: B:172:0x03ef  */
    /* JADX WARN: Removed duplicated region for block: B:176:0x040b  */
    /* JADX WARN: Removed duplicated region for block: B:178:0x048f  */
    /* JADX WARN: Removed duplicated region for block: B:198:0x052a A[ORIG_RETURN, RETURN] */
    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$UnknownArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Bitmap m5179(InterfaceC3104 interfaceC3104, BitmapFactory.Options options, AbstractC3089 abstractC3089, EnumC2841 enumC2841, EnumC2849 enumC2849, boolean z, int i, int i2, boolean z2, InterfaceC3097 interfaceC3097) {
        int i3;
        long j;
        int i4;
        boolean z3;
        String str;
        String str2;
        int i5;
        String str3;
        int iRound;
        String str4;
        int i6;
        int i7;
        int i8;
        boolean zM5187;
        String str5;
        boolean zHasAlpha;
        int iRound2;
        int i9;
        int i10;
        Bitmap bitmapM5170;
        boolean z4;
        Bitmap bitmap;
        ColorSpace colorSpace;
        Bitmap.Config config;
        String str6;
        String str7;
        int i11;
        int i12;
        int iMax;
        int iFloor;
        double dFloor;
        int iRound3;
        long jM5320 = C3236.m5320();
        int[] iArrM5178 = m5178(interfaceC3104, options, interfaceC3097, this.f9310);
        int i13 = iArrM5178[0];
        int i14 = iArrM5178[1];
        String str8 = options.outMimeType;
        boolean z5 = (i13 == -1 || i14 == -1) ? false : z;
        int iMo5190 = interfaceC3104.mo5190();
        switch (iMo5190) {
            case 3:
            case 4:
                i3 = 180;
                break;
            case 5:
            case 6:
                i3 = 90;
                break;
            case 7:
            case 8:
                i3 = 270;
                break;
            default:
                i3 = 0;
                break;
        }
        switch (iMo5190) {
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
                j = jM5320;
                i4 = iMo5190;
                z3 = true;
                break;
            default:
                j = jM5320;
                i4 = iMo5190;
                z3 = false;
                break;
        }
        int i15 = i == Integer.MIN_VALUE ? m5175(i3) ? i14 : i13 : i;
        int i16 = i2 == Integer.MIN_VALUE ? m5175(i3) ? i13 : i14 : i2;
        ImageHeaderParser.ImageType imageTypeMo5191 = interfaceC3104.mo5191();
        InterfaceC2942 interfaceC2942 = this.f9310;
        boolean z6 = z5;
        boolean z7 = z3;
        if (i13 <= 0) {
            str = "Downsampler";
            str2 = ", target density: ";
            i5 = i14;
            str3 = "]";
            iRound = i16;
            str4 = ", density: ";
            i6 = i13;
            i7 = i15;
            i8 = 3;
        } else {
            if (i14 > 0) {
                if (m5175(i3)) {
                    str6 = "]";
                    str7 = ", density: ";
                    i12 = i14;
                    i11 = i13;
                } else {
                    str6 = "]";
                    str7 = ", density: ";
                    i11 = i14;
                    i12 = i13;
                }
                float fMo5168 = abstractC3089.mo5168(i12, i11, i15, i16);
                if (fMo5168 <= 0.0f) {
                    throw new IllegalArgumentException("Cannot scale with factor: " + fMo5168 + " from: " + abstractC3089 + ", source: [" + i13 + "x" + i14 + "], target: [" + i15 + "x" + i16 + str6);
                }
                int i17 = i3;
                AbstractC3089.EnumC3094 enumC3094Mo5167 = abstractC3089.mo5167(i12, i11, i15, i16);
                if (enumC3094Mo5167 == null) {
                    throw new IllegalArgumentException("Cannot round with null rounding");
                }
                float f = i12;
                float f2 = i11;
                int i18 = i16;
                int i19 = i15;
                int iM5176 = i12 / m5176(fMo5168 * f);
                int iM51762 = i11 / m5176(fMo5168 * f2);
                int iMax2 = enumC3094Mo5167 == AbstractC3089.EnumC3094.MEMORY ? Math.max(iM5176, iM51762) : Math.min(iM5176, iM51762);
                if (Build.VERSION.SDK_INT > 23 || !f9306.contains(options.outMimeType)) {
                    iMax = Math.max(1, Integer.highestOneBit(iMax2));
                    if (enumC3094Mo5167 == AbstractC3089.EnumC3094.MEMORY && iMax < 1.0f / fMo5168) {
                        iMax <<= 1;
                    }
                } else {
                    iMax = 1;
                }
                options.inSampleSize = iMax;
                if (imageTypeMo5191 == ImageHeaderParser.ImageType.JPEG) {
                    float fMin = Math.min(iMax, 8);
                    iFloor = (int) Math.ceil(f / fMin);
                    iRound3 = (int) Math.ceil(f2 / fMin);
                    int i20 = iMax / 8;
                    if (i20 > 0) {
                        iFloor /= i20;
                        iRound3 /= i20;
                    }
                } else {
                    if (imageTypeMo5191 == ImageHeaderParser.ImageType.PNG || imageTypeMo5191 == ImageHeaderParser.ImageType.PNG_A) {
                        float f3 = iMax;
                        iFloor = (int) Math.floor(f / f3);
                        dFloor = Math.floor(f2 / f3);
                    } else if (imageTypeMo5191 == ImageHeaderParser.ImageType.WEBP || imageTypeMo5191 == ImageHeaderParser.ImageType.WEBP_A) {
                        if (Build.VERSION.SDK_INT >= 24) {
                            float f4 = iMax;
                            iFloor = Math.round(f / f4);
                            iRound3 = Math.round(f2 / f4);
                        } else {
                            float f5 = iMax;
                            iFloor = (int) Math.floor(f / f5);
                            dFloor = Math.floor(f2 / f5);
                        }
                    } else if (i12 % iMax == 0 && i11 % iMax == 0) {
                        iFloor = i12 / iMax;
                        iRound3 = i11 / iMax;
                    } else {
                        int[] iArrM51782 = m5178(interfaceC3104, options, interfaceC3097, interfaceC2942);
                        iFloor = iArrM51782[0];
                        iRound3 = iArrM51782[1];
                    }
                    iRound3 = (int) dFloor;
                }
                i7 = i19;
                iRound = i18;
                double dMo5168 = abstractC3089.mo5168(iFloor, iRound3, i7, iRound);
                int iM5169 = m5169(dMo5168);
                int iM51763 = m5176(((double) iM5169) * dMo5168);
                options.inTargetDensity = m5176((dMo5168 / ((double) (iM51763 / iM5169))) * ((double) iM51763));
                int iM51692 = m5169(dMo5168);
                options.inDensity = iM51692;
                int i21 = options.inTargetDensity;
                if (i21 > 0 && iM51692 > 0 && i21 != iM51692) {
                    options.inScaled = true;
                } else {
                    options.inTargetDensity = 0;
                    options.inDensity = 0;
                }
                str = "Downsampler";
                if (Log.isLoggable(str, 2)) {
                    i5 = i14;
                    i6 = i13;
                    StringBuilder sbM4890 = C2803.m4890("Calculate scaling, source: [", i6, "x", i5, "], degreesToRotate: ");
                    sbM4890.append(i17);
                    sbM4890.append(", target: [");
                    sbM4890.append(i7);
                    sbM4890.append("x");
                    sbM4890.append(iRound);
                    sbM4890.append("], power of two scaled: [");
                    sbM4890.append(iFloor);
                    sbM4890.append("x");
                    sbM4890.append(iRound3);
                    sbM4890.append("], exact scale factor: ");
                    sbM4890.append(fMo5168);
                    sbM4890.append(", power of 2 sample size: ");
                    sbM4890.append(iMax);
                    sbM4890.append(", adjusted scale factor: ");
                    sbM4890.append(dMo5168);
                    str2 = ", target density: ";
                    sbM4890.append(str2);
                    sbM4890.append(options.inTargetDensity);
                    str4 = str7;
                    sbM4890.append(str4);
                    sbM4890.append(options.inDensity);
                    Log.v(str, sbM4890.toString());
                } else {
                    str4 = str7;
                    str2 = ", target density: ";
                    i5 = i14;
                    i6 = i13;
                }
                zM5187 = this.f9314.m5187(i7, iRound, z6, z7);
                if (zM5187) {
                    options.inPreferredConfig = Bitmap.Config.HARDWARE;
                    options.inMutable = false;
                }
                if (zM5187) {
                    str5 = str2;
                    if (enumC2841 != EnumC2841.PREFER_ARGB_8888) {
                        try {
                            zHasAlpha = interfaceC3104.mo5191().hasAlpha();
                        } catch (IOException e) {
                            if (Log.isLoggable(str, 3)) {
                                Log.d(str, "Cannot determine whether the image has alpha or not from header, format " + enumC2841, e);
                            }
                            zHasAlpha = false;
                        }
                        Bitmap.Config config2 = zHasAlpha ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
                        options.inPreferredConfig = config2;
                        if (config2 == Bitmap.Config.RGB_565) {
                            options.inDither = true;
                        }
                    } else {
                        options.inPreferredConfig = Bitmap.Config.ARGB_8888;
                    }
                } else {
                    str5 = str2;
                }
                int i22 = options.inSampleSize;
                if (i6 >= 0 || i5 < 0 || !z2) {
                    int i23 = options.inTargetDensity;
                    float f6 = !(i23 <= 0 && (i9 = options.inDensity) > 0 && i23 != i9) ? options.inTargetDensity / options.inDensity : 1.0f;
                    int i24 = options.inSampleSize;
                    float f7 = i24;
                    int iCeil = (int) Math.ceil(i6 / f7);
                    int iCeil2 = (int) Math.ceil(i5 / f7);
                    iRound2 = Math.round(iCeil * f6);
                    iRound = Math.round(iCeil2 * f6);
                    if (Log.isLoggable(str, 2)) {
                        StringBuilder sbM48902 = C2803.m4890("Calculated target [", iRound2, "x", iRound, "] for source [");
                        sbM48902.append(i6);
                        sbM48902.append("x");
                        sbM48902.append(i5);
                        sbM48902.append("], sampleSize: ");
                        sbM48902.append(i24);
                        sbM48902.append(", targetDensity: ");
                        sbM48902.append(options.inTargetDensity);
                        sbM48902.append(str4);
                        sbM48902.append(options.inDensity);
                        sbM48902.append(", density multiplier: ");
                        sbM48902.append(f6);
                        Log.v(str, sbM48902.toString());
                    }
                } else {
                    iRound2 = i7;
                }
                if (iRound2 > 0 && iRound > 0) {
                    InterfaceC2942 interfaceC29422 = this.f9310;
                    if (Build.VERSION.SDK_INT < 26) {
                        config = options.inPreferredConfig != Bitmap.Config.HARDWARE ? options.outConfig : null;
                    }
                    if (config == null) {
                        config = options.inPreferredConfig;
                    }
                    options.inBitmap = interfaceC29422.mo5089(iRound2, iRound, config);
                }
                i10 = Build.VERSION.SDK_INT;
                if (i10 < 28) {
                    options.inPreferredColorSpace = ColorSpace.get(enumC2849 == EnumC2849.DISPLAY_P3 && (colorSpace = options.outColorSpace) != null && colorSpace.isWideGamut() ? ColorSpace.Named.DISPLAY_P3 : ColorSpace.Named.SRGB);
                } else if (i10 >= 26) {
                    options.inPreferredColorSpace = ColorSpace.get(ColorSpace.Named.SRGB);
                }
                bitmapM5170 = m5170(interfaceC3104, options, interfaceC3097, this.f9310);
                interfaceC3097.mo5183(this.f9310, bitmapM5170);
                if (Log.isLoggable(str, 2)) {
                    StringBuilder sbM4889 = C2803.m4889("Decoded ");
                    sbM4889.append(m5173(bitmapM5170));
                    sbM4889.append(" from [");
                    sbM4889.append(i6);
                    sbM4889.append("x");
                    sbM4889.append(i5);
                    sbM4889.append("] ");
                    sbM4889.append(str8);
                    sbM4889.append(" with inBitmap ");
                    sbM4889.append(m5173(options.inBitmap));
                    sbM4889.append(" for [");
                    sbM4889.append(i);
                    sbM4889.append("x");
                    sbM4889.append(i2);
                    sbM4889.append("], sample size: ");
                    sbM4889.append(options.inSampleSize);
                    sbM4889.append(str4);
                    sbM4889.append(options.inDensity);
                    sbM4889.append(str5);
                    sbM4889.append(options.inTargetDensity);
                    sbM4889.append(", thread: ");
                    sbM4889.append(Thread.currentThread().getName());
                    sbM4889.append(", duration: ");
                    sbM4889.append(C3236.m5319(j));
                    Log.v(str, sbM4889.toString());
                }
                if (bitmapM5170 != null) {
                    return null;
                }
                bitmapM5170.setDensity(this.f9311.densityDpi);
                InterfaceC2942 interfaceC29423 = this.f9310;
                switch (i4) {
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                    case 6:
                    case 7:
                    case 8:
                        z4 = true;
                        break;
                    default:
                        z4 = false;
                        break;
                }
                if (z4) {
                    Matrix matrix = new Matrix();
                    switch (i4) {
                        case 2:
                            matrix.setScale(-1.0f, 1.0f);
                            break;
                        case 3:
                            matrix.setRotate(180.0f);
                            break;
                        case 4:
                            matrix.setRotate(180.0f);
                            matrix.postScale(-1.0f, 1.0f);
                            break;
                        case 5:
                            matrix.setRotate(90.0f);
                            matrix.postScale(-1.0f, 1.0f);
                            break;
                        case 6:
                            matrix.setRotate(90.0f);
                            break;
                        case 7:
                            matrix.setRotate(-90.0f);
                            matrix.postScale(-1.0f, 1.0f);
                            break;
                        case 8:
                            matrix.setRotate(-90.0f);
                            break;
                    }
                    RectF rectF = new RectF(0.0f, 0.0f, bitmapM5170.getWidth(), bitmapM5170.getHeight());
                    matrix.mapRect(rectF);
                    Bitmap bitmapMo5085 = interfaceC29423.mo5085(Math.round(rectF.width()), Math.round(rectF.height()), C3115.m5197(bitmapM5170));
                    matrix.postTranslate(-rectF.left, -rectF.top);
                    bitmapMo5085.setHasAlpha(bitmapM5170.hasAlpha());
                    C3115.m5199(bitmapM5170, bitmapMo5085, matrix);
                    bitmap = bitmapMo5085;
                } else {
                    bitmap = bitmapM5170;
                }
                if (bitmapM5170.equals(bitmap)) {
                    return bitmap;
                }
                this.f9310.mo5088(bitmapM5170);
                return bitmap;
            }
            i8 = 3;
            str = "Downsampler";
            str2 = ", target density: ";
            i5 = i14;
            str3 = "]";
            iRound = i16;
            str4 = ", density: ";
            i6 = i13;
            i7 = i15;
        }
        if (Log.isLoggable(str, i8)) {
            Log.d(str, "Unable to determine dimensions for: " + imageTypeMo5191 + " with target [" + i7 + "x" + iRound + str3);
        }
        zM5187 = this.f9314.m5187(i7, iRound, z6, z7);
        if (zM5187) {
        }
        if (zM5187) {
        }
        int i222 = options.inSampleSize;
        if (i6 >= 0) {
            int i232 = options.inTargetDensity;
            if (i232 <= 0) {
                if (!(i232 <= 0 && (i9 = options.inDensity) > 0 && i232 != i9)) {
                }
                int i242 = options.inSampleSize;
                float f72 = i242;
                int iCeil3 = (int) Math.ceil(i6 / f72);
                int iCeil22 = (int) Math.ceil(i5 / f72);
                iRound2 = Math.round(iCeil3 * f6);
                iRound = Math.round(iCeil22 * f6);
                if (Log.isLoggable(str, 2)) {
                }
            }
        }
        if (iRound2 > 0) {
            InterfaceC2942 interfaceC294222 = this.f9310;
            if (Build.VERSION.SDK_INT < 26) {
            }
            if (config == null) {
            }
            options.inBitmap = interfaceC294222.mo5089(iRound2, iRound, config);
        }
        i10 = Build.VERSION.SDK_INT;
        if (i10 < 28) {
        }
        bitmapM5170 = m5170(interfaceC3104, options, interfaceC3097, this.f9310);
        interfaceC3097.mo5183(this.f9310, bitmapM5170);
        if (Log.isLoggable(str, 2)) {
        }
        if (bitmapM5170 != null) {
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public InterfaceC2932<Bitmap> m5180(InputStream inputStream, int i, int i2, C2848 c2848, InterfaceC3097 interfaceC3097) {
        return m5181(new InterfaceC3104.C3105(inputStream, this.f9313, this.f9312), i, i2, c2848, interfaceC3097);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final InterfaceC2932<Bitmap> m5181(InterfaceC3104 interfaceC3104, int i, int i2, C2848 c2848, InterfaceC3097 interfaceC3097) {
        byte[] bArr = (byte[]) this.f9312.mo5081(65536, byte[].class);
        BitmapFactory.Options optionsM5171 = m5171();
        optionsM5171.inTempStorage = bArr;
        EnumC2841 enumC2841 = (EnumC2841) c2848.m4979(f9302);
        EnumC2849 enumC2849 = (EnumC2849) c2848.m4979(f9303);
        try {
            return C3083.m5166(m5179(interfaceC3104, optionsM5171, (AbstractC3089) c2848.m4979(AbstractC3089.f9297), enumC2841, enumC2849, c2848.m4979(f9305) != null && ((Boolean) c2848.m4979(f9305)).booleanValue(), i, i2, ((Boolean) c2848.m4979(f9304)).booleanValue(), interfaceC3097), this.f9310);
        } finally {
            m5174(optionsM5171);
            this.f9312.mo5080(bArr);
        }
    }
}
