package p138.p145.p146.p151.p160;

import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.graphics.ColorSpace;
import android.graphics.ImageDecoder;
import android.os.Build;
import android.util.Log;
import android.util.Size;
import java.io.IOException;
import p138.p139.p143.p144.C2803;
import p138.p145.p146.p151.C2848;
import p138.p145.p146.p151.EnumC2841;
import p138.p145.p146.p151.EnumC2849;
import p138.p145.p146.p151.InterfaceC2850;
import p138.p145.p146.p151.p154.InterfaceC2932;
import p138.p145.p146.p151.p160.p161.AbstractC3089;
import p138.p145.p146.p151.p160.p161.C3082;
import p138.p145.p146.p151.p160.p161.C3083;
import p138.p145.p146.p151.p160.p161.C3095;
import p138.p145.p146.p151.p160.p161.C3103;

/* JADX INFO: renamed from: ދ.ؠ.֏.ތ.ތ.֏, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public abstract class AbstractC3075<T> implements InterfaceC2850<ImageDecoder.Source, T> {

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

    /* JADX INFO: renamed from: ދ.ؠ.֏.ތ.ތ.֏$֏, reason: contains not printable characters */
    public class C3076 implements ImageDecoder.OnHeaderDecodedListener {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final /* synthetic */ int f9270;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final /* synthetic */ int f9271;

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public final /* synthetic */ boolean f9272;

        /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
        public final /* synthetic */ EnumC2841 f9273;

        /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
        public final /* synthetic */ AbstractC3089 f9274;

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public final /* synthetic */ EnumC2849 f9275;

        /* JADX INFO: renamed from: ދ.ؠ.֏.ތ.ތ.֏$֏$֏, reason: contains not printable characters */
        public class C3077 implements ImageDecoder.OnPartialImageListener {
            public C3077(C3076 c3076) {
            }

            @Override // android.graphics.ImageDecoder.OnPartialImageListener
            public boolean onPartialImage(ImageDecoder.DecodeException decodeException) {
                return false;
            }
        }

        public C3076(int i, int i2, boolean z, EnumC2841 enumC2841, AbstractC3089 abstractC3089, EnumC2849 enumC2849) {
            this.f9270 = i;
            this.f9271 = i2;
            this.f9272 = z;
            this.f9273 = enumC2841;
            this.f9274 = abstractC3089;
            this.f9275 = enumC2849;
        }

        @Override // android.graphics.ImageDecoder.OnHeaderDecodedListener
        @SuppressLint({"Override"})
        public void onHeaderDecoded(ImageDecoder imageDecoder, ImageDecoder.ImageInfo imageInfo, ImageDecoder.Source source) {
            boolean z = false;
            if (AbstractC3075.this.f9269.m5187(this.f9270, this.f9271, this.f9272, false)) {
                imageDecoder.setAllocator(3);
            } else {
                imageDecoder.setAllocator(1);
            }
            if (this.f9273 == EnumC2841.PREFER_RGB_565) {
                imageDecoder.setMemorySizePolicy(0);
            }
            imageDecoder.setOnPartialImageListener(new C3077(this));
            Size size = imageInfo.getSize();
            int width = this.f9270;
            if (width == Integer.MIN_VALUE) {
                width = size.getWidth();
            }
            int height = this.f9271;
            if (height == Integer.MIN_VALUE) {
                height = size.getHeight();
            }
            float fMo5168 = this.f9274.mo5168(size.getWidth(), size.getHeight(), width, height);
            int iRound = Math.round(size.getWidth() * fMo5168);
            int iRound2 = Math.round(size.getHeight() * fMo5168);
            if (Log.isLoggable("ImageDecoder", 2)) {
                StringBuilder sbM4889 = C2803.m4889("Resizing from [");
                sbM4889.append(size.getWidth());
                sbM4889.append("x");
                sbM4889.append(size.getHeight());
                sbM4889.append("] to [");
                sbM4889.append(iRound);
                sbM4889.append("x");
                sbM4889.append(iRound2);
                sbM4889.append("] scaleFactor: ");
                sbM4889.append(fMo5168);
                Log.v("ImageDecoder", sbM4889.toString());
            }
            imageDecoder.setTargetSize(iRound, iRound2);
            int i = Build.VERSION.SDK_INT;
            if (i < 28) {
                if (i >= 26) {
                    imageDecoder.setTargetColorSpace(ColorSpace.get(ColorSpace.Named.SRGB));
                }
            } else {
                if (this.f9275 == EnumC2849.DISPLAY_P3 && imageInfo.getColorSpace() != null && imageInfo.getColorSpace().isWideGamut()) {
                    z = true;
                }
                imageDecoder.setTargetColorSpace(ColorSpace.get(z ? ColorSpace.Named.DISPLAY_P3 : ColorSpace.Named.SRGB));
            }
        }
    }

    @Override // p138.p145.p146.p151.InterfaceC2850
    /* JADX INFO: renamed from: ֏, reason: avoid collision after fix types in other method and contains not printable characters and merged with bridge method [inline-methods] */
    public final InterfaceC2932<T> mo4981(ImageDecoder.Source source, int i, int i2, C2848 c2848) throws IOException {
        C3082 c3082 = (C3082) this;
        Bitmap bitmapDecodeBitmap = ImageDecoder.decodeBitmap(source, new C3076(i, i2, c2848.m4979(C3095.f9305) != null && ((Boolean) c2848.m4979(C3095.f9305)).booleanValue(), (EnumC2841) c2848.m4979(C3095.f9302), (AbstractC3089) c2848.m4979(AbstractC3089.f9297), (EnumC2849) c2848.m4979(C3095.f9303)));
        if (Log.isLoggable("BitmapImageDecoder", 2)) {
            StringBuilder sbM4889 = C2803.m4889("Decoded [");
            sbM4889.append(bitmapDecodeBitmap.getWidth());
            sbM4889.append("x");
            sbM4889.append(bitmapDecodeBitmap.getHeight());
            sbM4889.append("] for [");
            sbM4889.append(i);
            sbM4889.append("x");
            sbM4889.append(i2);
            sbM4889.append("]");
            Log.v("BitmapImageDecoder", sbM4889.toString());
        }
        return new C3083(bitmapDecodeBitmap, c3082.f9285);
    }

    @Override // p138.p145.p146.p151.InterfaceC2850
    /* JADX INFO: renamed from: ֏ */
    public boolean mo4982(ImageDecoder.Source source, C2848 c2848) {
        return true;
    }
}
