package com.google.android.gms.vision.face; import android.content.Context; import android.graphics.PointF; import android.os.RemoteException; import android.os.SystemClock; import com.google.android.gms.common.internal.GmsLogger; import com.google.android.gms.dynamic.IObjectWrapper; import com.google.android.gms.dynamic.ObjectWrapper; import com.google.android.gms.internal.vision.zzbl; import com.google.android.gms.internal.vision.zzbo; import com.google.android.gms.internal.vision.zzbq; import com.google.android.gms.internal.vision.zzca; import com.google.android.gms.internal.vision.zzcc; import com.google.android.gms.internal.vision.zzch; import com.google.android.gms.internal.vision.zzck; import com.google.android.gms.internal.vision.zzfy; import com.google.android.gms.internal.vision.zzjx; import com.google.android.gms.internal.vision.zzkf; import com.google.android.gms.internal.vision.zzl; import com.google.android.gms.internal.vision.zzn; import com.google.android.gms.vision.clearcut.DynamiteClearcutLogger; import com.google.android.gms.vision.face.internal.client.FaceParcel; import com.google.android.gms.vision.face.internal.client.LandmarkParcel; import com.google.android.gms.vision.face.internal.client.zze; import com.google.android.gms.vision.face.internal.client.zzh; import java.io.File; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; /* loaded from: classes2.dex */ final class NativeFaceDetectorV2Impl extends zzh { private static final GmsLogger zzcs = new GmsLogger("NativeFaceDetectorV2Imp", ""); private final long zzct; private final DynamiteClearcutLogger zzcu; private final zzca.zzd zzcv; private final FaceDetectorV2Jni zzcw; /* renamed from: com.google.android.gms.vision.face.NativeFaceDetectorV2Impl$1, reason: invalid class name */ /* loaded from: classes2.dex */ static /* synthetic */ class AnonymousClass1 { static final int[] zzcx; static final int[] zzcy; static { int[] iArr = new int[zzca.zzb.zzc.values().length]; zzcy = iArr; try { iArr[zzca.zzb.zzc.FACE_OVAL.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { zzcy[zzca.zzb.zzc.LEFT_EYEBROW_TOP.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } try { zzcy[zzca.zzb.zzc.LEFT_EYEBROW_BOTTOM.ordinal()] = 3; } catch (NoSuchFieldError unused3) { } try { zzcy[zzca.zzb.zzc.RIGHT_EYEBROW_TOP.ordinal()] = 4; } catch (NoSuchFieldError unused4) { } try { zzcy[zzca.zzb.zzc.RIGHT_EYEBROW_BOTTOM.ordinal()] = 5; } catch (NoSuchFieldError unused5) { } try { zzcy[zzca.zzb.zzc.LEFT_EYE.ordinal()] = 6; } catch (NoSuchFieldError unused6) { } try { zzcy[zzca.zzb.zzc.RIGHT_EYE.ordinal()] = 7; } catch (NoSuchFieldError unused7) { } try { zzcy[zzca.zzb.zzc.UPPER_LIP_TOP.ordinal()] = 8; } catch (NoSuchFieldError unused8) { } try { zzcy[zzca.zzb.zzc.UPPER_LIP_BOTTOM.ordinal()] = 9; } catch (NoSuchFieldError unused9) { } try { zzcy[zzca.zzb.zzc.LOWER_LIP_TOP.ordinal()] = 10; } catch (NoSuchFieldError unused10) { } try { zzcy[zzca.zzb.zzc.LOWER_LIP_BOTTOM.ordinal()] = 11; } catch (NoSuchFieldError unused11) { } try { zzcy[zzca.zzb.zzc.NOSE_BRIDGE.ordinal()] = 12; } catch (NoSuchFieldError unused12) { } try { zzcy[zzca.zzb.zzc.NOSE_BOTTOM.ordinal()] = 13; } catch (NoSuchFieldError unused13) { } try { zzcy[zzca.zzb.zzc.LEFT_CHEEK_CENTER.ordinal()] = 14; } catch (NoSuchFieldError unused14) { } try { zzcy[zzca.zzb.zzc.RIGHT_CHEEK_CENTER.ordinal()] = 15; } catch (NoSuchFieldError unused15) { } int[] iArr2 = new int[zzjx.zze.zzb.values().length]; zzcx = iArr2; try { iArr2[zzjx.zze.zzb.LEFT_EYE.ordinal()] = 1; } catch (NoSuchFieldError unused16) { } try { zzcx[zzjx.zze.zzb.RIGHT_EYE.ordinal()] = 2; } catch (NoSuchFieldError unused17) { } try { zzcx[zzjx.zze.zzb.NOSE_TIP.ordinal()] = 3; } catch (NoSuchFieldError unused18) { } try { zzcx[zzjx.zze.zzb.LOWER_LIP.ordinal()] = 4; } catch (NoSuchFieldError unused19) { } try { zzcx[zzjx.zze.zzb.MOUTH_LEFT.ordinal()] = 5; } catch (NoSuchFieldError unused20) { } try { zzcx[zzjx.zze.zzb.MOUTH_RIGHT.ordinal()] = 6; } catch (NoSuchFieldError unused21) { } try { zzcx[zzjx.zze.zzb.LEFT_EAR_TRAGION.ordinal()] = 7; } catch (NoSuchFieldError unused22) { } try { zzcx[zzjx.zze.zzb.RIGHT_EAR_TRAGION.ordinal()] = 8; } catch (NoSuchFieldError unused23) { } try { zzcx[zzjx.zze.zzb.LEFT_CHEEK_CENTER.ordinal()] = 9; } catch (NoSuchFieldError unused24) { } try { zzcx[zzjx.zze.zzb.RIGHT_CHEEK_CENTER.ordinal()] = 10; } catch (NoSuchFieldError unused25) { } try { zzcx[zzjx.zze.zzb.LEFT_EAR_TOP.ordinal()] = 11; } catch (NoSuchFieldError unused26) { } try { zzcx[zzjx.zze.zzb.RIGHT_EAR_TOP.ordinal()] = 12; } catch (NoSuchFieldError unused27) { } } } /* JADX INFO: Access modifiers changed from: package-private */ public NativeFaceDetectorV2Impl(Context context, DynamiteClearcutLogger dynamiteClearcutLogger, File file, zze zzeVar, FaceDetectorV2Jni faceDetectorV2Jni) { zzca.zzg zzgVar = (zzca.zzg) ((zzfy) zzca.zzg.zzbo().zzj("models").zzfg()); zzca.zzd.zza zzf = zzca.zzd.zzbi().zzb((zzca.zze) ((zzfy) zzca.zze.zzbk().zzh(zzgVar).zzi(zzgVar).zzj(zzgVar).zzfg())).zzb((zzca.zza) ((zzfy) zzca.zza.zzaw().zzc(zzgVar).zzd(zzgVar).zzfg())).zzb((zzca.zzf) ((zzfy) zzca.zzf.zzbm().zzo(zzgVar).zzp(zzgVar).zzq(zzgVar).zzr(zzgVar).zzfg())).zzd(zzeVar.zzcm).zze(zzeVar.trackingEnabled).zze(zzeVar.proportionalMinFaceSize).zzf(true); int i = zzeVar.mode; if (i == 0) { zzf.zzb(zzck.FAST); } else if (i == 1) { zzf.zzb(zzck.ACCURATE); } else if (i == 2) { zzf.zzb(zzck.SELFIE); } int i2 = zzeVar.landmarkType; if (i2 == 0) { zzf.zzb(zzch.NO_LANDMARK); } else if (i2 == 1) { zzf.zzb(zzch.ALL_LANDMARKS); } else if (i2 == 2) { zzf.zzb(zzch.CONTOUR_LANDMARKS); } int i3 = zzeVar.zzcn; if (i3 == 0) { zzf.zzb(zzcc.NO_CLASSIFICATION); } else if (i3 == 1) { zzf.zzb(zzcc.ALL_CLASSIFICATIONS); } zzca.zzd zzdVar = (zzca.zzd) ((zzfy) zzf.zzfg()); this.zzcv = zzdVar; this.zzct = faceDetectorV2Jni.zza(zzdVar, context.getAssets()); this.zzcu = dynamiteClearcutLogger; this.zzcw = faceDetectorV2Jni; } @Override // com.google.android.gms.vision.face.internal.client.zzg public final boolean zzd(int i) throws RemoteException { return true; } @Override // com.google.android.gms.vision.face.internal.client.zzg public final void zzn() throws RemoteException { this.zzcw.zza(this.zzct); } @Override // com.google.android.gms.vision.face.internal.client.zzg public final FaceParcel[] zzc(IObjectWrapper iObjectWrapper, zzn zznVar) throws RemoteException { zzbq zzbqVar; zzca.zzc zza; float f; float f2; float f3; long j; zzkf zzkfVar; zzcc zzccVar; LandmarkParcel[] landmarkParcelArr; com.google.android.gms.vision.face.internal.client.zza[] zzaVarArr; int i; long j2; List list; zzkf zzkfVar2; zzcc zzccVar2; int i2; long elapsedRealtime = SystemClock.elapsedRealtime(); try { ByteBuffer byteBuffer = (ByteBuffer) ObjectWrapper.unwrap(iObjectWrapper); zzbo.zza zzj = zzbo.zzai().zzi(zznVar.width).zzj(zznVar.height); int i3 = zznVar.rotation; if (i3 == 0) { zzbqVar = zzbq.ROTATION_0; } else if (i3 == 1) { zzbqVar = zzbq.ROTATION_270; } else if (i3 == 2) { zzbqVar = zzbq.ROTATION_180; } else if (i3 == 3) { zzbqVar = zzbq.ROTATION_90; } else { throw new IllegalArgumentException("Unsupported rotation degree."); } zzbo.zza zzb = zzj.zzb(zzbqVar).zzb(zzbl.NV21); if (zznVar.zzat > 0) { zzb.zzc(zznVar.zzat); } zzbo zzboVar = (zzbo) ((zzfy) zzb.zzfg()); if (byteBuffer.isDirect()) { zza = this.zzcw.zza(this.zzct, byteBuffer, zzboVar); } else if (byteBuffer.hasArray() && byteBuffer.arrayOffset() == 0) { zza = this.zzcw.zza(this.zzct, byteBuffer.array(), zzboVar); } else { byte[] bArr = new byte[byteBuffer.remaining()]; byteBuffer.get(bArr); zza = this.zzcw.zza(this.zzct, bArr, zzboVar); } zzcc zzbh = this.zzcv.zzbh(); zzch zzbg = this.zzcv.zzbg(); zzkf zzbe = zza.zzbe(); int zzip = zzbe.zzip(); FaceParcel[] faceParcelArr = new FaceParcel[zzip]; int i4 = 0; while (i4 < zzbe.zzip()) { zzjx zzcc = zzbe.zzcc(i4); zzjx.zzb zzhw = zzcc.zzhw(); float zzig = zzhw.zzig(); float zzii = (zzhw.zzii() - zzhw.zzig()) / 2.0f; float zzih = zzhw.zzih(); float zzij = (zzhw.zzij() - zzhw.zzih()) / 2.0f; float zzii2 = zzhw.zzii(); float zzig2 = zzhw.zzig(); float zzij2 = zzhw.zzij(); float zzih2 = zzhw.zzih(); float f4 = -1.0f; if (zzbh == zzcc.ALL_CLASSIFICATIONS) { float f5 = -1.0f; float f6 = -1.0f; for (zzjx.zza zzaVar : zzcc.zzib()) { if (zzaVar.getName().equals("joy")) { f6 = zzaVar.getConfidence(); } else if (zzaVar.getName().equals("left_eye_closed")) { f4 = 1.0f - zzaVar.getConfidence(); } else if (zzaVar.getName().equals("right_eye_closed")) { f5 = 1.0f - zzaVar.getConfidence(); } } f = f4; f2 = f5; f3 = f6; } else { f = -1.0f; f2 = -1.0f; f3 = -1.0f; } if (zzbg == zzch.ALL_LANDMARKS) { List zzhx = zzcc.zzhx(); ArrayList arrayList = new ArrayList(); int i5 = 0; while (i5 < zzhx.size()) { zzjx.zze zzeVar = zzhx.get(i5); zzjx.zze.zzb zzin = zzeVar.zzin(); switch (AnonymousClass1.zzcx[zzin.ordinal()]) { case 1: j2 = elapsedRealtime; list = zzhx; zzkfVar2 = zzbe; zzccVar2 = zzbh; i2 = 4; break; case 2: j2 = elapsedRealtime; list = zzhx; zzkfVar2 = zzbe; zzccVar2 = zzbh; i2 = 10; break; case 3: j2 = elapsedRealtime; list = zzhx; zzkfVar2 = zzbe; zzccVar2 = zzbh; i2 = 6; break; case 4: j2 = elapsedRealtime; list = zzhx; zzkfVar2 = zzbe; zzccVar2 = zzbh; i2 = 0; break; case 5: j2 = elapsedRealtime; list = zzhx; zzkfVar2 = zzbe; zzccVar2 = zzbh; i2 = 5; break; case 6: j2 = elapsedRealtime; list = zzhx; zzkfVar2 = zzbe; zzccVar2 = zzbh; i2 = 11; break; case 7: j2 = elapsedRealtime; list = zzhx; zzkfVar2 = zzbe; zzccVar2 = zzbh; i2 = 3; break; case 8: j2 = elapsedRealtime; list = zzhx; zzkfVar2 = zzbe; zzccVar2 = zzbh; i2 = 9; break; case 9: j2 = elapsedRealtime; list = zzhx; zzkfVar2 = zzbe; zzccVar2 = zzbh; i2 = 1; break; case 10: j2 = elapsedRealtime; list = zzhx; zzkfVar2 = zzbe; zzccVar2 = zzbh; i2 = 7; break; case 11: j2 = elapsedRealtime; list = zzhx; zzkfVar2 = zzbe; zzccVar2 = zzbh; i2 = 2; break; case 12: j2 = elapsedRealtime; list = zzhx; zzkfVar2 = zzbe; zzccVar2 = zzbh; i2 = 8; break; default: list = zzhx; GmsLogger gmsLogger = zzcs; zzkfVar2 = zzbe; String valueOf = String.valueOf(zzin); zzccVar2 = zzbh; j2 = elapsedRealtime; StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 23); sb.append("Unknown landmark type: "); sb.append(valueOf); gmsLogger.d("NativeFaceDetectorV2Imp", sb.toString()); i2 = -1; break; } if (i2 >= 0) { arrayList.add(new LandmarkParcel(-1, zzeVar.getX(), zzeVar.getY(), i2)); } i5++; zzhx = list; zzbe = zzkfVar2; zzbh = zzccVar2; elapsedRealtime = j2; } j = elapsedRealtime; zzkfVar = zzbe; zzccVar = zzbh; landmarkParcelArr = (LandmarkParcel[]) arrayList.toArray(new LandmarkParcel[0]); } else { j = elapsedRealtime; zzkfVar = zzbe; zzccVar = zzbh; landmarkParcelArr = new LandmarkParcel[0]; } if (zzbg == zzch.CONTOUR_LANDMARKS) { List list2 = (List) zzcc.zzc(zzca.zziv); zzaVarArr = new com.google.android.gms.vision.face.internal.client.zza[list2.size()]; int i6 = 0; while (i6 < list2.size()) { zzca.zzb zzbVar = (zzca.zzb) list2.get(i6); PointF[] pointFArr = new PointF[zzbVar.zzba()]; int i7 = 0; while (i7 < zzbVar.zzba()) { zzca.zzb.C0017zzb c0017zzb = zzbVar.zzaz().get(i7); pointFArr[i7] = new PointF(c0017zzb.getX(), c0017zzb.getY()); i7++; list2 = list2; } List list3 = list2; zzca.zzb.zzc zzay = zzbVar.zzay(); switch (AnonymousClass1.zzcy[zzay.ordinal()]) { case 1: i = 1; break; case 2: i = 2; break; case 3: i = 3; break; case 4: i = 4; break; case 5: i = 5; break; case 6: i = 6; break; case 7: i = 7; break; case 8: i = 8; break; case 9: i = 9; break; case 10: i = 10; break; case 11: i = 11; break; case 12: i = 12; break; case 13: i = 13; break; case 14: case 15: GmsLogger gmsLogger2 = zzcs; String valueOf2 = String.valueOf(zzay); StringBuilder sb2 = new StringBuilder(String.valueOf(valueOf2).length() + 35); sb2.append("Intentionally ignore contour type: "); sb2.append(valueOf2); gmsLogger2.d("NativeFaceDetectorV2Imp", sb2.toString()); break; default: GmsLogger gmsLogger3 = zzcs; String valueOf3 = String.valueOf(zzay); StringBuilder sb3 = new StringBuilder(String.valueOf(valueOf3).length() + 22); sb3.append("Unknown contour type: "); sb3.append(valueOf3); gmsLogger3.e("NativeFaceDetectorV2Imp", sb3.toString()); break; } i = -1; zzaVarArr[i6] = new com.google.android.gms.vision.face.internal.client.zza(pointFArr, i); i6++; list2 = list3; } } else { zzaVarArr = new com.google.android.gms.vision.face.internal.client.zza[0]; } faceParcelArr[i4] = new FaceParcel(3, (int) zzcc.zzic(), zzig + zzii, zzih + zzij, zzii2 - zzig2, zzij2 - zzih2, zzcc.zzhz(), -zzcc.zzhy(), zzcc.zzia(), landmarkParcelArr, f, f2, f3, zzaVarArr); i4++; zzbe = zzkfVar; zzbh = zzccVar; elapsedRealtime = j; } long j3 = elapsedRealtime; DynamiteClearcutLogger dynamiteClearcutLogger = this.zzcu; long elapsedRealtime2 = SystemClock.elapsedRealtime(); if (zznVar.id <= 2 || zzip != 0) { dynamiteClearcutLogger.zza(3, zzl.zza(zznVar, faceParcelArr, null, elapsedRealtime2 - j3)); } return faceParcelArr; } catch (Exception e) { zzcs.e("NativeFaceDetectorV2Imp", "Native face detection v2 failed", e); return new FaceParcel[0]; } } }