189 lines
8.7 KiB
Java
189 lines
8.7 KiB
Java
|
package o;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.graphics.Bitmap;
|
||
|
import android.graphics.BitmapFactory;
|
||
|
import android.opengl.EGL14;
|
||
|
import android.opengl.EGLDisplay;
|
||
|
import android.opengl.EGLSurface;
|
||
|
import android.opengl.GLES20;
|
||
|
import android.opengl.GLUtils;
|
||
|
import java.io.File;
|
||
|
import java.io.OutputStream;
|
||
|
import java.nio.ByteBuffer;
|
||
|
import java.util.concurrent.TimeoutException;
|
||
|
import o.C1083Vek;
|
||
|
import o.C6318cPT;
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public final class pFN implements utG {
|
||
|
@Override // o.utG
|
||
|
public final int b() {
|
||
|
return 2;
|
||
|
}
|
||
|
|
||
|
@Override // o.utG
|
||
|
public final void d(Context context, byte[] bArr, OutputStream outputStream, int i, int i2, int i3, int i4, boolean z, int i5) {
|
||
|
C14957gcv.e(context, "");
|
||
|
C14957gcv.e(bArr, "");
|
||
|
C14957gcv.e(outputStream, "");
|
||
|
C16886sAI c16886sAI = C16886sAI.a;
|
||
|
File e = C16886sAI.e(context);
|
||
|
String absolutePath = e.getAbsolutePath();
|
||
|
C14957gcv.c((Object) absolutePath, "");
|
||
|
BitmapFactory.Options options = new BitmapFactory.Options();
|
||
|
options.inJustDecodeBounds = false;
|
||
|
options.inPreferredConfig = Bitmap.Config.RGB_565;
|
||
|
options.inSampleSize = i5;
|
||
|
Bitmap decodeByteArray = BitmapFactory.decodeByteArray(bArr, 0, bArr.length, options);
|
||
|
C14957gcv.c(decodeByteArray, "");
|
||
|
Gm_(decodeByteArray, i, i2, i4, absolutePath, i3);
|
||
|
outputStream.write(C14888gbD.e(e));
|
||
|
}
|
||
|
|
||
|
private static void Gm_(Bitmap bitmap, int i, int i2, int i3, String str, int i4) {
|
||
|
ByteBuffer c;
|
||
|
float width = bitmap.getWidth();
|
||
|
float height = bitmap.getHeight();
|
||
|
C7280clM.c("src width = ".concat(String.valueOf(width)));
|
||
|
C7280clM.c("src height = ".concat(String.valueOf(height)));
|
||
|
float Gh_ = C9362diM.Gh_(bitmap, i, i2);
|
||
|
C7280clM.c("scale = ".concat(String.valueOf(Gh_)));
|
||
|
float f = width / Gh_;
|
||
|
float f2 = height / Gh_;
|
||
|
C7280clM.c("dst width = ".concat(String.valueOf(f)));
|
||
|
C7280clM.c("dst height = ".concat(String.valueOf(f2)));
|
||
|
Bitmap createScaledBitmap = Bitmap.createScaledBitmap(bitmap, (int) f, (int) f2, true);
|
||
|
C14957gcv.c(createScaledBitmap, "");
|
||
|
Bitmap Gl_ = C9362diM.Gl_(createScaledBitmap, i3);
|
||
|
C1083Vek.HBt hBt = new C1083Vek.HBt(str, Gl_.getWidth(), Gl_.getHeight(), (byte) 0);
|
||
|
if (i4 >= 0 && i4 <= 100) {
|
||
|
hBt.i = i4;
|
||
|
hBt.j = 1;
|
||
|
C1083Vek c1083Vek = new C1083Vek(hBt.f, hBt.a, hBt.f8421o, hBt.d, hBt.g, hBt.b, hBt.i, hBt.j, hBt.h, hBt.c, hBt.e);
|
||
|
if (c1083Vek.n) {
|
||
|
throw new IllegalStateException("Already started");
|
||
|
}
|
||
|
c1083Vek.n = true;
|
||
|
c1083Vek.b.b.start();
|
||
|
if (c1083Vek.n) {
|
||
|
if (c1083Vek.c == 2) {
|
||
|
synchronized (c1083Vek) {
|
||
|
C6318cPT c6318cPT = c1083Vek.b;
|
||
|
if (c6318cPT != null) {
|
||
|
if (c6318cPT.k != 2) {
|
||
|
throw new IllegalStateException("addBitmap is only allowed in bitmap input mode");
|
||
|
}
|
||
|
if (c6318cPT.d.b((((c6318cPT.l * 1000000) / c6318cPT.q) + 132) * 1000, ((((c6318cPT.l + c6318cPT.q) - 1) * 1000000) / c6318cPT.q) + 132)) {
|
||
|
synchronized (c6318cPT) {
|
||
|
sSl ssl = c6318cPT.a;
|
||
|
if (ssl != null) {
|
||
|
ssl.c();
|
||
|
nlo nloVar = c6318cPT.t;
|
||
|
int i5 = c6318cPT.s;
|
||
|
iPJ ipj = nloVar.b;
|
||
|
GLES20.glBindTexture(ipj.d, i5);
|
||
|
GLUtils.texImage2D(ipj.d, 0, Gl_, 0);
|
||
|
c6318cPT.b();
|
||
|
EGLDisplay eGLDisplay = c6318cPT.a.a;
|
||
|
EGLSurface eGLSurface = EGL14.EGL_NO_SURFACE;
|
||
|
if (!EGL14.eglMakeCurrent(eGLDisplay, eGLSurface, eGLSurface, EGL14.EGL_NO_CONTEXT)) {
|
||
|
throw new RuntimeException("eglMakeCurrent failed");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (c1083Vek.n) {
|
||
|
synchronized (c1083Vek) {
|
||
|
C6318cPT c6318cPT2 = c1083Vek.b;
|
||
|
if (c6318cPT2 != null) {
|
||
|
int i6 = c6318cPT2.k;
|
||
|
if (i6 == 2) {
|
||
|
C6318cPT.LWm lWm = c6318cPT2.d;
|
||
|
synchronized (lWm) {
|
||
|
if (lWm.d) {
|
||
|
if (lWm.e < 0) {
|
||
|
lWm.e = 0L;
|
||
|
}
|
||
|
} else if (lWm.a < 0) {
|
||
|
lWm.a = 0L;
|
||
|
}
|
||
|
lWm.c();
|
||
|
}
|
||
|
} else if (i6 == 0 && (c = c6318cPT2.c()) != null) {
|
||
|
c.clear();
|
||
|
c.flip();
|
||
|
synchronized (c6318cPT2.h) {
|
||
|
c6318cPT2.h.add(c);
|
||
|
}
|
||
|
c6318cPT2.m.post(new Runnable(c6318cPT2) { // from class: o.cPT.4
|
||
|
final C6318cPT c;
|
||
|
|
||
|
public AnonymousClass4(C6318cPT c6318cPT22) {
|
||
|
this.c = c6318cPT22;
|
||
|
}
|
||
|
|
||
|
@Override // java.lang.Runnable
|
||
|
public final void run() {
|
||
|
this.c.d();
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
C1083Vek.LWm lWm2 = c1083Vek.j;
|
||
|
synchronized (lWm2) {
|
||
|
long currentTimeMillis = System.currentTimeMillis();
|
||
|
for (long j = 5000; !lWm2.e && j > 0; j -= System.currentTimeMillis() - currentTimeMillis) {
|
||
|
try {
|
||
|
lWm2.wait(j);
|
||
|
} catch (InterruptedException unused) {
|
||
|
}
|
||
|
}
|
||
|
if (!lWm2.e) {
|
||
|
lWm2.e = true;
|
||
|
lWm2.a = new TimeoutException("timed out waiting for result");
|
||
|
}
|
||
|
Exception exc = lWm2.a;
|
||
|
if (exc != null) {
|
||
|
throw exc;
|
||
|
}
|
||
|
}
|
||
|
c1083Vek.e();
|
||
|
c1083Vek.b();
|
||
|
c1083Vek.close();
|
||
|
return;
|
||
|
}
|
||
|
throw new IllegalStateException("Already started");
|
||
|
}
|
||
|
StringBuilder sb = new StringBuilder("Not valid in input mode ");
|
||
|
sb.append(c1083Vek.c);
|
||
|
throw new IllegalStateException(sb.toString());
|
||
|
}
|
||
|
throw new IllegalStateException("Already started");
|
||
|
}
|
||
|
throw new IllegalArgumentException("Invalid quality: ".concat(String.valueOf(i4)));
|
||
|
}
|
||
|
|
||
|
@Override // o.utG
|
||
|
public final void d(Context context, String str, OutputStream outputStream, int i, int i2, int i3, int i4, boolean z, int i5, int i6) {
|
||
|
C14957gcv.e(context, "");
|
||
|
C14957gcv.e(str, "");
|
||
|
C14957gcv.e(outputStream, "");
|
||
|
C16886sAI c16886sAI = C16886sAI.a;
|
||
|
File e = C16886sAI.e(context);
|
||
|
String absolutePath = e.getAbsolutePath();
|
||
|
C14957gcv.c((Object) absolutePath, "");
|
||
|
BitmapFactory.Options options = new BitmapFactory.Options();
|
||
|
options.inJustDecodeBounds = false;
|
||
|
options.inPreferredConfig = Bitmap.Config.RGB_565;
|
||
|
options.inSampleSize = i5;
|
||
|
Bitmap decodeFile = BitmapFactory.decodeFile(str, options);
|
||
|
C14957gcv.c(decodeFile, "");
|
||
|
Gm_(decodeFile, i, i2, i4, absolutePath, i3);
|
||
|
outputStream.write(C14888gbD.e(e));
|
||
|
}
|
||
|
}
|