package b.f.j.p; import b.f.d.g.g; import b.f.d.g.i; import b.f.j.d.f; import b.f.j.j.e; import b.f.j.p.c0; import b.f.j.s.c; import b.f.j.s.d; import com.facebook.common.references.CloseableReference; import com.facebook.imagepipeline.memory.MemoryPooledByteBufferOutputStream; import com.facebook.imagepipeline.request.ImageRequest; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.concurrent.Executor; /* compiled from: ResizeAndRotateProducer */ public class c1 implements w0 { public final Executor a; /* renamed from: b reason: collision with root package name */ public final g f604b; public final w0 c; public final boolean d; public final c e; /* compiled from: ResizeAndRotateProducer */ public class a extends p { public final boolean c; public final c d; public final x0 e; public boolean f = false; public final c0 g; /* compiled from: ResizeAndRotateProducer */ /* renamed from: b.f.j.p.c1$a$a reason: collision with other inner class name */ public class C0066a implements c0.c { public C0066a(c1 c1Var) { } @Override // b.f.j.p.c0.c public void a(e eVar, int i) { a aVar = a.this; c cVar = aVar.d; eVar.x(); b.f.j.s.b createImageTranscoder = cVar.createImageTranscoder(eVar.l, a.this.c); Objects.requireNonNull(createImageTranscoder); aVar.e.o().e(aVar.e, "ResizeAndRotateProducer"); ImageRequest e = aVar.e.e(); i a = c1.this.f604b.a(); try { b.f.j.s.a c = createImageTranscoder.c(eVar, a, e.k, e.j, null, 85); if (c.a != 2) { Map n = aVar.n(eVar, e.j, c, createImageTranscoder.a()); CloseableReference A = CloseableReference.A(((MemoryPooledByteBufferOutputStream) a).b()); try { e eVar2 = new e(A); eVar2.l = b.f.i.b.a; try { eVar2.q(); aVar.e.o().j(aVar.e, "ResizeAndRotateProducer", n); if (c.a != 1) { i |= 16; } aVar.f629b.b(eVar2, i); a.close(); } finally { eVar2.close(); } } finally { if (A != null) { A.close(); } } } else { throw new RuntimeException("Error while transcoding the image"); } } catch (Exception e2) { aVar.e.o().k(aVar.e, "ResizeAndRotateProducer", e2, null); if (b.e(i)) { aVar.f629b.c(e2); } } catch (Throwable th) { a.close(); throw th; } } } /* compiled from: ResizeAndRotateProducer */ public class b extends e { public final /* synthetic */ l a; public b(c1 c1Var, l lVar) { this.a = lVar; } @Override // b.f.j.p.y0 public void a() { a.this.g.a(); a.this.f = true; this.a.d(); } @Override // b.f.j.p.e, b.f.j.p.y0 public void b() { if (a.this.e.p()) { a.this.g.d(); } } } public a(l lVar, x0 x0Var, boolean z2, c cVar) { super(lVar); this.e = x0Var; Objects.requireNonNull(x0Var.e()); this.c = z2; this.d = cVar; this.g = new c0(c1.this.a, new C0066a(c1.this), 100); x0Var.f(new b(c1.this, lVar)); } /* JADX WARNING: Code restructure failed: missing block: B:22:0x0075, code lost: if (r6 != false) goto L_0x0077; */ @Override // b.f.j.p.b public void i(Object obj, int i) { b.f.d.l.a aVar; boolean z2; boolean z3; e eVar = (e) obj; b.f.d.l.a aVar2 = b.f.d.l.a.UNSET; if (!this.f) { boolean e = b.e(i); boolean z4 = true; if (eVar != null) { eVar.x(); b.f.i.c cVar = eVar.l; ImageRequest e2 = this.e.e(); b.f.j.s.b createImageTranscoder = this.d.createImageTranscoder(cVar, this.c); Objects.requireNonNull(createImageTranscoder); eVar.x(); if (eVar.l == b.f.i.c.a) { aVar = aVar2; } else { eVar.x(); if (!createImageTranscoder.d(eVar.l)) { aVar = b.f.d.l.a.NO; } else { f fVar = e2.k; if (!fVar.d) { if (d.b(fVar, eVar) == 0) { if (!fVar.b() || fVar.d) { eVar.n = 0; z3 = false; } else { b.f.d.d.e eVar2 = d.a; eVar.x(); z3 = eVar2.contains(Integer.valueOf(eVar.n)); } } z2 = true; if (!z2 && !createImageTranscoder.b(eVar, e2.k, e2.j)) { z4 = false; } aVar = b.f.d.l.a.f(z4); } z2 = false; z4 = false; aVar = b.f.d.l.a.f(z4); } } if (!e && aVar == aVar2) { return; } if (aVar != b.f.d.l.a.YES) { if (cVar != b.f.i.b.a && cVar != b.f.i.b.k) { f fVar2 = this.e.e().k; if (!fVar2.c() && fVar2.b()) { int a = fVar2.a(); eVar = e.a(eVar); if (eVar != null) { eVar.m = a; } } } else if (!this.e.e().k.d) { eVar.x(); if (eVar.m != 0) { eVar.x(); if (!(eVar.m == -1 || (eVar = e.a(eVar)) == null)) { eVar.m = 0; } } } this.f629b.b(eVar, i); } else if (this.g.f(eVar, i)) { if (e || this.e.p()) { this.g.d(); } } } else if (e) { this.f629b.b(null, 1); } } } public final Map n(e eVar, b.f.j.d.e eVar2, b.f.j.s.a aVar, String str) { String str2; long j; if (!this.e.o().g(this.e, "ResizeAndRotateProducer")) { return null; } StringBuilder sb = new StringBuilder(); eVar.x(); sb.append(eVar.o); sb.append("x"); eVar.x(); sb.append(eVar.p); String sb2 = sb.toString(); if (eVar2 != null) { str2 = eVar2.a + "x" + eVar2.f563b; } else { str2 = "Unspecified"; } HashMap hashMap = new HashMap(); eVar.x(); hashMap.put("Image format", String.valueOf(eVar.l)); hashMap.put("Original size", sb2); hashMap.put("Requested size", str2); c0 c0Var = this.g; synchronized (c0Var) { j = c0Var.j - c0Var.i; } hashMap.put("queueTime", String.valueOf(j)); hashMap.put("Transcoder id", str); hashMap.put("Transcoding result", String.valueOf(aVar)); return new b.f.d.d.f(hashMap); } } public c1(Executor executor, g gVar, w0 w0Var, boolean z2, c cVar) { Objects.requireNonNull(executor); this.a = executor; Objects.requireNonNull(gVar); this.f604b = gVar; Objects.requireNonNull(w0Var); this.c = w0Var; Objects.requireNonNull(cVar); this.e = cVar; this.d = z2; } @Override // b.f.j.p.w0 public void b(l lVar, x0 x0Var) { this.c.b(new a(lVar, x0Var, this.d, this.e), x0Var); } }