package defpackage;

import android.graphics.ColorSpace;
import android.graphics.ImageDecoder;
import android.graphics.ImageDecoder$OnHeaderDecodedListener;
import android.os.Build;
import android.util.Log;
import android.util.Size;

/* renamed from: ˑˀᵬ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C2029 implements ImageDecoder$OnHeaderDecodedListener {

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final C0198 f8137;

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final EnumC1952 f8138;

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final boolean f8139;

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final int f8140;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final C4150 f8141 = C4150.m9049();

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final int f8142;

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final EnumC2855 f8143;

    public C2029(int i, int i2, C0210 c0210) {
        this.f8142 = i;
        this.f8140 = i2;
        this.f8143 = (EnumC2855) c0210.m1488(C4539.f16879);
        this.f8137 = (C0198) c0210.m1488(C0198.f1665);
        C3420 c3420 = C4539.f16880;
        this.f8139 = c0210.m1488(c3420) != null && ((Boolean) c0210.m1488(c3420)).booleanValue();
        this.f8138 = (EnumC1952) c0210.m1488(C4539.f16878);
    }

    public final void onHeaderDecoded(ImageDecoder imageDecoder, ImageDecoder.ImageInfo imageInfo, ImageDecoder.Source source) {
        C4150 c4150 = this.f8141;
        int width = this.f8142;
        int height = this.f8140;
        if (c4150.m9050(width, height, this.f8139, false)) {
            imageDecoder.setAllocator(3);
        } else {
            imageDecoder.setAllocator(1);
        }
        if (this.f8143 == EnumC2855.f11064) {
            imageDecoder.setMemorySizePolicy(0);
        }
        imageDecoder.setOnPartialImageListener(new C0426());
        Size size = imageInfo.getSize();
        if (width == Integer.MIN_VALUE) {
            width = size.getWidth();
        }
        if (height == Integer.MIN_VALUE) {
            height = size.getHeight();
        }
        float fM1465 = this.f8137.m1465(size.getWidth(), size.getHeight(), width, height);
        int iRound = Math.round(size.getWidth() * fM1465);
        int iRound2 = Math.round(fM1465 * size.getHeight());
        if (Log.isLoggable("ImageDecoder", 2)) {
            size.getWidth();
            size.getHeight();
        }
        imageDecoder.setTargetSize(iRound, iRound2);
        EnumC1952 enumC1952 = this.f8138;
        if (enumC1952 != null) {
            int i = Build.VERSION.SDK_INT;
            if (i >= 28) {
                imageDecoder.setTargetColorSpace(ColorSpace.get((enumC1952 == EnumC1952.f7865 && imageInfo.getColorSpace() != null && imageInfo.getColorSpace().isWideGamut()) ? ColorSpace.Named.DISPLAY_P3 : ColorSpace.Named.SRGB));
            } else if (i >= 26) {
                imageDecoder.setTargetColorSpace(ColorSpace.get(ColorSpace.Named.SRGB));
            }
        }
    }
}
