140 lines
5 KiB
Java
140 lines
5 KiB
Java
|
package c.o.a.v;
|
||
|
|
||
|
import android.graphics.Rect;
|
||
|
import android.graphics.YuvImage;
|
||
|
import android.hardware.Camera;
|
||
|
import androidx.annotation.NonNull;
|
||
|
import c.i.a.f.e.o.c;
|
||
|
import c.o.a.l;
|
||
|
import c.o.a.n.b;
|
||
|
import c.o.a.r.g;
|
||
|
import java.io.ByteArrayOutputStream;
|
||
|
/* compiled from: Snapshot1PictureRecorder */
|
||
|
public class e extends i {
|
||
|
public b m;
|
||
|
public Camera n;
|
||
|
public c.o.a.x.a o;
|
||
|
public int p;
|
||
|
|
||
|
/* compiled from: Snapshot1PictureRecorder */
|
||
|
public class a implements Camera.PreviewCallback {
|
||
|
|
||
|
/* compiled from: Snapshot1PictureRecorder */
|
||
|
/* renamed from: c.o.a.v.e$a$a reason: collision with other inner class name */
|
||
|
public class RunnableC0169a implements Runnable {
|
||
|
public final /* synthetic */ byte[] i;
|
||
|
public final /* synthetic */ c.o.a.x.b j;
|
||
|
public final /* synthetic */ int k;
|
||
|
public final /* synthetic */ c.o.a.x.b l;
|
||
|
|
||
|
public RunnableC0169a(byte[] bArr, c.o.a.x.b bVar, int i, c.o.a.x.b bVar2) {
|
||
|
this.i = bArr;
|
||
|
this.j = bVar;
|
||
|
this.k = i;
|
||
|
this.l = bVar2;
|
||
|
}
|
||
|
|
||
|
@Override // java.lang.Runnable
|
||
|
public void run() {
|
||
|
byte[] bArr;
|
||
|
byte[] bArr2 = this.i;
|
||
|
c.o.a.x.b bVar = this.j;
|
||
|
int i = this.k;
|
||
|
if (i == 0) {
|
||
|
bArr = bArr2;
|
||
|
} else if (i % 90 != 0 || i < 0 || i > 270) {
|
||
|
throw new IllegalArgumentException("0 <= rotation < 360, rotation % 90 == 0");
|
||
|
} else {
|
||
|
int i2 = bVar.i;
|
||
|
int i3 = bVar.j;
|
||
|
byte[] bArr3 = new byte[bArr2.length];
|
||
|
int i4 = i2 * i3;
|
||
|
boolean z2 = i % 180 != 0;
|
||
|
boolean z3 = i % 270 != 0;
|
||
|
boolean z4 = i >= 180;
|
||
|
for (int i5 = 0; i5 < i3; i5++) {
|
||
|
for (int i6 = 0; i6 < i2; i6++) {
|
||
|
int i7 = (i5 * i2) + i6;
|
||
|
int i8 = ((i5 >> 1) * i2) + i4 + (i6 & -2);
|
||
|
int i9 = i8 + 1;
|
||
|
int i10 = z2 ? i3 : i2;
|
||
|
int i11 = z2 ? i2 : i3;
|
||
|
int i12 = z2 ? i5 : i6;
|
||
|
int i13 = z2 ? i6 : i5;
|
||
|
if (z3) {
|
||
|
i12 = (i10 - i12) - 1;
|
||
|
}
|
||
|
if (z4) {
|
||
|
i13 = (i11 - i13) - 1;
|
||
|
}
|
||
|
int i14 = ((i13 >> 1) * i10) + i4 + (i12 & -2);
|
||
|
bArr3[(i13 * i10) + i12] = (byte) (bArr2[i7] & 255);
|
||
|
bArr3[i14] = (byte) (bArr2[i8] & 255);
|
||
|
bArr3[i14 + 1] = (byte) (bArr2[i9] & 255);
|
||
|
}
|
||
|
}
|
||
|
bArr = bArr3;
|
||
|
}
|
||
|
int i15 = e.this.p;
|
||
|
c.o.a.x.b bVar2 = this.l;
|
||
|
YuvImage yuvImage = new YuvImage(bArr, i15, bVar2.i, bVar2.j, null);
|
||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||
|
Rect v = c.v(this.l, e.this.o);
|
||
|
yuvImage.compressToJpeg(v, 90, byteArrayOutputStream);
|
||
|
byte[] byteArray = byteArrayOutputStream.toByteArray();
|
||
|
l.a aVar = e.this.i;
|
||
|
aVar.f = byteArray;
|
||
|
aVar.d = new c.o.a.x.b(v.width(), v.height());
|
||
|
e eVar = e.this;
|
||
|
eVar.i.f1473c = 0;
|
||
|
eVar.b();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public a() {
|
||
|
}
|
||
|
|
||
|
@Override // android.hardware.Camera.PreviewCallback
|
||
|
public void onPreviewFrame(@NonNull byte[] bArr, Camera camera) {
|
||
|
e.this.a(false);
|
||
|
e eVar = e.this;
|
||
|
l.a aVar = eVar.i;
|
||
|
int i = aVar.f1473c;
|
||
|
c.o.a.x.b bVar = aVar.d;
|
||
|
c.o.a.x.b C = eVar.m.C(c.o.a.n.t.b.SENSOR);
|
||
|
if (C != null) {
|
||
|
g.a(new RunnableC0169a(bArr, C, i, bVar));
|
||
|
camera.setPreviewCallbackWithBuffer(null);
|
||
|
camera.setPreviewCallbackWithBuffer(e.this.m);
|
||
|
c.o.a.p.a l1 = e.this.m.l1();
|
||
|
e eVar2 = e.this;
|
||
|
l1.e(eVar2.p, C, eVar2.m.K);
|
||
|
return;
|
||
|
}
|
||
|
throw new IllegalStateException("Preview stream size should never be null here.");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public e(@NonNull l.a aVar, @NonNull b bVar, @NonNull Camera camera, @NonNull c.o.a.x.a aVar2) {
|
||
|
super(aVar, bVar);
|
||
|
this.m = bVar;
|
||
|
this.n = camera;
|
||
|
this.o = aVar2;
|
||
|
this.p = camera.getParameters().getPreviewFormat();
|
||
|
}
|
||
|
|
||
|
@Override // c.o.a.v.d
|
||
|
public void b() {
|
||
|
this.m = null;
|
||
|
this.n = null;
|
||
|
this.o = null;
|
||
|
this.p = 0;
|
||
|
super.b();
|
||
|
}
|
||
|
|
||
|
@Override // c.o.a.v.d
|
||
|
public void c() {
|
||
|
this.n.setOneShotPreviewCallback(new a());
|
||
|
}
|
||
|
}
|