56 lines
1.9 KiB
Java
56 lines
1.9 KiB
Java
|
package com.kofax.mobile.sdk.af;
|
||
|
|
||
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
||
|
import com.google.common.primitives.UnsignedBytes;
|
||
|
|
||
|
/* loaded from: classes3.dex */
|
||
|
public class i implements com.kofax.mobile.sdk.aj.b {
|
||
|
@Override // com.kofax.mobile.sdk.aj.b
|
||
|
public int d(byte[] bArr, int i, int i2) {
|
||
|
int i3 = i * i2;
|
||
|
double d = 0.0d;
|
||
|
int i4 = 0;
|
||
|
int i5 = 0;
|
||
|
while (i4 < i2) {
|
||
|
int i6 = 0;
|
||
|
int i7 = 0;
|
||
|
while (i6 < i) {
|
||
|
int i8 = bArr[(i5 * i) + i7] & UnsignedBytes.MAX_VALUE;
|
||
|
int i9 = ((i5 >> 1) * i) + i3 + (i7 & (-2));
|
||
|
byte b = bArr[i9];
|
||
|
byte b2 = bArr[i9 + 1];
|
||
|
if (i8 < 16) {
|
||
|
i8 = 16;
|
||
|
}
|
||
|
float f = (i8 - 16) * 1.164f;
|
||
|
float f2 = (b & UnsignedBytes.MAX_VALUE) - 128;
|
||
|
float f3 = (1.596f * f2) + f;
|
||
|
float f4 = (b2 & UnsignedBytes.MAX_VALUE) - 128;
|
||
|
float f5 = (f - (f2 * 0.813f)) - (0.391f * f4);
|
||
|
float f6 = f + (f4 * 2.018f);
|
||
|
if (f3 < BitmapDescriptorFactory.HUE_RED) {
|
||
|
f3 = 0.0f;
|
||
|
} else if (f3 > 255.0f) {
|
||
|
f3 = 255.0f;
|
||
|
}
|
||
|
if (f5 < BitmapDescriptorFactory.HUE_RED) {
|
||
|
f5 = 0.0f;
|
||
|
} else if (f5 > 255.0f) {
|
||
|
f5 = 255.0f;
|
||
|
}
|
||
|
if (f6 < BitmapDescriptorFactory.HUE_RED) {
|
||
|
f6 = 0.0f;
|
||
|
} else if (f6 > 255.0f) {
|
||
|
f6 = 255.0f;
|
||
|
}
|
||
|
d += (f3 * 0.114d) + (f5 * 0.587d) + (f6 * 0.299d);
|
||
|
i6++;
|
||
|
i7++;
|
||
|
}
|
||
|
i4++;
|
||
|
i5++;
|
||
|
}
|
||
|
return (int) (d / i3);
|
||
|
}
|
||
|
}
|