438 lines
15 KiB
Java
438 lines
15 KiB
Java
package o;
|
|
|
|
import android.graphics.Rect;
|
|
import android.graphics.SurfaceTexture;
|
|
import android.media.MediaCodec;
|
|
import android.media.MediaFormat;
|
|
import android.opengl.EGL14;
|
|
import android.opengl.EGLDisplay;
|
|
import android.opengl.EGLExt;
|
|
import android.opengl.EGLSurface;
|
|
import android.opengl.GLES20;
|
|
import android.os.Handler;
|
|
import android.os.HandlerThread;
|
|
import android.view.Surface;
|
|
import com.kofax.mobile.sdk._internal.impl.extraction.rtti.RttiJsonExactionHelper;
|
|
import java.nio.Buffer;
|
|
import java.nio.ByteBuffer;
|
|
import java.nio.FloatBuffer;
|
|
import java.util.ArrayList;
|
|
import java.util.Objects;
|
|
|
|
/* renamed from: o.cPT, reason: case insensitive filesystem */
|
|
/* loaded from: classes.dex */
|
|
public final class C6318cPT implements AutoCloseable, SurfaceTexture.OnFrameAvailableListener {
|
|
private final Rect B;
|
|
private SurfaceTexture C;
|
|
public sSl a;
|
|
public MediaCodec b;
|
|
final Sts c;
|
|
public LWm d;
|
|
final int f;
|
|
final int g;
|
|
final int i;
|
|
final int j;
|
|
public final int k;
|
|
public int l;
|
|
public final Handler m;
|
|
final int n;
|
|
|
|
/* renamed from: o, reason: collision with root package name */
|
|
boolean f8616o;
|
|
final boolean p;
|
|
public final int q;
|
|
final int r;
|
|
public int s;
|
|
public nlo t;
|
|
private ByteBuffer u;
|
|
private final Rect v;
|
|
private final HandlerThread w;
|
|
private Surface x;
|
|
private Surface z;
|
|
private final ArrayList<ByteBuffer> y = new ArrayList<>();
|
|
public final ArrayList<ByteBuffer> h = new ArrayList<>();
|
|
final ArrayList<Integer> e = new ArrayList<>();
|
|
private final float[] A = new float[16];
|
|
|
|
/* renamed from: o.cPT$Sts */
|
|
/* loaded from: classes.dex */
|
|
public static abstract class Sts {
|
|
public abstract void a();
|
|
|
|
public abstract void c(ByteBuffer byteBuffer);
|
|
|
|
public abstract void zq_(MediaCodec.CodecException codecException);
|
|
|
|
public abstract void zr_(MediaFormat mediaFormat);
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:46:0x01be */
|
|
/* JADX WARN: Removed duplicated region for block: B:63:0x0261 */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public C6318cPT(int r20, int r21, boolean r22, int r23, int r24, android.os.Handler r25, o.C6318cPT.Sts r26) throws java.io.IOException {
|
|
/*
|
|
Method dump skipped, instructions count: 666
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: o.C6318cPT.<init>(int, int, boolean, int, int, android.os.Handler, o.cPT$Sts):void");
|
|
}
|
|
|
|
public final void b() {
|
|
GLES20.glViewport(0, 0, this.f, this.i);
|
|
for (int i = 0; i < this.g; i++) {
|
|
for (int i2 = 0; i2 < this.j; i2++) {
|
|
int i3 = this.f;
|
|
int i4 = i2 * i3;
|
|
int i5 = this.i;
|
|
int i6 = i * i5;
|
|
this.B.set(i4, i6, i3 + i4, i5 + i6);
|
|
nlo nloVar = this.t;
|
|
int i7 = this.s;
|
|
float[] fArr = iPJ.e;
|
|
Rect rect = this.B;
|
|
nloVar.a[0] = rect.left / nloVar.f;
|
|
nloVar.a[1] = 1.0f - (rect.bottom / nloVar.e);
|
|
nloVar.a[2] = rect.right / nloVar.f;
|
|
nloVar.a[3] = 1.0f - (rect.bottom / nloVar.e);
|
|
nloVar.a[4] = rect.left / nloVar.f;
|
|
nloVar.a[5] = 1.0f - (rect.top / nloVar.e);
|
|
nloVar.a[6] = rect.right / nloVar.f;
|
|
nloVar.a[7] = 1.0f - (rect.top / nloVar.e);
|
|
nloVar.d.put(nloVar.a);
|
|
nloVar.d.position(0);
|
|
iPJ ipj = nloVar.b;
|
|
float[] fArr2 = iPJ.c;
|
|
FloatBuffer floatBuffer = nlo.c;
|
|
FloatBuffer floatBuffer2 = nloVar.d;
|
|
iPJ.e("draw start");
|
|
GLES20.glUseProgram(ipj.b);
|
|
iPJ.e("glUseProgram");
|
|
GLES20.glActiveTexture(33984);
|
|
GLES20.glBindTexture(ipj.d, i7);
|
|
GLES20.glUniformMatrix4fv(ipj.f, 1, false, fArr2, 0);
|
|
iPJ.e("glUniformMatrix4fv");
|
|
GLES20.glUniformMatrix4fv(ipj.j, 1, false, fArr, 0);
|
|
iPJ.e("glUniformMatrix4fv");
|
|
GLES20.glEnableVertexAttribArray(ipj.a);
|
|
iPJ.e("glEnableVertexAttribArray");
|
|
GLES20.glVertexAttribPointer(ipj.a, 2, 5126, false, 8, (Buffer) floatBuffer);
|
|
iPJ.e("glVertexAttribPointer");
|
|
GLES20.glEnableVertexAttribArray(ipj.g);
|
|
iPJ.e("glEnableVertexAttribArray");
|
|
GLES20.glVertexAttribPointer(ipj.g, 2, 5126, false, 8, (Buffer) floatBuffer2);
|
|
iPJ.e("glVertexAttribPointer");
|
|
GLES20.glDrawArrays(5, 0, 4);
|
|
iPJ.e("glDrawArrays");
|
|
GLES20.glDisableVertexAttribArray(ipj.a);
|
|
GLES20.glDisableVertexAttribArray(ipj.g);
|
|
GLES20.glBindTexture(ipj.d, 0);
|
|
GLES20.glUseProgram(0);
|
|
sSl ssl = this.a;
|
|
int i8 = this.l;
|
|
this.l = i8 + 1;
|
|
EGLExt.eglPresentationTimeANDROID(ssl.a, ssl.c, (((i8 * 1000000) / this.q) + 132) * 1000);
|
|
sSl ssl2 = this.a;
|
|
EGL14.eglSwapBuffers(ssl2.a, ssl2.c);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.graphics.SurfaceTexture.OnFrameAvailableListener
|
|
public final void onFrameAvailable(SurfaceTexture surfaceTexture) {
|
|
synchronized (this) {
|
|
sSl ssl = this.a;
|
|
if (ssl == null) {
|
|
return;
|
|
}
|
|
ssl.c();
|
|
surfaceTexture.updateTexImage();
|
|
surfaceTexture.getTransformMatrix(this.A);
|
|
long timestamp = surfaceTexture.getTimestamp();
|
|
LWm lWm = this.d;
|
|
int i = this.l;
|
|
if (lWm.b(timestamp, ((((i + r4) - 1) * 1000000) / this.q) + 132)) {
|
|
b();
|
|
}
|
|
surfaceTexture.releaseTexImage();
|
|
EGLDisplay eGLDisplay = this.a.a;
|
|
EGLSurface eGLSurface = EGL14.EGL_NO_SURFACE;
|
|
if (EGL14.eglMakeCurrent(eGLDisplay, eGLSurface, eGLSurface, EGL14.EGL_NO_CONTEXT)) {
|
|
} else {
|
|
throw new RuntimeException("eglMakeCurrent failed");
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:79:0x014a, code lost:
|
|
|
|
throw new java.lang.IllegalArgumentException("src and dst rect size are different!");
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
final void d() {
|
|
/*
|
|
Method dump skipped, instructions count: 412
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: o.C6318cPT.d():void");
|
|
}
|
|
|
|
public final ByteBuffer c() {
|
|
ByteBuffer remove;
|
|
synchronized (this.y) {
|
|
while (!this.f8616o && this.y.isEmpty()) {
|
|
try {
|
|
this.y.wait();
|
|
} catch (InterruptedException unused) {
|
|
}
|
|
}
|
|
remove = this.f8616o ? null : this.y.remove(0);
|
|
}
|
|
return remove;
|
|
}
|
|
|
|
private ByteBuffer e() {
|
|
if (!this.f8616o && this.u == null) {
|
|
synchronized (this.h) {
|
|
this.u = this.h.isEmpty() ? null : this.h.remove(0);
|
|
}
|
|
}
|
|
if (this.f8616o) {
|
|
return null;
|
|
}
|
|
return this.u;
|
|
}
|
|
|
|
final void a() {
|
|
MediaCodec mediaCodec = this.b;
|
|
if (mediaCodec != null) {
|
|
mediaCodec.stop();
|
|
this.b.release();
|
|
this.b = null;
|
|
}
|
|
synchronized (this.y) {
|
|
this.f8616o = true;
|
|
this.y.notifyAll();
|
|
}
|
|
synchronized (this) {
|
|
nlo nloVar = this.t;
|
|
if (nloVar != null) {
|
|
if (nloVar.b != null) {
|
|
nloVar.b = null;
|
|
}
|
|
this.t = null;
|
|
}
|
|
sSl ssl = this.a;
|
|
if (ssl != null) {
|
|
if (!Objects.equals(ssl.a, EGL14.EGL_NO_DISPLAY)) {
|
|
EGL14.eglDestroySurface(ssl.a, ssl.c);
|
|
EGL14.eglDestroyContext(ssl.a, ssl.d);
|
|
EGL14.eglReleaseThread();
|
|
EGL14.eglTerminate(ssl.a);
|
|
}
|
|
ssl.e.release();
|
|
ssl.a = EGL14.EGL_NO_DISPLAY;
|
|
ssl.d = EGL14.EGL_NO_CONTEXT;
|
|
ssl.c = EGL14.EGL_NO_SURFACE;
|
|
ssl.e = null;
|
|
this.a = null;
|
|
}
|
|
SurfaceTexture surfaceTexture = this.C;
|
|
if (surfaceTexture != null) {
|
|
surfaceTexture.release();
|
|
this.C = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* renamed from: o.cPT$LWm */
|
|
/* loaded from: classes.dex */
|
|
public class LWm {
|
|
final C6318cPT c;
|
|
public final boolean d;
|
|
private boolean f;
|
|
public long e = -1;
|
|
private long j = -1;
|
|
public long a = -1;
|
|
private long h = -1;
|
|
long b = -1;
|
|
|
|
LWm(C6318cPT c6318cPT, boolean z) {
|
|
this.c = c6318cPT;
|
|
this.d = z;
|
|
}
|
|
|
|
public final boolean b(long j, long j2) {
|
|
boolean z;
|
|
synchronized (this) {
|
|
long j3 = this.e;
|
|
z = j3 < 0 || j <= j3;
|
|
if (z) {
|
|
this.h = j2;
|
|
}
|
|
this.j = j;
|
|
c();
|
|
}
|
|
return z;
|
|
}
|
|
|
|
public final void c() {
|
|
if (this.f) {
|
|
return;
|
|
}
|
|
if (this.a < 0) {
|
|
long j = this.e;
|
|
if (j >= 0 && this.j >= j) {
|
|
long j2 = this.h;
|
|
if (j2 >= 0) {
|
|
this.a = j2;
|
|
} else {
|
|
this.c.m.post(new Runnable(this) { // from class: o.cPT.LWm.1
|
|
final LWm a;
|
|
|
|
{
|
|
this.a = this;
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
if (this.a.c.b != null) {
|
|
this.a.c.b.signalEndOfInputStream();
|
|
}
|
|
}
|
|
});
|
|
this.f = true;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
long j3 = this.a;
|
|
if (j3 < 0 || j3 > this.b) {
|
|
return;
|
|
}
|
|
this.c.m.post(new Runnable(this) { // from class: o.cPT.LWm.1
|
|
final LWm a;
|
|
|
|
{
|
|
this.a = this;
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
if (this.a.c.b != null) {
|
|
this.a.c.b.signalEndOfInputStream();
|
|
}
|
|
}
|
|
});
|
|
this.f = true;
|
|
}
|
|
}
|
|
|
|
/* renamed from: o.cPT$RVV */
|
|
/* loaded from: classes.dex */
|
|
class RVV extends MediaCodec.Callback {
|
|
private boolean a;
|
|
final C6318cPT e;
|
|
|
|
RVV(C6318cPT c6318cPT) {
|
|
this.e = c6318cPT;
|
|
}
|
|
|
|
@Override // android.media.MediaCodec.Callback
|
|
public final void onOutputFormatChanged(MediaCodec mediaCodec, MediaFormat mediaFormat) {
|
|
if (mediaCodec != this.e.b) {
|
|
return;
|
|
}
|
|
if (!"image/vnd.android.heic".equals(mediaFormat.getString("mime"))) {
|
|
mediaFormat.setString("mime", "image/vnd.android.heic");
|
|
mediaFormat.setInteger(RttiJsonExactionHelper.WIDTH, this.e.r);
|
|
mediaFormat.setInteger(RttiJsonExactionHelper.HEIGHT, this.e.n);
|
|
if (this.e.p) {
|
|
mediaFormat.setInteger("tile-width", this.e.f);
|
|
mediaFormat.setInteger("tile-height", this.e.i);
|
|
mediaFormat.setInteger("grid-rows", this.e.g);
|
|
mediaFormat.setInteger("grid-cols", this.e.j);
|
|
}
|
|
}
|
|
this.e.c.zr_(mediaFormat);
|
|
}
|
|
|
|
@Override // android.media.MediaCodec.Callback
|
|
public final void onInputBufferAvailable(MediaCodec mediaCodec, int i) {
|
|
if (mediaCodec != this.e.b || this.e.f8616o) {
|
|
return;
|
|
}
|
|
this.e.e.add(Integer.valueOf(i));
|
|
this.e.d();
|
|
}
|
|
|
|
@Override // android.media.MediaCodec.Callback
|
|
public final void onOutputBufferAvailable(MediaCodec mediaCodec, int i, MediaCodec.BufferInfo bufferInfo) {
|
|
if (mediaCodec != this.e.b || this.a) {
|
|
return;
|
|
}
|
|
if (bufferInfo.size > 0 && (bufferInfo.flags & 2) == 0) {
|
|
ByteBuffer outputBuffer = mediaCodec.getOutputBuffer(i);
|
|
outputBuffer.position(bufferInfo.offset);
|
|
outputBuffer.limit(bufferInfo.offset + bufferInfo.size);
|
|
if (this.e.d != null) {
|
|
LWm lWm = this.e.d;
|
|
long j = bufferInfo.presentationTimeUs;
|
|
synchronized (lWm) {
|
|
lWm.b = j;
|
|
lWm.c();
|
|
}
|
|
}
|
|
this.e.c.c(outputBuffer);
|
|
}
|
|
this.a = ((bufferInfo.flags & 4) != 0) | this.a;
|
|
mediaCodec.releaseOutputBuffer(i, false);
|
|
if (this.a) {
|
|
zp_(null);
|
|
}
|
|
}
|
|
|
|
@Override // android.media.MediaCodec.Callback
|
|
public final void onError(MediaCodec mediaCodec, MediaCodec.CodecException codecException) {
|
|
if (mediaCodec != this.e.b) {
|
|
return;
|
|
}
|
|
zp_(codecException);
|
|
}
|
|
|
|
private void zp_(MediaCodec.CodecException codecException) {
|
|
this.e.a();
|
|
if (codecException == null) {
|
|
this.e.c.a();
|
|
} else {
|
|
this.e.c.zq_(codecException);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // java.lang.AutoCloseable
|
|
public final void close() {
|
|
synchronized (this.y) {
|
|
this.f8616o = true;
|
|
this.y.notifyAll();
|
|
}
|
|
this.m.postAtFrontOfQueue(new Runnable(this) { // from class: o.cPT.1
|
|
final C6318cPT b;
|
|
|
|
{
|
|
this.b = this;
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
this.b.a();
|
|
}
|
|
});
|
|
}
|
|
}
|