package n6; import android.graphics.ColorSpace; import android.graphics.ImageDecoder; import android.os.Build; import android.util.Log; import android.util.Size; import e6.i; import e6.j; import e6.k; import e6.l; import h6.h; import o6.m; import o6.q; /* loaded from: classes2.dex */ public abstract class a implements l { /* renamed from: a, reason: collision with root package name */ final q f12154a = q.h(); /* renamed from: n6.a$a, reason: collision with other inner class name */ class C0197a implements ImageDecoder.OnHeaderDecodedListener { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ int f12155a; /* renamed from: b, reason: collision with root package name */ final /* synthetic */ int f12156b; /* renamed from: c, reason: collision with root package name */ final /* synthetic */ boolean f12157c; /* renamed from: d, reason: collision with root package name */ final /* synthetic */ e6.b f12158d; /* renamed from: e, reason: collision with root package name */ final /* synthetic */ o6.l f12159e; /* renamed from: f, reason: collision with root package name */ final /* synthetic */ k f12160f; /* renamed from: n6.a$a$a, reason: collision with other inner class name */ class C0198a implements ImageDecoder.OnPartialImageListener { C0198a(C0197a c0197a) { } @Override // android.graphics.ImageDecoder.OnPartialImageListener public boolean onPartialImage(ImageDecoder.DecodeException decodeException) { return false; } } C0197a(int i10, int i11, boolean z10, e6.b bVar, o6.l lVar, k kVar) { this.f12155a = i10; this.f12156b = i11; this.f12157c = z10; this.f12158d = bVar; this.f12159e = lVar; this.f12160f = kVar; } @Override // android.graphics.ImageDecoder.OnHeaderDecodedListener public void onHeaderDecoded(ImageDecoder imageDecoder, ImageDecoder.ImageInfo imageInfo, ImageDecoder.Source source) { Size size; ColorSpace.Named named; ColorSpace colorSpace; ColorSpace colorSpace2; ColorSpace colorSpace3; ColorSpace colorSpace4; boolean isWideGamut; boolean z10 = false; if (a.this.f12154a.i(this.f12155a, this.f12156b, this.f12157c, false)) { imageDecoder.setAllocator(3); } else { imageDecoder.setAllocator(1); } if (this.f12158d == e6.b.PREFER_RGB_565) { imageDecoder.setMemorySizePolicy(0); } imageDecoder.setOnPartialImageListener(new C0198a(this)); size = imageInfo.getSize(); int i10 = this.f12155a; if (i10 == Integer.MIN_VALUE) { i10 = size.getWidth(); } int i11 = this.f12156b; if (i11 == Integer.MIN_VALUE) { i11 = size.getHeight(); } float b10 = this.f12159e.b(size.getWidth(), size.getHeight(), i10, i11); int round = Math.round(size.getWidth() * b10); int round2 = Math.round(size.getHeight() * b10); if (Log.isLoggable("ImageDecoder", 2)) { Log.v("ImageDecoder", "Resizing from [" + size.getWidth() + "x" + size.getHeight() + "] to [" + round + "x" + round2 + "] scaleFactor: " + b10); } imageDecoder.setTargetSize(round, round2); int i12 = Build.VERSION.SDK_INT; if (i12 < 28) { if (i12 >= 26) { named = ColorSpace.Named.SRGB; colorSpace = ColorSpace.get(named); imageDecoder.setTargetColorSpace(colorSpace); return; } return; } if (this.f12160f == k.DISPLAY_P3) { colorSpace3 = imageInfo.getColorSpace(); if (colorSpace3 != null) { colorSpace4 = imageInfo.getColorSpace(); isWideGamut = colorSpace4.isWideGamut(); if (isWideGamut) { z10 = true; } } } colorSpace2 = ColorSpace.get(z10 ? ColorSpace.Named.DISPLAY_P3 : ColorSpace.Named.SRGB); imageDecoder.setTargetColorSpace(colorSpace2); } } @Override // e6.l public /* bridge */ /* synthetic */ h a(Object obj, int i10, int i11, j jVar) { return d(y1.a.a(obj), i10, i11, jVar); } @Override // e6.l public /* bridge */ /* synthetic */ boolean b(Object obj, j jVar) { return e(y1.a.a(obj), jVar); } protected abstract h c(ImageDecoder.Source source, int i10, int i11, ImageDecoder.OnHeaderDecodedListener onHeaderDecodedListener); public final h d(ImageDecoder.Source source, int i10, int i11, j jVar) { e6.b bVar = (e6.b) jVar.d(m.f12751f); o6.l lVar = (o6.l) jVar.d(o6.l.f12746h); i iVar = m.f12755j; return c(source, i10, i11, new C0197a(i10, i11, jVar.d(iVar) != null && ((Boolean) jVar.d(iVar)).booleanValue(), bVar, lVar, (k) jVar.d(m.f12752g))); } public final boolean e(ImageDecoder.Source source, j jVar) { return true; } }