package com.applovin.impl; import android.graphics.SurfaceTexture; import android.media.MediaFormat; import android.opengl.GLES20; import android.opengl.Matrix; import java.util.Arrays; import java.util.concurrent.atomic.AtomicBoolean; /* loaded from: classes.dex */ final class dj implements uq, v2 { private int j; private SurfaceTexture k; private byte[] n; private final AtomicBoolean a = new AtomicBoolean(); private final AtomicBoolean b = new AtomicBoolean(true); private final ei c = new ei(); private final k9 d = new k9(); private final eo f = new eo(); private final eo g = new eo(); private final float[] h = new float[16]; private final float[] i = new float[16]; private volatile int l = 0; private int m = -1; public void a(int i) { this.l = i; } public SurfaceTexture b() { GLES20.glClearColor(0.5f, 0.5f, 0.5f, 1.0f); ba.a(); this.c.a(); ba.a(); this.j = ba.b(); SurfaceTexture surfaceTexture = new SurfaceTexture(this.j); this.k = surfaceTexture; surfaceTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() { // from class: com.applovin.impl.dj$$ExternalSyntheticLambda0 @Override // android.graphics.SurfaceTexture.OnFrameAvailableListener public final void onFrameAvailable(SurfaceTexture surfaceTexture2) { dj.this.a(surfaceTexture2); } }); return this.k; } public void a(float[] fArr, boolean z) { GLES20.glClear(16384); ba.a(); if (this.a.compareAndSet(true, false)) { ((SurfaceTexture) b1.a(this.k)).updateTexImage(); ba.a(); if (this.b.compareAndSet(true, false)) { Matrix.setIdentityM(this.h, 0); } long timestamp = this.k.getTimestamp(); Long l = (Long) this.f.b(timestamp); if (l != null) { this.d.a(this.h, l.longValue()); } ci ciVar = (ci) this.g.c(timestamp); if (ciVar != null) { this.c.b(ciVar); } } Matrix.multiplyMM(this.i, 0, fArr, 0, this.h, 0); this.c.a(this.j, this.i, z); } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void a(SurfaceTexture surfaceTexture) { this.a.set(true); } @Override // com.applovin.impl.v2 public void a(long j, float[] fArr) { this.d.a(j, fArr); } @Override // com.applovin.impl.v2 public void a() { this.f.a(); this.d.a(); this.b.set(true); } @Override // com.applovin.impl.uq public void a(long j, long j2, f9 f9Var, MediaFormat mediaFormat) { this.f.a(j2, Long.valueOf(j)); a(f9Var.w, f9Var.x, j2); } private void a(byte[] bArr, int i, long j) { byte[] bArr2 = this.n; int i2 = this.m; this.n = bArr; if (i == -1) { i = this.l; } this.m = i; if (i2 == i && Arrays.equals(bArr2, this.n)) { return; } byte[] bArr3 = this.n; ci a = bArr3 != null ? di.a(bArr3, this.m) : null; if (a == null || !ei.a(a)) { a = ci.a(this.m); } this.g.a(j, a); } }